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] 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