Skip to content

Commit

Permalink
Sdk release/next major (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-stripe committed Apr 10, 2024
1 parent 2a45f50 commit 93267e3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 57 deletions.
42 changes: 21 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,32 +138,32 @@
**⚠️ ACTION REQUIRED: the breaking change in this release likely affects you ⚠️**

* [#1253](https://github.com/stripe/stripe-ruby/pull/1253) [#1260](https://github.com/stripe/stripe-ruby/pull/1260) Pin latest API version as the default

In this release, Stripe API Version `2023-08-16` (the latest at time of release) will be sent by default on all requests. This is a significant change with wide ramifications. The API version affects the properties you see on responses, the parameters you are allowed to send on requests, and so on. The previous default was to use your [Stripe account's default API version](https://stripe.com/docs/development/dashboard/request-logs#view-your-default-api-version).

To successfully upgrade to stripe-ruby v9, you must either

1. **(Recommended) Upgrade your integration to be compatible with API Version `2023-08-16`.**

Please read the API Changelog carefully for each API Version from `2023-08-16` back to your [Stripe account's default API version](https://stripe.com/docs/development/dashboard/request-logs#view-your-default-api-version). Determine if you are using any of the APIs that have changed in a breaking way, and adjust your integration accordingly. Carefully test your changes with Stripe [Test Mode](https://stripe.com/docs/keys#test-live-modes) before deploying them to production.

You can read the [v9 migration guide](https://github.com/stripe/stripe-ruby/wiki/Migration-guide-for-v9) for more detailed instructions.
2. **(Alternative option) Specify a version other than `2023-08-16` when initializing `stripe-ruby`.**

If you were previously initializing stripe-ruby without an explicit API Version, you can postpone modifying your integration by specifying a version equal to your [Stripe account's default API version](https://stripe.com/docs/development/dashboard/request-logs#view-your-default-api-version). For example:

```diff
require 'stripe'
Stripe.api_key = "sk_test_..."
+ Stripe.api_version = '2020-08-27'
```

If you were already initializing stripe-ruby with an explicit API Version, upgrading to v9 will not affect your integration.

Read the [v9 migration guide](https://github.com/stripe/stripe-ruby/wiki/Migration-guide-for-v9) for more details.

Going forward, each major release of this library will be *pinned* by default to the latest Stripe API Version at the time of release.

That is, instead of upgrading stripe-ruby and separately upgrading your Stripe API Version through the Stripe Dashboard. whenever you upgrade major versions of stripe-ruby, you should also upgrade your integration to be compatible with the latest Stripe API version.

## 8.7.0 - 2023-08-10
Expand All @@ -190,7 +190,7 @@

* [#1225](https://github.com/stripe/stripe-ruby/pull/1225) Downgrade jaro_winkler
* [#1219](https://github.com/stripe/stripe-ruby/pull/1219) Update generated code

Documentation updates.
* [#1215](https://github.com/stripe/stripe-ruby/pull/1215) Update generated code

Expand Down Expand Up @@ -238,7 +238,7 @@ Breaking changes that arose during code generation of the library that we postpo
refund = Stripe::Refund.retrieve("re_123")
refund.description = "Refund description"
refund.save

# after
Stripe::Refund.update("re_123", description: "Refund description")
```
Expand Down Expand Up @@ -302,7 +302,7 @@ Breaking changes that arose during code generation of the library that we postpo
* [#1072](https://github.com/stripe/stripe-ruby/pull/1072) Trigger workflows on beta branches
* [#1071](https://github.com/stripe/stripe-ruby/pull/1071) Use request_stripe_object for all requests
* [#1070](https://github.com/stripe/stripe-ruby/pull/1070) API Updates

Switch from using meta-programing to generating explicit methods for custom methods.
* [#1069](https://github.com/stripe/stripe-ruby/pull/1069) chore: Stop special implementation of Account.persons method.

Expand All @@ -318,15 +318,15 @@ Breaking changes that arose during code generation of the library that we postpo
* Add support for new resources `Treasury.CreditReversal`, `Treasury.DebitReversal`, `Treasury.FinancialAccountFeatures`, `Treasury.FinancialAccount`, `Treasury.FlowDetails`, `Treasury.InboundTransfer`, `Treasury.OutboundPayment`, `Treasury.OutboundTransfer`, `Treasury.ReceivedCredit`, `Treasury.ReceivedDebit`, `Treasury.TransactionEntry`, and `Treasury.Transaction`
* Add support for `retrieve_payment_method` method on resource `Customer`
* Add support for `list_owners` and `list` methods on resource `FinancialConnections.Account`



## 6.0.0 - 2022-05-09
* [#1056](https://github.com/stripe/stripe-ruby/pull/1056) API Updates
Major version release. The [migration guide](https://github.com/stripe/stripe-ruby/wiki/Migration-Guide-for-v6) contains more information.

(⚠️ = breaking changes):
* ⚠️ Replace the legacy `Order` API with the new `Order` API.
* ⚠️ Replace the legacy `Order` API with the new `Order` API.
* New methods: `cancel`, `list_line_items`, `reopen`, and `submit`
* Removed methods: `pay` and `return_order`
* Removed resources: `OrderItem` and `OrderReturn`
Expand All @@ -335,7 +335,7 @@ Breaking changes that arose during code generation of the library that we postpo
## 5.55.0 - 2022-05-05
* [#1055](https://github.com/stripe/stripe-ruby/pull/1055) API Updates
* Add support for new resources `FinancialConnections.AccountOwner`, `FinancialConnections.AccountOwnership`, `FinancialConnections.Account`, and `FinancialConnections.Session`


## 5.54.0 - 2022-05-03
* [#1053](https://github.com/stripe/stripe-ruby/pull/1053) API Updates
Expand All @@ -346,7 +346,7 @@ Breaking changes that arose during code generation of the library that we postpo
* Add support for `expire` test helper method on resource `Refund`

## 5.52.0 - 2022-04-18
* [#1046](https://github.com/stripe/stripe-ruby/pull/1046) [#1047](https://github.com/stripe/stripe-ruby/pull/1047) API Updates
* [#1046](https://github.com/stripe/stripe-ruby/pull/1046) [#1047](https://github.com/stripe/stripe-ruby/pull/1047) API Updates
* Add support for new resources `FundingInstructions` and `Terminal.Configuration`

## 5.51.0 - 2022-04-15
Expand All @@ -368,7 +368,7 @@ Breaking changes that arose during code generation of the library that we postpo
* [#1040](https://github.com/stripe/stripe-ruby/pull/1040) API Updates
* Add support for Search API
* Add support for `search` method on resources `Charge`, `Customer`, `Invoice`, `PaymentIntent`, `Price`, `Product`, and `Subscription`

* [#1034](https://github.com/stripe/stripe-ruby/pull/1034) Add supporting classes for test helper generation

## 5.46.0 - 2022-03-23
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/api_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

module Stripe
module ApiVersion
CURRENT = "2023-10-16"
CURRENT = "2024-04-10"
end
end
20 changes: 8 additions & 12 deletions lib/stripe/stripe_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def self.default_connection_manager(config = Stripe.config)
# both socket errors that may represent an intermittent problem and some
# special HTTP statuses.
def self.should_retry?(error,
method:, num_retries:, config: Stripe.config)
num_retries:, config: Stripe.config)
return false if num_retries >= config.max_network_retries

case error
Expand Down Expand Up @@ -143,15 +143,12 @@ def self.should_retry?(error,
# These 429s are safe to retry.
return true if error.http_status == 429 && error.code == "lock_timeout"

# 500 Internal Server Error
# Retry on 500, 503, and other internal errors.
#
# We only bother retrying these for non-POST requests. POSTs end up
# being cached by the idempotency layer so there's no purpose in
# retrying them.
return true if error.http_status == 500 && method != :post

# 503 Service Unavailable
error.http_status == 503
# Note that we expect the stripe-should-retry header to be false
# in most cases when a 500 is returned, since our idempotency framework
# would typically replay it anyway.
true if error.http_status >= 500
else
false
end
Expand Down Expand Up @@ -490,7 +487,7 @@ def self.maybe_gc_connection_managers
end

http_resp =
execute_request_with_rescues(method, api_base, headers, usage, context) do
execute_request_with_rescues(api_base, headers, usage, context) do
self.class
.default_connection_manager(config)
.execute_request(method, url,
Expand Down Expand Up @@ -560,7 +557,7 @@ def self.maybe_gc_connection_managers
http_status >= 400
end

private def execute_request_with_rescues(method, api_base, headers, usage, context)
private def execute_request_with_rescues(api_base, headers, usage, context)
num_retries = 0

begin
Expand Down Expand Up @@ -611,7 +608,6 @@ def self.maybe_gc_connection_managers
user_data, resp, headers)

if self.class.should_retry?(e,
method: method,
num_retries: num_retries,
config: config)
num_retries += 1
Expand Down
41 changes: 18 additions & 23 deletions test/stripe/stripe_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,42 +289,42 @@ class StripeClientTest < Test::Unit::TestCase

should "retry on Errno::ECONNREFUSED" do
assert StripeClient.should_retry?(Errno::ECONNREFUSED.new,
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry on EOFError" do
assert StripeClient.should_retry?(EOFError.new,
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry on Errno::ECONNRESET" do
assert StripeClient.should_retry?(Errno::ECONNRESET.new,
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry on Errno::ETIMEDOUT" do
assert StripeClient.should_retry?(Errno::ETIMEDOUT.new,
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry on Errno::EHOSTUNREACH" do
assert StripeClient.should_retry?(Errno::EHOSTUNREACH.new,
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry on Net::OpenTimeout" do
assert StripeClient.should_retry?(Net::OpenTimeout.new,
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry on Net::ReadTimeout" do
assert StripeClient.should_retry?(Net::ReadTimeout.new,
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry on SocketError" do
assert StripeClient.should_retry?(SocketError.new,
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry when the `Stripe-Should-Retry` header is `true`" do
Expand All @@ -335,7 +335,7 @@ class StripeClientTest < Test::Unit::TestCase
# Note we send status 400 here, which would normally not be retried.
assert StripeClient.should_retry?(Stripe::StripeError.new(http_headers: headers,
http_status: 400),
method: :post, num_retries: 0)
num_retries: 0)
end

should "not retry when the `Stripe-Should-Retry` header is `false`" do
Expand All @@ -346,49 +346,44 @@ class StripeClientTest < Test::Unit::TestCase
# Note we send status 409 here, which would normally be retried.
refute StripeClient.should_retry?(Stripe::StripeError.new(http_headers: headers,
http_status: 409),
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry on a 409 Conflict" do
assert StripeClient.should_retry?(Stripe::StripeError.new(http_status: 409),
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry on a 429 Too Many Requests when lock timeout" do
assert StripeClient.should_retry?(Stripe::StripeError.new(http_status: 429,
code: "lock_timeout"),
method: :post, num_retries: 0)
num_retries: 0)
end

should "retry on a 500 Internal Server Error when non-POST" do
should "retry on a 500 Internal Server Error" do
assert StripeClient.should_retry?(Stripe::StripeError.new(http_status: 500),
method: :get, num_retries: 0)
num_retries: 0)
end

should "retry on a 503 Service Unavailable" do
assert StripeClient.should_retry?(Stripe::StripeError.new(http_status: 503),
method: :post, num_retries: 0)
num_retries: 0)
end

should "not retry at maximum count" do
refute StripeClient.should_retry?(RuntimeError.new,
method: :post, num_retries: Stripe.max_network_retries)
num_retries: Stripe.max_network_retries)
end

should "not retry on a certificate validation error" do
refute StripeClient.should_retry?(OpenSSL::SSL::SSLError.new,
method: :post, num_retries: 0)
num_retries: 0)
end

should "not retry on a 429 Too Many Requests when not lock timeout" do
refute StripeClient.should_retry?(Stripe::StripeError.new(http_status: 429,
code: "rate_limited"),
method: :post, num_retries: 0)
end

should "not retry on a 500 Internal Server Error when POST" do
refute StripeClient.should_retry?(Stripe::StripeError.new(http_status: 500),
method: :post, num_retries: 0)
num_retries: 0)
end
end

Expand Down

0 comments on commit 93267e3

Please sign in to comment.