diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index b05d9a15..ad928211 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v461 \ No newline at end of file +v481 \ No newline at end of file diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index 73d4461f..4f925048 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -86,6 +86,8 @@ module Stripe PromotionCode::OBJECT_NAME => PromotionCode, Quote::OBJECT_NAME => Quote, QuotePhase::OBJECT_NAME => QuotePhase, + QuotePreviewInvoice::OBJECT_NAME => QuotePreviewInvoice, + QuotePreviewSchedule::OBJECT_NAME => QuotePreviewSchedule, Radar::EarlyFraudWarning::OBJECT_NAME => Radar::EarlyFraudWarning, Radar::ValueList::OBJECT_NAME => Radar::ValueList, Radar::ValueListItem::OBJECT_NAME => Radar::ValueListItem, diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index 86fe51b8..5eb02a43 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -73,6 +73,8 @@ require "stripe/resources/product" require "stripe/resources/promotion_code" require "stripe/resources/quote" require "stripe/resources/quote_phase" +require "stripe/resources/quote_preview_invoice" +require "stripe/resources/quote_preview_schedule" require "stripe/resources/radar/early_fraud_warning" require "stripe/resources/radar/value_list" require "stripe/resources/radar/value_list_item" diff --git a/lib/stripe/resources/quote.rb b/lib/stripe/resources/quote.rb index 72aaf00e..0ce759bf 100644 --- a/lib/stripe/resources/quote.rb +++ b/lib/stripe/resources/quote.rb @@ -8,9 +8,17 @@ module Stripe extend Stripe::APIOperations::Create extend Stripe::APIOperations::List include Stripe::APIOperations::Save + extend Stripe::APIOperations::NestedResource OBJECT_NAME = "quote" + nested_resource_class_methods :todo, + operations: %i[list], + resource_plural: "TODO" + nested_resource_class_methods :todo, + operations: %i[list], + resource_plural: "TODO" + def accept(params = {}, opts = {}) request_stripe_object( method: :post, @@ -104,24 +112,6 @@ module Stripe ) end - def preview_invoices(params = {}, opts = {}) - request_stripe_object( - method: :get, - path: format("/v1/quotes/%s/preview_invoices", { quote: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - def preview_subscription_schedules(params = {}, opts = {}) - request_stripe_object( - method: :get, - path: format("/v1/quotes/%s/preview_subscription_schedules", { quote: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - def reestimate(params = {}, opts = {}) request_stripe_object( method: :post, @@ -229,24 +219,6 @@ module Stripe ) end - def self.preview_invoices(quote, params = {}, opts = {}) - request_stripe_object( - method: :get, - path: format("/v1/quotes/%s/preview_invoices", { quote: CGI.escape(quote) }), - params: params, - opts: opts - ) - end - - def self.preview_subscription_schedules(quote, params = {}, opts = {}) - request_stripe_object( - method: :get, - path: format("/v1/quotes/%s/preview_subscription_schedules", { quote: CGI.escape(quote) }), - params: params, - opts: opts - ) - end - def self.reestimate(quote, params = {}, opts = {}) request_stripe_object( method: :post, diff --git a/lib/stripe/resources/quote_preview_invoice.rb b/lib/stripe/resources/quote_preview_invoice.rb new file mode 100644 index 00000000..abf093a1 --- /dev/null +++ b/lib/stripe/resources/quote_preview_invoice.rb @@ -0,0 +1,42 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + # Invoices are statements of amounts owed by a customer, and are either + # generated one-off, or generated periodically from a subscription. + # + # They contain [invoice items](https://stripe.com/docs/api#invoiceitems), and proration adjustments + # that may be caused by subscription upgrades/downgrades (if necessary). + # + # If your invoice is configured to be billed through automatic charges, + # Stripe automatically finalizes your invoice and attempts payment. Note + # that finalizing the invoice, + # [when automatic](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection), does + # not happen immediately as the invoice is created. Stripe waits + # until one hour after the last webhook was successfully sent (or the last + # webhook timed out after failing). If you (and the platforms you may have + # connected to) have no webhooks configured, Stripe waits one hour after + # creation to finalize the invoice. + # + # If your invoice is configured to be billed by sending an email, then based on your + # [email settings](https://dashboard.stripe.com/account/billing/automatic), + # Stripe will email the invoice to your customer and await payment. These + # emails can contain a link to a hosted page to pay the invoice. + # + # Stripe applies any customer credit on the account before determining the + # amount due for the invoice (i.e., the amount that will be actually + # charged). If the amount due for the invoice is less than Stripe's [minimum allowed charge + # per currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts), the + # invoice is automatically marked paid, and we add the amount due to the + # customer's credit balance which is applied to the next invoice. + # + # More details on the customer's credit balance are + # [here](https://stripe.com/docs/billing/customer/balance). + # + # Related guide: [Send invoices to customers](https://stripe.com/docs/billing/invoices/sending) + class QuotePreviewInvoice < APIResource + extend Stripe::APIOperations::List + + OBJECT_NAME = "quote_preview_invoice" + end +end diff --git a/lib/stripe/resources/quote_preview_schedule.rb b/lib/stripe/resources/quote_preview_schedule.rb new file mode 100644 index 00000000..05c5cc70 --- /dev/null +++ b/lib/stripe/resources/quote_preview_schedule.rb @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + class QuotePreviewSchedule < APIResource + extend Stripe::APIOperations::List + + OBJECT_NAME = "quote_preview_schedule" + end +end diff --git a/lib/stripe/webhook.rb b/lib/stripe/webhook.rb index df1ed65d..63b2f0c8 100644 --- a/lib/stripe/webhook.rb +++ b/lib/stripe/webhook.rb @@ -108,8 +108,9 @@ module Stripe end if tolerance && timestamp < Time.now - tolerance + formatted_timestamp = Time.at(timestamp).strftime("%F %T") raise SignatureVerificationError.new( - "Timestamp outside the tolerance zone (#{Time.at(timestamp)})", + "Timestamp outside the tolerance zone (#{formatted_timestamp})", header, http_body: payload ) end