diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f1fcc46..e7d86124 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 10.9.0 - 2024-02-15 +* [#1329](https://github.com/stripe/stripe-ruby/pull/1329) Update generated code + * Fixed bug where `TaxId` resource `delete` method sent request to wrong URL (https://github.com/stripe/stripe-ruby/issues/1333) +* [#1324](https://github.com/stripe/stripe-ruby/pull/1324) Start running Sorbet in CI +* [#1327](https://github.com/stripe/stripe-ruby/pull/1327) Add methods for dynamically referenced constants + ## 10.9.0-beta.1 - 2024-02-08 * [#1321](https://github.com/stripe/stripe-ruby/pull/1321) Update generated code for beta * Release specs are identical. diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 4d2a1a3d..ca994629 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v827 \ No newline at end of file +v831 \ No newline at end of file diff --git a/lib/stripe/resources/account.rb b/lib/stripe/resources/account.rb index 205cee8c..8e788179 100644 --- a/lib/stripe/resources/account.rb +++ b/lib/stripe/resources/account.rb @@ -24,6 +24,9 @@ module Stripe nested_resource_class_methods :capability, operations: %i[retrieve update list], resource_plural: "capabilities" + nested_resource_class_methods :external_account, + operations: %i[create retrieve update delete list] + nested_resource_class_methods :login_link, operations: %i[create] nested_resource_class_methods :person, operations: %i[create retrieve update delete list] # Returns a list of people associated with the account's legal entity. The people are returned sorted by creation date, with the most recent people appearing first. @@ -72,10 +75,6 @@ module Stripe save_nested_resource :external_account - nested_resource_class_methods :external_account, - operations: %i[create retrieve update delete list] - nested_resource_class_methods :login_link, operations: %i[create] - def resource_url if self["id"] super diff --git a/lib/stripe/resources/customer.rb b/lib/stripe/resources/customer.rb index d746bf71..9b63a027 100644 --- a/lib/stripe/resources/customer.rb +++ b/lib/stripe/resources/customer.rb @@ -20,8 +20,9 @@ module Stripe nested_resource_class_methods :balance_transaction, operations: %i[create retrieve update list] nested_resource_class_methods :cash_balance_transaction, operations: %i[retrieve list] - nested_resource_class_methods :entitlement, operations: %i[list] + nested_resource_class_methods :source, operations: %i[create retrieve update delete list] nested_resource_class_methods :tax_id, operations: %i[create retrieve delete list] + nested_resource_class_methods :entitlement, operations: %i[list] # Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new # funding instructions will be created. If funding instructions have already been created for a given customer, the same @@ -108,8 +109,6 @@ module Stripe end save_nested_resource :source - nested_resource_class_methods :source, - operations: %i[create retrieve update delete list] # The API request for deleting a card or bank account and for detaching a # source object are the same. diff --git a/lib/stripe/resources/payment_intent.rb b/lib/stripe/resources/payment_intent.rb index f9d5c1a6..4c1c0831 100644 --- a/lib/stripe/resources/payment_intent.rb +++ b/lib/stripe/resources/payment_intent.rb @@ -93,6 +93,31 @@ module Stripe ) end + # Perform an decremental authorization on an eligible + # [PaymentIntent](https://stripe.com/docs/api/payment_intents/object). To be eligible, the + # PaymentIntent's status must be requires_capture and + # [decremental_authorization.status](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-decremental_authorization) + # must be available. + # + # Decremental authorizations decrease the authorized amount on your customer's card + # to the new, lower amount provided. A single PaymentIntent can call this endpoint multiple times to further decrease the authorized amount. + # + # After decrement, the PaymentIntent object + # returns with the updated + # [amount](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). + # The PaymentIntent will now be capturable up to the new authorized amount. + # + # Each PaymentIntent can have a maximum of 10 decremental or incremental authorization attempts, including declines. + # After it's captured, a PaymentIntent can no longer be decremented. + def decrement_authorization(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/payment_intents/%s/decrement_authorization", { intent: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + # Perform an incremental authorization on an eligible # [PaymentIntent](https://stripe.com/docs/api/payment_intents/object). To be eligible, the # PaymentIntent's status must be requires_capture and @@ -205,6 +230,31 @@ module Stripe ) end + # Perform an decremental authorization on an eligible + # [PaymentIntent](https://stripe.com/docs/api/payment_intents/object). To be eligible, the + # PaymentIntent's status must be requires_capture and + # [decremental_authorization.status](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-decremental_authorization) + # must be available. + # + # Decremental authorizations decrease the authorized amount on your customer's card + # to the new, lower amount provided. A single PaymentIntent can call this endpoint multiple times to further decrease the authorized amount. + # + # After decrement, the PaymentIntent object + # returns with the updated + # [amount](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). + # The PaymentIntent will now be capturable up to the new authorized amount. + # + # Each PaymentIntent can have a maximum of 10 decremental or incremental authorization attempts, including declines. + # After it's captured, a PaymentIntent can no longer be decremented. + def self.decrement_authorization(intent, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/payment_intents/%s/decrement_authorization", { intent: CGI.escape(intent) }), + params: params, + opts: opts + ) + end + # Perform an incremental authorization on an eligible # [PaymentIntent](https://stripe.com/docs/api/payment_intents/object). To be eligible, the # PaymentIntent's status must be requires_capture and diff --git a/lib/stripe/resources/tax_id.rb b/lib/stripe/resources/tax_id.rb index 246872d8..dad16243 100644 --- a/lib/stripe/resources/tax_id.rb +++ b/lib/stripe/resources/tax_id.rb @@ -30,21 +30,19 @@ module Stripe "'tax_id_id')`" end - # Deletes an existing tax_id object. def self.delete(id, params = {}, opts = {}) request_stripe_object( method: :delete, - path: format("/v1/customers/%s/tax_ids/%s", { customer: CGI.escape(customer), id: CGI.escape(id) }), + path: "#{resource_url}/#{id}", params: params, opts: opts ) end - # Deletes an existing tax_id object. def delete(params = {}, opts = {}) request_stripe_object( method: :delete, - path: format("/v1/customers/%s/tax_ids/%s", { customer: CGI.escape(self["id"]), id: CGI.escape(id) }), + path: resource_url.to_s, params: params, opts: opts ) diff --git a/test/stripe/generated_examples_test.rb b/test/stripe/generated_examples_test.rb index 0224cf47..e8973eec 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -482,6 +482,14 @@ module Stripe Stripe::Customer.search({ query: "name:'fakename' AND metadata['foo']:'bar'" }) assert_requested :get, "#{Stripe.api_base}/v1/customers/search?query=name:'fakename' AND metadata['foo']:'bar'" end + should "Test customers sources delete" do + Stripe::Customer.delete_source("cus_xxxxxxxxxxxxx", "ba_xxxxxxxxxxxxx") + assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources/ba_xxxxxxxxxxxxx?" + end + should "Test customers sources delete 2" do + Stripe::Customer.delete_source("cus_xxxxxxxxxxxxx", "card_xxxxxxxxxxxxx") + assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources/card_xxxxxxxxxxxxx?" + end should "Test customers sources get" do Stripe::Customer.list_sources( "cus_xxxxxxxxxxxxx", @@ -510,6 +518,10 @@ module Stripe Stripe::Customer.retrieve_source("cus_xxxxxxxxxxxxx", "card_xxxxxxxxxxxxx") assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources/card_xxxxxxxxxxxxx?" end + should "Test customers sources post" do + Stripe::Customer.update_source("cus_123", "card_123", { account_holder_name: "Kamil" }) + assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123/sources/card_123" + end should "Test customers sources post 2" do Stripe::Customer.create_source("cus_xxxxxxxxxxxxx", { source: "btok_xxxxxxxxxxxxx" }) assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources" @@ -518,6 +530,22 @@ module Stripe Stripe::Customer.create_source("cus_xxxxxxxxxxxxx", { source: "tok_xxxx" }) assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources" end + should "Test customers sources post 4" do + Stripe::Customer.update_source( + "cus_xxxxxxxxxxxxx", + "ba_xxxxxxxxxxxxx", + { metadata: { order_id: "6735" } } + ) + assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources/ba_xxxxxxxxxxxxx" + end + should "Test customers sources post 5" do + Stripe::Customer.update_source( + "cus_xxxxxxxxxxxxx", + "card_xxxxxxxxxxxxx", + { name: "Jenny Rosen" } + ) + assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources/card_xxxxxxxxxxxxx" + end should "Test customers tax ids delete" do Stripe::Customer.delete_tax_id("cus_xxxxxxxxxxxxx", "txi_xxxxxxxxxxxxx") assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/tax_ids/txi_xxxxxxxxxxxxx?"