From 74294666a2a28719462e9bb7af627d6a213b7025 Mon Sep 17 00:00:00 2001 From: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:01:34 -0800 Subject: [PATCH 1/9] Disable Metrics/ClassLength (#1355) --- .rubocop.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3b9fefdba..57d9cd9dd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -27,10 +27,7 @@ Metrics/BlockLength: - "test/**/*.rb" Metrics/ClassLength: - Exclude: - # Test classes get quite large, so exclude the test directory from having - # to adhere to this rule. - - "test/**/*.rb" + Enabled: false Metrics/MethodLength: # There's ~2 long methods in `StripeClient` and one in `NestedResource`. If From e2893a274e06e1c4b2d74bcd069e19ca3ec46d47 Mon Sep 17 00:00:00 2001 From: helenye-stripe <111009531+helenye-stripe@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:11:29 -0800 Subject: [PATCH 2/9] Reorder methods (#1347) --- lib/stripe/resources/account.rb | 138 ++++++------ lib/stripe/resources/apple_pay_domain.rb | 8 +- lib/stripe/resources/apps/secret.rb | 10 +- lib/stripe/resources/checkout/session.rb | 42 ++-- lib/stripe/resources/credit_note.rb | 70 +++--- lib/stripe/resources/customer.rb | 114 +++++----- lib/stripe/resources/ephemeral_key.rb | 18 +- lib/stripe/resources/file.rb | 10 +- .../financial_connections/account.rb | 68 +++--- .../identity/verification_session.rb | 76 +++---- lib/stripe/resources/invoice.rb | 144 ++++++------- lib/stripe/resources/issuing/authorization.rb | 16 +- lib/stripe/resources/issuing/dispute.rb | 32 +-- lib/stripe/resources/payment_intent.rb | 200 +++++++++--------- lib/stripe/resources/payment_link.rb | 20 +- lib/stripe/resources/payment_method.rb | 34 +-- lib/stripe/resources/payment_method_domain.rb | 58 ++--- lib/stripe/resources/payout.rb | 44 ++-- lib/stripe/resources/quote.rb | 102 ++++----- lib/stripe/resources/setup_intent.rb | 64 +++--- .../resources/sigma/scheduled_query_run.rb | 8 +- lib/stripe/resources/source.rb | 34 +-- lib/stripe/resources/subscription.rb | 72 +++---- lib/stripe/resources/subscription_schedule.rb | 38 ++-- lib/stripe/resources/tax/calculation.rb | 20 +- lib/stripe/resources/tax/transaction.rb | 20 +- lib/stripe/resources/terminal/reader.rb | 92 ++++---- .../resources/treasury/financial_account.rb | 50 ++--- .../resources/treasury/transaction_entry.rb | 8 +- 29 files changed, 805 insertions(+), 805 deletions(-) diff --git a/lib/stripe/resources/account.rb b/lib/stripe/resources/account.rb index 8e7881798..e22188ca7 100644 --- a/lib/stripe/resources/account.rb +++ b/lib/stripe/resources/account.rb @@ -29,6 +29,49 @@ def self.object_name nested_resource_class_methods :login_link, operations: %i[create] nested_resource_class_methods :person, operations: %i[create retrieve update delete list] + # With [Connect](https://stripe.com/docs/connect), you can create Stripe accounts for your users. + # To do this, you'll first need to [register your platform](https://dashboard.stripe.com/account/applications/settings). + # + # If you've already collected information for your connected accounts, you [can prefill that information](https://stripe.com/docs/connect/best-practices#onboarding) when + # creating the account. Connect Onboarding won't ask for the prefilled information during account onboarding. + # You can prefill any information on the account. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/accounts", params: params, opts: opts) + end + + # With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage. + # + # Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero. + # + # If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead. + def self.delete(id, params = {}, opts = {}) + request_stripe_object( + method: :delete, + path: format("/v1/accounts/%s", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + # With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage. + # + # Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero. + # + # If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead. + def delete(params = {}, opts = {}) + request_stripe_object( + method: :delete, + path: format("/v1/accounts/%s", { account: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Returns a list of accounts connected to your platform via [Connect](https://stripe.com/docs/connect). If you're not a platform, the list is empty. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/accounts", params: filters, opts: opts) + end + # 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. def persons(params = {}, opts = {}) request_stripe_object( @@ -39,6 +82,16 @@ def persons(params = {}, opts = {}) ) end + # 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. + def self.persons(account, params = {}, opts = {}) + request_stripe_object( + method: :get, + path: format("/v1/accounts/%s/persons", { account: CGI.escape(account) }), + params: params, + opts: opts + ) + end + # With [Connect](https://stripe.com/docs/connect), you may flag accounts as suspicious. # # Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero. @@ -51,23 +104,31 @@ def reject(params = {}, opts = {}) ) end - # 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. - def self.persons(account, params = {}, opts = {}) + # With [Connect](https://stripe.com/docs/connect), you may flag accounts as suspicious. + # + # Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero. + def self.reject(account, params = {}, opts = {}) request_stripe_object( - method: :get, - path: format("/v1/accounts/%s/persons", { account: CGI.escape(account) }), + method: :post, + path: format("/v1/accounts/%s/reject", { account: CGI.escape(account) }), params: params, opts: opts ) end - # With [Connect](https://stripe.com/docs/connect), you may flag accounts as suspicious. + # Updates a [connected account](https://stripe.com/docs/connect/accounts) by setting the values of the parameters passed. Any parameters not provided are + # left unchanged. # - # Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero. - def self.reject(account, params = {}, opts = {}) + # For Custom accounts, you can update any information on the account. For other accounts, you can update all information until that + # account has started to go through Connect Onboarding. Once you create an [Account Link or Account Session](https://stripe.com/docs/api/account_links), + # some properties can only be changed or updated for Custom accounts. + # + # To update your own account, use the [Dashboard](https://dashboard.stripe.com/settings/account). Refer to our + # [Connect](https://stripe.com/docs/connect/updating-accounts) documentation to learn more about updating accounts. + def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/accounts/%s/reject", { account: CGI.escape(account) }), + path: format("/v1/accounts/%s", { id: CGI.escape(id) }), params: params, opts: opts ) @@ -196,66 +257,5 @@ def deauthorize(client_id = nil, opts = {}) end update_hash end - - # With [Connect](https://stripe.com/docs/connect), you can create Stripe accounts for your users. - # To do this, you'll first need to [register your platform](https://dashboard.stripe.com/account/applications/settings). - # - # If you've already collected information for your connected accounts, you [can prefill that information](https://stripe.com/docs/connect/best-practices#onboarding) when - # creating the account. Connect Onboarding won't ask for the prefilled information during account onboarding. - # You can prefill any information on the account. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/accounts", params: params, opts: opts) - end - - # With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage. - # - # Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero. - # - # If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead. - def self.delete(id, params = {}, opts = {}) - request_stripe_object( - method: :delete, - path: format("/v1/accounts/%s", { id: CGI.escape(id) }), - params: params, - opts: opts - ) - end - - # With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage. - # - # Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero. - # - # If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead. - def delete(params = {}, opts = {}) - request_stripe_object( - method: :delete, - path: format("/v1/accounts/%s", { account: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - # Returns a list of accounts connected to your platform via [Connect](https://stripe.com/docs/connect). If you're not a platform, the list is empty. - def self.list(filters = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/accounts", params: filters, opts: opts) - end - - # Updates a [connected account](https://stripe.com/docs/connect/accounts) by setting the values of the parameters passed. Any parameters not provided are - # left unchanged. - # - # For Custom accounts, you can update any information on the account. For other accounts, you can update all information until that - # account has started to go through Connect Onboarding. Once you create an [Account Link or Account Session](https://stripe.com/docs/api/account_links), - # some properties can only be changed or updated for Custom accounts. - # - # To update your own account, use the [Dashboard](https://dashboard.stripe.com/settings/account). Refer to our - # [Connect](https://stripe.com/docs/connect/updating-accounts) documentation to learn more about updating accounts. - def self.update(id, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/accounts/%s", { id: CGI.escape(id) }), - params: params, - opts: opts - ) - end end end diff --git a/lib/stripe/resources/apple_pay_domain.rb b/lib/stripe/resources/apple_pay_domain.rb index 950caa529..2ac3d9389 100644 --- a/lib/stripe/resources/apple_pay_domain.rb +++ b/lib/stripe/resources/apple_pay_domain.rb @@ -13,10 +13,6 @@ def self.object_name "apple_pay_domain" end - def self.resource_url - "/v1/apple_pay/domains" - end - # Create an apple pay domain. def self.create(params = {}, opts = {}) request_stripe_object( @@ -56,5 +52,9 @@ def self.list(filters = {}, opts = {}) opts: opts ) end + + def self.resource_url + "/v1/apple_pay/domains" + end end end diff --git a/lib/stripe/resources/apps/secret.rb b/lib/stripe/resources/apps/secret.rb index b568e9502..c670aa707 100644 --- a/lib/stripe/resources/apps/secret.rb +++ b/lib/stripe/resources/apps/secret.rb @@ -21,6 +21,11 @@ def self.object_name "apps.secret" end + # Create or replace a secret in the secret store. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/apps/secrets", params: params, opts: opts) + end + # Deletes a secret from the secret store by name and scope. def self.delete_where(params = {}, opts = {}) request_stripe_object( @@ -41,11 +46,6 @@ def self.find(params = {}, opts = {}) ) end - # Create or replace a secret in the secret store. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/apps/secrets", params: params, opts: opts) - end - # List all secrets stored on the given scope. def self.list(filters = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/apps/secrets", params: filters, opts: opts) diff --git a/lib/stripe/resources/checkout/session.rb b/lib/stripe/resources/checkout/session.rb index 3949b4944..9760fa88d 100644 --- a/lib/stripe/resources/checkout/session.rb +++ b/lib/stripe/resources/checkout/session.rb @@ -26,23 +26,23 @@ def self.object_name "checkout.session" end - # A Session can be expired when it is in one of these statuses: open - # - # After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired. - def expire(params = {}, opts = {}) + # Creates a Session object. + def self.create(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/checkout/sessions/%s/expire", { session: CGI.escape(self["id"]) }), + path: "/v1/checkout/sessions", params: params, opts: opts ) end - # When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. - def list_line_items(params = {}, opts = {}) + # A Session can be expired when it is in one of these statuses: open + # + # After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired. + def expire(params = {}, opts = {}) request_stripe_object( - method: :get, - path: format("/v1/checkout/sessions/%s/line_items", { session: CGI.escape(self["id"]) }), + method: :post, + path: format("/v1/checkout/sessions/%s/expire", { session: CGI.escape(self["id"]) }), params: params, opts: opts ) @@ -60,32 +60,32 @@ def self.expire(session, params = {}, opts = {}) ) end - # When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. - def self.list_line_items(session, params = {}, opts = {}) + # Returns a list of Checkout Sessions. + def self.list(filters = {}, opts = {}) request_stripe_object( method: :get, - path: format("/v1/checkout/sessions/%s/line_items", { session: CGI.escape(session) }), - params: params, + path: "/v1/checkout/sessions", + params: filters, opts: opts ) end - # Creates a Session object. - def self.create(params = {}, opts = {}) + # When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + def list_line_items(params = {}, opts = {}) request_stripe_object( - method: :post, - path: "/v1/checkout/sessions", + method: :get, + path: format("/v1/checkout/sessions/%s/line_items", { session: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Returns a list of Checkout Sessions. - def self.list(filters = {}, opts = {}) + # When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + def self.list_line_items(session, params = {}, opts = {}) request_stripe_object( method: :get, - path: "/v1/checkout/sessions", - params: filters, + path: format("/v1/checkout/sessions/%s/line_items", { session: CGI.escape(session) }), + params: params, opts: opts ) end diff --git a/lib/stripe/resources/credit_note.rb b/lib/stripe/resources/credit_note.rb index ad465f18e..25737f796 100644 --- a/lib/stripe/resources/credit_note.rb +++ b/lib/stripe/resources/credit_note.rb @@ -15,14 +15,27 @@ def self.object_name "credit_note" end - # Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). - def void_credit_note(params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/credit_notes/%s/void", { id: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) + # Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces + # its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result + # in any combination of the following: + # + # + # Refund: create a new refund (using refund_amount) or link an existing refund (using refund). + # Customer balance credit: credit the customer's balance (using credit_amount) which will be automatically applied to their next invoice when it's finalized. + # Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount). + # + # + # For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total. + # + # You may issue multiple credit notes for an invoice. Each credit note will increment the invoice's pre_payment_credit_notes_amount + # or post_payment_credit_notes_amount depending on its status at the time of credit note creation. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/credit_notes", params: params, opts: opts) + end + + # Returns a list of credit notes. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/credit_notes", params: filters, opts: opts) end # When retrieving a credit note preview, you'll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items. @@ -45,44 +58,31 @@ def self.preview(params = {}, opts = {}) ) end - # Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). - def self.void_credit_note(id, params = {}, opts = {}) + # Updates an existing credit note. + def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/credit_notes/%s/void", { id: CGI.escape(id) }), + path: format("/v1/credit_notes/%s", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces - # its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result - # in any combination of the following: - # - # - # Refund: create a new refund (using refund_amount) or link an existing refund (using refund). - # Customer balance credit: credit the customer's balance (using credit_amount) which will be automatically applied to their next invoice when it's finalized. - # Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount). - # - # - # For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total. - # - # You may issue multiple credit notes for an invoice. Each credit note will increment the invoice's pre_payment_credit_notes_amount - # or post_payment_credit_notes_amount depending on its status at the time of credit note creation. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/credit_notes", params: params, opts: opts) - end - - # Returns a list of credit notes. - def self.list(filters = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/credit_notes", params: filters, opts: opts) + # Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). + def void_credit_note(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/credit_notes/%s/void", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) end - # Updates an existing credit note. - def self.update(id, params = {}, opts = {}) + # Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). + def self.void_credit_note(id, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/credit_notes/%s", { id: CGI.escape(id) }), + path: format("/v1/credit_notes/%s/void", { id: CGI.escape(id) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/customer.rb b/lib/stripe/resources/customer.rb index f7c421378..4755faf00 100644 --- a/lib/stripe/resources/customer.rb +++ b/lib/stripe/resources/customer.rb @@ -23,6 +23,11 @@ def self.object_name nested_resource_class_methods :source, operations: %i[create retrieve update delete list] nested_resource_class_methods :tax_id, operations: %i[create retrieve delete list] + # Creates a new customer object. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/customers", params: params, opts: opts) + end + # 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 # funding instructions will be retrieved. In other words, we will return the same funding instructions each time. @@ -35,43 +40,43 @@ def create_funding_instructions(params = {}, opts = {}) ) end - # Removes the currently applied discount on a customer. - def delete_discount(params = {}, opts = {}) + # 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 + # funding instructions will be retrieved. In other words, we will return the same funding instructions each time. + def self.create_funding_instructions(customer, params = {}, opts = {}) request_stripe_object( - method: :delete, - path: format("/v1/customers/%s/discount", { customer: CGI.escape(self["id"]) }), + method: :post, + path: format("/v1/customers/%s/funding_instructions", { customer: CGI.escape(customer) }), params: params, opts: opts ) end - # Returns a list of PaymentMethods for a given Customer - def list_payment_methods(params = {}, opts = {}) + # Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer. + def self.delete(id, params = {}, opts = {}) request_stripe_object( - method: :get, - path: format("/v1/customers/%s/payment_methods", { customer: CGI.escape(self["id"]) }), + method: :delete, + path: format("/v1/customers/%s", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Retrieves a PaymentMethod object for a given Customer. - def retrieve_payment_method(payment_method, params = {}, opts = {}) + # Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer. + def delete(params = {}, opts = {}) request_stripe_object( - method: :get, - path: format("/v1/customers/%s/payment_methods/%s", { customer: CGI.escape(self["id"]), payment_method: CGI.escape(payment_method) }), + method: :delete, + path: format("/v1/customers/%s", { customer: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # 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 - # funding instructions will be retrieved. In other words, we will return the same funding instructions each time. - def self.create_funding_instructions(customer, params = {}, opts = {}) + # Removes the currently applied discount on a customer. + def delete_discount(params = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/customers/%s/funding_instructions", { customer: CGI.escape(customer) }), + method: :delete, + path: format("/v1/customers/%s/discount", { customer: CGI.escape(self["id"]) }), params: params, opts: opts ) @@ -87,62 +92,59 @@ def self.delete_discount(customer, params = {}, opts = {}) ) end + # Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/customers", params: filters, opts: opts) + end + # Returns a list of PaymentMethods for a given Customer - def self.list_payment_methods(customer, params = {}, opts = {}) + def list_payment_methods(params = {}, opts = {}) request_stripe_object( method: :get, - path: format("/v1/customers/%s/payment_methods", { customer: CGI.escape(customer) }), + path: format("/v1/customers/%s/payment_methods", { customer: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Retrieves a PaymentMethod object for a given Customer. - def self.retrieve_payment_method(customer, payment_method, params = {}, opts = {}) + # Returns a list of PaymentMethods for a given Customer + def self.list_payment_methods(customer, params = {}, opts = {}) request_stripe_object( method: :get, - path: format("/v1/customers/%s/payment_methods/%s", { customer: CGI.escape(customer), payment_method: CGI.escape(payment_method) }), + path: format("/v1/customers/%s/payment_methods", { customer: CGI.escape(customer) }), params: params, opts: opts ) end - save_nested_resource :source - - # The API request for deleting a card or bank account and for detaching a - # source object are the same. - class << self - alias detach_source delete_source - end - - # Creates a new customer object. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/customers", params: params, opts: opts) - end - - # Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer. - def self.delete(id, params = {}, opts = {}) + # Retrieves a customer's cash balance. + def self.retrieve_cash_balance(customer, params = {}, opts = {}) request_stripe_object( - method: :delete, - path: format("/v1/customers/%s", { id: CGI.escape(id) }), + method: :get, + path: format("/v1/customers/%s/cash_balance", { customer: CGI.escape(customer) }), params: params, opts: opts ) end - # Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer. - def delete(params = {}, opts = {}) + # Retrieves a PaymentMethod object for a given Customer. + def retrieve_payment_method(payment_method, params = {}, opts = {}) request_stripe_object( - method: :delete, - path: format("/v1/customers/%s", { customer: CGI.escape(self["id"]) }), + method: :get, + path: format("/v1/customers/%s/payment_methods/%s", { customer: CGI.escape(self["id"]), payment_method: CGI.escape(payment_method) }), params: params, opts: opts ) end - # Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first. - def self.list(filters = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/customers", params: filters, opts: opts) + # Retrieves a PaymentMethod object for a given Customer. + def self.retrieve_payment_method(customer, payment_method, params = {}, opts = {}) + request_stripe_object( + method: :get, + path: format("/v1/customers/%s/payment_methods/%s", { customer: CGI.escape(customer), payment_method: CGI.escape(payment_method) }), + params: params, + opts: opts + ) end def self.search(params = {}, opts = {}) @@ -165,16 +167,6 @@ def self.update(id, params = {}, opts = {}) ) end - # Retrieves a customer's cash balance. - def self.retrieve_cash_balance(customer, params = {}, opts = {}) - request_stripe_object( - method: :get, - path: format("/v1/customers/%s/cash_balance", { customer: CGI.escape(customer) }), - params: params, - opts: opts - ) - end - # Changes the settings on a customer's cash balance. def self.update_cash_balance(customer, params = {}, opts = {}) request_stripe_object( @@ -185,6 +177,14 @@ def self.update_cash_balance(customer, params = {}, opts = {}) ) end + save_nested_resource :source + + # The API request for deleting a card or bank account and for detaching a + # source object are the same. + class << self + alias detach_source delete_source + end + def test_helpers TestHelpers.new(self) end diff --git a/lib/stripe/resources/ephemeral_key.rb b/lib/stripe/resources/ephemeral_key.rb index 6c25f3b20..c2115b2fa 100644 --- a/lib/stripe/resources/ephemeral_key.rb +++ b/lib/stripe/resources/ephemeral_key.rb @@ -11,15 +11,6 @@ def self.object_name "ephemeral_key" end - def self.create(params = {}, opts = {}) - opts = Util.normalize_opts(opts) - unless opts[:stripe_version] - raise ArgumentError, - "stripe_version must be specified to create an ephemeral key" - end - super - end - # Invalidates a short-lived API key for a given resource. def self.delete(id, params = {}, opts = {}) request_stripe_object( @@ -39,5 +30,14 @@ def delete(params = {}, opts = {}) opts: opts ) end + + def self.create(params = {}, opts = {}) + opts = Util.normalize_opts(opts) + unless opts[:stripe_version] + raise ArgumentError, + "stripe_version must be specified to create an ephemeral key" + end + super + end end end diff --git a/lib/stripe/resources/file.rb b/lib/stripe/resources/file.rb index 3088faede..7f991f263 100644 --- a/lib/stripe/resources/file.rb +++ b/lib/stripe/resources/file.rb @@ -18,6 +18,11 @@ def self.object_name "file" end + # Returns a list of the files that your account has access to. Stripe sorts and returns the files by their creation dates, placing the most recently created files at the top. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/files", params: filters, opts: opts) + end + # This resource can have two different object names. In latter API # versions, only `file` is used, but since stripe-ruby may be used with # any API version, we need to support deserializing the older @@ -43,10 +48,5 @@ def self.create(params = {}, opts = {}) }.merge(Util.normalize_opts(opts)) super end - - # Returns a list of the files that your account has access to. Stripe sorts and returns the files by their creation dates, placing the most recently created files at the top. - def self.list(filters = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/files", params: filters, opts: opts) - end end end diff --git a/lib/stripe/resources/financial_connections/account.rb b/lib/stripe/resources/financial_connections/account.rb index 4e1163ce2..0669e373e 100644 --- a/lib/stripe/resources/financial_connections/account.rb +++ b/lib/stripe/resources/financial_connections/account.rb @@ -22,71 +22,71 @@ def disconnect(params = {}, opts = {}) ) end - # Lists all owners for a given Account - def list_owners(params = {}, opts = {}) + # Disables your access to a Financial Connections Account. You will no longer be able to access data associated with the account (e.g. balances, transactions). + def self.disconnect(account, params = {}, opts = {}) request_stripe_object( - method: :get, - path: format("/v1/financial_connections/accounts/%s/owners", { account: CGI.escape(self["id"]) }), + method: :post, + path: format("/v1/financial_connections/accounts/%s/disconnect", { account: CGI.escape(account) }), params: params, opts: opts ) end - # Refreshes the data associated with a Financial Connections Account. - def refresh_account(params = {}, opts = {}) + # Returns a list of Financial Connections Account objects. + def self.list(filters = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/financial_connections/accounts/%s/refresh", { account: CGI.escape(self["id"]) }), - params: params, + method: :get, + path: "/v1/financial_connections/accounts", + params: filters, opts: opts ) end - # Subscribes to periodic refreshes of data associated with a Financial Connections Account. - def subscribe(params = {}, opts = {}) + # Lists all owners for a given Account + def list_owners(params = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/financial_connections/accounts/%s/subscribe", { account: CGI.escape(self["id"]) }), + method: :get, + path: format("/v1/financial_connections/accounts/%s/owners", { account: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Unsubscribes from periodic refreshes of data associated with a Financial Connections Account. - def unsubscribe(params = {}, opts = {}) + # Lists all owners for a given Account + def self.list_owners(account, params = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/financial_connections/accounts/%s/unsubscribe", { account: CGI.escape(self["id"]) }), + method: :get, + path: format("/v1/financial_connections/accounts/%s/owners", { account: CGI.escape(account) }), params: params, opts: opts ) end - # Disables your access to a Financial Connections Account. You will no longer be able to access data associated with the account (e.g. balances, transactions). - def self.disconnect(account, params = {}, opts = {}) + # Refreshes the data associated with a Financial Connections Account. + def refresh_account(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/financial_connections/accounts/%s/disconnect", { account: CGI.escape(account) }), + path: format("/v1/financial_connections/accounts/%s/refresh", { account: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Lists all owners for a given Account - def self.list_owners(account, params = {}, opts = {}) + # Refreshes the data associated with a Financial Connections Account. + def self.refresh_account(account, params = {}, opts = {}) request_stripe_object( - method: :get, - path: format("/v1/financial_connections/accounts/%s/owners", { account: CGI.escape(account) }), + method: :post, + path: format("/v1/financial_connections/accounts/%s/refresh", { account: CGI.escape(account) }), params: params, opts: opts ) end - # Refreshes the data associated with a Financial Connections Account. - def self.refresh_account(account, params = {}, opts = {}) + # Subscribes to periodic refreshes of data associated with a Financial Connections Account. + def subscribe(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/financial_connections/accounts/%s/refresh", { account: CGI.escape(account) }), + path: format("/v1/financial_connections/accounts/%s/subscribe", { account: CGI.escape(self["id"]) }), params: params, opts: opts ) @@ -103,21 +103,21 @@ def self.subscribe(account, params = {}, opts = {}) end # Unsubscribes from periodic refreshes of data associated with a Financial Connections Account. - def self.unsubscribe(account, params = {}, opts = {}) + def unsubscribe(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/financial_connections/accounts/%s/unsubscribe", { account: CGI.escape(account) }), + path: format("/v1/financial_connections/accounts/%s/unsubscribe", { account: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Returns a list of Financial Connections Account objects. - def self.list(filters = {}, opts = {}) + # Unsubscribes from periodic refreshes of data associated with a Financial Connections Account. + def self.unsubscribe(account, params = {}, opts = {}) request_stripe_object( - method: :get, - path: "/v1/financial_connections/accounts", - params: filters, + method: :post, + path: format("/v1/financial_connections/accounts/%s/unsubscribe", { account: CGI.escape(account) }), + params: params, opts: opts ) end diff --git a/lib/stripe/resources/identity/verification_session.rb b/lib/stripe/resources/identity/verification_session.rb index 79f82f870..9ba8789b0 100644 --- a/lib/stripe/resources/identity/verification_session.rb +++ b/lib/stripe/resources/identity/verification_session.rb @@ -36,6 +36,44 @@ def cancel(params = {}, opts = {}) ) end + # A VerificationSession object can be canceled when it is in requires_input [status](https://stripe.com/docs/identity/how-sessions-work). + # + # Once canceled, future submission attempts are disabled. This cannot be undone. [Learn more](https://stripe.com/docs/identity/verification-sessions#cancel). + def self.cancel(session, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/identity/verification_sessions/%s/cancel", { session: CGI.escape(session) }), + params: params, + opts: opts + ) + end + + # Creates a VerificationSession object. + # + # After the VerificationSession is created, display a verification modal using the session client_secret or send your users to the session's url. + # + # If your API key is in test mode, verification checks won't actually process, though everything else will occur as if in live mode. + # + # Related guide: [Verify your users' identity documents](https://stripe.com/docs/identity/verify-identity-documents) + def self.create(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: "/v1/identity/verification_sessions", + params: params, + opts: opts + ) + end + + # Returns a list of VerificationSessions + def self.list(filters = {}, opts = {}) + request_stripe_object( + method: :get, + path: "/v1/identity/verification_sessions", + params: filters, + opts: opts + ) + end + # Redact a VerificationSession to remove all collected information from Stripe. This will redact # the VerificationSession and all objects related to it, including VerificationReports, Events, # request logs, etc. @@ -64,18 +102,6 @@ def redact(params = {}, opts = {}) ) end - # A VerificationSession object can be canceled when it is in requires_input [status](https://stripe.com/docs/identity/how-sessions-work). - # - # Once canceled, future submission attempts are disabled. This cannot be undone. [Learn more](https://stripe.com/docs/identity/verification-sessions#cancel). - def self.cancel(session, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/identity/verification_sessions/%s/cancel", { session: CGI.escape(session) }), - params: params, - opts: opts - ) - end - # Redact a VerificationSession to remove all collected information from Stripe. This will redact # the VerificationSession and all objects related to it, including VerificationReports, Events, # request logs, etc. @@ -104,32 +130,6 @@ def self.redact(session, params = {}, opts = {}) ) end - # Creates a VerificationSession object. - # - # After the VerificationSession is created, display a verification modal using the session client_secret or send your users to the session's url. - # - # If your API key is in test mode, verification checks won't actually process, though everything else will occur as if in live mode. - # - # Related guide: [Verify your users' identity documents](https://stripe.com/docs/identity/verify-identity-documents) - def self.create(params = {}, opts = {}) - request_stripe_object( - method: :post, - path: "/v1/identity/verification_sessions", - params: params, - opts: opts - ) - end - - # Returns a list of VerificationSessions - def self.list(filters = {}, opts = {}) - request_stripe_object( - method: :get, - path: "/v1/identity/verification_sessions", - params: filters, - opts: opts - ) - end - # Updates a VerificationSession object. # # When the session status is requires_input, you can use this method to update the diff --git a/lib/stripe/resources/invoice.rb b/lib/stripe/resources/invoice.rb index 98081194e..2c26ab5c0 100644 --- a/lib/stripe/resources/invoice.rb +++ b/lib/stripe/resources/invoice.rb @@ -46,83 +46,91 @@ def self.object_name "invoice" end - # Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method. - def finalize_invoice(params = {}, opts = {}) + # This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you [finalize the invoice, which allows you to [pay](#pay_invoice) or send](https://stripe.com/docs/api#finalize_invoice) the invoice to your customers. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/invoices", params: params, opts: opts) + end + + # Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). + def self.delete(id, params = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/invoices/%s/finalize", { invoice: CGI.escape(self["id"]) }), + method: :delete, + path: format("/v1/invoices/%s", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. - def mark_uncollectible(params = {}, opts = {}) + # Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). + def delete(params = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/invoices/%s/mark_uncollectible", { invoice: CGI.escape(self["id"]) }), + method: :delete, + path: format("/v1/invoices/%s", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. - def pay(params = {}, opts = {}) + # Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method. + def finalize_invoice(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/invoices/%s/pay", { invoice: CGI.escape(self["id"]) }), + path: format("/v1/invoices/%s/finalize", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email. - # - # Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event. - def send_invoice(params = {}, opts = {}) + # Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method. + def self.finalize_invoice(invoice, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/invoices/%s/send", { invoice: CGI.escape(self["id"]) }), + path: format("/v1/invoices/%s/finalize", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end - # Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. - def void_invoice(params = {}, opts = {}) + # You can list all invoices, or list the invoices for a specific customer. The invoices are returned sorted by creation date, with the most recently created invoices appearing first. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/invoices", params: filters, opts: opts) + end + + # When retrieving an upcoming invoice, you'll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + def self.list_upcoming_line_items(params = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/invoices/%s/void", { invoice: CGI.escape(self["id"]) }), + method: :get, + path: "/v1/invoices/upcoming/lines", params: params, opts: opts ) end - # Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method. - def self.finalize_invoice(invoice, params = {}, opts = {}) + # Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + def mark_uncollectible(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/invoices/%s/finalize", { invoice: CGI.escape(invoice) }), + path: format("/v1/invoices/%s/mark_uncollectible", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # When retrieving an upcoming invoice, you'll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. - def self.list_upcoming_line_items(params = {}, opts = {}) + # Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + def self.mark_uncollectible(invoice, params = {}, opts = {}) request_stripe_object( - method: :get, - path: "/v1/invoices/upcoming/lines", + method: :post, + path: format("/v1/invoices/%s/mark_uncollectible", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end - # Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. - def self.mark_uncollectible(invoice, params = {}, opts = {}) + # Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. + def pay(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/invoices/%s/mark_uncollectible", { invoice: CGI.escape(invoice) }), + path: format("/v1/invoices/%s/pay", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) @@ -138,6 +146,26 @@ def self.pay(invoice, params = {}, opts = {}) ) end + def self.search(params = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/invoices/search", params: params, opts: opts) + end + + def self.search_auto_paging_each(params = {}, opts = {}, &blk) + search(params, opts).auto_paging_each(&blk) + end + + # Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email. + # + # Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event. + def send_invoice(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/send", { invoice: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + # Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email. # # Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event. @@ -159,64 +187,36 @@ def self.upcoming(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/invoices/upcoming", params: params, opts: opts) end - # Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. - def self.void_invoice(invoice, params = {}, opts = {}) + # Draft invoices are fully editable. Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized), + # monetary values, as well as collection_method, become uneditable. + # + # If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on, + # sending reminders for, or [automatically reconciling](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass + # auto_advance=false. + def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/invoices/%s/void", { invoice: CGI.escape(invoice) }), - params: params, - opts: opts - ) - end - - # This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you [finalize the invoice, which allows you to [pay](#pay_invoice) or send](https://stripe.com/docs/api#finalize_invoice) the invoice to your customers. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/invoices", params: params, opts: opts) - end - - # Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). - def self.delete(id, params = {}, opts = {}) - request_stripe_object( - method: :delete, path: format("/v1/invoices/%s", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). - def delete(params = {}, opts = {}) + # Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. + def void_invoice(params = {}, opts = {}) request_stripe_object( - method: :delete, - path: format("/v1/invoices/%s", { invoice: CGI.escape(self["id"]) }), + method: :post, + path: format("/v1/invoices/%s/void", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # You can list all invoices, or list the invoices for a specific customer. The invoices are returned sorted by creation date, with the most recently created invoices appearing first. - def self.list(filters = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/invoices", params: filters, opts: opts) - end - - def self.search(params = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/invoices/search", params: params, opts: opts) - end - - def self.search_auto_paging_each(params = {}, opts = {}, &blk) - search(params, opts).auto_paging_each(&blk) - end - - # Draft invoices are fully editable. Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized), - # monetary values, as well as collection_method, become uneditable. - # - # If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on, - # sending reminders for, or [automatically reconciling](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass - # auto_advance=false. - def self.update(id, params = {}, opts = {}) + # Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. + def self.void_invoice(invoice, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/invoices/%s", { id: CGI.escape(id) }), + path: format("/v1/invoices/%s/void", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/issuing/authorization.rb b/lib/stripe/resources/issuing/authorization.rb index dc60286a8..8d4ebfd7e 100644 --- a/lib/stripe/resources/issuing/authorization.rb +++ b/lib/stripe/resources/issuing/authorization.rb @@ -28,23 +28,23 @@ def approve(params = {}, opts = {}) ) end - # [Deprecated] Declines a pending Issuing Authorization object. This request should be made within the timeout window of the [real time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. - # This method is deprecated. Instead, [respond directly to the webhook request to decline an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). - def decline(params = {}, opts = {}) + # [Deprecated] Approves a pending Issuing Authorization object. This request should be made within the timeout window of the [real-time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. + # This method is deprecated. Instead, [respond directly to the webhook request to approve an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). + def self.approve(authorization, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/issuing/authorizations/%s/decline", { authorization: CGI.escape(self["id"]) }), + path: format("/v1/issuing/authorizations/%s/approve", { authorization: CGI.escape(authorization) }), params: params, opts: opts ) end - # [Deprecated] Approves a pending Issuing Authorization object. This request should be made within the timeout window of the [real-time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. - # This method is deprecated. Instead, [respond directly to the webhook request to approve an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). - def self.approve(authorization, params = {}, opts = {}) + # [Deprecated] Declines a pending Issuing Authorization object. This request should be made within the timeout window of the [real time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. + # This method is deprecated. Instead, [respond directly to the webhook request to decline an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). + def decline(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/issuing/authorizations/%s/approve", { authorization: CGI.escape(authorization) }), + path: format("/v1/issuing/authorizations/%s/decline", { authorization: CGI.escape(self["id"]) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/issuing/dispute.rb b/lib/stripe/resources/issuing/dispute.rb index c0318b54e..98527d73f 100644 --- a/lib/stripe/resources/issuing/dispute.rb +++ b/lib/stripe/resources/issuing/dispute.rb @@ -16,42 +16,42 @@ def self.object_name "issuing.dispute" end - # Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence). - def submit(params = {}, opts = {}) + # Creates an Issuing Dispute object. Individual pieces of evidence within the evidence object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence) for more details about evidence requirements. + def self.create(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/issuing/disputes/%s/submit", { dispute: CGI.escape(self["id"]) }), + path: "/v1/issuing/disputes", params: params, opts: opts ) end - # Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence). - def self.submit(dispute, params = {}, opts = {}) + # Returns a list of Issuing Dispute objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + def self.list(filters = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/issuing/disputes/%s/submit", { dispute: CGI.escape(dispute) }), - params: params, + method: :get, + path: "/v1/issuing/disputes", + params: filters, opts: opts ) end - # Creates an Issuing Dispute object. Individual pieces of evidence within the evidence object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence) for more details about evidence requirements. - def self.create(params = {}, opts = {}) + # Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence). + def submit(params = {}, opts = {}) request_stripe_object( method: :post, - path: "/v1/issuing/disputes", + path: format("/v1/issuing/disputes/%s/submit", { dispute: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Returns a list of Issuing Dispute objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. - def self.list(filters = {}, opts = {}) + # Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence). + def self.submit(dispute, params = {}, opts = {}) request_stripe_object( - method: :get, - path: "/v1/issuing/disputes", - params: filters, + method: :post, + path: format("/v1/issuing/disputes/%s/submit", { dispute: CGI.escape(dispute) }), + params: params, opts: opts ) end diff --git a/lib/stripe/resources/payment_intent.rb b/lib/stripe/resources/payment_intent.rb index f9d5c1a65..d25d8a304 100644 --- a/lib/stripe/resources/payment_intent.rb +++ b/lib/stripe/resources/payment_intent.rb @@ -34,6 +34,16 @@ def apply_customer_balance(params = {}, opts = {}) ) end + # Manually reconcile the remaining amount for a customer_balance PaymentIntent. + def self.apply_customer_balance(intent, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/payment_intents/%s/apply_customer_balance", { intent: CGI.escape(intent) }), + params: params, + opts: opts + ) + end + # You can cancel a PaymentIntent object when it's in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](https://stripe.com/docs/payments/intents), processing. # # After it's canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded. @@ -48,6 +58,20 @@ def cancel(params = {}, opts = {}) ) end + # You can cancel a PaymentIntent object when it's in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](https://stripe.com/docs/payments/intents), processing. + # + # After it's canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded. + # + # You can't cancel the PaymentIntent for a Checkout Session. [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead. + def self.cancel(intent, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/payment_intents/%s/cancel", { intent: CGI.escape(intent) }), + params: params, + opts: opts + ) + end + # Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture. # # Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation. @@ -62,6 +86,20 @@ def capture(params = {}, opts = {}) ) end + # Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture. + # + # Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation. + # + # Learn more about [separate authorization and capture](https://stripe.com/docs/payments/capture-later). + def self.capture(intent, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/payment_intents/%s/capture", { intent: CGI.escape(intent) }), + params: params, + opts: opts + ) + end + # Confirm that your customer intends to pay with current or provided # payment method. Upon confirmation, the PaymentIntent will attempt to initiate # a payment. @@ -93,87 +131,6 @@ def confirm(params = {}, 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 - # [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) - # must be true. - # - # Incremental authorizations attempt to increase the authorized amount on - # your customer's card to the new, higher amount provided. Similar to the - # initial authorization, incremental authorizations can be declined. A - # single PaymentIntent can call this endpoint multiple times to further - # increase the authorized amount. - # - # If the incremental authorization succeeds, the PaymentIntent object - # returns with the updated - # [amount](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). - # If the incremental authorization fails, a - # [card_declined](https://stripe.com/docs/error-codes#card-declined) error returns, and no other - # fields on the PaymentIntent or Charge update. The PaymentIntent - # object remains capturable for the previously authorized amount. - # - # Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. - # After it's captured, a PaymentIntent can no longer be incremented. - # - # Learn more about [incremental authorizations](https://stripe.com/docs/terminal/features/incremental-authorizations). - def increment_authorization(params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/payment_intents/%s/increment_authorization", { intent: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - # Verifies microdeposits on a PaymentIntent object. - def verify_microdeposits(params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/payment_intents/%s/verify_microdeposits", { intent: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - # Manually reconcile the remaining amount for a customer_balance PaymentIntent. - def self.apply_customer_balance(intent, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/payment_intents/%s/apply_customer_balance", { intent: CGI.escape(intent) }), - params: params, - opts: opts - ) - end - - # You can cancel a PaymentIntent object when it's in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](https://stripe.com/docs/payments/intents), processing. - # - # After it's canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded. - # - # You can't cancel the PaymentIntent for a Checkout Session. [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead. - def self.cancel(intent, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/payment_intents/%s/cancel", { intent: CGI.escape(intent) }), - params: params, - opts: opts - ) - end - - # Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture. - # - # Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation. - # - # Learn more about [separate authorization and capture](https://stripe.com/docs/payments/capture-later). - def self.capture(intent, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/payment_intents/%s/capture", { intent: CGI.escape(intent) }), - params: params, - opts: opts - ) - end - # Confirm that your customer intends to pay with current or provided # payment method. Upon confirmation, the PaymentIntent will attempt to initiate # a payment. @@ -205,6 +162,20 @@ def self.confirm(intent, params = {}, opts = {}) ) end + # Creates a PaymentIntent object. + # + # After the PaymentIntent is created, attach a payment method and [confirm](https://stripe.com/docs/api/payment_intents/confirm) + # to continue the payment. Learn more about the available payment flows + # with the Payment Intents API. + # + # When you use confirm=true during creation, it's equivalent to creating + # and confirming the PaymentIntent in the same call. You can use any parameters + # available in the [confirm API](https://stripe.com/docs/api/payment_intents/confirm) when you supply + # confirm=true. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/payment_intents", 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 @@ -229,39 +200,48 @@ def self.confirm(intent, params = {}, opts = {}) # After it's captured, a PaymentIntent can no longer be incremented. # # Learn more about [incremental authorizations](https://stripe.com/docs/terminal/features/incremental-authorizations). - def self.increment_authorization(intent, params = {}, opts = {}) + def increment_authorization(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/payment_intents/%s/increment_authorization", { intent: CGI.escape(intent) }), + path: format("/v1/payment_intents/%s/increment_authorization", { intent: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Verifies microdeposits on a PaymentIntent object. - def self.verify_microdeposits(intent, params = {}, opts = {}) + # 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 + # [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) + # must be true. + # + # Incremental authorizations attempt to increase the authorized amount on + # your customer's card to the new, higher amount provided. Similar to the + # initial authorization, incremental authorizations can be declined. A + # single PaymentIntent can call this endpoint multiple times to further + # increase the authorized amount. + # + # If the incremental authorization succeeds, the PaymentIntent object + # returns with the updated + # [amount](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). + # If the incremental authorization fails, a + # [card_declined](https://stripe.com/docs/error-codes#card-declined) error returns, and no other + # fields on the PaymentIntent or Charge update. The PaymentIntent + # object remains capturable for the previously authorized amount. + # + # Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. + # After it's captured, a PaymentIntent can no longer be incremented. + # + # Learn more about [incremental authorizations](https://stripe.com/docs/terminal/features/incremental-authorizations). + def self.increment_authorization(intent, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/payment_intents/%s/verify_microdeposits", { intent: CGI.escape(intent) }), + path: format("/v1/payment_intents/%s/increment_authorization", { intent: CGI.escape(intent) }), params: params, opts: opts ) end - # Creates a PaymentIntent object. - # - # After the PaymentIntent is created, attach a payment method and [confirm](https://stripe.com/docs/api/payment_intents/confirm) - # to continue the payment. Learn more about the available payment flows - # with the Payment Intents API. - # - # When you use confirm=true during creation, it's equivalent to creating - # and confirming the PaymentIntent in the same call. You can use any parameters - # available in the [confirm API](https://stripe.com/docs/api/payment_intents/confirm) when you supply - # confirm=true. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/payment_intents", params: params, opts: opts) - end - # Returns a list of PaymentIntents. def self.list(filters = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/payment_intents", params: filters, opts: opts) @@ -295,5 +275,25 @@ def self.update(id, params = {}, opts = {}) opts: opts ) end + + # Verifies microdeposits on a PaymentIntent object. + def verify_microdeposits(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/payment_intents/%s/verify_microdeposits", { intent: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Verifies microdeposits on a PaymentIntent object. + def self.verify_microdeposits(intent, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/payment_intents/%s/verify_microdeposits", { intent: CGI.escape(intent) }), + params: params, + opts: opts + ) + end end end diff --git a/lib/stripe/resources/payment_link.rb b/lib/stripe/resources/payment_link.rb index 9673bd22d..d01787067 100644 --- a/lib/stripe/resources/payment_link.rb +++ b/lib/stripe/resources/payment_link.rb @@ -17,6 +17,16 @@ def self.object_name "payment_link" end + # Creates a payment link. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/payment_links", params: params, opts: opts) + end + + # Returns a list of your payment links. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/payment_links", params: filters, opts: opts) + end + # When retrieving a payment link, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. def list_line_items(params = {}, opts = {}) request_stripe_object( @@ -37,16 +47,6 @@ def self.list_line_items(payment_link, params = {}, opts = {}) ) end - # Creates a payment link. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/payment_links", params: params, opts: opts) - end - - # Returns a list of your payment links. - def self.list(filters = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/payment_links", params: filters, opts: opts) - end - # Updates a payment link. def self.update(id, params = {}, opts = {}) request_stripe_object( diff --git a/lib/stripe/resources/payment_method.rb b/lib/stripe/resources/payment_method.rb index 56f4d6de6..3415bf08b 100644 --- a/lib/stripe/resources/payment_method.rb +++ b/lib/stripe/resources/payment_method.rb @@ -39,16 +39,6 @@ def attach(params = {}, opts = {}) ) end - # Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer. - def detach(params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/payment_methods/%s/detach", { payment_method: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - # Attaches a PaymentMethod object to a Customer. # # To attach a new PaymentMethod to a customer for future payments, we recommend you use a [SetupIntent](https://stripe.com/docs/api/setup_intents) @@ -71,6 +61,23 @@ def self.attach(payment_method, params = {}, opts = {}) ) end + # Creates a PaymentMethod object. Read the [Stripe.js reference](https://stripe.com/docs/stripe-js/reference#stripe-create-payment-method) to learn how to create PaymentMethods via Stripe.js. + # + # Instead of creating a PaymentMethod directly, we recommend using the [PaymentIntents API to accept a payment immediately or the SetupIntent](https://stripe.com/docs/payments/accept-a-payment) API to collect payment method details ahead of a future payment. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/payment_methods", params: params, opts: opts) + end + + # Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer. + def detach(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/payment_methods/%s/detach", { payment_method: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + # Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer. def self.detach(payment_method, params = {}, opts = {}) request_stripe_object( @@ -81,13 +88,6 @@ def self.detach(payment_method, params = {}, opts = {}) ) end - # Creates a PaymentMethod object. Read the [Stripe.js reference](https://stripe.com/docs/stripe-js/reference#stripe-create-payment-method) to learn how to create PaymentMethods via Stripe.js. - # - # Instead of creating a PaymentMethod directly, we recommend using the [PaymentIntents API to accept a payment immediately or the SetupIntent](https://stripe.com/docs/payments/accept-a-payment) API to collect payment method details ahead of a future payment. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/payment_methods", params: params, opts: opts) - end - # Returns a list of PaymentMethods for Treasury flows. If you want to list the PaymentMethods attached to a Customer for payments, you should use the [List a Customer's PaymentMethods](https://stripe.com/docs/api/payment_methods/customer_list) API instead. def self.list(filters = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/payment_methods", params: filters, opts: opts) diff --git a/lib/stripe/resources/payment_method_domain.rb b/lib/stripe/resources/payment_method_domain.rb index 155e16997..26a2c6f7c 100644 --- a/lib/stripe/resources/payment_method_domain.rb +++ b/lib/stripe/resources/payment_method_domain.rb @@ -16,61 +16,61 @@ def self.object_name "payment_method_domain" end - # Some payment methods such as Apple Pay require additional steps to verify a domain. If the requirements weren't satisfied when the domain was created, the payment method will be inactive on the domain. - # The payment method doesn't appear in Elements for this domain until it is active. - # - # To activate a payment method on an existing payment method domain, complete the required validation steps specific to the payment method, and then validate the payment method domain with this endpoint. - # - # Related guides: [Payment method domains](https://stripe.com/docs/payments/payment-methods/pmd-registration). - def validate(params = {}, opts = {}) + # Creates a payment method domain. + def self.create(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/payment_method_domains/%s/validate", { payment_method_domain: CGI.escape(self["id"]) }), + path: "/v1/payment_method_domains", params: params, opts: opts ) end - # Some payment methods such as Apple Pay require additional steps to verify a domain. If the requirements weren't satisfied when the domain was created, the payment method will be inactive on the domain. - # The payment method doesn't appear in Elements for this domain until it is active. - # - # To activate a payment method on an existing payment method domain, complete the required validation steps specific to the payment method, and then validate the payment method domain with this endpoint. - # - # Related guides: [Payment method domains](https://stripe.com/docs/payments/payment-methods/pmd-registration). - def self.validate(payment_method_domain, params = {}, opts = {}) + # Lists the details of existing payment method domains. + def self.list(filters = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/payment_method_domains/%s/validate", { payment_method_domain: CGI.escape(payment_method_domain) }), - params: params, + method: :get, + path: "/v1/payment_method_domains", + params: filters, opts: opts ) end - # Creates a payment method domain. - def self.create(params = {}, opts = {}) + # Updates an existing payment method domain. + def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, - path: "/v1/payment_method_domains", + path: format("/v1/payment_method_domains/%s", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Lists the details of existing payment method domains. - def self.list(filters = {}, opts = {}) + # Some payment methods such as Apple Pay require additional steps to verify a domain. If the requirements weren't satisfied when the domain was created, the payment method will be inactive on the domain. + # The payment method doesn't appear in Elements for this domain until it is active. + # + # To activate a payment method on an existing payment method domain, complete the required validation steps specific to the payment method, and then validate the payment method domain with this endpoint. + # + # Related guides: [Payment method domains](https://stripe.com/docs/payments/payment-methods/pmd-registration). + def validate(params = {}, opts = {}) request_stripe_object( - method: :get, - path: "/v1/payment_method_domains", - params: filters, + method: :post, + path: format("/v1/payment_method_domains/%s/validate", { payment_method_domain: CGI.escape(self["id"]) }), + params: params, opts: opts ) end - # Updates an existing payment method domain. - def self.update(id, params = {}, opts = {}) + # Some payment methods such as Apple Pay require additional steps to verify a domain. If the requirements weren't satisfied when the domain was created, the payment method will be inactive on the domain. + # The payment method doesn't appear in Elements for this domain until it is active. + # + # To activate a payment method on an existing payment method domain, complete the required validation steps specific to the payment method, and then validate the payment method domain with this endpoint. + # + # Related guides: [Payment method domains](https://stripe.com/docs/payments/payment-methods/pmd-registration). + def self.validate(payment_method_domain, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/payment_method_domains/%s", { id: CGI.escape(id) }), + path: format("/v1/payment_method_domains/%s/validate", { payment_method_domain: CGI.escape(payment_method_domain) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/payout.rb b/lib/stripe/resources/payout.rb index 4bb2cf23b..1f98b485b 100644 --- a/lib/stripe/resources/payout.rb +++ b/lib/stripe/resources/payout.rb @@ -30,23 +30,37 @@ def cancel(params = {}, opts = {}) ) end - # Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is manual and in the pending status, use /v1/payouts/:id/cancel instead. - # - # By requesting a reversal through /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account authorizes the debit on the bank account and that no other authorization is required. - def reverse(params = {}, opts = {}) + # You can cancel a previously created payout if its status is pending. Stripe refunds the funds to your available balance. You can't cancel automatic Stripe payouts. + def self.cancel(payout, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/payouts/%s/reverse", { payout: CGI.escape(self["id"]) }), + path: format("/v1/payouts/%s/cancel", { payout: CGI.escape(payout) }), params: params, opts: opts ) end - # You can cancel a previously created payout if its status is pending. Stripe refunds the funds to your available balance. You can't cancel automatic Stripe payouts. - def self.cancel(payout, params = {}, opts = {}) + # To send funds to your own bank account, create a new payout object. Your [Stripe balance](https://stripe.com/docs/api#balance) must cover the payout amount. If it doesn't, you receive an “Insufficient Funds” error. + # + # If your API key is in test mode, money won't actually be sent, though every other action occurs as if you're in live mode. + # + # If you create a manual payout on a Stripe account that uses multiple payment source types, you need to specify the source type balance that the payout draws from. The [balance object](https://stripe.com/docs/api#balance_object) details available and pending amounts by source type. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/payouts", params: params, opts: opts) + end + + # Returns a list of existing payouts sent to third-party bank accounts or payouts that Stripe sent to you. The payouts return in sorted order, with the most recently created payouts appearing first. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/payouts", params: filters, opts: opts) + end + + # Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is manual and in the pending status, use /v1/payouts/:id/cancel instead. + # + # By requesting a reversal through /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account authorizes the debit on the bank account and that no other authorization is required. + def reverse(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/payouts/%s/cancel", { payout: CGI.escape(payout) }), + path: format("/v1/payouts/%s/reverse", { payout: CGI.escape(self["id"]) }), params: params, opts: opts ) @@ -64,20 +78,6 @@ def self.reverse(payout, params = {}, opts = {}) ) end - # To send funds to your own bank account, create a new payout object. Your [Stripe balance](https://stripe.com/docs/api#balance) must cover the payout amount. If it doesn't, you receive an “Insufficient Funds” error. - # - # If your API key is in test mode, money won't actually be sent, though every other action occurs as if you're in live mode. - # - # If you create a manual payout on a Stripe account that uses multiple payment source types, you need to specify the source type balance that the payout draws from. The [balance object](https://stripe.com/docs/api#balance_object) details available and pending amounts by source type. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/payouts", params: params, opts: opts) - end - - # Returns a list of existing payouts sent to third-party bank accounts or payouts that Stripe sent to you. The payouts return in sorted order, with the most recently created payouts appearing first. - def self.list(filters = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/payouts", params: filters, opts: opts) - end - # Updates the specified payout by setting the values of the parameters you pass. We don't change parameters that you don't provide. This request only accepts the metadata as arguments. def self.update(id, params = {}, opts = {}) request_stripe_object( diff --git a/lib/stripe/resources/quote.rb b/lib/stripe/resources/quote.rb index 28ddd819c..69c5ef48b 100644 --- a/lib/stripe/resources/quote.rb +++ b/lib/stripe/resources/quote.rb @@ -24,84 +24,71 @@ def accept(params = {}, opts = {}) ) end - # Cancels the quote. - def cancel(params = {}, opts = {}) + # Accepts the specified quote. + def self.accept(quote, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/quotes/%s/cancel", { quote: CGI.escape(self["id"]) }), + path: format("/v1/quotes/%s/accept", { quote: CGI.escape(quote) }), params: params, opts: opts ) end - # Finalizes the quote. - def finalize_quote(params = {}, opts = {}) + # Cancels the quote. + def cancel(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/quotes/%s/finalize", { quote: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - # When retrieving a quote, there is an includable [computed.upfront.line_items](https://stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items. - def list_computed_upfront_line_items(params = {}, opts = {}) - request_stripe_object( - method: :get, - path: format("/v1/quotes/%s/computed_upfront_line_items", { quote: CGI.escape(self["id"]) }), + path: format("/v1/quotes/%s/cancel", { quote: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. - def list_line_items(params = {}, opts = {}) + # Cancels the quote. + def self.cancel(quote, params = {}, opts = {}) request_stripe_object( - method: :get, - path: format("/v1/quotes/%s/line_items", { quote: CGI.escape(self["id"]) }), + method: :post, + path: format("/v1/quotes/%s/cancel", { quote: CGI.escape(quote) }), params: params, opts: opts ) end - # Download the PDF for a finalized quote - def pdf(params = {}, opts = {}, &read_body_chunk_block) - config = opts[:client]&.config || Stripe.config - opts = { api_base: config.uploads_base }.merge(opts) - request_stream( - method: :get, - path: format("/v1/quotes/%s/pdf", { quote: CGI.escape(self["id"]) }), - params: params, - opts: opts, - &read_body_chunk_block - ) + # A quote models prices and services for a customer. Default options for header, description, footer, and expires_at can be set in the dashboard via the [quote template](https://dashboard.stripe.com/settings/billing/quote). + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/quotes", params: params, opts: opts) end - # Accepts the specified quote. - def self.accept(quote, params = {}, opts = {}) + # Finalizes the quote. + def finalize_quote(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/quotes/%s/accept", { quote: CGI.escape(quote) }), + path: format("/v1/quotes/%s/finalize", { quote: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Cancels the quote. - def self.cancel(quote, params = {}, opts = {}) + # Finalizes the quote. + def self.finalize_quote(quote, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/quotes/%s/cancel", { quote: CGI.escape(quote) }), + path: format("/v1/quotes/%s/finalize", { quote: CGI.escape(quote) }), params: params, opts: opts ) end - # Finalizes the quote. - def self.finalize_quote(quote, params = {}, opts = {}) + # Returns a list of your quotes. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/quotes", params: filters, opts: opts) + end + + # When retrieving a quote, there is an includable [computed.upfront.line_items](https://stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items. + def list_computed_upfront_line_items(params = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/quotes/%s/finalize", { quote: CGI.escape(quote) }), + method: :get, + path: format("/v1/quotes/%s/computed_upfront_line_items", { quote: CGI.escape(self["id"]) }), params: params, opts: opts ) @@ -117,6 +104,16 @@ def self.list_computed_upfront_line_items(quote, params = {}, opts = {}) ) end + # When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + def list_line_items(params = {}, opts = {}) + request_stripe_object( + method: :get, + path: format("/v1/quotes/%s/line_items", { quote: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + # When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. def self.list_line_items(quote, params = {}, opts = {}) request_stripe_object( @@ -127,6 +124,19 @@ def self.list_line_items(quote, params = {}, opts = {}) ) end + # Download the PDF for a finalized quote + def pdf(params = {}, opts = {}, &read_body_chunk_block) + config = opts[:client]&.config || Stripe.config + opts = { api_base: config.uploads_base }.merge(opts) + request_stream( + method: :get, + path: format("/v1/quotes/%s/pdf", { quote: CGI.escape(self["id"]) }), + params: params, + opts: opts, + &read_body_chunk_block + ) + end + # Download the PDF for a finalized quote def self.pdf(quote, params = {}, opts = {}, &read_body_chunk_block) config = opts[:client]&.config || Stripe.config @@ -140,16 +150,6 @@ def self.pdf(quote, params = {}, opts = {}, &read_body_chunk_block) ) end - # A quote models prices and services for a customer. Default options for header, description, footer, and expires_at can be set in the dashboard via the [quote template](https://dashboard.stripe.com/settings/billing/quote). - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/quotes", params: params, opts: opts) - end - - # Returns a list of your quotes. - def self.list(filters = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/quotes", params: filters, opts: opts) - end - # A quote models prices and services for a customer. def self.update(id, params = {}, opts = {}) request_stripe_object( diff --git a/lib/stripe/resources/setup_intent.rb b/lib/stripe/resources/setup_intent.rb index 878563065..3fb300caa 100644 --- a/lib/stripe/resources/setup_intent.rb +++ b/lib/stripe/resources/setup_intent.rb @@ -45,6 +45,18 @@ def cancel(params = {}, opts = {}) ) end + # You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action. + # + # After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. + def self.cancel(intent, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/setup_intents/%s/cancel", { intent: CGI.escape(intent) }), + params: params, + opts: opts + ) + end + # Confirm that your customer intends to set up the current or # provided payment method. For example, you would confirm a SetupIntent # when a customer hits the “Save” button on a payment method management @@ -68,28 +80,6 @@ def confirm(params = {}, opts = {}) ) end - # Verifies microdeposits on a SetupIntent object. - def verify_microdeposits(params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/setup_intents/%s/verify_microdeposits", { intent: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - # You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action. - # - # After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. - def self.cancel(intent, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/setup_intents/%s/cancel", { intent: CGI.escape(intent) }), - params: params, - opts: opts - ) - end - # Confirm that your customer intends to set up the current or # provided payment method. For example, you would confirm a SetupIntent # when a customer hits the “Save” button on a payment method management @@ -113,16 +103,6 @@ def self.confirm(intent, params = {}, opts = {}) ) end - # Verifies microdeposits on a SetupIntent object. - def self.verify_microdeposits(intent, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/setup_intents/%s/verify_microdeposits", { intent: CGI.escape(intent) }), - params: params, - opts: opts - ) - end - # Creates a SetupIntent object. # # After you create the SetupIntent, attach a payment method and [confirm](https://stripe.com/docs/api/setup_intents/confirm) @@ -145,5 +125,25 @@ def self.update(id, params = {}, opts = {}) opts: opts ) end + + # Verifies microdeposits on a SetupIntent object. + def verify_microdeposits(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/setup_intents/%s/verify_microdeposits", { intent: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Verifies microdeposits on a SetupIntent object. + def self.verify_microdeposits(intent, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/setup_intents/%s/verify_microdeposits", { intent: CGI.escape(intent) }), + params: params, + opts: opts + ) + end end end diff --git a/lib/stripe/resources/sigma/scheduled_query_run.rb b/lib/stripe/resources/sigma/scheduled_query_run.rb index d87df3629..b5626aa8f 100644 --- a/lib/stripe/resources/sigma/scheduled_query_run.rb +++ b/lib/stripe/resources/sigma/scheduled_query_run.rb @@ -15,10 +15,6 @@ def self.object_name "scheduled_query_run" end - def self.resource_url - "/v1/sigma/scheduled_query_runs" - end - # Returns a list of scheduled query runs. def self.list(filters = {}, opts = {}) request_stripe_object( @@ -28,6 +24,10 @@ def self.list(filters = {}, opts = {}) opts: opts ) end + + def self.resource_url + "/v1/sigma/scheduled_query_runs" + end end end end diff --git a/lib/stripe/resources/source.rb b/lib/stripe/resources/source.rb index 95a209c21..aff52e27e 100644 --- a/lib/stripe/resources/source.rb +++ b/lib/stripe/resources/source.rb @@ -24,6 +24,23 @@ def self.object_name nested_resource_class_methods :source_transaction, operations: %i[retrieve list] + # Creates a new source object. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/sources", params: params, opts: opts) + end + + # Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + # + # This request accepts the metadata and owner as arguments. It is also possible to update type specific information for selected payment methods. Please refer to our [payment method guides](https://stripe.com/docs/sources) for more detail. + def self.update(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/sources/%s", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + # Verify a given source. def verify(params = {}, opts = {}) request_stripe_object( @@ -67,22 +84,5 @@ def source_transactions(params = {}, opts = {}) end extend Gem::Deprecate deprecate :source_transactions, :"Source.list_source_transactions", 2020, 1 - - # Creates a new source object. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/sources", params: params, opts: opts) - end - - # Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged. - # - # This request accepts the metadata and owner as arguments. It is also possible to update type specific information for selected payment methods. Please refer to our [payment method guides](https://stripe.com/docs/sources) for more detail. - def self.update(id, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/sources/%s", { id: CGI.escape(id) }), - params: params, - opts: opts - ) - end end end diff --git a/lib/stripe/resources/subscription.rb b/lib/stripe/resources/subscription.rb index 6ad2462d2..c26dcb431 100644 --- a/lib/stripe/resources/subscription.rb +++ b/lib/stripe/resources/subscription.rb @@ -30,35 +30,36 @@ def cancel(params = {}, opts = {}) ) end - # Removes the currently applied discount on a subscription. - def delete_discount(params = {}, opts = {}) + # Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + # + # Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + # + # By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + def self.cancel(subscription_exposed_id, params = {}, opts = {}) request_stripe_object( method: :delete, - path: format("/v1/subscriptions/%s/discount", { subscription_exposed_id: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - # Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date. - def resume(params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/subscriptions/%s/resume", { subscription: CGI.escape(self["id"]) }), + path: format("/v1/subscriptions/%s", { subscription_exposed_id: CGI.escape(subscription_exposed_id) }), params: params, opts: opts ) end - # Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + # Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions. # - # Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + # When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request. + # The payment_behavior parameter determines the exact behavior of the initial payment. # - # By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. - def self.cancel(subscription_exposed_id, params = {}, opts = {}) + # To start subscriptions where the first invoice always begins in a draft status, use [subscription schedules](https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing) instead. + # Schedules provide the flexibility to model more complex billing configurations that change over time. + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/subscriptions", params: params, opts: opts) + end + + # Removes the currently applied discount on a subscription. + def delete_discount(params = {}, opts = {}) request_stripe_object( method: :delete, - path: format("/v1/subscriptions/%s", { subscription_exposed_id: CGI.escape(subscription_exposed_id) }), + path: format("/v1/subscriptions/%s/discount", { subscription_exposed_id: CGI.escape(self["id"]) }), params: params, opts: opts ) @@ -74,32 +75,29 @@ def self.delete_discount(subscription_exposed_id, params = {}, opts = {}) ) end + # By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/subscriptions", params: filters, opts: opts) + end + # Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date. - def self.resume(subscription, params = {}, opts = {}) + def resume(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/subscriptions/%s/resume", { subscription: CGI.escape(subscription) }), + path: format("/v1/subscriptions/%s/resume", { subscription: CGI.escape(self["id"]) }), params: params, opts: opts ) end - save_nested_resource :source - - # Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions. - # - # When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request. - # The payment_behavior parameter determines the exact behavior of the initial payment. - # - # To start subscriptions where the first invoice always begins in a draft status, use [subscription schedules](https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing) instead. - # Schedules provide the flexibility to model more complex billing configurations that change over time. - def self.create(params = {}, opts = {}) - request_stripe_object(method: :post, path: "/v1/subscriptions", params: params, opts: opts) - end - - # By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled. - def self.list(filters = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/subscriptions", params: filters, opts: opts) + # Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date. + def self.resume(subscription, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/subscriptions/%s/resume", { subscription: CGI.escape(subscription) }), + params: params, + opts: opts + ) end def self.search(params = {}, opts = {}) @@ -144,5 +142,7 @@ def self.update(id, params = {}, opts = {}) opts: opts ) end + + save_nested_resource :source end end diff --git a/lib/stripe/resources/subscription_schedule.rb b/lib/stripe/resources/subscription_schedule.rb index 9274cd7b2..6e2b9456f 100644 --- a/lib/stripe/resources/subscription_schedule.rb +++ b/lib/stripe/resources/subscription_schedule.rb @@ -25,52 +25,52 @@ def cancel(params = {}, opts = {}) ) end - # Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property. - def release(params = {}, opts = {}) + # Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active. + def self.cancel(schedule, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/subscription_schedules/%s/release", { schedule: CGI.escape(self["id"]) }), + path: format("/v1/subscription_schedules/%s/cancel", { schedule: CGI.escape(schedule) }), params: params, opts: opts ) end - # Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active. - def self.cancel(schedule, params = {}, opts = {}) + # Creates a new subscription schedule object. Each customer can have up to 500 active or scheduled subscriptions. + def self.create(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/subscription_schedules/%s/cancel", { schedule: CGI.escape(schedule) }), + path: "/v1/subscription_schedules", params: params, opts: opts ) end - # Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property. - def self.release(schedule, params = {}, opts = {}) + # Retrieves the list of your subscription schedules. + def self.list(filters = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/subscription_schedules/%s/release", { schedule: CGI.escape(schedule) }), - params: params, + method: :get, + path: "/v1/subscription_schedules", + params: filters, opts: opts ) end - # Creates a new subscription schedule object. Each customer can have up to 500 active or scheduled subscriptions. - def self.create(params = {}, opts = {}) + # Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property. + def release(params = {}, opts = {}) request_stripe_object( method: :post, - path: "/v1/subscription_schedules", + path: format("/v1/subscription_schedules/%s/release", { schedule: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Retrieves the list of your subscription schedules. - def self.list(filters = {}, opts = {}) + # Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property. + def self.release(schedule, params = {}, opts = {}) request_stripe_object( - method: :get, - path: "/v1/subscription_schedules", - params: filters, + method: :post, + path: format("/v1/subscription_schedules/%s/release", { schedule: CGI.escape(schedule) }), + params: params, opts: opts ) end diff --git a/lib/stripe/resources/tax/calculation.rb b/lib/stripe/resources/tax/calculation.rb index 99607b49f..33aa06277 100644 --- a/lib/stripe/resources/tax/calculation.rb +++ b/lib/stripe/resources/tax/calculation.rb @@ -14,31 +14,31 @@ def self.object_name "tax.calculation" end - # Retrieves the line items of a persisted tax calculation as a collection. - def list_line_items(params = {}, opts = {}) + # Calculates tax based on input and returns a Tax Calculation object. + def self.create(params = {}, opts = {}) request_stripe_object( - method: :get, - path: format("/v1/tax/calculations/%s/line_items", { calculation: CGI.escape(self["id"]) }), + method: :post, + path: "/v1/tax/calculations", params: params, opts: opts ) end # Retrieves the line items of a persisted tax calculation as a collection. - def self.list_line_items(calculation, params = {}, opts = {}) + def list_line_items(params = {}, opts = {}) request_stripe_object( method: :get, - path: format("/v1/tax/calculations/%s/line_items", { calculation: CGI.escape(calculation) }), + path: format("/v1/tax/calculations/%s/line_items", { calculation: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Calculates tax based on input and returns a Tax Calculation object. - def self.create(params = {}, opts = {}) + # Retrieves the line items of a persisted tax calculation as a collection. + def self.list_line_items(calculation, params = {}, opts = {}) request_stripe_object( - method: :post, - path: "/v1/tax/calculations", + method: :get, + path: format("/v1/tax/calculations/%s/line_items", { calculation: CGI.escape(calculation) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/tax/transaction.rb b/lib/stripe/resources/tax/transaction.rb index 25ba3447c..cacff9c3d 100644 --- a/lib/stripe/resources/tax/transaction.rb +++ b/lib/stripe/resources/tax/transaction.rb @@ -12,16 +12,6 @@ def self.object_name "tax.transaction" end - # Retrieves the line items of a committed standalone transaction as a collection. - def list_line_items(params = {}, opts = {}) - request_stripe_object( - method: :get, - path: format("/v1/tax/transactions/%s/line_items", { transaction: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - # Creates a Tax Transaction from a calculation. def self.create_from_calculation(params = {}, opts = {}) request_stripe_object( @@ -42,6 +32,16 @@ def self.create_reversal(params = {}, opts = {}) ) end + # Retrieves the line items of a committed standalone transaction as a collection. + def list_line_items(params = {}, opts = {}) + request_stripe_object( + method: :get, + path: format("/v1/tax/transactions/%s/line_items", { transaction: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + # Retrieves the line items of a committed standalone transaction as a collection. def self.list_line_items(transaction, params = {}, opts = {}) request_stripe_object( diff --git a/lib/stripe/resources/terminal/reader.rb b/lib/stripe/resources/terminal/reader.rb index 731f4ce0e..232349dcd 100644 --- a/lib/stripe/resources/terminal/reader.rb +++ b/lib/stripe/resources/terminal/reader.rb @@ -27,132 +27,132 @@ def cancel_action(params = {}, opts = {}) ) end - # Initiates a payment flow on a Reader. - def process_payment_intent(params = {}, opts = {}) + # Cancels the current reader action. + def self.cancel_action(reader, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/terminal/readers/%s/process_payment_intent", { reader: CGI.escape(self["id"]) }), + path: format("/v1/terminal/readers/%s/cancel_action", { reader: CGI.escape(reader) }), params: params, opts: opts ) end - # Initiates a setup intent flow on a Reader. - def process_setup_intent(params = {}, opts = {}) + # Creates a new Reader object. + def self.create(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/terminal/readers/%s/process_setup_intent", { reader: CGI.escape(self["id"]) }), + path: "/v1/terminal/readers", params: params, opts: opts ) end - # Initiates a refund on a Reader - def refund_payment(params = {}, opts = {}) + # Deletes a Reader object. + def self.delete(id, params = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/terminal/readers/%s/refund_payment", { reader: CGI.escape(self["id"]) }), + method: :delete, + path: format("/v1/terminal/readers/%s", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Sets reader display to show cart details. - def set_reader_display(params = {}, opts = {}) + # Deletes a Reader object. + def delete(params = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/terminal/readers/%s/set_reader_display", { reader: CGI.escape(self["id"]) }), + method: :delete, + path: format("/v1/terminal/readers/%s", { reader: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Cancels the current reader action. - def self.cancel_action(reader, params = {}, opts = {}) + # Returns a list of Reader objects. + def self.list(filters = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/terminal/readers/%s/cancel_action", { reader: CGI.escape(reader) }), - params: params, + method: :get, + path: "/v1/terminal/readers", + params: filters, opts: opts ) end # Initiates a payment flow on a Reader. - def self.process_payment_intent(reader, params = {}, opts = {}) + def process_payment_intent(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/terminal/readers/%s/process_payment_intent", { reader: CGI.escape(reader) }), + path: format("/v1/terminal/readers/%s/process_payment_intent", { reader: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Initiates a setup intent flow on a Reader. - def self.process_setup_intent(reader, params = {}, opts = {}) + # Initiates a payment flow on a Reader. + def self.process_payment_intent(reader, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/terminal/readers/%s/process_setup_intent", { reader: CGI.escape(reader) }), + path: format("/v1/terminal/readers/%s/process_payment_intent", { reader: CGI.escape(reader) }), params: params, opts: opts ) end - # Initiates a refund on a Reader - def self.refund_payment(reader, params = {}, opts = {}) + # Initiates a setup intent flow on a Reader. + def process_setup_intent(params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/terminal/readers/%s/refund_payment", { reader: CGI.escape(reader) }), + path: format("/v1/terminal/readers/%s/process_setup_intent", { reader: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Sets reader display to show cart details. - def self.set_reader_display(reader, params = {}, opts = {}) + # Initiates a setup intent flow on a Reader. + def self.process_setup_intent(reader, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/terminal/readers/%s/set_reader_display", { reader: CGI.escape(reader) }), + path: format("/v1/terminal/readers/%s/process_setup_intent", { reader: CGI.escape(reader) }), params: params, opts: opts ) end - # Creates a new Reader object. - def self.create(params = {}, opts = {}) + # Initiates a refund on a Reader + def refund_payment(params = {}, opts = {}) request_stripe_object( method: :post, - path: "/v1/terminal/readers", + path: format("/v1/terminal/readers/%s/refund_payment", { reader: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Deletes a Reader object. - def self.delete(id, params = {}, opts = {}) + # Initiates a refund on a Reader + def self.refund_payment(reader, params = {}, opts = {}) request_stripe_object( - method: :delete, - path: format("/v1/terminal/readers/%s", { id: CGI.escape(id) }), + method: :post, + path: format("/v1/terminal/readers/%s/refund_payment", { reader: CGI.escape(reader) }), params: params, opts: opts ) end - # Deletes a Reader object. - def delete(params = {}, opts = {}) + # Sets reader display to show cart details. + def set_reader_display(params = {}, opts = {}) request_stripe_object( - method: :delete, - path: format("/v1/terminal/readers/%s", { reader: CGI.escape(self["id"]) }), + method: :post, + path: format("/v1/terminal/readers/%s/set_reader_display", { reader: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Returns a list of Reader objects. - def self.list(filters = {}, opts = {}) + # Sets reader display to show cart details. + def self.set_reader_display(reader, params = {}, opts = {}) request_stripe_object( - method: :get, - path: "/v1/terminal/readers", - params: filters, + method: :post, + path: format("/v1/terminal/readers/%s/set_reader_display", { reader: CGI.escape(reader) }), + params: params, opts: opts ) end diff --git a/lib/stripe/resources/treasury/financial_account.rb b/lib/stripe/resources/treasury/financial_account.rb index 29e2839c4..22cdfa831 100644 --- a/lib/stripe/resources/treasury/financial_account.rb +++ b/lib/stripe/resources/treasury/financial_account.rb @@ -15,71 +15,71 @@ def self.object_name "treasury.financial_account" end - # Retrieves Features information associated with the FinancialAccount. - def retrieve_features(params = {}, opts = {}) + # Creates a new FinancialAccount. For now, each connected account can only have one FinancialAccount. + def self.create(params = {}, opts = {}) request_stripe_object( - method: :get, - path: format("/v1/treasury/financial_accounts/%s/features", { financial_account: CGI.escape(self["id"]) }), + method: :post, + path: "/v1/treasury/financial_accounts", params: params, opts: opts ) end - # Updates the Features associated with a FinancialAccount. - def update_features(params = {}, opts = {}) + # Returns a list of FinancialAccounts. + def self.list(filters = {}, opts = {}) request_stripe_object( - method: :post, - path: format("/v1/treasury/financial_accounts/%s/features", { financial_account: CGI.escape(self["id"]) }), - params: params, + method: :get, + path: "/v1/treasury/financial_accounts", + params: filters, opts: opts ) end # Retrieves Features information associated with the FinancialAccount. - def self.retrieve_features(financial_account, params = {}, opts = {}) + def retrieve_features(params = {}, opts = {}) request_stripe_object( method: :get, - path: format("/v1/treasury/financial_accounts/%s/features", { financial_account: CGI.escape(financial_account) }), + path: format("/v1/treasury/financial_accounts/%s/features", { financial_account: CGI.escape(self["id"]) }), params: params, opts: opts ) end - # Updates the Features associated with a FinancialAccount. - def self.update_features(financial_account, params = {}, opts = {}) + # Retrieves Features information associated with the FinancialAccount. + def self.retrieve_features(financial_account, params = {}, opts = {}) request_stripe_object( - method: :post, + method: :get, path: format("/v1/treasury/financial_accounts/%s/features", { financial_account: CGI.escape(financial_account) }), params: params, opts: opts ) end - # Creates a new FinancialAccount. For now, each connected account can only have one FinancialAccount. - def self.create(params = {}, opts = {}) + # Updates the details of a FinancialAccount. + def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, - path: "/v1/treasury/financial_accounts", + path: format("/v1/treasury/financial_accounts/%s", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Returns a list of FinancialAccounts. - def self.list(filters = {}, opts = {}) + # Updates the Features associated with a FinancialAccount. + def update_features(params = {}, opts = {}) request_stripe_object( - method: :get, - path: "/v1/treasury/financial_accounts", - params: filters, + method: :post, + path: format("/v1/treasury/financial_accounts/%s/features", { financial_account: CGI.escape(self["id"]) }), + params: params, opts: opts ) end - # Updates the details of a FinancialAccount. - def self.update(id, params = {}, opts = {}) + # Updates the Features associated with a FinancialAccount. + def self.update_features(financial_account, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/treasury/financial_accounts/%s", { id: CGI.escape(id) }), + path: format("/v1/treasury/financial_accounts/%s/features", { financial_account: CGI.escape(financial_account) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/treasury/transaction_entry.rb b/lib/stripe/resources/treasury/transaction_entry.rb index 696311652..599624352 100644 --- a/lib/stripe/resources/treasury/transaction_entry.rb +++ b/lib/stripe/resources/treasury/transaction_entry.rb @@ -12,10 +12,6 @@ def self.object_name "treasury.transaction_entry" end - def self.resource_url - "/v1/treasury/transaction_entries" - end - # Retrieves a list of TransactionEntry objects. def self.list(filters = {}, opts = {}) request_stripe_object( @@ -25,6 +21,10 @@ def self.list(filters = {}, opts = {}) opts: opts ) end + + def self.resource_url + "/v1/treasury/transaction_entries" + end end end end From 4705a5f5f9aa2140bbb0286a716fb0a0aa6e95de Mon Sep 17 00:00:00 2001 From: helenye-stripe <111009531+helenye-stripe@users.noreply.github.com> Date: Mon, 11 Mar 2024 13:10:30 -0700 Subject: [PATCH 3/9] Refactor after SDK based generation pattern (#1354) * Refactor after SDK based generation pattern * update for object types & reorder --- lib/stripe/object_types.rb | 9 ++-- lib/stripe/resources/account.rb | 2 +- lib/stripe/resources/charge.rb | 2 +- lib/stripe/resources/customer.rb | 2 +- lib/stripe/resources/issuing/authorization.rb | 48 +++++++++---------- lib/stripe/resources/issuing/card.rb | 44 ++++++++--------- lib/stripe/resources/source.rb | 2 +- lib/stripe/resources/subscription_item.rb | 2 +- lib/stripe/resources/tax/settings.rb | 1 - lib/stripe/resources/transfer.rb | 2 +- .../resources/treasury/inbound_transfer.rb | 28 +++++------ .../resources/treasury/outbound_payment.rb | 28 +++++------ .../resources/treasury/outbound_transfer.rb | 28 +++++------ test/stripe/generated_examples_test.rb | 19 ++++++++ 14 files changed, 117 insertions(+), 100 deletions(-) diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index c871f811d..86b36e8f7 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -1,4 +1,3 @@ -# File generated from our OpenAPI spec # frozen_string_literal: true # rubocop:disable Metrics/MethodLength @@ -11,9 +10,9 @@ def self.object_names_to_classes # data structures ListObject.object_name => ListObject, SearchResultObject.object_name => SearchResultObject, - - # business objects File.object_name_alt => File, + + # The beginning of the section generated from our OpenAPI spec Account.object_name => Account, AccountLink.object_name => AccountLink, AccountSession.object_name => AccountSession, @@ -51,8 +50,7 @@ def self.object_names_to_classes FileLink.object_name => FileLink, FinancialConnections::Account.object_name => FinancialConnections::Account, FinancialConnections::AccountOwner.object_name => FinancialConnections::AccountOwner, - FinancialConnections::AccountOwnership.object_name => - FinancialConnections::AccountOwnership, + FinancialConnections::AccountOwnership.object_name => FinancialConnections::AccountOwnership, FinancialConnections::Session.object_name => FinancialConnections::Session, FinancialConnections::Transaction.object_name => FinancialConnections::Transaction, FundingInstructions.object_name => FundingInstructions, @@ -130,6 +128,7 @@ def self.object_names_to_classes UsageRecord.object_name => UsageRecord, UsageRecordSummary.object_name => UsageRecordSummary, WebhookEndpoint.object_name => WebhookEndpoint, + # The end of the section generated from our OpenAPI spec } end end diff --git a/lib/stripe/resources/account.rb b/lib/stripe/resources/account.rb index e22188ca7..5968b8e3e 100644 --- a/lib/stripe/resources/account.rb +++ b/lib/stripe/resources/account.rb @@ -13,8 +13,8 @@ class Account < APIResource extend Stripe::APIOperations::Create include Stripe::APIOperations::Delete extend Stripe::APIOperations::List - include Stripe::APIOperations::Save extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save OBJECT_NAME = "account" def self.object_name diff --git a/lib/stripe/resources/charge.rb b/lib/stripe/resources/charge.rb index 48d0f3505..8177b75f6 100644 --- a/lib/stripe/resources/charge.rb +++ b/lib/stripe/resources/charge.rb @@ -9,9 +9,9 @@ module Stripe class Charge < APIResource extend Stripe::APIOperations::Create extend Stripe::APIOperations::List + extend Stripe::APIOperations::NestedResource extend Stripe::APIOperations::Search include Stripe::APIOperations::Save - extend Stripe::APIOperations::NestedResource OBJECT_NAME = "charge" def self.object_name diff --git a/lib/stripe/resources/customer.rb b/lib/stripe/resources/customer.rb index 4755faf00..4587b20ce 100644 --- a/lib/stripe/resources/customer.rb +++ b/lib/stripe/resources/customer.rb @@ -9,9 +9,9 @@ class Customer < APIResource extend Stripe::APIOperations::Create include Stripe::APIOperations::Delete extend Stripe::APIOperations::List + extend Stripe::APIOperations::NestedResource extend Stripe::APIOperations::Search include Stripe::APIOperations::Save - extend Stripe::APIOperations::NestedResource OBJECT_NAME = "customer" def self.object_name diff --git a/lib/stripe/resources/issuing/authorization.rb b/lib/stripe/resources/issuing/authorization.rb index 8d4ebfd7e..decc5e3b7 100644 --- a/lib/stripe/resources/issuing/authorization.rb +++ b/lib/stripe/resources/issuing/authorization.rb @@ -101,6 +101,16 @@ def self.capture(authorization, params = {}, opts = {}) ) end + # Capture a test-mode authorization. + def capture(params = {}, opts = {}) + @resource.request_stripe_object( + method: :post, + path: format("/v1/test_helpers/issuing/authorizations/%s/capture", { authorization: CGI.escape(@resource["id"]) }), + params: params, + opts: opts + ) + end + # Create a test-mode authorization. def self.create(params = {}, opts = {}) request_stripe_object( @@ -121,51 +131,41 @@ def self.expire(authorization, params = {}, opts = {}) ) end - # Increment a test-mode Authorization. - def self.increment(authorization, params = {}, opts = {}) - request_stripe_object( + # Expire a test-mode Authorization. + def expire(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/authorizations/%s/increment", { authorization: CGI.escape(authorization) }), + path: format("/v1/test_helpers/issuing/authorizations/%s/expire", { authorization: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Reverse a test-mode Authorization. - def self.reverse(authorization, params = {}, opts = {}) + # Increment a test-mode Authorization. + def self.increment(authorization, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/authorizations/%s/reverse", { authorization: CGI.escape(authorization) }), - params: params, - opts: opts - ) - end - - # Capture a test-mode authorization. - def capture(params = {}, opts = {}) - @resource.request_stripe_object( - method: :post, - path: format("/v1/test_helpers/issuing/authorizations/%s/capture", { authorization: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/authorizations/%s/increment", { authorization: CGI.escape(authorization) }), params: params, opts: opts ) end - # Expire a test-mode Authorization. - def expire(params = {}, opts = {}) + # Increment a test-mode Authorization. + def increment(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/authorizations/%s/expire", { authorization: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/authorizations/%s/increment", { authorization: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Increment a test-mode Authorization. - def increment(params = {}, opts = {}) - @resource.request_stripe_object( + # Reverse a test-mode Authorization. + def self.reverse(authorization, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/authorizations/%s/increment", { authorization: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/authorizations/%s/reverse", { authorization: CGI.escape(authorization) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/issuing/card.rb b/lib/stripe/resources/issuing/card.rb index 28f3247b7..36cdf0ecc 100644 --- a/lib/stripe/resources/issuing/card.rb +++ b/lib/stripe/resources/issuing/card.rb @@ -54,61 +54,61 @@ def self.deliver_card(card, params = {}, opts = {}) ) end - # Updates the shipping status of the specified Issuing Card object to failure. - def self.fail_card(card, params = {}, opts = {}) - request_stripe_object( + # Updates the shipping status of the specified Issuing Card object to delivered. + def deliver_card(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/fail", { card: CGI.escape(card) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/deliver", { card: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Updates the shipping status of the specified Issuing Card object to returned. - def self.return_card(card, params = {}, opts = {}) + # Updates the shipping status of the specified Issuing Card object to failure. + def self.fail_card(card, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/return", { card: CGI.escape(card) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/fail", { card: CGI.escape(card) }), params: params, opts: opts ) end - # Updates the shipping status of the specified Issuing Card object to shipped. - def self.ship_card(card, params = {}, opts = {}) - request_stripe_object( + # Updates the shipping status of the specified Issuing Card object to failure. + def fail_card(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/ship", { card: CGI.escape(card) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/fail", { card: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Updates the shipping status of the specified Issuing Card object to delivered. - def deliver_card(params = {}, opts = {}) - @resource.request_stripe_object( + # Updates the shipping status of the specified Issuing Card object to returned. + def self.return_card(card, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/deliver", { card: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/return", { card: CGI.escape(card) }), params: params, opts: opts ) end - # Updates the shipping status of the specified Issuing Card object to failure. - def fail_card(params = {}, opts = {}) + # Updates the shipping status of the specified Issuing Card object to returned. + def return_card(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/fail", { card: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/return", { card: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Updates the shipping status of the specified Issuing Card object to returned. - def return_card(params = {}, opts = {}) - @resource.request_stripe_object( + # Updates the shipping status of the specified Issuing Card object to shipped. + def self.ship_card(card, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/return", { card: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/ship", { card: CGI.escape(card) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/source.rb b/lib/stripe/resources/source.rb index aff52e27e..ba5e442ba 100644 --- a/lib/stripe/resources/source.rb +++ b/lib/stripe/resources/source.rb @@ -14,8 +14,8 @@ module Stripe # Related guides: [Sources API](https://stripe.com/docs/sources) and [Sources & Customers](https://stripe.com/docs/sources/customers). class Source < APIResource extend Stripe::APIOperations::Create - include Stripe::APIOperations::Save extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save OBJECT_NAME = "source" def self.object_name diff --git a/lib/stripe/resources/subscription_item.rb b/lib/stripe/resources/subscription_item.rb index 61948da98..d37a70b2a 100644 --- a/lib/stripe/resources/subscription_item.rb +++ b/lib/stripe/resources/subscription_item.rb @@ -8,8 +8,8 @@ class SubscriptionItem < APIResource extend Stripe::APIOperations::Create include Stripe::APIOperations::Delete extend Stripe::APIOperations::List - include Stripe::APIOperations::Save extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save OBJECT_NAME = "subscription_item" def self.object_name diff --git a/lib/stripe/resources/tax/settings.rb b/lib/stripe/resources/tax/settings.rb index 66eab9e80..1250ea35f 100644 --- a/lib/stripe/resources/tax/settings.rb +++ b/lib/stripe/resources/tax/settings.rb @@ -8,7 +8,6 @@ module Tax # Related guide: [Using the Settings API](https://stripe.com/docs/tax/settings-api) class Settings < SingletonAPIResource include Stripe::APIOperations::SingletonSave - OBJECT_NAME = "tax.settings" def self.object_name "tax.settings" diff --git a/lib/stripe/resources/transfer.rb b/lib/stripe/resources/transfer.rb index 4543fad3a..476be51fd 100644 --- a/lib/stripe/resources/transfer.rb +++ b/lib/stripe/resources/transfer.rb @@ -15,8 +15,8 @@ module Stripe class Transfer < APIResource extend Stripe::APIOperations::Create extend Stripe::APIOperations::List - include Stripe::APIOperations::Save extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save OBJECT_NAME = "transfer" def self.object_name diff --git a/lib/stripe/resources/treasury/inbound_transfer.rb b/lib/stripe/resources/treasury/inbound_transfer.rb index c48b0da14..ec55fdc11 100644 --- a/lib/stripe/resources/treasury/inbound_transfer.rb +++ b/lib/stripe/resources/treasury/inbound_transfer.rb @@ -73,41 +73,41 @@ def self.fail(id, params = {}, opts = {}) ) end - # Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. - def self.return_inbound_transfer(id, params = {}, opts = {}) - request_stripe_object( + # Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state. + def fail(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/inbound_transfers/%s/return", { id: CGI.escape(id) }), + path: format("/v1/test_helpers/treasury/inbound_transfers/%s/fail", { id: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state. - def self.succeed(id, params = {}, opts = {}) + # Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. + def self.return_inbound_transfer(id, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/inbound_transfers/%s/succeed", { id: CGI.escape(id) }), + path: format("/v1/test_helpers/treasury/inbound_transfers/%s/return", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state. - def fail(params = {}, opts = {}) + # Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. + def return_inbound_transfer(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/inbound_transfers/%s/fail", { id: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/inbound_transfers/%s/return", { id: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. - def return_inbound_transfer(params = {}, opts = {}) - @resource.request_stripe_object( + # Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state. + def self.succeed(id, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/inbound_transfers/%s/return", { id: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/inbound_transfers/%s/succeed", { id: CGI.escape(id) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/treasury/outbound_payment.rb b/lib/stripe/resources/treasury/outbound_payment.rb index a376de29b..232db3b6b 100644 --- a/lib/stripe/resources/treasury/outbound_payment.rb +++ b/lib/stripe/resources/treasury/outbound_payment.rb @@ -75,41 +75,41 @@ def self.fail(id, params = {}, opts = {}) ) end - # Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. - def self.post(id, params = {}, opts = {}) - request_stripe_object( + # Transitions a test mode created OutboundPayment to the failed status. The OutboundPayment must already be in the processing state. + def fail(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_payments/%s/post", { id: CGI.escape(id) }), + path: format("/v1/test_helpers/treasury/outbound_payments/%s/fail", { id: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundPayment to the returned status. The OutboundPayment must already be in the processing state. - def self.return_outbound_payment(id, params = {}, opts = {}) + # Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. + def self.post(id, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_payments/%s/return", { id: CGI.escape(id) }), + path: format("/v1/test_helpers/treasury/outbound_payments/%s/post", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundPayment to the failed status. The OutboundPayment must already be in the processing state. - def fail(params = {}, opts = {}) + # Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. + def post(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_payments/%s/fail", { id: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/outbound_payments/%s/post", { id: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. - def post(params = {}, opts = {}) - @resource.request_stripe_object( + # Transitions a test mode created OutboundPayment to the returned status. The OutboundPayment must already be in the processing state. + def self.return_outbound_payment(id, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_payments/%s/post", { id: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/outbound_payments/%s/return", { id: CGI.escape(id) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/treasury/outbound_transfer.rb b/lib/stripe/resources/treasury/outbound_transfer.rb index 261cdbea6..59451cb6c 100644 --- a/lib/stripe/resources/treasury/outbound_transfer.rb +++ b/lib/stripe/resources/treasury/outbound_transfer.rb @@ -75,41 +75,41 @@ def self.fail(outbound_transfer, params = {}, opts = {}) ) end - # Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. - def self.post(outbound_transfer, params = {}, opts = {}) - request_stripe_object( + # Transitions a test mode created OutboundTransfer to the failed status. The OutboundTransfer must already be in the processing state. + def fail(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_transfers/%s/post", { outbound_transfer: CGI.escape(outbound_transfer) }), + path: format("/v1/test_helpers/treasury/outbound_transfers/%s/fail", { outbound_transfer: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundTransfer to the returned status. The OutboundTransfer must already be in the processing state. - def self.return_outbound_transfer(outbound_transfer, params = {}, opts = {}) + # Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. + def self.post(outbound_transfer, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_transfers/%s/return", { outbound_transfer: CGI.escape(outbound_transfer) }), + path: format("/v1/test_helpers/treasury/outbound_transfers/%s/post", { outbound_transfer: CGI.escape(outbound_transfer) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundTransfer to the failed status. The OutboundTransfer must already be in the processing state. - def fail(params = {}, opts = {}) + # Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. + def post(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_transfers/%s/fail", { outbound_transfer: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/outbound_transfers/%s/post", { outbound_transfer: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. - def post(params = {}, opts = {}) - @resource.request_stripe_object( + # Transitions a test mode created OutboundTransfer to the returned status. The OutboundTransfer must already be in the processing state. + def self.return_outbound_transfer(outbound_transfer, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_transfers/%s/post", { outbound_transfer: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/outbound_transfers/%s/return", { outbound_transfer: CGI.escape(outbound_transfer) }), params: params, opts: opts ) diff --git a/test/stripe/generated_examples_test.rb b/test/stripe/generated_examples_test.rb index 1533be1f4..10de5d909 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -1600,6 +1600,25 @@ class CodegennedExampleTest < Test::Unit::TestCase Stripe::TaxCode.retrieve("txcd_xxxxxxxxxxxxx") assert_requested :get, "#{Stripe.api_base}/v1/tax_codes/txcd_xxxxxxxxxxxxx?" end + should "Test tax ids delete" do + Stripe::TaxId.delete("taxid_123") + assert_requested :delete, "#{Stripe.api_base}/v1/tax_ids/taxid_123?" + end + should "Test tax ids get" do + Stripe::TaxId.list + assert_requested :get, "#{Stripe.api_base}/v1/tax_ids?" + end + should "Test tax ids get 2" do + Stripe::TaxId.retrieve("taxid_123") + assert_requested :get, "#{Stripe.api_base}/v1/tax_ids/taxid_123?" + end + should "Test tax ids post" do + Stripe::TaxId.create({ + type: "eu_vat", + value: "123", + }) + assert_requested :post, "#{Stripe.api_base}/v1/tax_ids" + end should "Test tax rates get" do Stripe::TaxRate.list({ limit: 3 }) assert_requested :get, "#{Stripe.api_base}/v1/tax_rates?limit=3" From cece539ed77f7d14c9afcf13668d9e538d10fd8f Mon Sep 17 00:00:00 2001 From: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:24:55 +0000 Subject: [PATCH 4/9] Update generated code for v873 --- OPENAPI_VERSION | 2 +- lib/stripe/resources/confirmation_token.rb | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 64010e9ed..aed05b4a2 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v872 \ No newline at end of file +v873 \ No newline at end of file diff --git a/lib/stripe/resources/confirmation_token.rb b/lib/stripe/resources/confirmation_token.rb index 5bc38d619..8dcdcfd4b 100644 --- a/lib/stripe/resources/confirmation_token.rb +++ b/lib/stripe/resources/confirmation_token.rb @@ -12,5 +12,26 @@ class ConfirmationToken < APIResource def self.object_name "confirmation_token" end + + def test_helpers + TestHelpers.new(self) + end + + class TestHelpers < APIResourceTestHelpers + RESOURCE_CLASS = ConfirmationToken + def self.resource_class + "ConfirmationToken" + end + + # Creates a test mode Confirmation Token server side for your integration tests. + def self.create(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: "/v1/test_helpers/confirmation_tokens", + params: params, + opts: opts + ) + end + end end end From 0b3c0f3244ed395f05ad8726fe376aaec1e39738 Mon Sep 17 00:00:00 2001 From: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:47:03 +0000 Subject: [PATCH 5/9] Update generated code for v875 --- OPENAPI_VERSION | 2 +- lib/stripe/resources/invoice.rb | 60 +++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index aed05b4a2..8d65184cd 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v873 \ No newline at end of file +v875 \ No newline at end of file diff --git a/lib/stripe/resources/invoice.rb b/lib/stripe/resources/invoice.rb index 8cd16194f..58815ab5c 100644 --- a/lib/stripe/resources/invoice.rb +++ b/lib/stripe/resources/invoice.rb @@ -49,6 +49,26 @@ def self.object_name nested_resource_class_methods :payment, operations: %i[retrieve list] + # Adds multiple line items to an invoice. This is only possible when an invoice is still a draft. + def add_lines(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/add_lines", { invoice: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Adds multiple line items to an invoice. This is only possible when an invoice is still a draft. + def self.add_lines(invoice, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/add_lines", { invoice: CGI.escape(invoice) }), + params: params, + opts: opts + ) + end + # Attaches a PaymentIntent to the invoice, adding it to the list of payments. # When the PaymentIntent's status changes to succeeded, the payment is credited # to the invoice, increasing its amount_paid. When the invoice is fully paid, the @@ -199,6 +219,26 @@ def self.pay(invoice, params = {}, opts = {}) ) end + # Removes multiple line items from an invoice. This is only possible when an invoice is still a draft. + def remove_lines(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/remove_lines", { invoice: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Removes multiple line items from an invoice. This is only possible when an invoice is still a draft. + def self.remove_lines(invoice, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/remove_lines", { invoice: CGI.escape(invoice) }), + params: params, + opts: opts + ) + end + def self.search(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/invoices/search", params: params, opts: opts) end @@ -255,6 +295,26 @@ def self.update(id, params = {}, opts = {}) ) end + # Updates multiple line items on an invoice. This is only possible when an invoice is still a draft. + def update_lines(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/update_lines", { invoice: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Updates multiple line items on an invoice. This is only possible when an invoice is still a draft. + def self.update_lines(invoice, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/update_lines", { invoice: CGI.escape(invoice) }), + params: params, + opts: opts + ) + end + # Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. def void_invoice(params = {}, opts = {}) request_stripe_object( From a8aac472ec2aac8b07364af01be2f5ed2f8fc047 Mon Sep 17 00:00:00 2001 From: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:34:26 +0000 Subject: [PATCH 6/9] Update generated code for v878 --- OPENAPI_VERSION | 2 +- test/stripe/generated_examples_test.rb | 39 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 8d65184cd..0963e32fc 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v875 \ No newline at end of file +v878 \ No newline at end of file diff --git a/test/stripe/generated_examples_test.rb b/test/stripe/generated_examples_test.rb index 78a76a35d..892685c53 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -899,6 +899,30 @@ class CodegennedExampleTest < Test::Unit::TestCase Stripe::Issuing::Dispute.submit("idp_xxxxxxxxxxxxx") assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes/idp_xxxxxxxxxxxxx/submit?" end + should "Test issuing personalization designs get" do + Stripe::Issuing::PersonalizationDesign.list + assert_requested :get, "#{Stripe.api_base}/v1/issuing/personalization_designs?" + end + should "Test issuing personalization designs get 2" do + Stripe::Issuing::PersonalizationDesign.retrieve("pd_xyz") + assert_requested :get, "#{Stripe.api_base}/v1/issuing/personalization_designs/pd_xyz?" + end + should "Test issuing personalization designs post" do + Stripe::Issuing::PersonalizationDesign.create({ physical_bundle: "pb_xyz" }) + assert_requested :post, "#{Stripe.api_base}/v1/issuing/personalization_designs" + end + should "Test issuing personalization designs post 2" do + Stripe::Issuing::PersonalizationDesign.update("pd_xyz") + assert_requested :post, "#{Stripe.api_base}/v1/issuing/personalization_designs/pd_xyz?" + end + should "Test issuing physical bundles get" do + Stripe::Issuing::PhysicalBundle.list + assert_requested :get, "#{Stripe.api_base}/v1/issuing/physical_bundles?" + end + should "Test issuing physical bundles get 2" do + Stripe::Issuing::PhysicalBundle.retrieve("pb_xyz") + assert_requested :get, "#{Stripe.api_base}/v1/issuing/physical_bundles/pb_xyz?" + end should "Test issuing transactions get" do Stripe::Issuing::Transaction.list({ limit: 3 }) assert_requested :get, "#{Stripe.api_base}/v1/issuing/transactions?limit=3" @@ -1934,6 +1958,21 @@ class CodegennedExampleTest < Test::Unit::TestCase Stripe::Issuing::Card::TestHelpers.ship_card("card_123") assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/cards/card_123/shipping/ship?" end + should "Test test helpers issuing personalization designs activate post" do + Stripe::Issuing::PersonalizationDesign::TestHelpers.activate("pd_xyz") + assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/personalization_designs/pd_xyz/activate?" + end + should "Test test helpers issuing personalization designs deactivate post" do + Stripe::Issuing::PersonalizationDesign::TestHelpers.deactivate("pd_xyz") + assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/personalization_designs/pd_xyz/deactivate?" + end + should "Test test helpers issuing personalization designs reject post" do + Stripe::Issuing::PersonalizationDesign::TestHelpers.reject( + "pd_xyz", + { rejection_reasons: { card_logo: ["geographic_location"] } } + ) + assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/personalization_designs/pd_xyz/reject" + end should "Test test helpers issuing transactions create force capture post" do Stripe::Issuing::Transaction::TestHelpers.create_force_capture({ amount: 100, From ad00c3e6212354ebb98222875e1787b22edd5440 Mon Sep 17 00:00:00 2001 From: "stripe-openapi[bot]" <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 11:58:37 -0700 Subject: [PATCH 7/9] Update generated code (#1359) * Update generated code for v872 * Update generated code for v878 --- OPENAPI_VERSION | 2 +- lib/stripe/object_types.rb | 2 + lib/stripe/resources.rb | 2 + .../issuing/personalization_design.rb | 119 ++++++++++++++++++ .../resources/issuing/physical_bundle.rb | 26 ++++ test/stripe/generated_examples_test.rb | 43 +++++++ 6 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 lib/stripe/resources/issuing/personalization_design.rb create mode 100644 lib/stripe/resources/issuing/physical_bundle.rb diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 2e1dc524f..0963e32fc 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v841 \ No newline at end of file +v878 \ No newline at end of file diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index 86b36e8f7..07d7b823f 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -63,6 +63,8 @@ def self.object_names_to_classes Issuing::Card.object_name => Issuing::Card, Issuing::Cardholder.object_name => Issuing::Cardholder, Issuing::Dispute.object_name => Issuing::Dispute, + Issuing::PersonalizationDesign.object_name => Issuing::PersonalizationDesign, + Issuing::PhysicalBundle.object_name => Issuing::PhysicalBundle, Issuing::Token.object_name => Issuing::Token, Issuing::Transaction.object_name => Issuing::Transaction, LineItem.object_name => LineItem, diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index 024ba1f91..f3c03d1ff 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -51,6 +51,8 @@ require "stripe/resources/issuing/card" require "stripe/resources/issuing/cardholder" require "stripe/resources/issuing/dispute" +require "stripe/resources/issuing/personalization_design" +require "stripe/resources/issuing/physical_bundle" require "stripe/resources/issuing/token" require "stripe/resources/issuing/transaction" require "stripe/resources/line_item" diff --git a/lib/stripe/resources/issuing/personalization_design.rb b/lib/stripe/resources/issuing/personalization_design.rb new file mode 100644 index 000000000..37d00f50a --- /dev/null +++ b/lib/stripe/resources/issuing/personalization_design.rb @@ -0,0 +1,119 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Issuing + # A Personalization Design is a logical grouping of a Physical Bundle, card logo, and carrier text that represents a product line. + class PersonalizationDesign < APIResource + extend Stripe::APIOperations::Create + extend Stripe::APIOperations::List + include Stripe::APIOperations::Save + + OBJECT_NAME = "issuing.personalization_design" + def self.object_name + "issuing.personalization_design" + end + + # Creates a personalization design object. + def self.create(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: "/v1/issuing/personalization_designs", + params: params, + opts: opts + ) + end + + # Returns a list of personalization design objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + def self.list(filters = {}, opts = {}) + request_stripe_object( + method: :get, + path: "/v1/issuing/personalization_designs", + params: filters, + opts: opts + ) + end + + # Updates a card personalization object. + def self.update(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/issuing/personalization_designs/%s", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + def test_helpers + TestHelpers.new(self) + end + + class TestHelpers < APIResourceTestHelpers + RESOURCE_CLASS = PersonalizationDesign + def self.resource_class + "PersonalizationDesign" + end + + # Updates the status of the specified testmode personalization design object to active. + def self.activate(personalization_design, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/test_helpers/issuing/personalization_designs/%s/activate", { personalization_design: CGI.escape(personalization_design) }), + params: params, + opts: opts + ) + end + + # Updates the status of the specified testmode personalization design object to active. + def activate(params = {}, opts = {}) + @resource.request_stripe_object( + method: :post, + path: format("/v1/test_helpers/issuing/personalization_designs/%s/activate", { personalization_design: CGI.escape(@resource["id"]) }), + params: params, + opts: opts + ) + end + + # Updates the status of the specified testmode personalization design object to inactive. + def self.deactivate(personalization_design, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/test_helpers/issuing/personalization_designs/%s/deactivate", { personalization_design: CGI.escape(personalization_design) }), + params: params, + opts: opts + ) + end + + # Updates the status of the specified testmode personalization design object to inactive. + def deactivate(params = {}, opts = {}) + @resource.request_stripe_object( + method: :post, + path: format("/v1/test_helpers/issuing/personalization_designs/%s/deactivate", { personalization_design: CGI.escape(@resource["id"]) }), + params: params, + opts: opts + ) + end + + # Updates the status of the specified testmode personalization design object to rejected. + def self.reject(personalization_design, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/test_helpers/issuing/personalization_designs/%s/reject", { personalization_design: CGI.escape(personalization_design) }), + params: params, + opts: opts + ) + end + + # Updates the status of the specified testmode personalization design object to rejected. + def reject(params = {}, opts = {}) + @resource.request_stripe_object( + method: :post, + path: format("/v1/test_helpers/issuing/personalization_designs/%s/reject", { personalization_design: CGI.escape(@resource["id"]) }), + params: params, + opts: opts + ) + end + end + end + end +end diff --git a/lib/stripe/resources/issuing/physical_bundle.rb b/lib/stripe/resources/issuing/physical_bundle.rb new file mode 100644 index 000000000..890eab761 --- /dev/null +++ b/lib/stripe/resources/issuing/physical_bundle.rb @@ -0,0 +1,26 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Issuing + # A Physical Bundle represents the bundle of physical items - card stock, carrier letter, and envelope - that is shipped to a cardholder when you create a physical card. + class PhysicalBundle < APIResource + extend Stripe::APIOperations::List + + OBJECT_NAME = "issuing.physical_bundle" + def self.object_name + "issuing.physical_bundle" + end + + # Returns a list of physical bundle objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + def self.list(filters = {}, opts = {}) + request_stripe_object( + method: :get, + path: "/v1/issuing/physical_bundles", + params: filters, + opts: opts + ) + end + end + end +end diff --git a/test/stripe/generated_examples_test.rb b/test/stripe/generated_examples_test.rb index 10de5d909..f9260fb79 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -426,6 +426,10 @@ class CodegennedExampleTest < Test::Unit::TestCase Stripe::Customer.update_cash_balance("cus_123", { settings: { reconciliation_mode: "manual" } }) assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123/cash_balance" end + should "Test customers cash balance transactions get" do + Stripe::Customer.list_cash_balance_transactions("cus_123", { limit: 3 }) + assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_123/cash_balance_transactions?limit=3" + end should "Test customers delete" do Stripe::Customer.delete("cus_xxxxxxxxxxxxx") assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx?" @@ -895,6 +899,30 @@ class CodegennedExampleTest < Test::Unit::TestCase Stripe::Issuing::Dispute.submit("idp_xxxxxxxxxxxxx") assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes/idp_xxxxxxxxxxxxx/submit?" end + should "Test issuing personalization designs get" do + Stripe::Issuing::PersonalizationDesign.list + assert_requested :get, "#{Stripe.api_base}/v1/issuing/personalization_designs?" + end + should "Test issuing personalization designs get 2" do + Stripe::Issuing::PersonalizationDesign.retrieve("pd_xyz") + assert_requested :get, "#{Stripe.api_base}/v1/issuing/personalization_designs/pd_xyz?" + end + should "Test issuing personalization designs post" do + Stripe::Issuing::PersonalizationDesign.create({ physical_bundle: "pb_xyz" }) + assert_requested :post, "#{Stripe.api_base}/v1/issuing/personalization_designs" + end + should "Test issuing personalization designs post 2" do + Stripe::Issuing::PersonalizationDesign.update("pd_xyz") + assert_requested :post, "#{Stripe.api_base}/v1/issuing/personalization_designs/pd_xyz?" + end + should "Test issuing physical bundles get" do + Stripe::Issuing::PhysicalBundle.list + assert_requested :get, "#{Stripe.api_base}/v1/issuing/physical_bundles?" + end + should "Test issuing physical bundles get 2" do + Stripe::Issuing::PhysicalBundle.retrieve("pb_xyz") + assert_requested :get, "#{Stripe.api_base}/v1/issuing/physical_bundles/pb_xyz?" + end should "Test issuing transactions get" do Stripe::Issuing::Transaction.list({ limit: 3 }) assert_requested :get, "#{Stripe.api_base}/v1/issuing/transactions?limit=3" @@ -1921,6 +1949,21 @@ class CodegennedExampleTest < Test::Unit::TestCase Stripe::Issuing::Card::TestHelpers.ship_card("card_123") assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/cards/card_123/shipping/ship?" end + should "Test test helpers issuing personalization designs activate post" do + Stripe::Issuing::PersonalizationDesign::TestHelpers.activate("pd_xyz") + assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/personalization_designs/pd_xyz/activate?" + end + should "Test test helpers issuing personalization designs deactivate post" do + Stripe::Issuing::PersonalizationDesign::TestHelpers.deactivate("pd_xyz") + assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/personalization_designs/pd_xyz/deactivate?" + end + should "Test test helpers issuing personalization designs reject post" do + Stripe::Issuing::PersonalizationDesign::TestHelpers.reject( + "pd_xyz", + { rejection_reasons: { card_logo: ["geographic_location"] } } + ) + assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/personalization_designs/pd_xyz/reject" + end should "Test test helpers issuing transactions create force capture post" do Stripe::Issuing::Transaction::TestHelpers.create_force_capture({ amount: 100, From 3a51dfaba7fac2211a844c63f2af85db4eaad29d Mon Sep 17 00:00:00 2001 From: Ramya Rao Date: Thu, 14 Mar 2024 12:31:59 -0700 Subject: [PATCH 8/9] Bump version to 10.12.0 --- CHANGELOG.md | 10 ++++++++++ VERSION | 2 +- lib/stripe/version.rb | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe251cbdc..d4e7198b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,14 @@ # Changelog +## 10.12.0 - 2024-03-14 +* [#1359](https://github.com/stripe/stripe-ruby/pull/1359) Update generated code + * Add support for new resources `Issuing.PersonalizationDesign` and `Issuing.PhysicalBundle` + * Add support for `create`, `list`, `retrieve`, and `update` methods on resource `PersonalizationDesign` + * Add support for `list` and `retrieve` methods on resource `PhysicalBundle` +* [#1354](https://github.com/stripe/stripe-ruby/pull/1354) Refactor after SDK based generation pattern +* [#1347](https://github.com/stripe/stripe-ruby/pull/1347) Reorder methods with lexographical sort +* [#1355](https://github.com/stripe/stripe-ruby/pull/1355) Disable Metrics/ClassLength +* [#1351](https://github.com/stripe/stripe-ruby/pull/1351) Update CHANGELOG.md + ## 10.11.0 - 2024-02-29 * [#1348](https://github.com/stripe/stripe-ruby/pull/1348) Use sorbet gem instead of sorbet-static * [#1342](https://github.com/stripe/stripe-ruby/pull/1342) Update generated code diff --git a/VERSION b/VERSION index 725870228..c4d592e16 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.11.0 +10.12.0 diff --git a/lib/stripe/version.rb b/lib/stripe/version.rb index f41e1af70..9b59cd32e 100644 --- a/lib/stripe/version.rb +++ b/lib/stripe/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Stripe - VERSION = "10.11.0" + VERSION = "10.12.0" end From 7ddec7d6d8f0fc48b6c3bae4e7329d000a389d88 Mon Sep 17 00:00:00 2001 From: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 22:14:21 +0000 Subject: [PATCH 9/9] Update generated code for v879 --- OPENAPI_VERSION | 2 +- lib/stripe/object_types.rb | 4 + lib/stripe/resources.rb | 4 + lib/stripe/resources/billing/meter.rb | 83 +++++++++++++++++++ lib/stripe/resources/billing/meter_event.rb | 27 ++++++ .../billing/meter_event_adjustment.rb | 26 ++++++ .../resources/billing/meter_event_summary.rb | 15 ++++ 7 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 lib/stripe/resources/billing/meter.rb create mode 100644 lib/stripe/resources/billing/meter_event.rb create mode 100644 lib/stripe/resources/billing/meter_event_adjustment.rb create mode 100644 lib/stripe/resources/billing/meter_event_summary.rb diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 0963e32fc..32951953e 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v878 \ No newline at end of file +v879 \ No newline at end of file diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index d7e365412..3fb708233 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -24,6 +24,10 @@ def self.object_names_to_classes Balance.object_name => Balance, BalanceTransaction.object_name => BalanceTransaction, BankAccount.object_name => BankAccount, + Billing::Meter.object_name => Billing::Meter, + Billing::MeterEvent.object_name => Billing::MeterEvent, + Billing::MeterEventAdjustment.object_name => Billing::MeterEventAdjustment, + Billing::MeterEventSummary.object_name => Billing::MeterEventSummary, BillingPortal::Configuration.object_name => BillingPortal::Configuration, BillingPortal::Session.object_name => BillingPortal::Session, Capability.object_name => Capability, diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index f738e09b1..b34be48fd 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -12,6 +12,10 @@ require "stripe/resources/balance" require "stripe/resources/balance_transaction" require "stripe/resources/bank_account" +require "stripe/resources/billing/meter" +require "stripe/resources/billing/meter_event" +require "stripe/resources/billing/meter_event_adjustment" +require "stripe/resources/billing/meter_event_summary" require "stripe/resources/billing_portal/configuration" require "stripe/resources/billing_portal/session" require "stripe/resources/capability" diff --git a/lib/stripe/resources/billing/meter.rb b/lib/stripe/resources/billing/meter.rb new file mode 100644 index 000000000..49bcf2e0f --- /dev/null +++ b/lib/stripe/resources/billing/meter.rb @@ -0,0 +1,83 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Billing + # A billing meter is a resource that allows you to track usage of a particular event. For example, you might create a billing meter to track the number of API calls made by a particular user. You can then use the billing meter to charge the user for the number of API calls they make. + class Meter < APIResource + extend Stripe::APIOperations::Create + extend Stripe::APIOperations::List + extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save + + OBJECT_NAME = "billing.meter" + def self.object_name + "billing.meter" + end + + nested_resource_class_methods :event_summary, + operations: %i[list], + resource_plural: "event_summaries" + + # Creates a billing meter + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/billing/meters", params: params, opts: opts) + end + + # Deactivates a billing meter + def deactivate(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/meters/%s/deactivate", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Deactivates a billing meter + def self.deactivate(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/meters/%s/deactivate", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + # Retrieve a list of billing meters. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/billing/meters", params: filters, opts: opts) + end + + # Reactivates a billing meter + def reactivate(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/meters/%s/reactivate", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Reactivates a billing meter + def self.reactivate(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/meters/%s/reactivate", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + # Updates a billing meter + def self.update(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/meters/%s", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + end + end +end diff --git a/lib/stripe/resources/billing/meter_event.rb b/lib/stripe/resources/billing/meter_event.rb new file mode 100644 index 000000000..53190ce8a --- /dev/null +++ b/lib/stripe/resources/billing/meter_event.rb @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Billing + # A billing meter event represents a customer's usage of a product. Meter events are used to bill a customer based on their usage. + # Meter events are associated with billing meters, which define the shape of the event's payload and how those events are aggregated for billing. + class MeterEvent < APIResource + extend Stripe::APIOperations::Create + + OBJECT_NAME = "billing.meter_event" + def self.object_name + "billing.meter_event" + end + + # Creates a billing meter event + def self.create(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: "/v1/billing/meter_events", + params: params, + opts: opts + ) + end + end + end +end diff --git a/lib/stripe/resources/billing/meter_event_adjustment.rb b/lib/stripe/resources/billing/meter_event_adjustment.rb new file mode 100644 index 000000000..1da80385d --- /dev/null +++ b/lib/stripe/resources/billing/meter_event_adjustment.rb @@ -0,0 +1,26 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Billing + # A billing meter event adjustment represents the status of a meter event adjustment. + class MeterEventAdjustment < APIResource + extend Stripe::APIOperations::Create + + OBJECT_NAME = "billing.meter_event_adjustment" + def self.object_name + "billing.meter_event_adjustment" + end + + # Creates a billing meter event adjustment + def self.create(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: "/v1/billing/meter_event_adjustments", + params: params, + opts: opts + ) + end + end + end +end diff --git a/lib/stripe/resources/billing/meter_event_summary.rb b/lib/stripe/resources/billing/meter_event_summary.rb new file mode 100644 index 000000000..0fb71afd5 --- /dev/null +++ b/lib/stripe/resources/billing/meter_event_summary.rb @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Billing + # A billing meter event summary represents an aggregated view of a customer's billing meter events within a specified timeframe. It indicates how much + # usage was accrued by a customer for that period. + class MeterEventSummary < APIResource + OBJECT_NAME = "billing.meter_event_summary" + def self.object_name + "billing.meter_event_summary" + end + end + end +end