From 3195b08ee709296239758558c4b226e8aad85826 Mon Sep 17 00:00:00 2001 From: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com> Date: Thu, 8 Dec 2022 14:48:50 -0800 Subject: [PATCH 1/7] API Updates (#1581) * Codegen for openapi v213 * manual fix for tests --- OPENAPI_VERSION | 2 +- charge.go | 2 +- customer.go | 2 +- paymentmethod.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index eaf5acec6b..48a3024267 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v212 \ No newline at end of file +v213 \ No newline at end of file diff --git a/charge.go b/charge.go index 0e536329bf..a3c020c762 100644 --- a/charge.go +++ b/charge.go @@ -1052,7 +1052,7 @@ type Charge struct { Disputed bool `json:"disputed"` // ID of the balance transaction that describes the reversal of the balance on your account due to payment failure. FailureBalanceTransaction *BalanceTransaction `json:"failure_balance_transaction"` - // Error code explaining reason for charge failure if available (see [the errors section](https://stripe.com/docs/api#errors) for a list of codes). + // Error code explaining reason for charge failure if available (see [the errors section](https://stripe.com/docs/error-codes) for a list of codes). FailureCode string `json:"failure_code"` // Message to user further explaining reason for charge failure if available. FailureMessage string `json:"failure_message"` diff --git a/customer.go b/customer.go index 832abf707b..e6f54a01bc 100644 --- a/customer.go +++ b/customer.go @@ -178,7 +178,7 @@ type CustomerParams struct { type CustomerListPaymentMethodsParams struct { ListParams `form:"*"` Customer *string `form:"-"` // Included in URL - // A required filter on the list, based on the object `type` field. + // An optional filter on the list, based on the object `type` field. Without the filter, the list includes all current and future payment method types. If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. Type *string `form:"type"` } diff --git a/paymentmethod.go b/paymentmethod.go index 222326bd29..89800b8f6c 100644 --- a/paymentmethod.go +++ b/paymentmethod.go @@ -436,7 +436,7 @@ type PaymentMethodListParams struct { ListParams `form:"*"` // The ID of the customer whose PaymentMethods will be retrieved. Customer *string `form:"customer"` - // A required filter on the list, based on the object `type` field. + // An optional filter on the list, based on the object `type` field. Without the filter, the list includes all current and future payment method types. If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. Type *string `form:"type"` } From 9ac583d58276d6721b2a92be35c67b8cd9fa17f3 Mon Sep 17 00:00:00 2001 From: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com> Date: Thu, 15 Dec 2022 11:12:37 -0800 Subject: [PATCH 2/7] API Updates (#1584) Codegen for openapi v214 --- OPENAPI_VERSION | 2 +- balance.go | 3 +-- checkout_session.go | 2 +- creditnote.go | 2 ++ customerbalancetransaction.go | 5 +++-- financialconnections_account.go | 14 +++++++------- paymentintent.go | 4 ++-- reporting_reportrun.go | 5 ++--- 8 files changed, 19 insertions(+), 18 deletions(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 48a3024267..de4ec3f3b1 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v213 \ No newline at end of file +v214 \ No newline at end of file diff --git a/balance.go b/balance.go index b2e52693fd..66c06a29b1 100644 --- a/balance.go +++ b/balance.go @@ -17,8 +17,7 @@ const ( ) // Retrieves the current account balance, based on the authentication that was used to make the request. -// -// For a sample request, see [Accounting for negative balances](https://stripe.com/docs/connect/account-balances#accounting-for-negative-balances). +// For a sample request, see [Accounting for negative balances](https://stripe.com/docs/connect/account-balances#accounting-for-negative-balances). type BalanceParams struct { Params `form:"*"` } diff --git a/checkout_session.go b/checkout_session.go index 87858bc5f8..977afc4652 100644 --- a/checkout_session.go +++ b/checkout_session.go @@ -1397,7 +1397,7 @@ type CheckoutSessionParams struct { // When a Customer is not created, you can still retrieve email, address, and other customer data entered in Checkout // with [customer_details](https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-customer_details). // - // Sessions that don't create Customers instead create [Guest Customers](https://support.stripe.com/questions/guest-customer-faq) + // Sessions that don't create Customers instead are grouped by [guest customers](https://stripe.com/docs/payments/checkout/guest-customers) // in the Dashboard. Promotion codes limited to first time customers will return invalid for these Sessions. // // Can only be set in `payment` and `setup` mode. diff --git a/creditnote.go b/creditnote.go index 60d5920f5b..be442a925e 100644 --- a/creditnote.go +++ b/creditnote.go @@ -61,10 +61,12 @@ type CreditNoteLineParams struct { // 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 diff --git a/customerbalancetransaction.go b/customerbalancetransaction.go index 861ac47eed..e95149cfee 100644 --- a/customerbalancetransaction.go +++ b/customerbalancetransaction.go @@ -8,7 +8,7 @@ package stripe import "encoding/json" -// Transaction type: `adjustment`, `applied_to_invoice`, `credit_note`, `initial`, `invoice_too_large`, `invoice_too_small`, `unspent_receiver_credit`, or `unapplied_from_invoice`. See the [Customer Balance page](https://stripe.com/docs/billing/customer/balance#types) to learn more about transaction types. +// Transaction type: `adjustment`, `applied_to_invoice`, `credit_note`, `initial`, `invoice_overpaid`, `invoice_too_large`, `invoice_too_small`, `unspent_receiver_credit`, or `unapplied_from_invoice`. See the [Customer Balance page](https://stripe.com/docs/billing/customer/balance#types) to learn more about transaction types. type CustomerBalanceTransactionType string // List of values that CustomerBalanceTransactionType can take @@ -17,6 +17,7 @@ const ( CustomerBalanceTransactionTypeAppliedToInvoice CustomerBalanceTransactionType = "applied_to_invoice" CustomerBalanceTransactionTypeCreditNote CustomerBalanceTransactionType = "credit_note" CustomerBalanceTransactionTypeInitial CustomerBalanceTransactionType = "initial" + CustomerBalanceTransactionTypeInvoiceOverpaid CustomerBalanceTransactionType = "invoice_overpaid" CustomerBalanceTransactionTypeInvoiceTooLarge CustomerBalanceTransactionType = "invoice_too_large" CustomerBalanceTransactionTypeInvoiceTooSmall CustomerBalanceTransactionType = "invoice_too_small" CustomerBalanceTransactionTypeMigration CustomerBalanceTransactionType = "migration" @@ -74,7 +75,7 @@ type CustomerBalanceTransaction struct { Metadata map[string]string `json:"metadata"` // String representing the object's type. Objects of the same type share the same value. Object string `json:"object"` - // Transaction type: `adjustment`, `applied_to_invoice`, `credit_note`, `initial`, `invoice_too_large`, `invoice_too_small`, `unspent_receiver_credit`, or `unapplied_from_invoice`. See the [Customer Balance page](https://stripe.com/docs/billing/customer/balance#types) to learn more about transaction types. + // Transaction type: `adjustment`, `applied_to_invoice`, `credit_note`, `initial`, `invoice_overpaid`, `invoice_too_large`, `invoice_too_small`, `unspent_receiver_credit`, or `unapplied_from_invoice`. See the [Customer Balance page](https://stripe.com/docs/billing/customer/balance#types) to learn more about transaction types. Type CustomerBalanceTransactionType `json:"type"` } diff --git a/financialconnections_account.go b/financialconnections_account.go index f23e581936..0c7c84b862 100644 --- a/financialconnections_account.go +++ b/financialconnections_account.go @@ -78,16 +78,16 @@ const ( // If `category` is `cash`, one of: // -// - `checking` -// - `savings` -// - `other` +// - `checking` +// - `savings` +// - `other` // // If `category` is `credit`, one of: // -// - `mortgage` -// - `line_of_credit` -// - `credit_card` -// - `other` +// - `mortgage` +// - `line_of_credit` +// - `credit_card` +// - `other` // // If `category` is `investment` or `other`, this will be `other`. type FinancialConnectionsAccountSubcategory string diff --git a/paymentintent.go b/paymentintent.go index 6ee97abe46..5f86c686a1 100644 --- a/paymentintent.go +++ b/paymentintent.go @@ -1627,11 +1627,11 @@ type PaymentIntentConfirmParams struct { UseStripeSDK *bool `form:"use_stripe_sdk"` } -// A PaymentIntent object can be canceled when it is in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action, or processing. +// A PaymentIntent object can be canceled when it is 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. // // Once canceled, no additional charges will be made by the PaymentIntent and any operations on the PaymentIntent will fail with an error. For PaymentIntents with status='requires_capture', the remaining amount_capturable will automatically be refunded. // -// You cannot cancel the PaymentIntent for a Checkout Session. [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead +// You cannot cancel the PaymentIntent for a Checkout Session. [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead. type PaymentIntentCancelParams struct { Params `form:"*"` // Reason for canceling this PaymentIntent. Possible values are `duplicate`, `fraudulent`, `requested_by_customer`, or `abandoned` diff --git a/reporting_reportrun.go b/reporting_reportrun.go index 692f8dd030..01ab033978 100644 --- a/reporting_reportrun.go +++ b/reporting_reportrun.go @@ -7,9 +7,8 @@ package stripe // Status of this report run. This will be `pending` when the run is initially created. -// -// When the run finishes, this will be set to `succeeded` and the `result` field will be populated. -// Rarely, we may encounter an error, at which point this will be set to `failed` and the `error` field will be populated. +// When the run finishes, this will be set to `succeeded` and the `result` field will be populated. +// Rarely, we may encounter an error, at which point this will be set to `failed` and the `error` field will be populated. type ReportingReportRunStatus string // List of values that ReportingReportRunStatus can take From 85b14ffa3f6f4fedef963ab48eb4888cf7dd0f5a Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 15 Dec 2022 11:15:34 -0800 Subject: [PATCH 3/7] Bump version to 74.3.0 --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- stripe.go | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8872359bb4..ba779afdff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 74.3.0 - 2022-12-15 +* [#1584](https://github.com/stripe/stripe-go/pull/1584) API Updates + * Add support for new value `invoice_overpaid` on enum `CustomerBalanceTransactionType` +* [#1581](https://github.com/stripe/stripe-go/pull/1581) API Updates + + ## 74.2.0 - 2022-12-06 * [#1579](https://github.com/stripe/stripe-go/pull/1579) API Updates * Add support for `FlowData` on `BillingPortalSessionParams` diff --git a/VERSION b/VERSION index 37c7f2b082..48b4d4fb7d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -74.2.0 +74.3.0 diff --git a/stripe.go b/stripe.go index 202cf11366..3ba8933e53 100644 --- a/stripe.go +++ b/stripe.go @@ -1198,7 +1198,7 @@ func StringSlice(v []string) []*string { // // clientversion is the binding version -const clientversion = "74.2.0" +const clientversion = "74.3.0" // defaultHTTPTimeout is the default timeout on the http.Client used by the library. // This is chosen to be consistent with the other Stripe language libraries and From 8f32a3eea0abd80f139615e7465265958b52054a Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 15 Dec 2022 11:19:23 -0800 Subject: [PATCH 4/7] Set version to 74.3.0 to simplify merge --- VERSION | 2 +- stripe.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index d39d18e26e..48b4d4fb7d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -74.3.0-beta.1 +74.3.0 diff --git a/stripe.go b/stripe.go index cee365589f..f7994715c5 100644 --- a/stripe.go +++ b/stripe.go @@ -1198,7 +1198,7 @@ func StringSlice(v []string) []*string { // // clientversion is the binding version -const clientversion = "74.3.0-beta.1" +const clientversion = "74.3.0" // defaultHTTPTimeout is the default timeout on the http.Client used by the library. // This is chosen to be consistent with the other Stripe language libraries and From d7986cdc7a0820c78d426dc32c178ba23b083073 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 15 Dec 2022 11:19:24 -0800 Subject: [PATCH 5/7] Reset version to 74.3.0-beta.1 --- VERSION | 2 +- stripe.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 48b4d4fb7d..d39d18e26e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -74.3.0 +74.3.0-beta.1 diff --git a/stripe.go b/stripe.go index f7994715c5..cee365589f 100644 --- a/stripe.go +++ b/stripe.go @@ -1198,7 +1198,7 @@ func StringSlice(v []string) []*string { // // clientversion is the binding version -const clientversion = "74.3.0" +const clientversion = "74.3.0-beta.1" // defaultHTTPTimeout is the default timeout on the http.Client used by the library. // This is chosen to be consistent with the other Stripe language libraries and From 836e26af592f7abd1f85232e4348089cf06e7bcd Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 15 Dec 2022 11:19:33 -0800 Subject: [PATCH 6/7] Codegen for openapi v214 --- OPENAPI_VERSION | 2 +- invoice.go | 20 +- invoicelineitem.go | 21 +- quote.go | 824 +++++++++++++++++++++++++++++++++++++++- quote/client.go | 198 ++++++++++ subscriptionschedule.go | 30 +- 6 files changed, 1081 insertions(+), 14 deletions(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 48a3024267..de4ec3f3b1 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v213 \ No newline at end of file +v214 \ No newline at end of file diff --git a/invoice.go b/invoice.go index f6188d1926..738b0d36f4 100644 --- a/invoice.go +++ b/invoice.go @@ -11,6 +11,15 @@ import ( "github.com/stripe/stripe-go/v74/form" ) +// Describes whether the quote line is affecting a new schedule or an existing schedule. +type InvoiceAppliesToType string + +// List of values that InvoiceAppliesToType can take +const ( + InvoiceAppliesToTypeNewReference InvoiceAppliesToType = "new_reference" + InvoiceAppliesToTypeSubscriptionSchedule InvoiceAppliesToType = "subscription_schedule" +) + // The status of the most recent automated tax calculation for this invoice. type InvoiceAutomaticTaxStatus string @@ -932,6 +941,14 @@ type InvoiceListLinesParams struct { ListParams `form:"*"` Invoice *string `form:"-"` // Included in URL } +type InvoiceAppliesTo struct { + // A custom string that identifies a new subscription schedule being created upon quote acceptance. All quote lines with the same `new_reference` field will be applied to the creation of a new subscription schedule. + NewReference string `json:"new_reference"` + // The ID of the schedule the line applies to. + SubscriptionSchedule string `json:"subscription_schedule"` + // Describes whether the quote line is affecting a new schedule or an existing schedule. + Type InvoiceAppliesToType `json:"type"` +} type InvoiceAutomaticTax struct { // Whether Stripe automatically computes tax on this invoice. Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices. Enabled bool `json:"enabled"` @@ -1150,7 +1167,8 @@ type Invoice struct { // ID of the Connect Application that created the invoice. Application *Application `json:"application"` // The fee in %s that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid. - ApplicationFeeAmount int64 `json:"application_fee_amount"` + ApplicationFeeAmount int64 `json:"application_fee_amount"` + AppliesTo *InvoiceAppliesTo `json:"applies_to"` // Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule. AttemptCount int64 `json:"attempt_count"` // Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the `invoice.created` webhook, for example, so you might not want to display that invoice as unpaid to your users. diff --git a/invoicelineitem.go b/invoicelineitem.go index 628b5c695f..b5787fb310 100644 --- a/invoicelineitem.go +++ b/invoicelineitem.go @@ -6,6 +6,15 @@ package stripe +// Describes whether the quote line is affecting a new schedule or an existing schedule. +type InvoiceLineItemAppliesToType string + +// List of values that InvoiceLineItemAppliesToType can take +const ( + InvoiceLineItemAppliesToTypeNewReference InvoiceLineItemAppliesToType = "new_reference" + InvoiceLineItemAppliesToTypeSubscriptionSchedule InvoiceLineItemAppliesToType = "subscription_schedule" +) + // A string identifying the type of the source of this line item, either an `invoiceitem` or a `subscription`. type InvoiceLineItemType string @@ -15,6 +24,15 @@ const ( InvoiceLineItemTypeSubscription InvoiceLineItemType = "subscription" ) +type InvoiceLineItemAppliesTo struct { + // A custom string that identifies a new subscription schedule being created upon quote acceptance. All quote lines with the same `new_reference` field will be applied to the creation of a new subscription schedule. + NewReference string `json:"new_reference"` + // The ID of the schedule the line applies to. + SubscriptionSchedule string `json:"subscription_schedule"` + // Describes whether the quote line is affecting a new schedule or an existing schedule. + Type InvoiceLineItemAppliesToType `json:"type"` +} + // The amount of discount calculated per discount for this line item. type InvoiceLineItemDiscountAmount struct { // The amount, in %s, of the discount. @@ -40,7 +58,8 @@ type InvoiceLineItem struct { // The amount, in %s. Amount int64 `json:"amount"` // The integer amount in %s representing the amount for this line item, excluding all tax and discounts. - AmountExcludingTax int64 `json:"amount_excluding_tax"` + AmountExcludingTax int64 `json:"amount_excluding_tax"` + AppliesTo *InvoiceLineItemAppliesTo `json:"applies_to"` // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). Currency Currency `json:"currency"` // An arbitrary string attached to the object. Often useful for displaying to users. diff --git a/quote.go b/quote.go index a44cebbfaf..eecf6fa620 100644 --- a/quote.go +++ b/quote.go @@ -46,10 +46,69 @@ type QuoteStatus string // List of values that QuoteStatus can take const ( - QuoteStatusAccepted QuoteStatus = "accepted" - QuoteStatusCanceled QuoteStatus = "canceled" - QuoteStatusDraft QuoteStatus = "draft" - QuoteStatusOpen QuoteStatus = "open" + QuoteStatusAccepted QuoteStatus = "accepted" + QuoteStatusAccepting QuoteStatus = "accepting" + QuoteStatusCanceled QuoteStatus = "canceled" + QuoteStatusDraft QuoteStatus = "draft" + QuoteStatusOpen QuoteStatus = "open" + QuoteStatusStale QuoteStatus = "stale" +) + +// The reason this quote was marked as canceled. +type QuoteStatusDetailsCanceledReason string + +// List of values that QuoteStatusDetailsCanceledReason can take +const ( + QuoteStatusDetailsCanceledReasonQuoteAccepted QuoteStatusDetailsCanceledReason = "quote_accepted" + QuoteStatusDetailsCanceledReasonQuoteExpired QuoteStatusDetailsCanceledReason = "quote_expired" + QuoteStatusDetailsCanceledReasonQuoteSuperseded QuoteStatusDetailsCanceledReason = "quote_superseded" + QuoteStatusDetailsCanceledReasonSubscriptionCanceled QuoteStatusDetailsCanceledReason = "subscription_canceled" + QuoteStatusDetailsCanceledReasonUserCanceled QuoteStatusDetailsCanceledReason = "user_canceled" +) + +// The reason the quote was marked as stale. +type QuoteStatusDetailsStaleLastReasonType string + +// List of values that QuoteStatusDetailsStaleLastReasonType can take +const ( + QuoteStatusDetailsStaleLastReasonTypeBillOnAcceptanceInvalid QuoteStatusDetailsStaleLastReasonType = "bill_on_acceptance_invalid" + QuoteStatusDetailsStaleLastReasonTypeLineInvalid QuoteStatusDetailsStaleLastReasonType = "line_invalid" + QuoteStatusDetailsStaleLastReasonTypeSubscriptionChanged QuoteStatusDetailsStaleLastReasonType = "subscription_changed" + QuoteStatusDetailsStaleLastReasonTypeSubscriptionScheduleChanged QuoteStatusDetailsStaleLastReasonType = "subscription_schedule_changed" +) + +// The type of method to specify the `bill_from` time. +type QuoteSubscriptionDataBillOnAcceptanceBillFromType string + +// List of values that QuoteSubscriptionDataBillOnAcceptanceBillFromType can take +const ( + QuoteSubscriptionDataBillOnAcceptanceBillFromTypeLineStartsAt QuoteSubscriptionDataBillOnAcceptanceBillFromType = "line_starts_at" + QuoteSubscriptionDataBillOnAcceptanceBillFromTypeNow QuoteSubscriptionDataBillOnAcceptanceBillFromType = "now" + QuoteSubscriptionDataBillOnAcceptanceBillFromTypeQuoteAcceptanceDate QuoteSubscriptionDataBillOnAcceptanceBillFromType = "quote_acceptance_date" + QuoteSubscriptionDataBillOnAcceptanceBillFromTypeTimestamp QuoteSubscriptionDataBillOnAcceptanceBillFromType = "timestamp" +) + +// Specifies a type of interval unit. Either `day`, `week`, `month` or `year`. +type QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationInterval string + +// List of values that QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationInterval can take +const ( + QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationIntervalDay QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationInterval = "day" + QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationIntervalMonth QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationInterval = "month" + QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationIntervalWeek QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationInterval = "week" + QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationIntervalYear QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationInterval = "year" +) + +// The type of method to specify the `bill_until` time. +type QuoteSubscriptionDataBillOnAcceptanceBillUntilType string + +// List of values that QuoteSubscriptionDataBillOnAcceptanceBillUntilType can take +const ( + QuoteSubscriptionDataBillOnAcceptanceBillUntilTypeDuration QuoteSubscriptionDataBillOnAcceptanceBillUntilType = "duration" + QuoteSubscriptionDataBillOnAcceptanceBillUntilTypeLineEndsAt QuoteSubscriptionDataBillOnAcceptanceBillUntilType = "line_ends_at" + QuoteSubscriptionDataBillOnAcceptanceBillUntilTypeScheduleEnd QuoteSubscriptionDataBillOnAcceptanceBillUntilType = "schedule_end" + QuoteSubscriptionDataBillOnAcceptanceBillUntilTypeTimestamp QuoteSubscriptionDataBillOnAcceptanceBillUntilType = "timestamp" + QuoteSubscriptionDataBillOnAcceptanceBillUntilTypeUpcomingInvoice QuoteSubscriptionDataBillOnAcceptanceBillUntilType = "upcoming_invoice" ) // Configures when the subscription schedule generates prorations for phase transitions. Possible values are `prorate_on_next_phase` or `prorate_up_front` with the default being `prorate_on_next_phase`. `prorate_on_next_phase` will apply phase changes and generate prorations at transition time.`prorate_up_front` will bill for all phases within the current billing cycle up front. @@ -88,6 +147,86 @@ const ( QuoteSubscriptionDataProrationBehaviorNone QuoteSubscriptionDataProrationBehavior = "none" ) +// Describes whether the quote line is affecting a new schedule or an existing schedule. +type QuoteSubscriptionDataOverrideAppliesToType string + +// List of values that QuoteSubscriptionDataOverrideAppliesToType can take +const ( + QuoteSubscriptionDataOverrideAppliesToTypeNewReference QuoteSubscriptionDataOverrideAppliesToType = "new_reference" + QuoteSubscriptionDataOverrideAppliesToTypeSubscriptionSchedule QuoteSubscriptionDataOverrideAppliesToType = "subscription_schedule" +) + +// The type of method to specify the `bill_from` time. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromType string + +// List of values that QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromType can take +const ( + QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromTypeLineStartsAt QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromType = "line_starts_at" + QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromTypeNow QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromType = "now" + QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromTypeQuoteAcceptanceDate QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromType = "quote_acceptance_date" + QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromTypeTimestamp QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromType = "timestamp" +) + +// Specifies a type of interval unit. Either `day`, `week`, `month` or `year`. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationInterval string + +// List of values that QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationInterval can take +const ( + QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationIntervalDay QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationInterval = "day" + QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationIntervalMonth QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationInterval = "month" + QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationIntervalWeek QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationInterval = "week" + QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationIntervalYear QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationInterval = "year" +) + +// The type of method to specify the `bill_until` time. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilType string + +// List of values that QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilType can take +const ( + QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilTypeDuration QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilType = "duration" + QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilTypeLineEndsAt QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilType = "line_ends_at" + QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilTypeScheduleEnd QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilType = "schedule_end" + QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilTypeTimestamp QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilType = "timestamp" + QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilTypeUpcomingInvoice QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilType = "upcoming_invoice" +) + +// Configures when the subscription schedule generates prorations for phase transitions. Possible values are `prorate_on_next_phase` or `prorate_up_front` with the default being `prorate_on_next_phase`. `prorate_on_next_phase` will apply phase changes and generate prorations at transition time.`prorate_up_front` will bill for all phases within the current billing cycle up front. +type QuoteSubscriptionDataOverrideBillingBehavior string + +// List of values that QuoteSubscriptionDataOverrideBillingBehavior can take +const ( + QuoteSubscriptionDataOverrideBillingBehaviorProrateOnNextPhase QuoteSubscriptionDataOverrideBillingBehavior = "prorate_on_next_phase" + QuoteSubscriptionDataOverrideBillingBehaviorProrateUpFront QuoteSubscriptionDataOverrideBillingBehavior = "prorate_up_front" +) + +// Behavior of the subscription schedule and underlying subscription when it ends. Possible values are `release` and `cancel`. +type QuoteSubscriptionDataOverrideEndBehavior string + +// List of values that QuoteSubscriptionDataOverrideEndBehavior can take +const ( + QuoteSubscriptionDataOverrideEndBehaviorCancel QuoteSubscriptionDataOverrideEndBehavior = "cancel" + QuoteSubscriptionDataOverrideEndBehaviorRelease QuoteSubscriptionDataOverrideEndBehavior = "release" +) + +// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the quote is accepted. +type QuoteSubscriptionDataOverrideProrationBehavior string + +// List of values that QuoteSubscriptionDataOverrideProrationBehavior can take +const ( + QuoteSubscriptionDataOverrideProrationBehaviorAlwaysInvoice QuoteSubscriptionDataOverrideProrationBehavior = "always_invoice" + QuoteSubscriptionDataOverrideProrationBehaviorCreateProrations QuoteSubscriptionDataOverrideProrationBehavior = "create_prorations" + QuoteSubscriptionDataOverrideProrationBehaviorNone QuoteSubscriptionDataOverrideProrationBehavior = "none" +) + +// Describes whether the quote line is affecting a new schedule or an existing schedule. +type QuoteSubscriptionScheduleAppliesToType string + +// List of values that QuoteSubscriptionScheduleAppliesToType can take +const ( + QuoteSubscriptionScheduleAppliesToTypeNewReference QuoteSubscriptionScheduleAppliesToType = "new_reference" + QuoteSubscriptionScheduleAppliesToTypeSubscriptionSchedule QuoteSubscriptionScheduleAppliesToType = "subscription_schedule" +) + // Retrieves the quote with the given ID. type QuoteParams struct { Params `form:"*"` @@ -119,12 +258,16 @@ type QuoteParams struct { InvoiceSettings *QuoteInvoiceSettingsParams `form:"invoice_settings"` // A list of line items the customer is being quoted for. Each line item includes information about the product, the quantity, and the resulting cost. LineItems []*QuoteLineItemParams `form:"line_items"` + // A list of lines on the quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted. + Lines []*QuoteLineParams `form:"lines"` // The account on behalf of which to charge. OnBehalfOf *string `form:"on_behalf_of"` // List representing phases of the Quote. Each phase can be customized to have different durations, prices, and coupons. Phases []*QuotePhaseParams `form:"phases"` // When creating a subscription or subscription schedule, the specified configuration data will be used. There must be at least one line item with a recurring price for a subscription or subscription schedule to be created. A subscription schedule is created if `subscription_data[effective_date]` is present and in the future, otherwise a subscription is created. SubscriptionData *QuoteSubscriptionDataParams `form:"subscription_data"` + // List representing overrides for `subscription_data` configurations for specific groups. + SubscriptionDataOverrides []*QuoteSubscriptionDataOverrideParams `form:"subscription_data_overrides"` // ID of the test clock to attach to the quote. TestClock *string `form:"test_clock"` // The data with which to automatically create a Transfer for each of the invoices. @@ -239,6 +382,268 @@ type QuoteLineItemParams struct { TaxRates []*string `form:"tax_rates"` } +// Details to determine how long the discount should be applied for. +type QuoteLineActionAddDiscountDiscountEndParams struct { + // The type of calculation made to determine when the discount ends. + Type *string `form:"type"` +} + +// Details for the `add_discount` type. +type QuoteLineActionAddDiscountParams struct { + // The coupon code to redeem. + Coupon *string `form:"coupon"` + // An ID of an existing discount for a coupon that was already redeemed. + Discount *string `form:"discount"` + // Details to determine how long the discount should be applied for. + DiscountEnd *QuoteLineActionAddDiscountDiscountEndParams `form:"discount_end"` + // The index, starting at 0, at which to position the new discount. When not supplied, Stripe defaults to appending the discount to the end of the `discounts` array. + Index *int64 `form:"index"` +} + +// Time span for the redeemed discount. +type QuoteLineActionAddItemDiscountDiscountEndDurationParams struct { + // Specifies a type of interval unit. Either `day`, `week`, `month` or `year`. + Interval *string `form:"interval"` + // The number of intervals, as an whole number greater than 0. Stripe multiplies this by the interval type to get the overall duration. + IntervalCount *int64 `form:"interval_count"` +} + +// Details to determine how long the discount should be applied for. +type QuoteLineActionAddItemDiscountDiscountEndParams struct { + // Time span for the redeemed discount. + Duration *QuoteLineActionAddItemDiscountDiscountEndDurationParams `form:"duration"` + // A precise Unix timestamp for the discount to end. Must be in the future. + Timestamp *int64 `form:"timestamp"` + // The type of calculation made to determine when the discount ends. + Type *string `form:"type"` +} + +// The discounts applied to the item. Subscription item discounts are applied before subscription discounts. +type QuoteLineActionAddItemDiscountParams struct { + // ID of the coupon to create a new discount for. + Coupon *string `form:"coupon"` + // ID of an existing discount on the object (or one of its ancestors) to reuse. + Discount *string `form:"discount"` + // Details to determine how long the discount should be applied for. + DiscountEnd *QuoteLineActionAddItemDiscountDiscountEndParams `form:"discount_end"` +} + +// Options that configure the trial on the subscription item. +type QuoteLineActionAddItemTrialParams struct { + // List of price IDs which, if present on the subscription following a paid trial, constitute opting-in to the paid trial. + ConvertsTo []*string `form:"converts_to"` + // Determines the type of trial for this item. + Type *string `form:"type"` +} + +// Details for the `add_item` type. +type QuoteLineActionAddItemParams struct { + // The discounts applied to the item. Subscription item discounts are applied before subscription discounts. + Discounts []*QuoteLineActionAddItemDiscountParams `form:"discounts"` + // Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. + Metadata map[string]string `form:"metadata"` + // The ID of the price object. + Price *string `form:"price"` + // Quantity for this item. + Quantity *int64 `form:"quantity"` + // The tax rates that apply to this subscription item. When set, the `default_tax_rates` on the subscription do not apply to this `subscription_item`. + TaxRates []*string `form:"tax_rates"` + // Options that configure the trial on the subscription item. + Trial *QuoteLineActionAddItemTrialParams `form:"trial"` +} + +// Details for the `remove_discount` type. +type QuoteLineActionRemoveDiscountParams struct { + // The coupon code to remove from the `discounts` array. + Coupon *string `form:"coupon"` + // The ID of a discount to remove from the `discounts` array. + Discount *string `form:"discount"` +} + +// Details for the `remove_item` type. +type QuoteLineActionRemoveItemParams struct { + // ID of a price to remove. + Price *string `form:"price"` +} + +// Details for the `set_discounts` type. +type QuoteLineActionSetDiscountParams struct { + // The coupon code to replace the `discounts` array with. + Coupon *string `form:"coupon"` + // An ID of an existing discount to replace the `discounts` array with. + Discount *string `form:"discount"` +} + +// Time span for the redeemed discount. +type QuoteLineActionSetItemDiscountDiscountEndDurationParams struct { + // Specifies a type of interval unit. Either `day`, `week`, `month` or `year`. + Interval *string `form:"interval"` + // The number of intervals, as an whole number greater than 0. Stripe multiplies this by the interval type to get the overall duration. + IntervalCount *int64 `form:"interval_count"` +} + +// Details to determine how long the discount should be applied for. +type QuoteLineActionSetItemDiscountDiscountEndParams struct { + // Time span for the redeemed discount. + Duration *QuoteLineActionSetItemDiscountDiscountEndDurationParams `form:"duration"` + // A precise Unix timestamp for the discount to end. Must be in the future. + Timestamp *int64 `form:"timestamp"` + // The type of calculation made to determine when the discount ends. + Type *string `form:"type"` +} + +// If an item with the `price` already exists, passing this will override the `discounts` array on the subscription item that matches that price. Otherwise, the `items` array is cleared and a single new item is added with the supplied `discounts`. +type QuoteLineActionSetItemDiscountParams struct { + // ID of the coupon to create a new discount for. + Coupon *string `form:"coupon"` + // ID of an existing discount on the object (or one of its ancestors) to reuse. + Discount *string `form:"discount"` + // Details to determine how long the discount should be applied for. + DiscountEnd *QuoteLineActionSetItemDiscountDiscountEndParams `form:"discount_end"` +} + +// If an item with the `price` already exists, passing this will override the `trial` configuration on the subscription item that matches that price. Otherwise, the `items` array is cleared and a single new item is added with the supplied `trial`. +type QuoteLineActionSetItemTrialParams struct { + // List of price IDs which, if present on the subscription following a paid trial, constitute opting-in to the paid trial. + ConvertsTo []*string `form:"converts_to"` + // Determines the type of trial for this item. + Type *string `form:"type"` +} + +// Details for the `set_items` type. +type QuoteLineActionSetItemParams struct { + // If an item with the `price` already exists, passing this will override the `discounts` array on the subscription item that matches that price. Otherwise, the `items` array is cleared and a single new item is added with the supplied `discounts`. + Discounts []*QuoteLineActionSetItemDiscountParams `form:"discounts"` + // If an item with the `price` already exists, passing this will override the `metadata` on the subscription item that matches that price. Otherwise, the `items` array is cleared and a single new item is added with the supplied `metadata`. + Metadata map[string]string `form:"metadata"` + // The ID of the price object. + Price *string `form:"price"` + // If an item with the `price` already exists, passing this will override the quantity on the subscription item that matches that price. Otherwise, the `items` array is cleared and a single new item is added with the supplied `quantity`. + Quantity *int64 `form:"quantity"` + // If an item with the `price` already exists, passing this will override the `tax_rates` array on the subscription item that matches that price. Otherwise, the `items` array is cleared and a single new item is added with the supplied `tax_rates`. + TaxRates []*string `form:"tax_rates"` + // If an item with the `price` already exists, passing this will override the `trial` configuration on the subscription item that matches that price. Otherwise, the `items` array is cleared and a single new item is added with the supplied `trial`. + Trial *QuoteLineActionSetItemTrialParams `form:"trial"` +} + +// An array of operations the quote line performs. +type QuoteLineActionParams struct { + // Details for the `add_discount` type. + AddDiscount *QuoteLineActionAddDiscountParams `form:"add_discount"` + // Details for the `add_item` type. + AddItem *QuoteLineActionAddItemParams `form:"add_item"` + // Details for the `add_metadata` type: specify a hash of key-value pairs. + AddMetadata map[string]string `form:"add_metadata"` + // Details for the `remove_discount` type. + RemoveDiscount *QuoteLineActionRemoveDiscountParams `form:"remove_discount"` + // Details for the `remove_item` type. + RemoveItem *QuoteLineActionRemoveItemParams `form:"remove_item"` + // Details for the `remove_metadata` type: specify an array of metadata keys. + RemoveMetadata []*string `form:"remove_metadata"` + // Details for the `set_discounts` type. + SetDiscounts []*QuoteLineActionSetDiscountParams `form:"set_discounts"` + // Details for the `set_items` type. + SetItems []*QuoteLineActionSetItemParams `form:"set_items"` + // Details for the `set_metadata` type: specify an array of key-value pairs. + SetMetadata map[string]string `form:"set_metadata"` + // The type of action the quote line performs. + Type *string `form:"type"` +} + +// Details to identify the subscription schedule the quote line applies to. +type QuoteLineAppliesToParams struct { + // A custom string that identifies a new subscription schedule being created upon quote acceptance. All quote lines with the same `new_reference` field will be applied to the creation of a new subscription schedule. + NewReference *string `form:"new_reference"` + // The ID of the schedule the line applies to. + SubscriptionSchedule *string `form:"subscription_schedule"` + // Describes whether the quote line is affecting a new schedule or an existing schedule. + Type *string `form:"type"` +} + +// Use the `end` time of a given discount. +type QuoteLineEndsAtDiscountEndParams struct { + // The ID of a specific discount. + Discount *string `form:"discount"` +} + +// Time span for the quote line starting from the `starts_at` date. +type QuoteLineEndsAtDurationParams struct { + // Specifies a type of interval unit. Either `day`, `week`, `month` or `year`. + Interval *string `form:"interval"` + // The number of intervals, as an whole number greater than 0. Stripe multiplies this by the interval type to get the overall duration. + IntervalCount *int64 `form:"interval_count"` +} + +// Details to identify the end of the time range modified by the proposed change. If not supplied, the quote line is considered a point-in-time operation that only affects the exact timestamp at `starts_at`, and a restricted set of attributes is supported on the quote line. +type QuoteLineEndsAtParams struct { + // Use the `end` time of a given discount. + DiscountEnd *QuoteLineEndsAtDiscountEndParams `form:"discount_end"` + // Time span for the quote line starting from the `starts_at` date. + Duration *QuoteLineEndsAtDurationParams `form:"duration"` + // A precise Unix timestamp. + Timestamp *int64 `form:"timestamp"` + // Select a way to pass in `ends_at`. + Type *string `form:"type"` +} + +// Use the `end` time of a given discount. +type QuoteLineStartsAtDiscountEndParams struct { + // The ID of a specific discount. + Discount *string `form:"discount"` +} + +// The timestamp the given line ends at. +type QuoteLineStartsAtLineEndsAtParams struct { + // The ID of a quote line. + ID *string `form:"id"` + // The position of the previous quote line in the `lines` array after which this line should begin. Indexes start from 0 and must be less than the index of the current line in the array. + Index *int64 `form:"index"` +} + +// Details to identify the earliest timestamp where the proposed change should take effect. +type QuoteLineStartsAtParams struct { + // Use the `end` time of a given discount. + DiscountEnd *QuoteLineStartsAtDiscountEndParams `form:"discount_end"` + // The timestamp the given line ends at. + LineEndsAt *QuoteLineStartsAtLineEndsAtParams `form:"line_ends_at"` + // A precise Unix timestamp. + Timestamp *int64 `form:"timestamp"` + // Select a way to pass in `starts_at`. + Type *string `form:"type"` +} + +// Defines how the subscription should behave when a trial ends. +type QuoteLineTrialSettingsEndBehaviorParams struct { + // Configure how an opt-in following a paid trial is billed when using `billing_behavior: prorate_up_front`. + ProrateUpFront *string `form:"prorate_up_front"` +} + +// Settings related to subscription trials. +type QuoteLineTrialSettingsParams struct { + // Defines how the subscription should behave when a trial ends. + EndBehavior *QuoteLineTrialSettingsEndBehaviorParams `form:"end_behavior"` +} + +// A list of lines on the quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted. +type QuoteLineParams struct { + // An array of operations the quote line performs. + Actions []*QuoteLineActionParams `form:"actions"` + // Details to identify the subscription schedule the quote line applies to. + AppliesTo *QuoteLineAppliesToParams `form:"applies_to"` + // For a point-in-time operation, this attribute lets you set or update whether the subscription's billing cycle anchor is reset at the `starts_at` timestamp. + BillingCycleAnchor *string `form:"billing_cycle_anchor"` + // Details to identify the end of the time range modified by the proposed change. If not supplied, the quote line is considered a point-in-time operation that only affects the exact timestamp at `starts_at`, and a restricted set of attributes is supported on the quote line. + EndsAt *QuoteLineEndsAtParams `form:"ends_at"` + // The ID of an existing line on the quote. + ID *string `form:"id"` + // Changes to how Stripe handles prorations during the quote line's time span. Affects if and how prorations are created when a future phase starts. + ProrationBehavior *string `form:"proration_behavior"` + // Details to identify the earliest timestamp where the proposed change should take effect. + StartsAt *QuoteLineStartsAtParams `form:"starts_at"` + // Settings related to subscription trials. + TrialSettings *QuoteLineTrialSettingsParams `form:"trial_settings"` +} + // Time span for the redeemed discount. type QuotePhaseDiscountDiscountEndDurationParams struct { // Specifies a type of interval unit. Either `day`, `week`, `month` or `year`. @@ -339,6 +744,62 @@ type QuotePhaseLineItemParams struct { TaxRates []*string `form:"tax_rates"` } +// Details of a Quote line to start the bill period from. +type QuoteSubscriptionDataBillOnAcceptanceBillFromLineStartsAtParams struct { + // The ID of a quote line. + ID *string `form:"id"` + // The position of the previous quote line in the `lines` array after which this line should begin. Indexes start from 0 and must be less than the index of the current line in the array. + Index *int64 `form:"index"` +} + +// Details for a Unix timestamp to start the bill period from. +type QuoteSubscriptionDataBillOnAcceptanceBillFromTimestampParams struct { + // A precise Unix timestamp. + Timestamp *int64 `form:"timestamp"` +} + +// The start of the period to bill from when the Quote is accepted. +type QuoteSubscriptionDataBillOnAcceptanceBillFromParams struct { + // Details of a Quote line to start the bill period from. + LineStartsAt *QuoteSubscriptionDataBillOnAcceptanceBillFromLineStartsAtParams `form:"line_starts_at"` + // Details for a Unix timestamp to start the bill period from. + Timestamp *QuoteSubscriptionDataBillOnAcceptanceBillFromTimestampParams `form:"timestamp"` + // The type of method to specify the `bill_from` time. + Type *string `form:"type"` +} + +// Details of a Quote line item from which to bill until. +type QuoteSubscriptionDataBillOnAcceptanceBillUntilLineStartsAtParams struct { + // The ID of a quote line. + ID *string `form:"id"` + // The position of the previous quote line in the `lines` array after which this line should begin. Indexes start from 0 and must be less than the index of the current line in the array. + Index *int64 `form:"index"` +} + +// Details of a Unix timestamp to bill until. +type QuoteSubscriptionDataBillOnAcceptanceBillUntilTimestampParams struct { + // A precise Unix timestamp. + Timestamp *int64 `form:"timestamp"` +} + +// The end of the period to bill until when the Quote is accepted. +type QuoteSubscriptionDataBillOnAcceptanceBillUntilParams struct { + // Details of a Quote line item from which to bill until. + LineStartsAt *QuoteSubscriptionDataBillOnAcceptanceBillUntilLineStartsAtParams `form:"line_starts_at"` + // Details of a Unix timestamp to bill until. + Timestamp *QuoteSubscriptionDataBillOnAcceptanceBillUntilTimestampParams `form:"timestamp"` + // The type of method to specify the `bill_until` time. + Type *string `form:"type"` +} + +// The start of the period to bill from when the Quote is accepted. +type QuoteSubscriptionDataBillOnAcceptanceParams struct { + // The start of the period to bill from when the Quote is accepted. + BillFrom *QuoteSubscriptionDataBillOnAcceptanceBillFromParams `form:"bill_from"` + // The end of the period to bill until when the Quote is accepted. + BillUntil *QuoteSubscriptionDataBillOnAcceptanceBillUntilParams `form:"bill_until"` +} + // If specified, the invoicing for the given billing cycle iterations will be processed when the quote is accepted. Cannot be used with `effective_date`. type QuoteSubscriptionDataPrebillingParams struct { // This is used to determine the number of billing cycles to prebill. @@ -351,6 +812,8 @@ type QuoteSubscriptionDataParams struct { BillingBehavior *string `form:"billing_behavior"` // When specified as `reset`, the subscription will always start a new billing period when the quote is accepted. BillingCycleAnchor *string `form:"billing_cycle_anchor"` + // The start of the period to bill from when the Quote is accepted. + BillOnAcceptance *QuoteSubscriptionDataBillOnAcceptanceParams `form:"bill_on_acceptance"` // The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription. Description *string `form:"description"` // When creating a new subscription, the date of which the subscription schedule will start after the quote is accepted. When updating a subscription, the date of which the subscription will be updated using a subscription schedule. The special value `current_period_end` can be provided to update a subscription at the end of its current period. The `effective_date` is ignored if it is in the past when the quote is accepted. @@ -383,6 +846,96 @@ func (q *QuoteSubscriptionDataParams) AppendTo(body *form.Values, keyParts []str } } +// Whether the override applies to an existing Subscription Schedule or a new Subscription Schedule. +type QuoteSubscriptionDataOverrideAppliesToParams struct { + // A custom string that identifies a new subscription schedule being created upon quote acceptance. All quote lines with the same `new_reference` field will be applied to the creation of a new subscription schedule. + NewReference *string `form:"new_reference"` + // The ID of the schedule the line applies to. + SubscriptionSchedule *string `form:"subscription_schedule"` + // Describes whether the quote line is affecting a new schedule or an existing schedule. + Type *string `form:"type"` +} + +// Details of a Quote line to start the bill period from. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromLineStartsAtParams struct { + // The ID of a quote line. + ID *string `form:"id"` + // The position of the previous quote line in the `lines` array after which this line should begin. Indexes start from 0 and must be less than the index of the current line in the array. + Index *int64 `form:"index"` +} + +// Details for a Unix timestamp to start the bill period from. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromTimestampParams struct { + // A precise Unix timestamp. + Timestamp *int64 `form:"timestamp"` +} + +// The start of the period to bill from when the Quote is accepted. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromParams struct { + // Details of a Quote line to start the bill period from. + LineStartsAt *QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromLineStartsAtParams `form:"line_starts_at"` + // Details for a Unix timestamp to start the bill period from. + Timestamp *QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromTimestampParams `form:"timestamp"` + // The type of method to specify the `bill_from` time. + Type *string `form:"type"` +} + +// Details of a Quote line item from which to bill until. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilLineStartsAtParams struct { + // The ID of a quote line. + ID *string `form:"id"` + // The position of the previous quote line in the `lines` array after which this line should begin. Indexes start from 0 and must be less than the index of the current line in the array. + Index *int64 `form:"index"` +} + +// Details of a Unix timestamp to bill until. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilTimestampParams struct { + // A precise Unix timestamp. + Timestamp *int64 `form:"timestamp"` +} + +// The end of the period to bill until when the Quote is accepted. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilParams struct { + // Details of a Quote line item from which to bill until. + LineStartsAt *QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilLineStartsAtParams `form:"line_starts_at"` + // Details of a Unix timestamp to bill until. + Timestamp *QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilTimestampParams `form:"timestamp"` + // The type of method to specify the `bill_until` time. + Type *string `form:"type"` +} + +// The start of the period to bill from when the Quote is accepted. +type QuoteSubscriptionDataOverrideBillOnAcceptanceParams struct { + // The start of the period to bill from when the Quote is accepted. + BillFrom *QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromParams `form:"bill_from"` + // The end of the period to bill until when the Quote is accepted. + BillUntil *QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilParams `form:"bill_until"` +} + +// List representing overrides for `subscription_data` configurations for specific groups. +type QuoteSubscriptionDataOverrideParams struct { + // Whether the override applies to an existing Subscription Schedule or a new Subscription Schedule. + AppliesTo *QuoteSubscriptionDataOverrideAppliesToParams `form:"applies_to"` + // Configures when the subscription schedule generates prorations for phase transitions. Possible values are `prorate_on_next_phase` or `prorate_up_front` with the default being `prorate_on_next_phase`. `prorate_on_next_phase` will apply phase changes and generate prorations at transition time.`prorate_up_front` will bill for all phases within the current billing cycle up front. + BillingBehavior *string `form:"billing_behavior"` + // The start of the period to bill from when the Quote is accepted. + BillOnAcceptance *QuoteSubscriptionDataOverrideBillOnAcceptanceParams `form:"bill_on_acceptance"` + // The customer the Subscription Data override applies to. This is only relevant when `applies_to.type=new_reference`. + Customer *string `form:"customer"` + // The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription. + Description *string `form:"description"` + // Configures how the subscription schedule behaves when it ends. Possible values are `release` or `cancel` with the default being `release`. `release` will end the subscription schedule and keep the underlying subscription running.`cancel` will end the subscription schedule and cancel the underlying subscription. + EndBehavior *string `form:"end_behavior"` + // Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations). When creating a subscription, valid values are `create_prorations` or `none`. + // + // When updating a subscription, valid values are `create_prorations`, `none`, or `always_invoice`. + // + // Passing `create_prorations` will cause proration invoice items to be created when applicable. These proration items will only be invoiced immediately under [certain conditions](https://stripe.com/docs/subscriptions/upgrading-downgrading#immediate-payment). In order to always invoice immediately for prorations, pass `always_invoice`. + // + // Prorations can be disabled by passing `none`. + ProrationBehavior *string `form:"proration_behavior"` +} + // The data with which to automatically create a Transfer for each of the invoices. type QuoteTransferDataParams struct { // The amount that will be transferred automatically when the invoice is paid. If no amount is set, the full amount is transferred. There cannot be any line items with recurring prices when using this field. @@ -431,6 +984,16 @@ type QuoteAcceptParams struct { Params `form:"*"` } +// Recompute the upcoming invoice estimate for the quote. +type QuoteReestimateParams struct { + Params `form:"*"` +} + +// Converts a stale quote to draft. +type QuoteDraftQuoteParams struct { + Params `form:"*"` +} + // 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. type QuoteListLineItemsParams struct { ListParams `form:"*"` @@ -443,6 +1006,42 @@ type QuoteListComputedUpfrontLineItemsParams struct { Quote *string `form:"-"` // Included in URL } +// Preview the invoices that would be generated by accepting the quote. +type QuotePreviewInvoicesParams struct { + ListParams `form:"*"` + Quote *string `form:"-"` // Included in URL +} + +// Details to identify the subscription schedule the quote line applies to. +type QuotePreviewInvoiceLinesAppliesToParams struct { + // A custom string that identifies a new subscription schedule being created upon quote acceptance. All quote lines with the same `new_reference` field will be applied to the creation of a new subscription schedule. + NewReference *string `form:"new_reference"` + // The ID of the schedule the line applies to. + SubscriptionSchedule *string `form:"subscription_schedule"` + // Describes whether the quote line is affecting a new schedule or an existing schedule. + Type *string `form:"type"` +} + +// Preview the invoice line items that would be generated by accepting the quote. +type QuotePreviewInvoiceLinesParams struct { + ListParams `form:"*"` + Quote *string `form:"-"` // Included in URL + // Details to identify the subscription schedule the quote line applies to. + AppliesTo *QuotePreviewInvoiceLinesAppliesToParams `form:"applies_to"` +} + +// Preview the schedules that would be generated by accepting the quote +type QuotePreviewSubscriptionSchedulesParams struct { + ListParams `form:"*"` + Quote *string `form:"-"` // Included in URL +} + +// When retrieving a quote, there is an includable lines property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of lines. +type QuoteListLinesParams struct { + ListParams `form:"*"` + Quote *string `form:"-"` // Included in URL +} + // Download the PDF for a finalized quote type QuotePDFParams struct { Params `form:"*"` @@ -550,7 +1149,9 @@ type QuoteComputedUpfront struct { type QuoteComputed struct { // The definitive totals and line items the customer will be charged on a recurring basis. Takes into account the line items with recurring prices and discounts with `duration=forever` coupons only. Defaults to `null` if no inputted line items with recurring prices. Recurring *QuoteComputedRecurring `json:"recurring"` - Upfront *QuoteComputedUpfront `json:"upfront"` + // The time at which the quote's estimated schedules and upcoming invoices were generated. + UpdatedAt int64 `json:"updated_at"` + Upfront *QuoteComputedUpfront `json:"upfront"` } // Details of the quote that was cloned. See the [cloning documentation](https://stripe.com/docs/quotes/clone) for more details. @@ -566,6 +1167,58 @@ type QuoteInvoiceSettings struct { // Number of days within which a customer must pay invoices generated by this quote. This value will be `null` for quotes where `collection_method=charge_automatically`. DaysUntilDue int64 `json:"days_until_due"` } + +// Details on when and why a quote has been marked as canceled. +type QuoteStatusDetailsCanceled struct { + // The reason this quote was marked as canceled. + Reason QuoteStatusDetailsCanceledReason `json:"reason"` + // Time at which the quote was marked as canceled. Measured in seconds since the Unix epoch. + TransitionedAt int64 `json:"transitioned_at"` +} + +// The state of the subscription before the quote was marked as stale. +type QuoteStatusDetailsStaleLastReasonSubscriptionChanged struct { + // The subscription's state before the quote was marked as stale. + PreviousSubscription *Subscription `json:"previous_subscription"` +} + +// The state of the subscription schedule before the quote was marked as stale. +type QuoteStatusDetailsStaleLastReasonSubscriptionScheduleChanged struct { + // The subscription schedule's state before the quote was marked as stale. + PreviousSubscriptionSchedule *SubscriptionSchedule `json:"previous_subscription_schedule"` +} + +// The most recent reason this quote was marked as stale. +type QuoteStatusDetailsStaleLastReason struct { + // The ID of the line that is invalid if the stale reason type is `line_invalid`. + LineInvalid string `json:"line_invalid"` + // The state of the subscription before the quote was marked as stale. + SubscriptionChanged *QuoteStatusDetailsStaleLastReasonSubscriptionChanged `json:"subscription_changed"` + // The state of the subscription schedule before the quote was marked as stale. + SubscriptionScheduleChanged *QuoteStatusDetailsStaleLastReasonSubscriptionScheduleChanged `json:"subscription_schedule_changed"` + // The reason the quote was marked as stale. + Type QuoteStatusDetailsStaleLastReasonType `json:"type"` +} + +// Details on when and why a quote has been marked as stale. +type QuoteStatusDetailsStale struct { + // Time at which the quote expires. Measured in seconds since the Unix epoch. + ExpiresAt int64 `json:"expires_at"` + // The most recent reason this quote was marked as stale. + LastReason *QuoteStatusDetailsStaleLastReason `json:"last_reason"` + // Time at which the stale reason was updated. Measured in seconds since the Unix epoch. + LastUpdatedAt int64 `json:"last_updated_at"` + // Time at which the quote was marked as stale. Measured in seconds since the Unix epoch. + TransitionedAt int64 `json:"transitioned_at"` +} + +// Details on when and why a quote has been marked as stale or canceled. +type QuoteStatusDetails struct { + // Details on when and why a quote has been marked as canceled. + Canceled *QuoteStatusDetailsCanceled `json:"canceled"` + // Details on when and why a quote has been marked as stale. + Stale *QuoteStatusDetailsStale `json:"stale"` +} type QuoteStatusTransitions struct { // The time that the quote was accepted. Measured in seconds since Unix epoch. AcceptedAt int64 `json:"accepted_at"` @@ -575,6 +1228,60 @@ type QuoteStatusTransitions struct { FinalizedAt int64 `json:"finalized_at"` } +// The timestamp the given line starts at. +type QuoteSubscriptionDataBillOnAcceptanceBillFromLineStartsAt struct { + // Unique identifier for the object. + ID string `json:"id"` +} + +// The start of the period to bill from when the Quote is accepted. +type QuoteSubscriptionDataBillOnAcceptanceBillFrom struct { + // The materialized time. + Computed int64 `json:"computed"` + // The timestamp the given line starts at. + LineStartsAt *QuoteSubscriptionDataBillOnAcceptanceBillFromLineStartsAt `json:"line_starts_at"` + // A precise Unix timestamp. + Timestamp int64 `json:"timestamp"` + // The type of method to specify the `bill_from` time. + Type QuoteSubscriptionDataBillOnAcceptanceBillFromType `json:"type"` +} + +// Time span for the quote line starting from the `starts_at` date. +type QuoteSubscriptionDataBillOnAcceptanceBillUntilDuration struct { + // Specifies a type of interval unit. Either `day`, `week`, `month` or `year`. + Interval QuoteSubscriptionDataBillOnAcceptanceBillUntilDurationInterval `json:"interval"` + // The number of intervals, as an whole number greater than 0. Stripe multiplies this by the interval type to get the overall duration. + IntervalCount int64 `json:"interval_count"` +} + +// The timestamp the given line ends at. +type QuoteSubscriptionDataBillOnAcceptanceBillUntilLineEndsAt struct { + // Unique identifier for the object. + ID string `json:"id"` +} + +// The end of the period to bill until when the Quote is accepted. +type QuoteSubscriptionDataBillOnAcceptanceBillUntil struct { + // The materialized time. + Computed int64 `json:"computed"` + // Time span for the quote line starting from the `starts_at` date. + Duration *QuoteSubscriptionDataBillOnAcceptanceBillUntilDuration `json:"duration"` + // The timestamp the given line ends at. + LineEndsAt *QuoteSubscriptionDataBillOnAcceptanceBillUntilLineEndsAt `json:"line_ends_at"` + // A precise Unix timestamp. + Timestamp int64 `json:"timestamp"` + // The type of method to specify the `bill_until` time. + Type QuoteSubscriptionDataBillOnAcceptanceBillUntilType `json:"type"` +} + +// TODO +type QuoteSubscriptionDataBillOnAcceptance struct { + // The start of the period to bill from when the Quote is accepted. + BillFrom *QuoteSubscriptionDataBillOnAcceptanceBillFrom `json:"bill_from"` + // The end of the period to bill until when the Quote is accepted. + BillUntil *QuoteSubscriptionDataBillOnAcceptanceBillUntil `json:"bill_until"` +} + // If specified, the invoicing for the given billing cycle iterations will be processed when the quote is accepted. Cannot be used with `effective_date`. type QuoteSubscriptionDataPrebilling struct { Iterations int64 `json:"iterations"` @@ -584,6 +1291,8 @@ type QuoteSubscriptionData struct { BillingBehavior QuoteSubscriptionDataBillingBehavior `json:"billing_behavior"` // Whether the subscription will always start a new billing period when the quote is accepted. BillingCycleAnchor QuoteSubscriptionDataBillingCycleAnchor `json:"billing_cycle_anchor"` + // TODO + BillOnAcceptance *QuoteSubscriptionDataBillOnAcceptance `json:"bill_on_acceptance"` // The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription. Description string `json:"description"` // When creating a new subscription, the date of which the subscription schedule will start after the quote is accepted. This date is ignored if it is in the past when the quote is accepted. Measured in seconds since the Unix epoch. @@ -601,6 +1310,98 @@ type QuoteSubscriptionData struct { // Integer representing the number of trial period days before the customer is charged for the first time. TrialPeriodDays int64 `json:"trial_period_days"` } +type QuoteSubscriptionDataOverrideAppliesTo struct { + // A custom string that identifies a new subscription schedule being created upon quote acceptance. All quote lines with the same `new_reference` field will be applied to the creation of a new subscription schedule. + NewReference string `json:"new_reference"` + // The ID of the schedule the line applies to. + SubscriptionSchedule string `json:"subscription_schedule"` + // Describes whether the quote line is affecting a new schedule or an existing schedule. + Type QuoteSubscriptionDataOverrideAppliesToType `json:"type"` +} + +// The timestamp the given line starts at. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromLineStartsAt struct { + // Unique identifier for the object. + ID string `json:"id"` +} + +// The start of the period to bill from when the Quote is accepted. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillFrom struct { + // The materialized time. + Computed int64 `json:"computed"` + // The timestamp the given line starts at. + LineStartsAt *QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromLineStartsAt `json:"line_starts_at"` + // A precise Unix timestamp. + Timestamp int64 `json:"timestamp"` + // The type of method to specify the `bill_from` time. + Type QuoteSubscriptionDataOverrideBillOnAcceptanceBillFromType `json:"type"` +} + +// Time span for the quote line starting from the `starts_at` date. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDuration struct { + // Specifies a type of interval unit. Either `day`, `week`, `month` or `year`. + Interval QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDurationInterval `json:"interval"` + // The number of intervals, as an whole number greater than 0. Stripe multiplies this by the interval type to get the overall duration. + IntervalCount int64 `json:"interval_count"` +} + +// The timestamp the given line ends at. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilLineEndsAt struct { + // Unique identifier for the object. + ID string `json:"id"` +} + +// The end of the period to bill until when the Quote is accepted. +type QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntil struct { + // The materialized time. + Computed int64 `json:"computed"` + // Time span for the quote line starting from the `starts_at` date. + Duration *QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilDuration `json:"duration"` + // The timestamp the given line ends at. + LineEndsAt *QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilLineEndsAt `json:"line_ends_at"` + // A precise Unix timestamp. + Timestamp int64 `json:"timestamp"` + // The type of method to specify the `bill_until` time. + Type QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntilType `json:"type"` +} + +// The start of the period to bill from when the Quote is accepted. +type QuoteSubscriptionDataOverrideBillOnAcceptance struct { + // The start of the period to bill from when the Quote is accepted. + BillFrom *QuoteSubscriptionDataOverrideBillOnAcceptanceBillFrom `json:"bill_from"` + // The end of the period to bill until when the Quote is accepted. + BillUntil *QuoteSubscriptionDataOverrideBillOnAcceptanceBillUntil `json:"bill_until"` +} +type QuoteSubscriptionDataOverride struct { + AppliesTo *QuoteSubscriptionDataOverrideAppliesTo `json:"applies_to"` + // Configures when the subscription schedule generates prorations for phase transitions. Possible values are `prorate_on_next_phase` or `prorate_up_front` with the default being `prorate_on_next_phase`. `prorate_on_next_phase` will apply phase changes and generate prorations at transition time.`prorate_up_front` will bill for all phases within the current billing cycle up front. + BillingBehavior QuoteSubscriptionDataOverrideBillingBehavior `json:"billing_behavior"` + // The start of the period to bill from when the Quote is accepted. + BillOnAcceptance *QuoteSubscriptionDataOverrideBillOnAcceptance `json:"bill_on_acceptance"` + // The customer which this quote belongs to. A customer is required before finalizing the quote. Once specified, it cannot be changed. + Customer string `json:"customer"` + // The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription. + Description string `json:"description"` + // Behavior of the subscription schedule and underlying subscription when it ends. Possible values are `release` and `cancel`. + EndBehavior QuoteSubscriptionDataOverrideEndBehavior `json:"end_behavior"` + // Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the quote is accepted. + ProrationBehavior QuoteSubscriptionDataOverrideProrationBehavior `json:"proration_behavior"` +} +type QuoteSubscriptionScheduleAppliesTo struct { + // A custom string that identifies a new subscription schedule being created upon quote acceptance. All quote lines with the same `new_reference` field will be applied to the creation of a new subscription schedule. + NewReference string `json:"new_reference"` + // The ID of the schedule the line applies to. + SubscriptionSchedule string `json:"subscription_schedule"` + // Describes whether the quote line is affecting a new schedule or an existing schedule. + Type QuoteSubscriptionScheduleAppliesToType `json:"type"` +} + +// The subscription schedule that was created or updated from this quote. +type QuoteSubscriptionSchedule struct { + AppliesTo *QuoteSubscriptionScheduleAppliesTo `json:"applies_to"` + // The subscription schedule that was created or updated from this quote. + SubscriptionSchedule string `json:"subscription_schedule"` +} // The aggregated discounts. type QuoteTotalDetailsBreakdownDiscount struct { @@ -694,6 +1495,8 @@ type Quote struct { InvoiceSettings *QuoteInvoiceSettings `json:"invoice_settings"` // A list of items the customer is being quoted for. LineItems *LineItemList `json:"line_items"` + // A list of lines on the quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted. + Lines []string `json:"lines"` // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. Livemode bool `json:"livemode"` // Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. @@ -705,13 +1508,18 @@ type Quote struct { // The account on behalf of which to charge. See the [Connect documentation](https://support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts) for details. OnBehalfOf *Account `json:"on_behalf_of"` // The status of the quote. - Status QuoteStatus `json:"status"` + Status QuoteStatus `json:"status"` + // Details on when and why a quote has been marked as stale or canceled. + StatusDetails *QuoteStatusDetails `json:"status_details"` StatusTransitions *QuoteStatusTransitions `json:"status_transitions"` // The subscription that was created or updated from this quote. - Subscription *Subscription `json:"subscription"` - SubscriptionData *QuoteSubscriptionData `json:"subscription_data"` + Subscription *Subscription `json:"subscription"` + SubscriptionData *QuoteSubscriptionData `json:"subscription_data"` + SubscriptionDataOverrides []*QuoteSubscriptionDataOverride `json:"subscription_data_overrides"` // The subscription schedule that was created or updated from this quote. SubscriptionSchedule *SubscriptionSchedule `json:"subscription_schedule"` + // The subscription schedules that were created or updated from this quote. + SubscriptionSchedules []*QuoteSubscriptionSchedule `json:"subscription_schedules"` // ID of the test clock this quote belongs to. TestClock *TestHelpersTestClock `json:"test_clock"` TotalDetails *QuoteTotalDetails `json:"total_details"` diff --git a/quote/client.go b/quote/client.go index 3703e2075d..af9401385f 100644 --- a/quote/client.go +++ b/quote/client.go @@ -85,6 +85,19 @@ func (c Client) Cancel(id string, params *stripe.QuoteCancelParams) (*stripe.Quo return quote, err } +// DraftQuote is the method for the `POST /v1/quotes/{quote}/draft` API. +func DraftQuote(id string, params *stripe.QuoteDraftQuoteParams) (*stripe.Quote, error) { + return getC().DraftQuote(id, params) +} + +// DraftQuote is the method for the `POST /v1/quotes/{quote}/draft` API. +func (c Client) DraftQuote(id string, params *stripe.QuoteDraftQuoteParams) (*stripe.Quote, error) { + path := stripe.FormatURLPath("/v1/quotes/%s/draft", id) + quote := &stripe.Quote{} + err := c.B.Call(http.MethodPost, path, c.Key, params, quote) + return quote, err +} + // FinalizeQuote is the method for the `POST /v1/quotes/{quote}/finalize` API. func FinalizeQuote(id string, params *stripe.QuoteFinalizeQuoteParams) (*stripe.Quote, error) { return getC().FinalizeQuote(id, params) @@ -111,6 +124,19 @@ func (c Client) PDF(id string, params *stripe.QuotePDFParams) (*stripe.APIStream return stream, err } +// Reestimate is the method for the `POST /v1/quotes/{quote}/reestimate` API. +func Reestimate(id string, params *stripe.QuoteReestimateParams) (*stripe.Quote, error) { + return getC().Reestimate(id, params) +} + +// Reestimate is the method for the `POST /v1/quotes/{quote}/reestimate` API. +func (c Client) Reestimate(id string, params *stripe.QuoteReestimateParams) (*stripe.Quote, error) { + path := stripe.FormatURLPath("/v1/quotes/%s/reestimate", id) + quote := &stripe.Quote{} + err := c.B.Call(http.MethodPost, path, c.Key, params, quote) + return quote, err +} + // List returns a list of quotes. func List(params *stripe.QuoteListParams) *Iter { return getC().List(params) @@ -219,6 +245,178 @@ func (i *LineItemIter) LineItemList() *stripe.LineItemList { return i.List().(*stripe.LineItemList) } +// ListLines is the method for the `GET /v1/quotes/{quote}/lines` API. +func ListLines(params *stripe.QuoteListLinesParams) *LineIter { + return getC().ListLines(params) +} + +// ListLines is the method for the `GET /v1/quotes/{quote}/lines` API. +func (c Client) ListLines(listParams *stripe.QuoteListLinesParams) *LineIter { + path := stripe.FormatURLPath( + "/v1/quotes/%s/lines", + stripe.StringValue(listParams.Quote), + ) + return &LineIter{ + Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { + list := &stripe.QuoteLineList{} + err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list) + + ret := make([]interface{}, len(list.Data)) + for i, v := range list.Data { + ret[i] = v + } + + return ret, list, err + }), + } +} + +// LineIter is an iterator for quote lines. +type LineIter struct { + *stripe.Iter +} + +// QuoteLine returns the quote line which the iterator is currently pointing to. +func (i *LineIter) QuoteLine() *stripe.QuoteLine { + return i.Current().(*stripe.QuoteLine) +} + +// QuoteLineList returns the current list object which the iterator is +// currently using. List objects will change as new API calls are made to +// continue pagination. +func (i *LineIter) QuoteLineList() *stripe.QuoteLineList { + return i.List().(*stripe.QuoteLineList) +} + +// PreviewInvoiceLines is the method for the `GET /v1/quotes/{quote}/preview_invoice_lines` API. +func PreviewInvoiceLines(params *stripe.QuotePreviewInvoiceLinesParams) *InvoiceLineItemIter { + return getC().PreviewInvoiceLines(params) +} + +// PreviewInvoiceLines is the method for the `GET /v1/quotes/{quote}/preview_invoice_lines` API. +func (c Client) PreviewInvoiceLines(listParams *stripe.QuotePreviewInvoiceLinesParams) *InvoiceLineItemIter { + path := stripe.FormatURLPath( + "/v1/quotes/%s/preview_invoice_lines", + stripe.StringValue(listParams.Quote), + ) + return &InvoiceLineItemIter{ + Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { + list := &stripe.InvoiceLineItemList{} + err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list) + + ret := make([]interface{}, len(list.Data)) + for i, v := range list.Data { + ret[i] = v + } + + return ret, list, err + }), + } +} + +// InvoiceLineItemIter is an iterator for invoice line items. +type InvoiceLineItemIter struct { + *stripe.Iter +} + +// InvoiceLineItem returns the invoice line item which the iterator is currently pointing to. +func (i *InvoiceLineItemIter) InvoiceLineItem() *stripe.InvoiceLineItem { + return i.Current().(*stripe.InvoiceLineItem) +} + +// InvoiceLineItemList returns the current list object which the iterator is +// currently using. List objects will change as new API calls are made to +// continue pagination. +func (i *InvoiceLineItemIter) InvoiceLineItemList() *stripe.InvoiceLineItemList { + return i.List().(*stripe.InvoiceLineItemList) +} + +// PreviewInvoices is the method for the `GET /v1/quotes/{quote}/preview_invoices` API. +func PreviewInvoices(params *stripe.QuotePreviewInvoicesParams) *InvoiceIter { + return getC().PreviewInvoices(params) +} + +// PreviewInvoices is the method for the `GET /v1/quotes/{quote}/preview_invoices` API. +func (c Client) PreviewInvoices(listParams *stripe.QuotePreviewInvoicesParams) *InvoiceIter { + path := stripe.FormatURLPath( + "/v1/quotes/%s/preview_invoices", + stripe.StringValue(listParams.Quote), + ) + return &InvoiceIter{ + Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { + list := &stripe.InvoiceList{} + err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list) + + ret := make([]interface{}, len(list.Data)) + for i, v := range list.Data { + ret[i] = v + } + + return ret, list, err + }), + } +} + +// InvoiceIter is an iterator for invoices. +type InvoiceIter struct { + *stripe.Iter +} + +// Invoice returns the invoice which the iterator is currently pointing to. +func (i *InvoiceIter) Invoice() *stripe.Invoice { + return i.Current().(*stripe.Invoice) +} + +// InvoiceList returns the current list object which the iterator is +// currently using. List objects will change as new API calls are made to +// continue pagination. +func (i *InvoiceIter) InvoiceList() *stripe.InvoiceList { + return i.List().(*stripe.InvoiceList) +} + +// PreviewSubscriptionSchedules is the method for the `GET /v1/quotes/{quote}/preview_subscription_schedules` API. +func PreviewSubscriptionSchedules(params *stripe.QuotePreviewSubscriptionSchedulesParams) *SubscriptionScheduleIter { + return getC().PreviewSubscriptionSchedules(params) +} + +// PreviewSubscriptionSchedules is the method for the `GET /v1/quotes/{quote}/preview_subscription_schedules` API. +func (c Client) PreviewSubscriptionSchedules(listParams *stripe.QuotePreviewSubscriptionSchedulesParams) *SubscriptionScheduleIter { + path := stripe.FormatURLPath( + "/v1/quotes/%s/preview_subscription_schedules", + stripe.StringValue(listParams.Quote), + ) + return &SubscriptionScheduleIter{ + Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { + list := &stripe.SubscriptionScheduleList{} + err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list) + + ret := make([]interface{}, len(list.Data)) + for i, v := range list.Data { + ret[i] = v + } + + return ret, list, err + }), + } +} + +// SubscriptionScheduleIter is an iterator for subscription schedules. +type SubscriptionScheduleIter struct { + *stripe.Iter +} + +// SubscriptionSchedule returns the subscription schedule which the iterator is currently pointing to. +func (i *SubscriptionScheduleIter) SubscriptionSchedule() *stripe.SubscriptionSchedule { + return i.Current().(*stripe.SubscriptionSchedule) +} + +// SubscriptionScheduleList returns the current list object which the iterator is +// currently using. List objects will change as new API calls are made to +// continue pagination. +func (i *SubscriptionScheduleIter) SubscriptionScheduleList() *stripe.SubscriptionScheduleList { + return i.List().(*stripe.SubscriptionScheduleList) +} + func getC() Client { return Client{stripe.GetBackend(stripe.APIBackend), stripe.GetBackend(stripe.UploadsBackend), stripe.Key} } diff --git a/subscriptionschedule.go b/subscriptionschedule.go index b1c75fe17c..7c31892de2 100644 --- a/subscriptionschedule.go +++ b/subscriptionschedule.go @@ -11,6 +11,15 @@ import ( "github.com/stripe/stripe-go/v74/form" ) +// Describes whether the quote line is affecting a new schedule or an existing schedule. +type SubscriptionScheduleAppliesToType string + +// List of values that SubscriptionScheduleAppliesToType can take +const ( + SubscriptionScheduleAppliesToTypeNewReference SubscriptionScheduleAppliesToType = "new_reference" + SubscriptionScheduleAppliesToTypeSubscriptionSchedule SubscriptionScheduleAppliesToType = "subscription_schedule" +) + // Configures when the subscription schedule generates prorations for phase transitions. Possible values are `prorate_on_next_phase` or `prorate_up_front` with the default being `prorate_on_next_phase`. `prorate_on_next_phase` will apply phase changes and generate prorations at transition time.`prorate_up_front` will bill for all phases within the current billing cycle up front. type SubscriptionScheduleBillingBehavior string @@ -45,7 +54,6 @@ type SubscriptionSchedulePhaseAddInvoiceItemDiscountDiscountEndType string // List of values that SubscriptionSchedulePhaseAddInvoiceItemDiscountDiscountEndType can take const ( - SubscriptionSchedulePhaseAddInvoiceItemDiscountDiscountEndTypeDuration SubscriptionSchedulePhaseAddInvoiceItemDiscountDiscountEndType = "duration" SubscriptionSchedulePhaseAddInvoiceItemDiscountDiscountEndTypeTimestamp SubscriptionSchedulePhaseAddInvoiceItemDiscountDiscountEndType = "timestamp" ) @@ -63,7 +71,6 @@ type SubscriptionSchedulePhaseDiscountDiscountEndType string // List of values that SubscriptionSchedulePhaseDiscountDiscountEndType can take const ( - SubscriptionSchedulePhaseDiscountDiscountEndTypeDuration SubscriptionSchedulePhaseDiscountDiscountEndType = "duration" SubscriptionSchedulePhaseDiscountDiscountEndTypeTimestamp SubscriptionSchedulePhaseDiscountDiscountEndType = "timestamp" ) @@ -72,7 +79,6 @@ type SubscriptionSchedulePhaseItemDiscountDiscountEndType string // List of values that SubscriptionSchedulePhaseItemDiscountDiscountEndType can take const ( - SubscriptionSchedulePhaseItemDiscountDiscountEndTypeDuration SubscriptionSchedulePhaseItemDiscountDiscountEndType = "duration" SubscriptionSchedulePhaseItemDiscountDiscountEndTypeTimestamp SubscriptionSchedulePhaseItemDiscountDiscountEndType = "timestamp" ) @@ -735,6 +741,16 @@ type SubscriptionScheduleReleaseParams struct { PreserveCancelDate *bool `form:"preserve_cancel_date"` } +// Details to identify the subscription schedule the quote line applies to. +type SubscriptionScheduleAppliesTo struct { + // A custom string that identifies a new subscription schedule being created upon quote acceptance. All quote lines with the same `new_reference` field will be applied to the creation of a new subscription schedule. + NewReference string `json:"new_reference"` + // The ID of the schedule the line applies to. + SubscriptionSchedule string `json:"subscription_schedule"` + // Describes whether the quote line is affecting a new schedule or an existing schedule. + Type SubscriptionScheduleAppliesToType `json:"type"` +} + // Object representing the start and end dates for the current phase of the subscription schedule, if it is `active`. type SubscriptionScheduleCurrentPhase struct { // The end of this phase of the subscription schedule. @@ -786,6 +802,8 @@ type SubscriptionSchedulePhaseAddInvoiceItemDiscount struct { Discount *Discount `json:"discount"` // Details to determine how long the discount should be applied for. DiscountEnd *SubscriptionSchedulePhaseAddInvoiceItemDiscountDiscountEnd `json:"discount_end"` + // The index, starting at 0, at which to position the new discount. When not supplied, Stripe defaults to appending the discount to the end of the `discounts` array. + Index int64 `json:"index"` } // A list of prices and quantities that will generate invoice items appended to the next invoice for this phase. @@ -816,6 +834,8 @@ type SubscriptionSchedulePhaseDiscount struct { Discount *Discount `json:"discount"` // Details to determine how long the discount should be applied for. DiscountEnd *SubscriptionSchedulePhaseDiscountDiscountEnd `json:"discount_end"` + // The index, starting at 0, at which to position the new discount. When not supplied, Stripe defaults to appending the discount to the end of the `discounts` array. + Index int64 `json:"index"` } // The invoice settings applicable during this phase. @@ -840,6 +860,8 @@ type SubscriptionSchedulePhaseItemDiscount struct { Discount *Discount `json:"discount"` // Details to determine how long the discount should be applied for. DiscountEnd *SubscriptionSchedulePhaseItemDiscountDiscountEnd `json:"discount_end"` + // The index, starting at 0, at which to position the new discount. When not supplied, Stripe defaults to appending the discount to the end of the `discounts` array. + Index int64 `json:"index"` } // Options that configure the trial on the subscription item. @@ -947,6 +969,8 @@ type SubscriptionSchedule struct { APIResource // ID of the Connect Application that created the schedule. Application *Application `json:"application"` + // Details to identify the subscription schedule the quote line applies to. + AppliesTo *SubscriptionScheduleAppliesTo `json:"applies_to"` // Configures when the subscription schedule generates prorations for phase transitions. Possible values are `prorate_on_next_phase` or `prorate_up_front` with the default being `prorate_on_next_phase`. `prorate_on_next_phase` will apply phase changes and generate prorations at transition time.`prorate_up_front` will bill for all phases within the current billing cycle up front. BillingBehavior SubscriptionScheduleBillingBehavior `json:"billing_behavior"` // Time at which the subscription schedule was canceled. Measured in seconds since the Unix epoch. From ddcd19316e4599468dbf1498855215d7f58ef897 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 15 Dec 2022 15:09:39 -0800 Subject: [PATCH 7/7] Regenerate --- client/api.go | 8 + quoteline.go | 437 +++++++++++++++++++++++++++++++++++++++ taxcalculation.go | 222 ++++++++++++++++++++ taxcalculation/client.go | 86 ++++++++ taxtransaction.go | 174 ++++++++++++++++ taxtransaction/client.go | 73 +++++++ 6 files changed, 1000 insertions(+) create mode 100644 quoteline.go create mode 100644 taxcalculation.go create mode 100644 taxcalculation/client.go create mode 100644 taxtransaction.go create mode 100644 taxtransaction/client.go diff --git a/client/api.go b/client/api.go index 9ab3fa9064..2447687e77 100644 --- a/client/api.go +++ b/client/api.go @@ -85,9 +85,11 @@ import ( "github.com/stripe/stripe-go/v74/subscription" "github.com/stripe/stripe-go/v74/subscriptionitem" "github.com/stripe/stripe-go/v74/subscriptionschedule" + "github.com/stripe/stripe-go/v74/taxcalculation" "github.com/stripe/stripe-go/v74/taxcode" "github.com/stripe/stripe-go/v74/taxid" "github.com/stripe/stripe-go/v74/taxrate" + "github.com/stripe/stripe-go/v74/taxtransaction" terminalconfiguration "github.com/stripe/stripe-go/v74/terminal/configuration" terminalconnectiontoken "github.com/stripe/stripe-go/v74/terminal/connectiontoken" terminallocation "github.com/stripe/stripe-go/v74/terminal/location" @@ -275,12 +277,16 @@ type API struct { Subscriptions *subscription.Client // SubscriptionSchedules is the client used to invoke /subscription_schedules APIs. SubscriptionSchedules *subscriptionschedule.Client + // TaxCalculations is the client used to invoke /tax/calculations APIs. + TaxCalculations *taxcalculation.Client // TaxCodes is the client used to invoke /tax_codes APIs. TaxCodes *taxcode.Client // TaxIDs is the client used to invoke /customers/{customer}/tax_ids APIs. TaxIDs *taxid.Client // TaxRates is the client used to invoke /tax_rates APIs. TaxRates *taxrate.Client + // TaxTransactions is the client used to invoke /tax/transactions APIs. + TaxTransactions *taxtransaction.Client // TerminalConfigurations is the client used to invoke /terminal/configurations APIs. TerminalConfigurations *terminalconfiguration.Client // TerminalConnectionTokens is the client used to invoke /terminal/connection_tokens APIs. @@ -431,9 +437,11 @@ func (a *API) Init(key string, backends *stripe.Backends) { a.SubscriptionItems = &subscriptionitem.Client{B: backends.API, Key: key} a.Subscriptions = &subscription.Client{B: backends.API, Key: key} a.SubscriptionSchedules = &subscriptionschedule.Client{B: backends.API, Key: key} + a.TaxCalculations = &taxcalculation.Client{B: backends.API, Key: key} a.TaxCodes = &taxcode.Client{B: backends.API, Key: key} a.TaxIDs = &taxid.Client{B: backends.API, Key: key} a.TaxRates = &taxrate.Client{B: backends.API, Key: key} + a.TaxTransactions = &taxtransaction.Client{B: backends.API, Key: key} a.TerminalConfigurations = &terminalconfiguration.Client{B: backends.API, Key: key} a.TerminalConnectionTokens = &terminalconnectiontoken.Client{B: backends.API, Key: key} a.TerminalLocations = &terminallocation.Client{B: backends.API, Key: key} diff --git a/quoteline.go b/quoteline.go new file mode 100644 index 0000000000..bd36c2e38d --- /dev/null +++ b/quoteline.go @@ -0,0 +1,437 @@ +// +// +// File generated from our OpenAPI spec +// +// + +package stripe + +// The discount end type +type QuoteLineActionAddDiscountDiscountEndType string + +// List of values that QuoteLineActionAddDiscountDiscountEndType can take +const ( + QuoteLineActionAddDiscountDiscountEndTypeTimestamp QuoteLineActionAddDiscountDiscountEndType = "timestamp" +) + +// The discount end type +type QuoteLineActionAddItemDiscountDiscountEndType string + +// List of values that QuoteLineActionAddItemDiscountDiscountEndType can take +const ( + QuoteLineActionAddItemDiscountDiscountEndTypeTimestamp QuoteLineActionAddItemDiscountDiscountEndType = "timestamp" +) + +type QuoteLineActionAddItemTrialType string + +// List of values that QuoteLineActionAddItemTrialType can take +const ( + QuoteLineActionAddItemTrialTypeFree QuoteLineActionAddItemTrialType = "free" + QuoteLineActionAddItemTrialTypePaid QuoteLineActionAddItemTrialType = "paid" +) + +// The discount end type +type QuoteLineActionRemoveDiscountDiscountEndType string + +// List of values that QuoteLineActionRemoveDiscountDiscountEndType can take +const ( + QuoteLineActionRemoveDiscountDiscountEndTypeTimestamp QuoteLineActionRemoveDiscountDiscountEndType = "timestamp" +) + +// The discount end type +type QuoteLineActionSetDiscountDiscountEndType string + +// List of values that QuoteLineActionSetDiscountDiscountEndType can take +const ( + QuoteLineActionSetDiscountDiscountEndTypeTimestamp QuoteLineActionSetDiscountDiscountEndType = "timestamp" +) + +// The discount end type +type QuoteLineActionSetItemDiscountDiscountEndType string + +// List of values that QuoteLineActionSetItemDiscountDiscountEndType can take +const ( + QuoteLineActionSetItemDiscountDiscountEndTypeTimestamp QuoteLineActionSetItemDiscountDiscountEndType = "timestamp" +) + +type QuoteLineActionSetItemTrialType string + +// List of values that QuoteLineActionSetItemTrialType can take +const ( + QuoteLineActionSetItemTrialTypeFree QuoteLineActionSetItemTrialType = "free" + QuoteLineActionSetItemTrialTypePaid QuoteLineActionSetItemTrialType = "paid" +) + +// The type of action the quote line performs. +type QuoteLineActionType string + +// List of values that QuoteLineActionType can take +const ( + QuoteLineActionTypeAddDiscount QuoteLineActionType = "add_discount" + QuoteLineActionTypeAddItem QuoteLineActionType = "add_item" + QuoteLineActionTypeAddMetadata QuoteLineActionType = "add_metadata" + QuoteLineActionTypeClearDiscounts QuoteLineActionType = "clear_discounts" + QuoteLineActionTypeClearMetadata QuoteLineActionType = "clear_metadata" + QuoteLineActionTypeRemoveDiscount QuoteLineActionType = "remove_discount" + QuoteLineActionTypeRemoveItem QuoteLineActionType = "remove_item" + QuoteLineActionTypeRemoveMetadata QuoteLineActionType = "remove_metadata" + QuoteLineActionTypeSetDiscounts QuoteLineActionType = "set_discounts" + QuoteLineActionTypeSetItems QuoteLineActionType = "set_items" + QuoteLineActionTypeSetMetadata QuoteLineActionType = "set_metadata" +) + +// Describes whether the quote line is affecting a new schedule or an existing schedule. +type QuoteLineAppliesToType string + +// List of values that QuoteLineAppliesToType can take +const ( + QuoteLineAppliesToTypeNewReference QuoteLineAppliesToType = "new_reference" + QuoteLineAppliesToTypeSubscriptionSchedule QuoteLineAppliesToType = "subscription_schedule" +) + +// For a point-in-time operation, this attribute lets you set or update whether the subscription's billing cycle anchor is reset at the `starts_at` timestamp. +type QuoteLineBillingCycleAnchor string + +// List of values that QuoteLineBillingCycleAnchor can take +const ( + QuoteLineBillingCycleAnchorAutomatic QuoteLineBillingCycleAnchor = "automatic" + QuoteLineBillingCycleAnchorLineStartsAt QuoteLineBillingCycleAnchor = "line_starts_at" +) + +// Specifies a type of interval unit. Either `day`, `week`, `month` or `year`. +type QuoteLineEndsAtDurationInterval string + +// List of values that QuoteLineEndsAtDurationInterval can take +const ( + QuoteLineEndsAtDurationIntervalDay QuoteLineEndsAtDurationInterval = "day" + QuoteLineEndsAtDurationIntervalMonth QuoteLineEndsAtDurationInterval = "month" + QuoteLineEndsAtDurationIntervalWeek QuoteLineEndsAtDurationInterval = "week" + QuoteLineEndsAtDurationIntervalYear QuoteLineEndsAtDurationInterval = "year" +) + +// Select a way to pass in `ends_at`. +type QuoteLineEndsAtType string + +// List of values that QuoteLineEndsAtType can take +const ( + QuoteLineEndsAtTypeDiscountEnd QuoteLineEndsAtType = "discount_end" + QuoteLineEndsAtTypeDuration QuoteLineEndsAtType = "duration" + QuoteLineEndsAtTypeQuoteAcceptanceDate QuoteLineEndsAtType = "quote_acceptance_date" + QuoteLineEndsAtTypeScheduleEnd QuoteLineEndsAtType = "schedule_end" + QuoteLineEndsAtTypeTimestamp QuoteLineEndsAtType = "timestamp" + QuoteLineEndsAtTypeUpcomingInvoice QuoteLineEndsAtType = "upcoming_invoice" +) + +// Changes to how Stripe handles prorations during the quote line's time span. Affects if and how prorations are created when a future phase starts. +type QuoteLineProrationBehavior string + +// List of values that QuoteLineProrationBehavior can take +const ( + QuoteLineProrationBehaviorAlwaysInvoice QuoteLineProrationBehavior = "always_invoice" + QuoteLineProrationBehaviorCreateProrations QuoteLineProrationBehavior = "create_prorations" + QuoteLineProrationBehaviorNone QuoteLineProrationBehavior = "none" +) + +// Select a way to pass in `starts_at`. +type QuoteLineStartsAtType string + +// List of values that QuoteLineStartsAtType can take +const ( + QuoteLineStartsAtTypeDiscountEnd QuoteLineStartsAtType = "discount_end" + QuoteLineStartsAtTypeLineEndsAt QuoteLineStartsAtType = "line_ends_at" + QuoteLineStartsAtTypeNow QuoteLineStartsAtType = "now" + QuoteLineStartsAtTypeQuoteAcceptanceDate QuoteLineStartsAtType = "quote_acceptance_date" + QuoteLineStartsAtTypeScheduleEnd QuoteLineStartsAtType = "schedule_end" + QuoteLineStartsAtTypeTimestamp QuoteLineStartsAtType = "timestamp" + QuoteLineStartsAtTypeUpcomingInvoice QuoteLineStartsAtType = "upcoming_invoice" +) + +// Configure how an opt-in following a paid trial is billed when using `billing_behavior: prorate_up_front`. +type QuoteLineTrialSettingsEndBehaviorProrateUpFront string + +// List of values that QuoteLineTrialSettingsEndBehaviorProrateUpFront can take +const ( + QuoteLineTrialSettingsEndBehaviorProrateUpFrontDefer QuoteLineTrialSettingsEndBehaviorProrateUpFront = "defer" + QuoteLineTrialSettingsEndBehaviorProrateUpFrontInclude QuoteLineTrialSettingsEndBehaviorProrateUpFront = "include" +) + +// Details to determine how long the discount should be applied for. +type QuoteLineActionAddDiscountDiscountEnd struct { + // The discount end timestamp + Timestamp int64 `json:"timestamp"` + // The discount end type + Type QuoteLineActionAddDiscountDiscountEndType `json:"type"` +} + +// Details for the `add_discount` type. +type QuoteLineActionAddDiscount struct { + // ID of the coupon to create a new discount for. + Coupon *Coupon `json:"coupon"` + // ID of an existing discount on the object (or one of its ancestors) to reuse. + Discount *Discount `json:"discount"` + // Details to determine how long the discount should be applied for. + DiscountEnd *QuoteLineActionAddDiscountDiscountEnd `json:"discount_end"` + // The index, starting at 0, at which to position the new discount. When not supplied, Stripe defaults to appending the discount to the end of the `discounts` array. + Index int64 `json:"index"` +} + +// Details to determine how long the discount should be applied for. +type QuoteLineActionAddItemDiscountDiscountEnd struct { + // The discount end timestamp + Timestamp int64 `json:"timestamp"` + // The discount end type + Type QuoteLineActionAddItemDiscountDiscountEndType `json:"type"` +} + +// The discounts applied to the subscription item. Subscription item discounts are applied before subscription discounts. Use `expand[]=discounts` to expand each discount. +type QuoteLineActionAddItemDiscount struct { + // ID of the coupon to create a new discount for. + Coupon *Coupon `json:"coupon"` + // ID of an existing discount on the object (or one of its ancestors) to reuse. + Discount *Discount `json:"discount"` + // Details to determine how long the discount should be applied for. + DiscountEnd *QuoteLineActionAddItemDiscountDiscountEnd `json:"discount_end"` + // The index, starting at 0, at which to position the new discount. When not supplied, Stripe defaults to appending the discount to the end of the `discounts` array. + Index int64 `json:"index"` +} + +// Options that configure the trial on the subscription item. +type QuoteLineActionAddItemTrial struct { + // List of price IDs which, if present on the subscription following a paid trial, constitute opting-in to the paid trial. + ConvertsTo []string `json:"converts_to"` + Type QuoteLineActionAddItemTrialType `json:"type"` +} + +// Details for the `add_item` type. +type QuoteLineActionAddItem struct { + // The discounts applied to the subscription item. Subscription item discounts are applied before subscription discounts. Use `expand[]=discounts` to expand each discount. + Discounts []*QuoteLineActionAddItemDiscount `json:"discounts"` + // Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an item. Metadata on this item will update the underlying subscription item's `metadata` when the phase is entered. + Metadata map[string]string `json:"metadata"` + // ID of the price to which the customer should be subscribed. + Price *Price `json:"price"` + // Quantity of the plan to which the customer should be subscribed. + Quantity int64 `json:"quantity"` + // The tax rates which apply to this `phase_item`. When set, the `default_tax_rates` on the phase do not apply to this `phase_item`. + TaxRates []*TaxRate `json:"tax_rates"` + // Options that configure the trial on the subscription item. + Trial *QuoteLineActionAddItemTrial `json:"trial"` +} + +// Details to determine how long the discount should be applied for. +type QuoteLineActionRemoveDiscountDiscountEnd struct { + // The discount end timestamp + Timestamp int64 `json:"timestamp"` + // The discount end type + Type QuoteLineActionRemoveDiscountDiscountEndType `json:"type"` +} + +// Details for the `remove_discount` type. +type QuoteLineActionRemoveDiscount struct { + // ID of the coupon to create a new discount for. + Coupon *Coupon `json:"coupon"` + // ID of an existing discount on the object (or one of its ancestors) to reuse. + Discount *Discount `json:"discount"` + // Details to determine how long the discount should be applied for. + DiscountEnd *QuoteLineActionRemoveDiscountDiscountEnd `json:"discount_end"` + // The index, starting at 0, at which to position the new discount. When not supplied, Stripe defaults to appending the discount to the end of the `discounts` array. + Index int64 `json:"index"` +} + +// Details for the `remove_item` type. +type QuoteLineActionRemoveItem struct { + // ID of a price to remove. + Price *Price `json:"price"` +} + +// Details to determine how long the discount should be applied for. +type QuoteLineActionSetDiscountDiscountEnd struct { + // The discount end timestamp + Timestamp int64 `json:"timestamp"` + // The discount end type + Type QuoteLineActionSetDiscountDiscountEndType `json:"type"` +} + +// Details for the `set_discounts` type. +type QuoteLineActionSetDiscount struct { + // ID of the coupon to create a new discount for. + Coupon *Coupon `json:"coupon"` + // ID of an existing discount on the object (or one of its ancestors) to reuse. + Discount *Discount `json:"discount"` + // Details to determine how long the discount should be applied for. + DiscountEnd *QuoteLineActionSetDiscountDiscountEnd `json:"discount_end"` + // The index, starting at 0, at which to position the new discount. When not supplied, Stripe defaults to appending the discount to the end of the `discounts` array. + Index int64 `json:"index"` +} + +// Details to determine how long the discount should be applied for. +type QuoteLineActionSetItemDiscountDiscountEnd struct { + // The discount end timestamp + Timestamp int64 `json:"timestamp"` + // The discount end type + Type QuoteLineActionSetItemDiscountDiscountEndType `json:"type"` +} + +// The discounts applied to the subscription item. Subscription item discounts are applied before subscription discounts. Use `expand[]=discounts` to expand each discount. +type QuoteLineActionSetItemDiscount struct { + // ID of the coupon to create a new discount for. + Coupon *Coupon `json:"coupon"` + // ID of an existing discount on the object (or one of its ancestors) to reuse. + Discount *Discount `json:"discount"` + // Details to determine how long the discount should be applied for. + DiscountEnd *QuoteLineActionSetItemDiscountDiscountEnd `json:"discount_end"` + // The index, starting at 0, at which to position the new discount. When not supplied, Stripe defaults to appending the discount to the end of the `discounts` array. + Index int64 `json:"index"` +} + +// Options that configure the trial on the subscription item. +type QuoteLineActionSetItemTrial struct { + // List of price IDs which, if present on the subscription following a paid trial, constitute opting-in to the paid trial. + ConvertsTo []string `json:"converts_to"` + Type QuoteLineActionSetItemTrialType `json:"type"` +} + +// Details for the `set_items` type. +type QuoteLineActionSetItem struct { + // The discounts applied to the subscription item. Subscription item discounts are applied before subscription discounts. Use `expand[]=discounts` to expand each discount. + Discounts []*QuoteLineActionSetItemDiscount `json:"discounts"` + // Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an item. Metadata on this item will update the underlying subscription item's `metadata` when the phase is entered. + Metadata map[string]string `json:"metadata"` + // ID of the price to which the customer should be subscribed. + Price *Price `json:"price"` + // Quantity of the plan to which the customer should be subscribed. + Quantity int64 `json:"quantity"` + // The tax rates which apply to this `phase_item`. When set, the `default_tax_rates` on the phase do not apply to this `phase_item`. + TaxRates []*TaxRate `json:"tax_rates"` + // Options that configure the trial on the subscription item. + Trial *QuoteLineActionSetItemTrial `json:"trial"` +} + +// A list of items the customer is being quoted for. +type QuoteLineAction struct { + // Details for the `add_discount` type. + AddDiscount *QuoteLineActionAddDiscount `json:"add_discount"` + // Details for the `add_item` type. + AddItem *QuoteLineActionAddItem `json:"add_item"` + // Details for the `add_metadata` type: specify a hash of key-value pairs. + AddMetadata map[string]string `json:"add_metadata"` + // Details for the `remove_discount` type. + RemoveDiscount *QuoteLineActionRemoveDiscount `json:"remove_discount"` + // Details for the `remove_item` type. + RemoveItem *QuoteLineActionRemoveItem `json:"remove_item"` + // Details for the `remove_metadata` type: specify an array of metadata keys. + RemoveMetadata []string `json:"remove_metadata"` + // Details for the `set_discounts` type. + SetDiscounts []*QuoteLineActionSetDiscount `json:"set_discounts"` + // Details for the `set_items` type. + SetItems []*QuoteLineActionSetItem `json:"set_items"` + // Details for the `set_metadata` type: specify an array of key-value pairs. + SetMetadata map[string]string `json:"set_metadata"` + // The type of action the quote line performs. + Type QuoteLineActionType `json:"type"` +} + +// Details to identify the subscription schedule the quote line applies to. +type QuoteLineAppliesTo struct { + // A custom string that identifies a new subscription schedule being created upon quote acceptance. All quote lines with the same `new_reference` field will be applied to the creation of a new subscription schedule. + NewReference string `json:"new_reference"` + // The ID of the schedule the line applies to. + SubscriptionSchedule string `json:"subscription_schedule"` + // Describes whether the quote line is affecting a new schedule or an existing schedule. + Type QuoteLineAppliesToType `json:"type"` +} + +// Use the `end` time of a given discount. +type QuoteLineEndsAtDiscountEnd struct { + // The ID of a specific discount. + Discount string `json:"discount"` +} + +// Time span for the quote line starting from the `starts_at` date. +type QuoteLineEndsAtDuration struct { + // Specifies a type of interval unit. Either `day`, `week`, `month` or `year`. + Interval QuoteLineEndsAtDurationInterval `json:"interval"` + // The number of intervals, as an whole number greater than 0. Stripe multiplies this by the interval type to get the overall duration. + IntervalCount int64 `json:"interval_count"` +} + +// Details to identify the end of the time range modified by the proposed change. If not supplied, the quote line is considered a point-in-time operation that only affects the exact timestamp at `starts_at`, and a restricted set of attributes is supported on the quote line. +type QuoteLineEndsAt struct { + // The timestamp value that will be used to determine when to make changes to the subscription schedule, as computed from the `ends_at` field. For example, if `ends_at[type]=upcoming_invoice`, the upcoming invoice date will be computed at the time the `ends_at` field was specified and saved. This field will not be recomputed upon future requests to update or finalize the quote unless `ends_at` is respecified. This field is guaranteed to be populated after quote acceptance. + Computed int64 `json:"computed"` + // Use the `end` time of a given discount. + DiscountEnd *QuoteLineEndsAtDiscountEnd `json:"discount_end"` + // Time span for the quote line starting from the `starts_at` date. + Duration *QuoteLineEndsAtDuration `json:"duration"` + // A precise Unix timestamp. + Timestamp int64 `json:"timestamp"` + // Select a way to pass in `ends_at`. + Type QuoteLineEndsAtType `json:"type"` +} + +// Use the `end` time of a given discount. +type QuoteLineStartsAtDiscountEnd struct { + // The ID of a specific discount. + Discount string `json:"discount"` +} + +// The timestamp the given line ends at. +type QuoteLineStartsAtLineEndsAt struct { + // Unique identifier for the object. + ID string `json:"id"` +} + +// Details to identify the earliest timestamp where the proposed change should take effect. +type QuoteLineStartsAt struct { + // The timestamp value that will be used to determine when to make changes to the subscription schedule, as computed from the `starts_at` field. For example, if `starts_at[type]=upcoming_invoice`, the upcoming invoice date will be computed at the time the `starts_at` field was specified and saved. This field will not be recomputed upon future requests to update or finalize the quote unless `starts_at` is respecified. This field is guaranteed to be populated after quote acceptance. + Computed int64 `json:"computed"` + // Use the `end` time of a given discount. + DiscountEnd *QuoteLineStartsAtDiscountEnd `json:"discount_end"` + // The timestamp the given line ends at. + LineEndsAt *QuoteLineStartsAtLineEndsAt `json:"line_ends_at"` + // A precise Unix timestamp. + Timestamp int64 `json:"timestamp"` + // Select a way to pass in `starts_at`. + Type QuoteLineStartsAtType `json:"type"` +} + +// Defines how the subscription should behave when a trial ends. +type QuoteLineTrialSettingsEndBehavior struct { + // Configure how an opt-in following a paid trial is billed when using `billing_behavior: prorate_up_front`. + ProrateUpFront QuoteLineTrialSettingsEndBehaviorProrateUpFront `json:"prorate_up_front"` +} + +// Settings related to subscription trials. +type QuoteLineTrialSettings struct { + // Defines how the subscription should behave when a trial ends. + EndBehavior *QuoteLineTrialSettingsEndBehavior `json:"end_behavior"` +} + +// A quote line defines a set of changes that will be applied upon quote acceptance. +type QuoteLine struct { + // A list of items the customer is being quoted for. + Actions []*QuoteLineAction `json:"actions"` + // Details to identify the subscription schedule the quote line applies to. + AppliesTo *QuoteLineAppliesTo `json:"applies_to"` + // For a point-in-time operation, this attribute lets you set or update whether the subscription's billing cycle anchor is reset at the `starts_at` timestamp. + BillingCycleAnchor QuoteLineBillingCycleAnchor `json:"billing_cycle_anchor"` + // Details to identify the end of the time range modified by the proposed change. If not supplied, the quote line is considered a point-in-time operation that only affects the exact timestamp at `starts_at`, and a restricted set of attributes is supported on the quote line. + EndsAt *QuoteLineEndsAt `json:"ends_at"` + // Unique identifier for the object. + ID string `json:"id"` + // String representing the object's type. Objects of the same type share the same value. + Object string `json:"object"` + // Changes to how Stripe handles prorations during the quote line's time span. Affects if and how prorations are created when a future phase starts. + ProrationBehavior QuoteLineProrationBehavior `json:"proration_behavior"` + // Details to identify the earliest timestamp where the proposed change should take effect. + StartsAt *QuoteLineStartsAt `json:"starts_at"` + // Settings related to subscription trials. + TrialSettings *QuoteLineTrialSettings `json:"trial_settings"` +} + +// QuoteLineList is a list of QuoteLines as retrieved from a list endpoint. +type QuoteLineList struct { + APIResource + ListMeta + Data []*QuoteLine `json:"data"` +} diff --git a/taxcalculation.go b/taxcalculation.go new file mode 100644 index 0000000000..8eff4b8aeb --- /dev/null +++ b/taxcalculation.go @@ -0,0 +1,222 @@ +// +// +// File generated from our OpenAPI spec +// +// + +package stripe + +// The type of customer address provided. +type TaxCalculationCustomerDetailsAddressSource string + +// List of values that TaxCalculationCustomerDetailsAddressSource can take +const ( + TaxCalculationCustomerDetailsAddressSourceBilling TaxCalculationCustomerDetailsAddressSource = "billing" + TaxCalculationCustomerDetailsAddressSourceShipping TaxCalculationCustomerDetailsAddressSource = "shipping" +) + +// The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown` +type TaxCalculationCustomerDetailsTaxIDType string + +// List of values that TaxCalculationCustomerDetailsTaxIDType can take +const ( + TaxCalculationCustomerDetailsTaxIDTypeAETRN TaxCalculationCustomerDetailsTaxIDType = "ae_trn" + TaxCalculationCustomerDetailsTaxIDTypeAUABN TaxCalculationCustomerDetailsTaxIDType = "au_abn" + TaxCalculationCustomerDetailsTaxIDTypeAUARN TaxCalculationCustomerDetailsTaxIDType = "au_arn" + TaxCalculationCustomerDetailsTaxIDTypeBGUIC TaxCalculationCustomerDetailsTaxIDType = "bg_uic" + TaxCalculationCustomerDetailsTaxIDTypeBRCNPJ TaxCalculationCustomerDetailsTaxIDType = "br_cnpj" + TaxCalculationCustomerDetailsTaxIDTypeBRCPF TaxCalculationCustomerDetailsTaxIDType = "br_cpf" + TaxCalculationCustomerDetailsTaxIDTypeCABN TaxCalculationCustomerDetailsTaxIDType = "ca_bn" + TaxCalculationCustomerDetailsTaxIDTypeCAGSTHST TaxCalculationCustomerDetailsTaxIDType = "ca_gst_hst" + TaxCalculationCustomerDetailsTaxIDTypeCAPSTBC TaxCalculationCustomerDetailsTaxIDType = "ca_pst_bc" + TaxCalculationCustomerDetailsTaxIDTypeCAPSTMB TaxCalculationCustomerDetailsTaxIDType = "ca_pst_mb" + TaxCalculationCustomerDetailsTaxIDTypeCAPSTSK TaxCalculationCustomerDetailsTaxIDType = "ca_pst_sk" + TaxCalculationCustomerDetailsTaxIDTypeCAQST TaxCalculationCustomerDetailsTaxIDType = "ca_qst" + TaxCalculationCustomerDetailsTaxIDTypeCHVAT TaxCalculationCustomerDetailsTaxIDType = "ch_vat" + TaxCalculationCustomerDetailsTaxIDTypeCLTIN TaxCalculationCustomerDetailsTaxIDType = "cl_tin" + TaxCalculationCustomerDetailsTaxIDTypeEGTIN TaxCalculationCustomerDetailsTaxIDType = "eg_tin" + TaxCalculationCustomerDetailsTaxIDTypeESCIF TaxCalculationCustomerDetailsTaxIDType = "es_cif" + TaxCalculationCustomerDetailsTaxIDTypeEUOSSVAT TaxCalculationCustomerDetailsTaxIDType = "eu_oss_vat" + TaxCalculationCustomerDetailsTaxIDTypeEUVAT TaxCalculationCustomerDetailsTaxIDType = "eu_vat" + TaxCalculationCustomerDetailsTaxIDTypeGBVAT TaxCalculationCustomerDetailsTaxIDType = "gb_vat" + TaxCalculationCustomerDetailsTaxIDTypeGEVAT TaxCalculationCustomerDetailsTaxIDType = "ge_vat" + TaxCalculationCustomerDetailsTaxIDTypeHKBR TaxCalculationCustomerDetailsTaxIDType = "hk_br" + TaxCalculationCustomerDetailsTaxIDTypeHUTIN TaxCalculationCustomerDetailsTaxIDType = "hu_tin" + TaxCalculationCustomerDetailsTaxIDTypeIDNPWP TaxCalculationCustomerDetailsTaxIDType = "id_npwp" + TaxCalculationCustomerDetailsTaxIDTypeILVAT TaxCalculationCustomerDetailsTaxIDType = "il_vat" + TaxCalculationCustomerDetailsTaxIDTypeINGST TaxCalculationCustomerDetailsTaxIDType = "in_gst" + TaxCalculationCustomerDetailsTaxIDTypeISVAT TaxCalculationCustomerDetailsTaxIDType = "is_vat" + TaxCalculationCustomerDetailsTaxIDTypeJPCN TaxCalculationCustomerDetailsTaxIDType = "jp_cn" + TaxCalculationCustomerDetailsTaxIDTypeJPRN TaxCalculationCustomerDetailsTaxIDType = "jp_rn" + TaxCalculationCustomerDetailsTaxIDTypeJPTRN TaxCalculationCustomerDetailsTaxIDType = "jp_trn" + TaxCalculationCustomerDetailsTaxIDTypeKEPIN TaxCalculationCustomerDetailsTaxIDType = "ke_pin" + TaxCalculationCustomerDetailsTaxIDTypeKRBRN TaxCalculationCustomerDetailsTaxIDType = "kr_brn" + TaxCalculationCustomerDetailsTaxIDTypeLIUID TaxCalculationCustomerDetailsTaxIDType = "li_uid" + TaxCalculationCustomerDetailsTaxIDTypeMXRFC TaxCalculationCustomerDetailsTaxIDType = "mx_rfc" + TaxCalculationCustomerDetailsTaxIDTypeMYFRP TaxCalculationCustomerDetailsTaxIDType = "my_frp" + TaxCalculationCustomerDetailsTaxIDTypeMYITN TaxCalculationCustomerDetailsTaxIDType = "my_itn" + TaxCalculationCustomerDetailsTaxIDTypeMYSST TaxCalculationCustomerDetailsTaxIDType = "my_sst" + TaxCalculationCustomerDetailsTaxIDTypeNOVAT TaxCalculationCustomerDetailsTaxIDType = "no_vat" + TaxCalculationCustomerDetailsTaxIDTypeNZGST TaxCalculationCustomerDetailsTaxIDType = "nz_gst" + TaxCalculationCustomerDetailsTaxIDTypePHTIN TaxCalculationCustomerDetailsTaxIDType = "ph_tin" + TaxCalculationCustomerDetailsTaxIDTypeRUINN TaxCalculationCustomerDetailsTaxIDType = "ru_inn" + TaxCalculationCustomerDetailsTaxIDTypeRUKPP TaxCalculationCustomerDetailsTaxIDType = "ru_kpp" + TaxCalculationCustomerDetailsTaxIDTypeSAVAT TaxCalculationCustomerDetailsTaxIDType = "sa_vat" + TaxCalculationCustomerDetailsTaxIDTypeSGGST TaxCalculationCustomerDetailsTaxIDType = "sg_gst" + TaxCalculationCustomerDetailsTaxIDTypeSGUEN TaxCalculationCustomerDetailsTaxIDType = "sg_uen" + TaxCalculationCustomerDetailsTaxIDTypeSITIN TaxCalculationCustomerDetailsTaxIDType = "si_tin" + TaxCalculationCustomerDetailsTaxIDTypeTHVAT TaxCalculationCustomerDetailsTaxIDType = "th_vat" + TaxCalculationCustomerDetailsTaxIDTypeTRTIN TaxCalculationCustomerDetailsTaxIDType = "tr_tin" + TaxCalculationCustomerDetailsTaxIDTypeTWVAT TaxCalculationCustomerDetailsTaxIDType = "tw_vat" + TaxCalculationCustomerDetailsTaxIDTypeUAVAT TaxCalculationCustomerDetailsTaxIDType = "ua_vat" + TaxCalculationCustomerDetailsTaxIDTypeUnknown TaxCalculationCustomerDetailsTaxIDType = "unknown" + TaxCalculationCustomerDetailsTaxIDTypeUSEIN TaxCalculationCustomerDetailsTaxIDType = "us_ein" + TaxCalculationCustomerDetailsTaxIDTypeZAVAT TaxCalculationCustomerDetailsTaxIDType = "za_vat" +) + +// The tax type, such as `vat` or `sales_tax`. +type TaxCalculationTaxBreakdownTaxRateDetailsTaxType string + +// List of values that TaxCalculationTaxBreakdownTaxRateDetailsTaxType can take +const ( + TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeGST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "gst" + TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeHST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "hst" + TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeJCT TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "jct" + TaxCalculationTaxBreakdownTaxRateDetailsTaxTypePST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "pst" + TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeQST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "qst" + TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeRST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "rst" + TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeSalesTax TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "sales_tax" + TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeVAT TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "vat" +) + +// The customer's tax IDs. +type TaxCalculationCustomerDetailsTaxIDParams struct { + // Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ph_tin`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` + Type *string `form:"type"` + // Value of the tax ID. + Value *string `form:"value"` +} + +// Details about the customer, including address and tax IDs. +type TaxCalculationCustomerDetailsParams struct { + // The customer's postal address (e.g., home or business location). + Address *AddressParams `form:"address"` + // The type of customer address provided. Required when using `address`. + AddressSource *string `form:"address_source"` + // The customer's IP address (IPv4 or IPv6). + IPAddress *string `form:"ip_address"` + // The customer's tax IDs. + TaxIDs []*TaxCalculationCustomerDetailsTaxIDParams `form:"tax_ids"` +} + +// A list of items the customer is purchasing. +type TaxCalculationLineItemParams struct { + // A positive integer in cents representing the line item's total price. If `tax_behavior=inclusive`, then this amount includes taxes. Otherwise, taxes are calculated on top of this amount. + Amount *int64 `form:"amount"` + // If provided, the product's `tax_code` will be used as the line item's `tax_code`. + Product *string `form:"product"` + // The number of units of the item being purchased. The `amount` is a total amount for the whole line. Used to calculate the per-unit price, when required. + Quantity *int64 `form:"quantity"` + // A custom identifier for this line item. Must be unique across the line items in the calculation. + Reference *string `form:"reference"` + // Specifies whether the `amount` includes taxes. If `tax_behavior=inclusive`, then the amount includes taxes. + TaxBehavior *string `form:"tax_behavior"` + // A [tax code](https://stripe.com/docs/tax/tax-categories) ID to use for this line item. If not provided, we will use the tax code from the provided `product` param. If neither `tax_code` or `product` is provided, we will use the default tax code from your Tax Settings. + TaxCode *string `form:"tax_code"` +} + +// Calculates tax based on input and returns a Tax Calculation object. +type TaxCalculationParams struct { + Params `form:"*"` + // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + Currency *string `form:"currency"` + // The ID of an existing customer to use for this calculation. If provided, the customer's address and tax IDs are copied to `customer_details`. + Customer *string `form:"customer"` + // Details about the customer, including address and tax IDs. + CustomerDetails *TaxCalculationCustomerDetailsParams `form:"customer_details"` + // A list of items the customer is purchasing. + LineItems []*TaxCalculationLineItemParams `form:"line_items"` + // The boolean value that indicates if the calculation is a preview. If true, the calculation is not stored. If false, the calculation is stored for 48 hours. Defaults to true. + Preview *bool `form:"preview"` + // A custom order or sale identifier, such as 'myOrder_123'. + Reference *string `form:"reference"` + // Timestamp of date at which the tax rules and rates in effect applies for the calculation. Measured in seconds since the Unix epoch. + TaxDate *int64 `form:"tax_date"` +} + +// Retrieves the line items of a persisted tax calculation as a collection. +type TaxCalculationListLineItemsParams struct { + ListParams `form:"*"` + Calculation *string `form:"-"` // Included in URL +} + +// The customer's tax IDs (e.g., EU VAT numbers). +type TaxCalculationCustomerDetailsTaxID struct { + // The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown` + Type TaxCalculationCustomerDetailsTaxIDType `json:"type"` + // The value of the tax ID. + Value string `json:"value"` +} +type TaxCalculationCustomerDetails struct { + // The customer's postal address (e.g., home or business location). + Address *Address `json:"address"` + // The type of customer address provided. + AddressSource TaxCalculationCustomerDetailsAddressSource `json:"address_source"` + // The customer's IP address (IPv4 or IPv6). + IPAddress string `json:"ip_address"` + // The customer's tax IDs (e.g., EU VAT numbers). + TaxIDs []*TaxCalculationCustomerDetailsTaxID `json:"tax_ids"` +} +type TaxCalculationTaxBreakdownTaxRateDetails struct { + // Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + Country string `json:"country"` + // The tax rate percentage as a string. For example, 8.5% is represented as `"8.5"`. + PercentageDecimal string `json:"percentage_decimal"` + // State, county, province, or region. + State string `json:"state"` + // The tax type, such as `vat` or `sales_tax`. + TaxType TaxCalculationTaxBreakdownTaxRateDetailsTaxType `json:"tax_type"` +} + +// Breakdown of individual tax amounts that add up to the total. +type TaxCalculationTaxBreakdown struct { + // The amount of tax, in integer cents. + Amount int64 `json:"amount"` + // Specifies whether the tax amount is included in the line item amount. + Inclusive bool `json:"inclusive"` + // The amount on which tax is calculated, in integer cents. + TaxableAmount int64 `json:"taxable_amount"` + TaxRateDetails *TaxCalculationTaxBreakdownTaxRateDetails `json:"tax_rate_details"` +} + +// A Tax `Calculation` allows you to calculate the tax to collect from your customer. +type TaxCalculation struct { + APIResource + // Total after taxes. + AmountTotal int64 `json:"amount_total"` + // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + Currency Currency `json:"currency"` + // The ID of an existing [Customer](https://stripe.com/docs/api/customers/object) used for the resource. + Customer string `json:"customer"` + CustomerDetails *TaxCalculationCustomerDetails `json:"customer_details"` + // Timestamp of date at which the tax calculation will expire. Empty if the calculation is an unsaved preview. + ExpiresAt int64 `json:"expires_at"` + // Unique identifier for the calculation. + ID string `json:"id"` + // The list of items the customer is purchasing. + LineItems *LineItemList `json:"line_items"` + // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. + Livemode bool `json:"livemode"` + // String representing the object's type. Objects of the same type share the same value. + Object string `json:"object"` + // A custom unique identifier, such as 'myOrder_123'. + Reference string `json:"reference"` + // The amount of tax to be collected on top of the line item prices. + TaxAmountExclusive int64 `json:"tax_amount_exclusive"` + // The amount of tax already included in the line item prices. + TaxAmountInclusive int64 `json:"tax_amount_inclusive"` + // Breakdown of individual tax amounts that add up to the total. + TaxBreakdown []*TaxCalculationTaxBreakdown `json:"tax_breakdown"` + // Timestamp of date at which the tax rules and rates in effect applies for the calculation. + TaxDate int64 `json:"tax_date"` +} diff --git a/taxcalculation/client.go b/taxcalculation/client.go new file mode 100644 index 0000000000..8d12122e80 --- /dev/null +++ b/taxcalculation/client.go @@ -0,0 +1,86 @@ +// +// +// File generated from our OpenAPI spec +// +// + +// Package taxcalculation provides the /tax/calculations APIs +package taxcalculation + +import ( + "net/http" + + stripe "github.com/stripe/stripe-go/v74" + "github.com/stripe/stripe-go/v74/form" +) + +// Client is used to invoke /tax/calculations APIs. +type Client struct { + B stripe.Backend + Key string +} + +// New creates a new tax calculation. +func New(params *stripe.TaxCalculationParams) (*stripe.TaxCalculation, error) { + return getC().New(params) +} + +// New creates a new tax calculation. +func (c Client) New(params *stripe.TaxCalculationParams) (*stripe.TaxCalculation, error) { + taxcalculation := &stripe.TaxCalculation{} + err := c.B.Call( + http.MethodPost, + "/v1/tax/calculations", + c.Key, + params, + taxcalculation, + ) + return taxcalculation, err +} + +// ListLineItems is the method for the `GET /v1/tax/calculations/{calculation}/line_items` API. +func ListLineItems(params *stripe.TaxCalculationListLineItemsParams) *LineItemIter { + return getC().ListLineItems(params) +} + +// ListLineItems is the method for the `GET /v1/tax/calculations/{calculation}/line_items` API. +func (c Client) ListLineItems(listParams *stripe.TaxCalculationListLineItemsParams) *LineItemIter { + path := stripe.FormatURLPath( + "/v1/tax/calculations/%s/line_items", + stripe.StringValue(listParams.Calculation), + ) + return &LineItemIter{ + Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { + list := &stripe.LineItemList{} + err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list) + + ret := make([]interface{}, len(list.Data)) + for i, v := range list.Data { + ret[i] = v + } + + return ret, list, err + }), + } +} + +// LineItemIter is an iterator for line items. +type LineItemIter struct { + *stripe.Iter +} + +// LineItem returns the line item which the iterator is currently pointing to. +func (i *LineItemIter) LineItem() *stripe.LineItem { + return i.Current().(*stripe.LineItem) +} + +// LineItemList returns the current list object which the iterator is +// currently using. List objects will change as new API calls are made to +// continue pagination. +func (i *LineItemIter) LineItemList() *stripe.LineItemList { + return i.List().(*stripe.LineItemList) +} + +func getC() Client { + return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key} +} diff --git a/taxtransaction.go b/taxtransaction.go new file mode 100644 index 0000000000..3173cefb67 --- /dev/null +++ b/taxtransaction.go @@ -0,0 +1,174 @@ +// +// +// File generated from our OpenAPI spec +// +// + +package stripe + +// The type of customer address provided. +type TaxTransactionCustomerDetailsAddressSource string + +// List of values that TaxTransactionCustomerDetailsAddressSource can take +const ( + TaxTransactionCustomerDetailsAddressSourceBilling TaxTransactionCustomerDetailsAddressSource = "billing" + TaxTransactionCustomerDetailsAddressSourceShipping TaxTransactionCustomerDetailsAddressSource = "shipping" +) + +// The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown` +type TaxTransactionCustomerDetailsTaxIDType string + +// List of values that TaxTransactionCustomerDetailsTaxIDType can take +const ( + TaxTransactionCustomerDetailsTaxIDTypeAETRN TaxTransactionCustomerDetailsTaxIDType = "ae_trn" + TaxTransactionCustomerDetailsTaxIDTypeAUABN TaxTransactionCustomerDetailsTaxIDType = "au_abn" + TaxTransactionCustomerDetailsTaxIDTypeAUARN TaxTransactionCustomerDetailsTaxIDType = "au_arn" + TaxTransactionCustomerDetailsTaxIDTypeBGUIC TaxTransactionCustomerDetailsTaxIDType = "bg_uic" + TaxTransactionCustomerDetailsTaxIDTypeBRCNPJ TaxTransactionCustomerDetailsTaxIDType = "br_cnpj" + TaxTransactionCustomerDetailsTaxIDTypeBRCPF TaxTransactionCustomerDetailsTaxIDType = "br_cpf" + TaxTransactionCustomerDetailsTaxIDTypeCABN TaxTransactionCustomerDetailsTaxIDType = "ca_bn" + TaxTransactionCustomerDetailsTaxIDTypeCAGSTHST TaxTransactionCustomerDetailsTaxIDType = "ca_gst_hst" + TaxTransactionCustomerDetailsTaxIDTypeCAPSTBC TaxTransactionCustomerDetailsTaxIDType = "ca_pst_bc" + TaxTransactionCustomerDetailsTaxIDTypeCAPSTMB TaxTransactionCustomerDetailsTaxIDType = "ca_pst_mb" + TaxTransactionCustomerDetailsTaxIDTypeCAPSTSK TaxTransactionCustomerDetailsTaxIDType = "ca_pst_sk" + TaxTransactionCustomerDetailsTaxIDTypeCAQST TaxTransactionCustomerDetailsTaxIDType = "ca_qst" + TaxTransactionCustomerDetailsTaxIDTypeCHVAT TaxTransactionCustomerDetailsTaxIDType = "ch_vat" + TaxTransactionCustomerDetailsTaxIDTypeCLTIN TaxTransactionCustomerDetailsTaxIDType = "cl_tin" + TaxTransactionCustomerDetailsTaxIDTypeEGTIN TaxTransactionCustomerDetailsTaxIDType = "eg_tin" + TaxTransactionCustomerDetailsTaxIDTypeESCIF TaxTransactionCustomerDetailsTaxIDType = "es_cif" + TaxTransactionCustomerDetailsTaxIDTypeEUOSSVAT TaxTransactionCustomerDetailsTaxIDType = "eu_oss_vat" + TaxTransactionCustomerDetailsTaxIDTypeEUVAT TaxTransactionCustomerDetailsTaxIDType = "eu_vat" + TaxTransactionCustomerDetailsTaxIDTypeGBVAT TaxTransactionCustomerDetailsTaxIDType = "gb_vat" + TaxTransactionCustomerDetailsTaxIDTypeGEVAT TaxTransactionCustomerDetailsTaxIDType = "ge_vat" + TaxTransactionCustomerDetailsTaxIDTypeHKBR TaxTransactionCustomerDetailsTaxIDType = "hk_br" + TaxTransactionCustomerDetailsTaxIDTypeHUTIN TaxTransactionCustomerDetailsTaxIDType = "hu_tin" + TaxTransactionCustomerDetailsTaxIDTypeIDNPWP TaxTransactionCustomerDetailsTaxIDType = "id_npwp" + TaxTransactionCustomerDetailsTaxIDTypeILVAT TaxTransactionCustomerDetailsTaxIDType = "il_vat" + TaxTransactionCustomerDetailsTaxIDTypeINGST TaxTransactionCustomerDetailsTaxIDType = "in_gst" + TaxTransactionCustomerDetailsTaxIDTypeISVAT TaxTransactionCustomerDetailsTaxIDType = "is_vat" + TaxTransactionCustomerDetailsTaxIDTypeJPCN TaxTransactionCustomerDetailsTaxIDType = "jp_cn" + TaxTransactionCustomerDetailsTaxIDTypeJPRN TaxTransactionCustomerDetailsTaxIDType = "jp_rn" + TaxTransactionCustomerDetailsTaxIDTypeJPTRN TaxTransactionCustomerDetailsTaxIDType = "jp_trn" + TaxTransactionCustomerDetailsTaxIDTypeKEPIN TaxTransactionCustomerDetailsTaxIDType = "ke_pin" + TaxTransactionCustomerDetailsTaxIDTypeKRBRN TaxTransactionCustomerDetailsTaxIDType = "kr_brn" + TaxTransactionCustomerDetailsTaxIDTypeLIUID TaxTransactionCustomerDetailsTaxIDType = "li_uid" + TaxTransactionCustomerDetailsTaxIDTypeMXRFC TaxTransactionCustomerDetailsTaxIDType = "mx_rfc" + TaxTransactionCustomerDetailsTaxIDTypeMYFRP TaxTransactionCustomerDetailsTaxIDType = "my_frp" + TaxTransactionCustomerDetailsTaxIDTypeMYITN TaxTransactionCustomerDetailsTaxIDType = "my_itn" + TaxTransactionCustomerDetailsTaxIDTypeMYSST TaxTransactionCustomerDetailsTaxIDType = "my_sst" + TaxTransactionCustomerDetailsTaxIDTypeNOVAT TaxTransactionCustomerDetailsTaxIDType = "no_vat" + TaxTransactionCustomerDetailsTaxIDTypeNZGST TaxTransactionCustomerDetailsTaxIDType = "nz_gst" + TaxTransactionCustomerDetailsTaxIDTypePHTIN TaxTransactionCustomerDetailsTaxIDType = "ph_tin" + TaxTransactionCustomerDetailsTaxIDTypeRUINN TaxTransactionCustomerDetailsTaxIDType = "ru_inn" + TaxTransactionCustomerDetailsTaxIDTypeRUKPP TaxTransactionCustomerDetailsTaxIDType = "ru_kpp" + TaxTransactionCustomerDetailsTaxIDTypeSAVAT TaxTransactionCustomerDetailsTaxIDType = "sa_vat" + TaxTransactionCustomerDetailsTaxIDTypeSGGST TaxTransactionCustomerDetailsTaxIDType = "sg_gst" + TaxTransactionCustomerDetailsTaxIDTypeSGUEN TaxTransactionCustomerDetailsTaxIDType = "sg_uen" + TaxTransactionCustomerDetailsTaxIDTypeSITIN TaxTransactionCustomerDetailsTaxIDType = "si_tin" + TaxTransactionCustomerDetailsTaxIDTypeTHVAT TaxTransactionCustomerDetailsTaxIDType = "th_vat" + TaxTransactionCustomerDetailsTaxIDTypeTRTIN TaxTransactionCustomerDetailsTaxIDType = "tr_tin" + TaxTransactionCustomerDetailsTaxIDTypeTWVAT TaxTransactionCustomerDetailsTaxIDType = "tw_vat" + TaxTransactionCustomerDetailsTaxIDTypeUAVAT TaxTransactionCustomerDetailsTaxIDType = "ua_vat" + TaxTransactionCustomerDetailsTaxIDTypeUnknown TaxTransactionCustomerDetailsTaxIDType = "unknown" + TaxTransactionCustomerDetailsTaxIDTypeUSEIN TaxTransactionCustomerDetailsTaxIDType = "us_ein" + TaxTransactionCustomerDetailsTaxIDTypeZAVAT TaxTransactionCustomerDetailsTaxIDType = "za_vat" +) + +// If `reversal`, this transaction reverses an earlier transaction. +type TaxTransactionType string + +// List of values that TaxTransactionType can take +const ( + TaxTransactionTypeReversal TaxTransactionType = "reversal" + TaxTransactionTypeTransaction TaxTransactionType = "transaction" +) + +// Retrieves a Tax Transaction object. +type TaxTransactionParams struct { + Params `form:"*"` + // Tax Calculation ID to be used as input when creating the transaction. + FromCalculation *string `form:"from_calculation"` +} + +// The line item amounts to reverse. +type TaxTransactionCreateReversalLineItemParams struct { + // The amount to reverse, in negative integer cents. + Amount *int64 `form:"amount"` + // The amount of tax to reverse, in negative integer cents. + AmountTax *int64 `form:"amount_tax"` + // Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. + Metadata map[string]string `form:"metadata"` + // The `id` of the line item to reverse in the original transaction. + OriginalLineItem *string `form:"original_line_item"` + // The quantity reversed. + Quantity *int64 `form:"quantity"` + // A custom identifier for this line item in the reversal transaction, such as 'L1-refund'. + Reference *string `form:"reference"` +} + +// Creates a partial or full reversal of a previously created Transaction. +type TaxTransactionCreateReversalParams struct { + Params `form:"*"` + // The line item amounts to reverse. + LineItems []*TaxTransactionCreateReversalLineItemParams `form:"line_items"` + // If `partial`, the provided line item amounts are reversed. If `full`, the original transaction is fully reversed. + Mode *string `form:"mode"` + // The ID of the transaction to partially or fully reverse. + OriginalTransaction *string `form:"original_transaction"` + // A custom identifier for this reversal, such as 'myOrder_123-refund_1'. Must be unique across all transactions. + Reference *string `form:"reference"` +} + +// The customer's tax IDs (e.g., EU VAT numbers). +type TaxTransactionCustomerDetailsTaxID struct { + // The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown` + Type TaxTransactionCustomerDetailsTaxIDType `json:"type"` + // The value of the tax ID. + Value string `json:"value"` +} +type TaxTransactionCustomerDetails struct { + // The customer's postal address (e.g., home or business location). + Address *Address `json:"address"` + // The type of customer address provided. + AddressSource TaxTransactionCustomerDetailsAddressSource `json:"address_source"` + // The customer's IP address (IPv4 or IPv6). + IPAddress string `json:"ip_address"` + // The customer's tax IDs (e.g., EU VAT numbers). + TaxIDs []*TaxTransactionCustomerDetailsTaxID `json:"tax_ids"` +} + +// If `type=reversal`, contains information about what was reversed. +type TaxTransactionReversal struct { + // The `id` of the `Transaction` object that this one reversed. + OriginalTransaction string `json:"original_transaction"` +} + +// A Tax `Transaction` records the tax collected from or refunded to your customer. +type TaxTransaction struct { + APIResource + // Time at which the object was created. Measured in seconds since the Unix epoch. + Created int64 `json:"created"` + // Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + Currency Currency `json:"currency"` + // The ID of an existing [Customer](https://stripe.com/docs/api/customers/object) used for the resource. + Customer string `json:"customer"` + CustomerDetails *TaxTransactionCustomerDetails `json:"customer_details"` + // Unique identifier for the transaction. + ID string `json:"id"` + // The tax collected or refunded, by line item. + LineItems *LineItemList `json:"line_items"` + // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. + Livemode bool `json:"livemode"` + // Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. + Metadata map[string]string `json:"metadata"` + // String representing the object's type. Objects of the same type share the same value. + Object string `json:"object"` + // A custom unique identifier, such as 'myOrder_123'. + Reference string `json:"reference"` + // If `type=reversal`, contains information about what was reversed. + Reversal *TaxTransactionReversal `json:"reversal"` + // Timestamp of date at which the tax rules and rates in effect applies for the calculation. + TaxDate int64 `json:"tax_date"` + // If `reversal`, this transaction reverses an earlier transaction. + Type TaxTransactionType `json:"type"` +} diff --git a/taxtransaction/client.go b/taxtransaction/client.go new file mode 100644 index 0000000000..086c54e73d --- /dev/null +++ b/taxtransaction/client.go @@ -0,0 +1,73 @@ +// +// +// File generated from our OpenAPI spec +// +// + +// Package taxtransaction provides the /tax/transactions APIs +package taxtransaction + +import ( + "net/http" + + stripe "github.com/stripe/stripe-go/v74" +) + +// Client is used to invoke /tax/transactions APIs. +type Client struct { + B stripe.Backend + Key string +} + +// New creates a new tax transaction. +func New(params *stripe.TaxTransactionParams) (*stripe.TaxTransaction, error) { + return getC().New(params) +} + +// New creates a new tax transaction. +func (c Client) New(params *stripe.TaxTransactionParams) (*stripe.TaxTransaction, error) { + taxtransaction := &stripe.TaxTransaction{} + err := c.B.Call( + http.MethodPost, + "/v1/tax/transactions", + c.Key, + params, + taxtransaction, + ) + return taxtransaction, err +} + +// Get returns the details of a tax transaction. +func Get(id string, params *stripe.TaxTransactionParams) (*stripe.TaxTransaction, error) { + return getC().Get(id, params) +} + +// Get returns the details of a tax transaction. +func (c Client) Get(id string, params *stripe.TaxTransactionParams) (*stripe.TaxTransaction, error) { + path := stripe.FormatURLPath("/v1/tax/transactions/%s", id) + taxtransaction := &stripe.TaxTransaction{} + err := c.B.Call(http.MethodGet, path, c.Key, params, taxtransaction) + return taxtransaction, err +} + +// CreateReversal is the method for the `POST /v1/tax/transactions/create_reversal` API. +func CreateReversal(params *stripe.TaxTransactionCreateReversalParams) (*stripe.TaxTransaction, error) { + return getC().CreateReversal(params) +} + +// CreateReversal is the method for the `POST /v1/tax/transactions/create_reversal` API. +func (c Client) CreateReversal(params *stripe.TaxTransactionCreateReversalParams) (*stripe.TaxTransaction, error) { + taxtransaction := &stripe.TaxTransaction{} + err := c.B.Call( + http.MethodPost, + "/v1/tax/transactions/create_reversal", + c.Key, + params, + taxtransaction, + ) + return taxtransaction, err +} + +func getC() Client { + return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key} +}