From 91626d37e8b51fdb404ad19078a83dc8a0ec43cf Mon Sep 17 00:00:00 2001 From: "stripe-openapi[bot]" <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 11:09:09 -0700 Subject: [PATCH] Support for APIs in the new API version 2025-03-31.basil (#1543) * Update generated code for v1559 * Update generated code for v1566 * Update generated code for v1572 * Update generated code for v1618 * Update generated code for v1635 --------- Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Co-authored-by: prathmesh-stripe <165320323+prathmesh-stripe@users.noreply.github.com> Co-authored-by: helenye-stripe <111009531+helenye-stripe@users.noreply.github.com> --- OPENAPI_VERSION | 2 +- lib/stripe/api_version.rb | 2 +- lib/stripe/object_types.rb | 3 +- lib/stripe/resources.rb | 3 +- lib/stripe/resources/checkout/session.rb | 12 +- lib/stripe/resources/invoice.rb | 21 -- lib/stripe/resources/invoice_payment.rb | 19 ++ lib/stripe/resources/payment_method_domain.rb | 12 +- lib/stripe/resources/person.rb | 2 +- lib/stripe/resources/price.rb | 2 +- lib/stripe/resources/subscription_item.rb | 6 - .../resources/treasury/financial_account.rb | 2 +- lib/stripe/resources/usage_record.rb | 17 -- lib/stripe/resources/usage_record_summary.rb | 12 - lib/stripe/resources/v2/event.rb | 1 + lib/stripe/resources/v2/event_destination.rb | 1 + lib/stripe/services.rb | 4 +- .../services/checkout/session_service.rb | 10 +- .../services/invoice_payment_service.rb | 28 +++ lib/stripe/services/invoice_service.rb | 20 +- .../invoice_upcoming_lines_service.rb | 17 -- .../services/payment_method_domain_service.rb | 6 +- lib/stripe/services/price_service.rb | 2 +- .../services/subscription_item_service.rb | 8 - .../subscription_item_usage_record_service.rb | 23 -- ...ption_item_usage_record_summary_service.rb | 19 -- .../treasury/financial_account_service.rb | 2 +- lib/stripe/services/v1_services.rb | 3 +- test/stripe/generated_examples_test.rb | 234 ++++++++++++++++-- 29 files changed, 290 insertions(+), 203 deletions(-) create mode 100644 lib/stripe/resources/invoice_payment.rb delete mode 100644 lib/stripe/resources/usage_record.rb delete mode 100644 lib/stripe/resources/usage_record_summary.rb create mode 100644 lib/stripe/services/invoice_payment_service.rb delete mode 100644 lib/stripe/services/invoice_upcoming_lines_service.rb delete mode 100644 lib/stripe/services/subscription_item_usage_record_service.rb delete mode 100644 lib/stripe/services/subscription_item_usage_record_summary_service.rb diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index ddf5ac54..11b5d327 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v1505 \ No newline at end of file +v1635 \ No newline at end of file diff --git a/lib/stripe/api_version.rb b/lib/stripe/api_version.rb index 0f0b73b4..44670ff5 100644 --- a/lib/stripe/api_version.rb +++ b/lib/stripe/api_version.rb @@ -3,6 +3,6 @@ module Stripe module ApiVersion - CURRENT = "2025-02-24.acacia" + CURRENT = "2025-03-31.basil" end end diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index c6f828d9..af0ab44b 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -70,6 +70,7 @@ module Stripe Invoice.object_name => Invoice, InvoiceItem.object_name => InvoiceItem, InvoiceLineItem.object_name => InvoiceLineItem, + InvoicePayment.object_name => InvoicePayment, InvoiceRenderingTemplate.object_name => InvoiceRenderingTemplate, Issuing::Authorization.object_name => Issuing::Authorization, Issuing::Card.object_name => Issuing::Card, @@ -140,8 +141,6 @@ module Stripe Treasury::ReceivedDebit.object_name => Treasury::ReceivedDebit, Treasury::Transaction.object_name => Treasury::Transaction, Treasury::TransactionEntry.object_name => Treasury::TransactionEntry, - UsageRecord.object_name => UsageRecord, - UsageRecordSummary.object_name => UsageRecordSummary, WebhookEndpoint.object_name => WebhookEndpoint, # object classes: The end of the section generated from our OpenAPI spec } diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index 9823c810..bd575637 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -59,6 +59,7 @@ require "stripe/resources/identity/verification_session" require "stripe/resources/invoice" require "stripe/resources/invoice_item" require "stripe/resources/invoice_line_item" +require "stripe/resources/invoice_payment" require "stripe/resources/invoice_rendering_template" require "stripe/resources/issuing/authorization" require "stripe/resources/issuing/card" @@ -129,8 +130,6 @@ require "stripe/resources/treasury/received_credit" require "stripe/resources/treasury/received_debit" require "stripe/resources/treasury/transaction" require "stripe/resources/treasury/transaction_entry" -require "stripe/resources/usage_record" -require "stripe/resources/usage_record_summary" require "stripe/resources/v2/billing/meter_event" require "stripe/resources/v2/billing/meter_event_adjustment" require "stripe/resources/v2/billing/meter_event_session" diff --git a/lib/stripe/resources/checkout/session.rb b/lib/stripe/resources/checkout/session.rb index 8fdd1121..bec5269a 100644 --- a/lib/stripe/resources/checkout/session.rb +++ b/lib/stripe/resources/checkout/session.rb @@ -27,7 +27,7 @@ module Stripe "checkout.session" end - # Creates a Session object. + # Creates a Checkout Session object. def self.create(params = {}, opts = {}) request_stripe_object( method: :post, @@ -37,9 +37,9 @@ module Stripe ) end - # A Session can be expired when it is in one of these statuses: open + # A Checkout 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. + # After it expires, a customer can't complete a Checkout Session and customers loading the Checkout Session see a message saying the Checkout Session is expired. def expire(params = {}, opts = {}) request_stripe_object( method: :post, @@ -49,9 +49,9 @@ module Stripe ) end - # A Session can be expired when it is in one of these statuses: open + # A Checkout 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. + # After it expires, a customer can't complete a Checkout Session and customers loading the Checkout Session see a message saying the Checkout Session is expired. def self.expire(session, params = {}, opts = {}) request_stripe_object( method: :post, @@ -91,7 +91,7 @@ module Stripe ) end - # Updates a Session object. + # Updates a Checkout Session object. def self.update(session, params = {}, opts = {}) request_stripe_object( method: :post, diff --git a/lib/stripe/resources/invoice.rb b/lib/stripe/resources/invoice.rb index 821b0b61..d507744e 100644 --- a/lib/stripe/resources/invoice.rb +++ b/lib/stripe/resources/invoice.rb @@ -135,16 +135,6 @@ module Stripe request_stripe_object(method: :get, path: "/v1/invoices", 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 = {}) - request_stripe_object( - method: :get, - path: "/v1/invoices/upcoming/lines", - 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 = {}) request_stripe_object( @@ -237,17 +227,6 @@ module Stripe ) end - # At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice. - # - # Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount. - # - # You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass the subscription_details.proration_date parameter when doing the actual subscription update. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_details.proration_date value passed in the request. - # - # Note: Currency conversion calculations use the latest exchange rates. Exchange rates may vary between the time of the preview and the time of the actual invoice creation. [Learn more](https://docs.stripe.com/currencies/conversions) - def self.upcoming(params = {}, opts = {}) - request_stripe_object(method: :get, path: "/v1/invoices/upcoming", params: params, opts: opts) - 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. # diff --git a/lib/stripe/resources/invoice_payment.rb b/lib/stripe/resources/invoice_payment.rb new file mode 100644 index 00000000..6fc0a4c9 --- /dev/null +++ b/lib/stripe/resources/invoice_payment.rb @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + # The invoice payment object + class InvoicePayment < APIResource + extend Stripe::APIOperations::List + + OBJECT_NAME = "invoice_payment" + def self.object_name + "invoice_payment" + end + + # When retrieving an invoice, there is an includable payments property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of payments. + def self.list(params = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/invoice_payments", params: params, opts: opts) + end + end +end diff --git a/lib/stripe/resources/payment_method_domain.rb b/lib/stripe/resources/payment_method_domain.rb index 67b959f9..762fb209 100644 --- a/lib/stripe/resources/payment_method_domain.rb +++ b/lib/stripe/resources/payment_method_domain.rb @@ -46,10 +46,10 @@ module Stripe ) 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. + # Some payment methods might require additional steps to register 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 or Embedded Checkout 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. + # To activate a payment method on an existing payment method domain, complete the required registration 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 = {}) @@ -61,10 +61,10 @@ module Stripe ) 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. + # Some payment methods might require additional steps to register 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 or Embedded Checkout 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. + # To activate a payment method on an existing payment method domain, complete the required registration 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 = {}) diff --git a/lib/stripe/resources/person.rb b/lib/stripe/resources/person.rb index 1262a5ad..79fa0399 100644 --- a/lib/stripe/resources/person.rb +++ b/lib/stripe/resources/person.rb @@ -4,7 +4,7 @@ module Stripe # This is an object representing a person associated with a Stripe account. # - # A platform cannot access a person for an account where [account.controller.requirement_collection](https://stripe.com/api/accounts/object#account_object-controller-requirement_collection) is `stripe`, which includes Standard and Express accounts, after creating an Account Link or Account Session to start Connect onboarding. + # A platform can only access a subset of data in a person for an account where [account.controller.requirement_collection](https://stripe.com/api/accounts/object#account_object-controller-requirement_collection) is `stripe`, which includes Standard and Express accounts, after creating an Account Link or Account Session to start Connect onboarding. # # See the [Standard onboarding](https://stripe.com/connect/standard-accounts) or [Express onboarding](https://stripe.com/connect/express-accounts) documentation for information about prefilling information and account onboarding steps. Learn more about [handling identity verification with the API](https://stripe.com/connect/handling-api-verification#person-information). class Person < APIResource diff --git a/lib/stripe/resources/price.rb b/lib/stripe/resources/price.rb index 6b93cd73..8440ced4 100644 --- a/lib/stripe/resources/price.rb +++ b/lib/stripe/resources/price.rb @@ -19,7 +19,7 @@ module Stripe "price" end - # Creates a new price for an existing product. The price can be recurring or one-time. + # Creates a new [Price for an existing Product](https://docs.stripe.com/api/prices). The Price can be recurring or one-time. def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/prices", params: params, opts: opts) end diff --git a/lib/stripe/resources/subscription_item.rb b/lib/stripe/resources/subscription_item.rb index 49929b79..a4c979be 100644 --- a/lib/stripe/resources/subscription_item.rb +++ b/lib/stripe/resources/subscription_item.rb @@ -8,7 +8,6 @@ module Stripe extend Stripe::APIOperations::Create include Stripe::APIOperations::Delete extend Stripe::APIOperations::List - extend Stripe::APIOperations::NestedResource include Stripe::APIOperations::Save OBJECT_NAME = "subscription_item" @@ -16,11 +15,6 @@ module Stripe "subscription_item" end - nested_resource_class_methods :usage_record, operations: %i[create] - nested_resource_class_methods :usage_record_summary, - operations: %i[list], - resource_plural: "usage_record_summaries" - # Adds a new item to an existing subscription. No existing items will be changed or replaced. def self.create(params = {}, opts = {}) request_stripe_object( diff --git a/lib/stripe/resources/treasury/financial_account.rb b/lib/stripe/resources/treasury/financial_account.rb index 4df600b9..0d82e725 100644 --- a/lib/stripe/resources/treasury/financial_account.rb +++ b/lib/stripe/resources/treasury/financial_account.rb @@ -35,7 +35,7 @@ module Stripe ) end - # Creates a new FinancialAccount. For now, each connected account can only have one FinancialAccount. + # Creates a new FinancialAccount. Each connected account can have up to three FinancialAccounts by default. def self.create(params = {}, opts = {}) request_stripe_object( method: :post, diff --git a/lib/stripe/resources/usage_record.rb b/lib/stripe/resources/usage_record.rb deleted file mode 100644 index 3444824f..00000000 --- a/lib/stripe/resources/usage_record.rb +++ /dev/null @@ -1,17 +0,0 @@ -# File generated from our OpenAPI spec -# frozen_string_literal: true - -module Stripe - # Usage records allow you to report customer usage and metrics to Stripe for - # metered billing of subscription prices. - # - # Related guide: [Metered billing](https://stripe.com/docs/billing/subscriptions/metered-billing) - # - # This is our legacy usage-based billing API. See the [updated usage-based billing docs](https://docs.stripe.com/billing/subscriptions/usage-based). - class UsageRecord < APIResource - OBJECT_NAME = "usage_record" - def self.object_name - "usage_record" - end - end -end diff --git a/lib/stripe/resources/usage_record_summary.rb b/lib/stripe/resources/usage_record_summary.rb deleted file mode 100644 index 1186754d..00000000 --- a/lib/stripe/resources/usage_record_summary.rb +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec -# frozen_string_literal: true - -module Stripe - # A usage record summary represents an aggregated view of how much usage was accrued for a subscription item within a subscription billing period. - class UsageRecordSummary < StripeObject - OBJECT_NAME = "usage_record_summary" - def self.object_name - "usage_record_summary" - end - end -end diff --git a/lib/stripe/resources/v2/event.rb b/lib/stripe/resources/v2/event.rb index df657b40..d41bc188 100644 --- a/lib/stripe/resources/v2/event.rb +++ b/lib/stripe/resources/v2/event.rb @@ -3,6 +3,7 @@ module Stripe module V2 + # Events are generated to keep you informed of activity in your business account. APIs in the /v2 namespace generate [thin events](https://docs.stripe.com/event-destinations#benefits-of-thin-events) which have small, unversioned payloads that include a reference to the ID of the object that has changed. The Events v2 API returns these new thin events. [Retrieve the event object](https://docs.stripe.com/event-destinations#fetch-data) for additional data about the event. Use the related object ID in the event payload to [fetch the API resource](https://docs.stripe.com/event-destinations#retrieve-the-object-associated-with-thin-events) of the object associated with the event. Comparatively, events generated by most API v1 include a versioned snapshot of an API object in their payload. class Event < APIResource OBJECT_NAME = "v2.core.event" def self.object_name diff --git a/lib/stripe/resources/v2/event_destination.rb b/lib/stripe/resources/v2/event_destination.rb index ea088023..9a0bb079 100644 --- a/lib/stripe/resources/v2/event_destination.rb +++ b/lib/stripe/resources/v2/event_destination.rb @@ -3,6 +3,7 @@ module Stripe module V2 + # Set up an event destination to receive events from Stripe across multiple destination types, including [webhook endpoints](https://docs.stripe.com/webhooks) and [Amazon EventBridge](https://docs.stripe.com/event-destinations/eventbridge). Event destinations support receiving [thin events](https://docs.stripe.com/api/v2/events) and [snapshot events](https://docs.stripe.com/api/events). class EventDestination < APIResource OBJECT_NAME = "v2.core.event_destination" def self.object_name diff --git a/lib/stripe/services.rb b/lib/stripe/services.rb index 8c9b7be1..2b03933a 100644 --- a/lib/stripe/services.rb +++ b/lib/stripe/services.rb @@ -71,9 +71,9 @@ require "stripe/services/identity/verification_session_service" require "stripe/services/identity_service" require "stripe/services/invoice_item_service" require "stripe/services/invoice_line_item_service" +require "stripe/services/invoice_payment_service" require "stripe/services/invoice_rendering_template_service" require "stripe/services/invoice_service" -require "stripe/services/invoice_upcoming_lines_service" require "stripe/services/issuing/authorization_service" require "stripe/services/issuing/card_service" require "stripe/services/issuing/cardholder_service" @@ -116,8 +116,6 @@ require "stripe/services/sigma_service" require "stripe/services/source_service" require "stripe/services/source_transaction_service" require "stripe/services/subscription_item_service" -require "stripe/services/subscription_item_usage_record_service" -require "stripe/services/subscription_item_usage_record_summary_service" require "stripe/services/subscription_schedule_service" require "stripe/services/subscription_service" require "stripe/services/tax/calculation_line_item_service" diff --git a/lib/stripe/services/checkout/session_service.rb b/lib/stripe/services/checkout/session_service.rb index bfe75502..20221eb8 100644 --- a/lib/stripe/services/checkout/session_service.rb +++ b/lib/stripe/services/checkout/session_service.rb @@ -11,7 +11,7 @@ module Stripe @line_items = Stripe::Checkout::SessionLineItemService.new(@requestor) end - # Creates a Session object. + # Creates a Checkout Session object. def create(params = {}, opts = {}) request( method: :post, @@ -22,9 +22,9 @@ module Stripe ) end - # A Session can be expired when it is in one of these statuses: open + # A Checkout 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. + # After it expires, a customer can't complete a Checkout Session and customers loading the Checkout Session see a message saying the Checkout Session is expired. def expire(session, params = {}, opts = {}) request( method: :post, @@ -46,7 +46,7 @@ module Stripe ) end - # Retrieves a Session object. + # Retrieves a Checkout Session object. def retrieve(session, params = {}, opts = {}) request( method: :get, @@ -57,7 +57,7 @@ module Stripe ) end - # Updates a Session object. + # Updates a Checkout Session object. def update(session, params = {}, opts = {}) request( method: :post, diff --git a/lib/stripe/services/invoice_payment_service.rb b/lib/stripe/services/invoice_payment_service.rb new file mode 100644 index 00000000..918868f4 --- /dev/null +++ b/lib/stripe/services/invoice_payment_service.rb @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + class InvoicePaymentService < StripeService + # When retrieving an invoice, there is an includable payments property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of payments. + def list(params = {}, opts = {}) + request( + method: :get, + path: "/v1/invoice_payments", + params: params, + opts: opts, + base_address: :api + ) + end + + # Retrieves the invoice payment with the given ID. + def retrieve(invoice_payment, params = {}, opts = {}) + request( + method: :get, + path: format("/v1/invoice_payments/%s", { invoice_payment: CGI.escape(invoice_payment) }), + params: params, + opts: opts, + base_address: :api + ) + end + end +end diff --git a/lib/stripe/services/invoice_service.rb b/lib/stripe/services/invoice_service.rb index 17899fa4..469bd800 100644 --- a/lib/stripe/services/invoice_service.rb +++ b/lib/stripe/services/invoice_service.rb @@ -3,12 +3,11 @@ module Stripe class InvoiceService < StripeService - attr_reader :line_items, :upcoming_lines + attr_reader :line_items def initialize(requestor) super(requestor) @line_items = Stripe::InvoiceLineItemService.new(@requestor) - @upcoming_lines = Stripe::InvoiceUpcomingLinesService.new(@requestor) end # Adds multiple line items to an invoice. This is only possible when an invoice is still a draft. @@ -142,23 +141,6 @@ module Stripe ) end - # At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice. - # - # Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount. - # - # You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass the subscription_details.proration_date parameter when doing the actual subscription update. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_details.proration_date value passed in the request. - # - # Note: Currency conversion calculations use the latest exchange rates. Exchange rates may vary between the time of the preview and the time of the actual invoice creation. [Learn more](https://docs.stripe.com/currencies/conversions) - def upcoming(params = {}, opts = {}) - request( - method: :get, - path: "/v1/invoices/upcoming", - params: params, - opts: opts, - base_address: :api - ) - 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. # diff --git a/lib/stripe/services/invoice_upcoming_lines_service.rb b/lib/stripe/services/invoice_upcoming_lines_service.rb deleted file mode 100644 index 6783da87..00000000 --- a/lib/stripe/services/invoice_upcoming_lines_service.rb +++ /dev/null @@ -1,17 +0,0 @@ -# File generated from our OpenAPI spec -# frozen_string_literal: true - -module Stripe - class InvoiceUpcomingLinesService < StripeService - # 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 list(params = {}, opts = {}) - request( - method: :get, - path: "/v1/invoices/upcoming/lines", - params: params, - opts: opts, - base_address: :api - ) - end - end -end diff --git a/lib/stripe/services/payment_method_domain_service.rb b/lib/stripe/services/payment_method_domain_service.rb index 7942238e..9721dc80 100644 --- a/lib/stripe/services/payment_method_domain_service.rb +++ b/lib/stripe/services/payment_method_domain_service.rb @@ -47,10 +47,10 @@ module Stripe ) 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. + # Some payment methods might require additional steps to register 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 or Embedded Checkout 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. + # To activate a payment method on an existing payment method domain, complete the required registration 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(payment_method_domain, params = {}, opts = {}) diff --git a/lib/stripe/services/price_service.rb b/lib/stripe/services/price_service.rb index c5ea620d..b6d48806 100644 --- a/lib/stripe/services/price_service.rb +++ b/lib/stripe/services/price_service.rb @@ -3,7 +3,7 @@ module Stripe class PriceService < StripeService - # Creates a new price for an existing product. The price can be recurring or one-time. + # Creates a new [Price for an existing Product](https://docs.stripe.com/api/prices). The Price can be recurring or one-time. def create(params = {}, opts = {}) request(method: :post, path: "/v1/prices", params: params, opts: opts, base_address: :api) end diff --git a/lib/stripe/services/subscription_item_service.rb b/lib/stripe/services/subscription_item_service.rb index be2522a8..78ab0cb3 100644 --- a/lib/stripe/services/subscription_item_service.rb +++ b/lib/stripe/services/subscription_item_service.rb @@ -3,14 +3,6 @@ module Stripe class SubscriptionItemService < StripeService - attr_reader :usage_records, :usage_record_summaries - - def initialize(requestor) - super(requestor) - @usage_records = Stripe::SubscriptionItemUsageRecordService.new(@requestor) - @usage_record_summaries = Stripe::SubscriptionItemUsageRecordSummaryService.new(@requestor) - end - # Adds a new item to an existing subscription. No existing items will be changed or replaced. def create(params = {}, opts = {}) request( diff --git a/lib/stripe/services/subscription_item_usage_record_service.rb b/lib/stripe/services/subscription_item_usage_record_service.rb deleted file mode 100644 index 3b33e0e9..00000000 --- a/lib/stripe/services/subscription_item_usage_record_service.rb +++ /dev/null @@ -1,23 +0,0 @@ -# File generated from our OpenAPI spec -# frozen_string_literal: true - -module Stripe - class SubscriptionItemUsageRecordService < StripeService - # Creates a usage record for a specified subscription item and date, and fills it with a quantity. - # - # Usage records provide quantity information that Stripe uses to track how much a customer is using your service. With usage information and the pricing model set up by the [metered billing](https://stripe.com/docs/billing/subscriptions/metered-billing) plan, Stripe helps you send accurate invoices to your customers. - # - # The default calculation for usage is to add up all the quantity values of the usage records within a billing period. You can change this default behavior with the billing plan's aggregate_usage [parameter](https://stripe.com/docs/api/plans/create#create_plan-aggregate_usage). When there is more than one usage record with the same timestamp, Stripe adds the quantity values together. In most cases, this is the desired resolution, however, you can change this behavior with the action parameter. - # - # The default pricing model for metered billing is [per-unit pricing. For finer granularity, you can configure metered billing to have a tiered pricing](https://stripe.com/docs/api/plans/object#plan_object-billing_scheme) model. - def create(subscription_item, params = {}, opts = {}) - request( - method: :post, - path: format("/v1/subscription_items/%s/usage_records", { subscription_item: CGI.escape(subscription_item) }), - params: params, - opts: opts, - base_address: :api - ) - end - end -end diff --git a/lib/stripe/services/subscription_item_usage_record_summary_service.rb b/lib/stripe/services/subscription_item_usage_record_summary_service.rb deleted file mode 100644 index 0d5da815..00000000 --- a/lib/stripe/services/subscription_item_usage_record_summary_service.rb +++ /dev/null @@ -1,19 +0,0 @@ -# File generated from our OpenAPI spec -# frozen_string_literal: true - -module Stripe - class SubscriptionItemUsageRecordSummaryService < StripeService - # For the specified subscription item, returns a list of summary objects. Each object in the list provides usage information that's been summarized from multiple usage records and over a subscription billing period (e.g., 15 usage records in the month of September). - # - # The list is sorted in reverse-chronological order (newest first). The first list item represents the most current usage period that hasn't ended yet. Since new usage records can still be added, the returned summary information for the subscription item's ID should be seen as unstable until the subscription billing period ends. - def list(subscription_item, params = {}, opts = {}) - request( - method: :get, - path: format("/v1/subscription_items/%s/usage_record_summaries", { subscription_item: CGI.escape(subscription_item) }), - params: params, - opts: opts, - base_address: :api - ) - end - end -end diff --git a/lib/stripe/services/treasury/financial_account_service.rb b/lib/stripe/services/treasury/financial_account_service.rb index 6e845d24..eaf694b7 100644 --- a/lib/stripe/services/treasury/financial_account_service.rb +++ b/lib/stripe/services/treasury/financial_account_service.rb @@ -22,7 +22,7 @@ module Stripe ) end - # Creates a new FinancialAccount. For now, each connected account can only have one FinancialAccount. + # Creates a new FinancialAccount. Each connected account can have up to three FinancialAccounts by default. def create(params = {}, opts = {}) request( method: :post, diff --git a/lib/stripe/services/v1_services.rb b/lib/stripe/services/v1_services.rb index 85078c7f..265b05ae 100644 --- a/lib/stripe/services/v1_services.rb +++ b/lib/stripe/services/v1_services.rb @@ -4,7 +4,7 @@ module Stripe class V1Services < StripeService # v1 accessors: The beginning of the section generated from our OpenAPI spec attr_reader :accounts - attr_reader :account_links, :account_sessions, :apple_pay_domains, :application_fees, :apps, :balance, :balance_transactions, :billing, :billing_portal, :charges, :checkout, :climate, :confirmation_tokens, :test_helpers, :country_specs, :coupons, :credit_notes, :customers, :customer_sessions, :disputes, :entitlements, :ephemeral_keys, :events, :exchange_rates, :files, :file_links, :financial_connections, :forwarding, :identity, :invoices, :invoice_rendering_templates, :invoice_items, :issuing, :mandates, :payment_intents, :payment_links, :payment_methods, :payment_method_configurations, :payment_method_domains, :payouts, :plans, :prices, :products, :promotion_codes, :quotes, :radar, :refunds, :reporting, :reviews, :sigma, :setup_attempts, :setup_intents, :shipping_rates, :sources, :subscriptions, :subscription_items, :subscription_schedules, :tax, :tax_codes, :tax_ids, :tax_rates, :terminal, :tokens, :topups, :transfers, :treasury, :webhook_endpoints + attr_reader :account_links, :account_sessions, :apple_pay_domains, :application_fees, :apps, :balance, :balance_transactions, :billing, :billing_portal, :charges, :checkout, :climate, :confirmation_tokens, :test_helpers, :country_specs, :coupons, :credit_notes, :customers, :customer_sessions, :disputes, :entitlements, :ephemeral_keys, :events, :exchange_rates, :files, :file_links, :financial_connections, :forwarding, :identity, :invoices, :invoice_payments, :invoice_rendering_templates, :invoice_items, :issuing, :mandates, :payment_intents, :payment_links, :payment_methods, :payment_method_configurations, :payment_method_domains, :payouts, :plans, :prices, :products, :promotion_codes, :quotes, :radar, :refunds, :reporting, :reviews, :sigma, :setup_attempts, :setup_intents, :shipping_rates, :sources, :subscriptions, :subscription_items, :subscription_schedules, :tax, :tax_codes, :tax_ids, :tax_rates, :terminal, :tokens, :topups, :transfers, :treasury, :webhook_endpoints # v1 accessors: The end of the section generated from our OpenAPI spec # OAuthService is manually maintained, as it has special behaviors @@ -44,6 +44,7 @@ module Stripe @forwarding = Stripe::ForwardingService.new(@requestor) @identity = Stripe::IdentityService.new(@requestor) @invoices = Stripe::InvoiceService.new(@requestor) + @invoice_payments = Stripe::InvoicePaymentService.new(@requestor) @invoice_rendering_templates = Stripe::InvoiceRenderingTemplateService.new(@requestor) @invoice_items = Stripe::InvoiceItemService.new(@requestor) @issuing = Stripe::IssuingService.new(@requestor) diff --git a/test/stripe/generated_examples_test.rb b/test/stripe/generated_examples_test.rb index e0ef2c58..34756138 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -1033,8 +1033,7 @@ module Stripe should "Test coupons post" do Stripe::Coupon.create({ percent_off: 25.5, - duration: "repeating", - duration_in_months: 3, + duration: "once", }) assert_requested :post, "#{Stripe.api_base}/v1/coupons" end @@ -1044,8 +1043,7 @@ module Stripe client.v1.coupons.create({ percent_off: 25.5, - duration: "repeating", - duration_in_months: 3, + duration: "once", }) assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v1/coupons" end @@ -2213,20 +2211,14 @@ module Stripe assert_requested :get, "#{Stripe::DEFAULT_API_BASE}/v1/invoiceitems/ii_xxxxxxxxxxxxx" end should "Test invoiceitems post" do - Stripe::InvoiceItem.create({ - customer: "cus_xxxxxxxxxxxxx", - price: "price_xxxxxxxxxxxxx", - }) + Stripe::InvoiceItem.create({ customer: "cus_xxxxxxxxxxxxx" }) assert_requested :post, "#{Stripe.api_base}/v1/invoiceitems" end should "Test invoiceitems post (service)" do stub_request(:post, "#{Stripe::DEFAULT_API_BASE}/v1/invoiceitems").to_return(body: "{}") client = StripeClient.new("sk_test_123") - client.v1.invoice_items.create({ - customer: "cus_xxxxxxxxxxxxx", - price: "price_xxxxxxxxxxxxx", - }) + client.v1.invoice_items.create({ customer: "cus_xxxxxxxxxxxxx" }) assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v1/invoiceitems" end should "Test invoiceitems post 2" do @@ -2389,20 +2381,6 @@ module Stripe client.v1.invoices.send_invoice("in_xxxxxxxxxxxxx") assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v1/invoices/in_xxxxxxxxxxxxx/send" end - should "Test invoices upcoming get" do - Stripe::Invoice.upcoming({ customer: "cus_9utnxg47pWjV1e" }) - assert_requested :get, "#{Stripe.api_base}/v1/invoices/upcoming?customer=cus_9utnxg47pWjV1e" - end - should "Test invoices upcoming get (service)" do - stub_request( - :get, - "#{Stripe::DEFAULT_API_BASE}/v1/invoices/upcoming?customer=cus_9utnxg47pWjV1e" - ).to_return(body: "{}") - client = StripeClient.new("sk_test_123") - - client.v1.invoices.upcoming({ customer: "cus_9utnxg47pWjV1e" }) - assert_requested :get, "#{Stripe::DEFAULT_API_BASE}/v1/invoices/upcoming?customer=cus_9utnxg47pWjV1e" - end should "Test invoices void post" do Stripe::Invoice.void_invoice("in_xxxxxxxxxxxxx") assert_requested :post, "#{Stripe.api_base}/v1/invoices/in_xxxxxxxxxxxxx/void" @@ -7283,5 +7261,209 @@ module Stripe ) assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v1/webhook_endpoints/we_xxxxxxxxxxxxx" end + should "Test v2 billing meter event session post (service)" do + stub_request(:post, "#{Stripe::DEFAULT_API_BASE}/v2/billing/meter_event_session").to_return( + body: '{"authentication_token":"authentication_token","created":"1970-01-12T21:42:34.472Z","expires_at":"1970-01-10T15:36:51.170Z","id":"obj_123","livemode":true,"object":"v2.billing.meter_event_session"}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.billing.meter_event_session.create + assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v2/billing/meter_event_session" + end + should "Test v2 billing meter event adjustment post (service)" do + stub_request( + :post, + "#{Stripe::DEFAULT_API_BASE}/v2/billing/meter_event_adjustments" + ).to_return( + body: '{"cancel":{"identifier":"identifier"},"created":"1970-01-12T21:42:34.472Z","event_name":"event_name","id":"obj_123","livemode":true,"object":"v2.billing.meter_event_adjustment","status":"complete","type":"cancel"}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.billing.meter_event_adjustments.create({ + cancel: { identifier: "identifier" }, + event_name: "event_name", + type: "cancel", + }) + assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v2/billing/meter_event_adjustments" + end + should "Test v2 billing meter event stream post (service)" do + stub_request( + :post, + "#{Stripe::DEFAULT_METER_EVENTS_BASE}/v2/billing/meter_event_stream" + ).to_return(body: "{}", status: 200) + client = StripeClient.new("sk_test_123") + + client.v2.billing.meter_event_stream.create({ + events: [ + { + event_name: "event_name", + identifier: "identifier", + payload: { undefined: "payload" }, + timestamp: "1970-01-01T15:18:46.294Z", + }, + ], + }) + assert_requested :post, "#{Stripe::DEFAULT_METER_EVENTS_BASE}/v2/billing/meter_event_stream" + end + should "Test v2 billing meter event post (service)" do + stub_request(:post, "#{Stripe::DEFAULT_API_BASE}/v2/billing/meter_events").to_return( + body: '{"created":"1970-01-12T21:42:34.472Z","event_name":"event_name","identifier":"identifier","livemode":true,"object":"v2.billing.meter_event","payload":{"undefined":"payload"},"timestamp":"1970-01-01T15:18:46.294Z"}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.billing.meter_events.create({ + event_name: "event_name", + payload: { undefined: "payload" }, + }) + assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v2/billing/meter_events" + end + should "Test v2 core event destination post (service)" do + stub_request(:post, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations").to_return( + body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","livemode":true,"metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","amazon_eventbridge":null,"webhook_endpoint":null}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.core.event_destinations.create({ + enabled_events: ["enabled_events"], + event_payload: "thin", + name: "name", + type: "amazon_eventbridge", + }) + assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations" + end + should "Test v2 core event destination delete (service)" do + stub_request( + :delete, + "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123" + ).to_return( + body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","livemode":true,"metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","amazon_eventbridge":null,"webhook_endpoint":null}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.core.event_destinations.delete("id_123") + assert_requested :delete, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123" + end + should "Test v2 core event destination post 2 (service)" do + stub_request( + :post, + "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123/disable" + ).to_return( + body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","livemode":true,"metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","amazon_eventbridge":null,"webhook_endpoint":null}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.core.event_destinations.disable("id_123") + assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123/disable" + end + should "Test v2 core event destination post 3 (service)" do + stub_request( + :post, + "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123/enable" + ).to_return( + body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","livemode":true,"metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","amazon_eventbridge":null,"webhook_endpoint":null}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.core.event_destinations.enable("id_123") + assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123/enable" + end + should "Test v2 core event destination get (service)" do + stub_request(:get, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations").to_return( + body: '{"data":[{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","livemode":true,"metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","amazon_eventbridge":null,"webhook_endpoint":null}],"next_page_url":null,"previous_page_url":null}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.core.event_destinations.list + assert_requested :get, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations" + end + should "Test v2 core event destination post 4 (service)" do + stub_request( + :post, + "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123/ping" + ).to_return( + body: '{"context":null,"created":"1970-01-12T21:42:34.472Z","id":"obj_123","livemode":true,"object":"v2.core.event","reason":null,"type":"type"}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.core.event_destinations.ping("id_123") + assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123/ping" + end + should "Test v2 core event destination get 2 (service)" do + stub_request(:get, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123").to_return( + body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","livemode":true,"metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","amazon_eventbridge":null,"webhook_endpoint":null}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.core.event_destinations.retrieve("id_123") + assert_requested :get, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123" + end + should "Test v2 core event destination post 5 (service)" do + stub_request( + :post, + "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123" + ).to_return( + body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","livemode":true,"metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","amazon_eventbridge":null,"webhook_endpoint":null}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.core.event_destinations.update("id_123") + assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123" + end + should "Test v2 core event get (service)" do + stub_request( + :get, + "#{Stripe::DEFAULT_API_BASE}/v2/core/events?object_id=object_id" + ).to_return( + body: '{"data":[{"context":null,"created":"1970-01-12T21:42:34.472Z","id":"obj_123","livemode":true,"object":"v2.core.event","reason":null,"type":"type"}],"next_page_url":null,"previous_page_url":null}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.core.events.list({ object_id: "object_id" }) + assert_requested :get, "#{Stripe::DEFAULT_API_BASE}/v2/core/events?object_id=object_id" + end + should "Test v2 core event get 2 (service)" do + stub_request(:get, "#{Stripe::DEFAULT_API_BASE}/v2/core/events/id_123").to_return( + body: '{"context":null,"created":"1970-01-12T21:42:34.472Z","id":"obj_123","livemode":true,"object":"v2.core.event","reason":null,"type":"type"}', + status: 200 + ) + client = StripeClient.new("sk_test_123") + + client.v2.core.events.retrieve("id_123") + assert_requested :get, "#{Stripe::DEFAULT_API_BASE}/v2/core/events/id_123" + end + should "Test temporary session expired error (service)" do + stub_request( + :post, + "#{Stripe::DEFAULT_METER_EVENTS_BASE}/v2/billing/meter_event_stream" + ).to_return( + body: '{"error":{"type":"temporary_session_expired","code":"billing_meter_event_session_expired"}}', + status: 400 + ) + client = StripeClient.new("sk_test_123") + + assert_raises Stripe::TemporarySessionExpiredError do + client.v2.billing.meter_event_stream.create({ + events: [ + { + event_name: "event_name", + payload: { undefined: "payload" }, + }, + ], + }) + end + assert_requested :post, "#{Stripe::DEFAULT_METER_EVENTS_BASE}/v2/billing/meter_event_stream" + end end end