From c2dda27bedc6ee8f413315fd3bfd7394a0bc15a6 Mon Sep 17 00:00:00 2001 From: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com> Date: Thu, 9 Mar 2023 11:28:54 -0800 Subject: [PATCH 1/5] API Updates (#1616) Codegen for openapi v249 --- OPENAPI_VERSION | 2 +- issuing_cardholder.go | 25 ++++++++++++++++--- subscription.go | 57 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 4 deletions(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index eb6678972b..f93f657afe 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v237 \ No newline at end of file +v249 \ No newline at end of file diff --git a/issuing_cardholder.go b/issuing_cardholder.go index 63adf7e804..6afc225790 100644 --- a/issuing_cardholder.go +++ b/issuing_cardholder.go @@ -13,9 +13,10 @@ type IssuingCardholderRequirementsDisabledReason string // List of values that IssuingCardholderRequirementsDisabledReason can take const ( - IssuingCardholderRequirementsDisabledReasonListed IssuingCardholderRequirementsDisabledReason = "listed" - IssuingCardholderRequirementsDisabledReasonRejectedListed IssuingCardholderRequirementsDisabledReason = "rejected.listed" - IssuingCardholderRequirementsDisabledReasonUnderReview IssuingCardholderRequirementsDisabledReason = "under_review" + IssuingCardholderRequirementsDisabledReasonListed IssuingCardholderRequirementsDisabledReason = "listed" + IssuingCardholderRequirementsDisabledReasonRejectedListed IssuingCardholderRequirementsDisabledReason = "rejected.listed" + IssuingCardholderRequirementsDisabledReasonRequirementsPastDue IssuingCardholderRequirementsDisabledReason = "requirements.past_due" + IssuingCardholderRequirementsDisabledReasonUnderReview IssuingCardholderRequirementsDisabledReason = "under_review" ) // Interval (or event) to which the amount applies. @@ -79,6 +80,22 @@ type IssuingCardholderCompanyParams struct { TaxID *string `form:"tax_id"` } +// Information about cardholder acceptance of [Authorized User Terms](https://stripe.com/docs/issuing/cards). +type IssuingCardholderIndividualCardIssuingUserTermsAcceptanceParams struct { + // The Unix timestamp marking when the cardholder accepted the Authorized User Terms. Required for Celtic Spend Card users. + Date *int64 `form:"date"` + // The IP address from which the cardholder accepted the Authorized User Terms. Required for Celtic Spend Card users. + IP *string `form:"ip"` + // The user agent of the browser from which the cardholder accepted the Authorized User Terms. + UserAgent *string `form:"user_agent"` +} + +// Information related to the card_issuing program for this cardholder. +type IssuingCardholderIndividualCardIssuingParams struct { + // Information about cardholder acceptance of [Authorized User Terms](https://stripe.com/docs/issuing/cards). + UserTermsAcceptance *IssuingCardholderIndividualCardIssuingUserTermsAcceptanceParams `form:"user_terms_acceptance"` +} + // The date of birth of this cardholder. type IssuingCardholderIndividualDOBParams struct { // The day of birth, between 1 and 31. @@ -105,6 +122,8 @@ type IssuingCardholderIndividualVerificationParams struct { // Additional information about an `individual` cardholder. type IssuingCardholderIndividualParams struct { + // Information related to the card_issuing program for this cardholder. + CardIssuing *IssuingCardholderIndividualCardIssuingParams `form:"card_issuing"` // The date of birth of this cardholder. DOB *IssuingCardholderIndividualDOBParams `form:"dob"` // The first name of this cardholder. Required before activating Cards. This field cannot contain any numbers, special characters (except periods, commas, hyphens, spaces and apostrophes) or non-latin letters. diff --git a/subscription.go b/subscription.go index 540894147a..5af8c1689d 100644 --- a/subscription.go +++ b/subscription.go @@ -11,6 +11,31 @@ import ( "github.com/stripe/stripe-go/v74/form" ) +// The customer submitted reason for why they cancelled, if the subscription was cancelled explicitly by the user. +type SubscriptionCancellationDetailsFeedback string + +// List of values that SubscriptionCancellationDetailsFeedback can take +const ( + SubscriptionCancellationDetailsFeedbackCustomerService SubscriptionCancellationDetailsFeedback = "customer_service" + SubscriptionCancellationDetailsFeedbackLowQuality SubscriptionCancellationDetailsFeedback = "low_quality" + SubscriptionCancellationDetailsFeedbackMissingFeatures SubscriptionCancellationDetailsFeedback = "missing_features" + SubscriptionCancellationDetailsFeedbackOther SubscriptionCancellationDetailsFeedback = "other" + SubscriptionCancellationDetailsFeedbackSwitchedService SubscriptionCancellationDetailsFeedback = "switched_service" + SubscriptionCancellationDetailsFeedbackTooComplex SubscriptionCancellationDetailsFeedback = "too_complex" + SubscriptionCancellationDetailsFeedbackTooExpensive SubscriptionCancellationDetailsFeedback = "too_expensive" + SubscriptionCancellationDetailsFeedbackUnused SubscriptionCancellationDetailsFeedback = "unused" +) + +// Why this subscription was cancelled. +type SubscriptionCancellationDetailsReason string + +// List of values that SubscriptionCancellationDetailsReason can take +const ( + SubscriptionCancellationDetailsReasonCancellationRequested SubscriptionCancellationDetailsReason = "cancellation_requested" + SubscriptionCancellationDetailsReasonPaymentDisputed SubscriptionCancellationDetailsReason = "payment_disputed" + SubscriptionCancellationDetailsReasonPaymentFailed SubscriptionCancellationDetailsReason = "payment_failed" +) + // Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. type SubscriptionCollectionMethod string @@ -438,6 +463,8 @@ type SubscriptionParams struct { CancelAt *int64 `form:"cancel_at"` // Boolean indicating whether this subscription should cancel at the end of the current period. CancelAtPeriodEnd *bool `form:"cancel_at_period_end"` + // Details about why this subscription was cancelled + CancellationDetails *SubscriptionCancellationDetailsParams `form:"cancellation_details"` // Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. Defaults to `charge_automatically`. CollectionMethod *string `form:"collection_method"` // The ID of the coupon to apply to this subscription. A coupon applied to a subscription will only affect invoices created for that particular subscription. @@ -508,6 +535,14 @@ func (s *SubscriptionParams) AppendTo(body *form.Values, keyParts []string) { } } +// Details about why this subscription was cancelled +type SubscriptionCancellationDetailsParams struct { + // Additional comments about why the user canceled the subscription, if the subscription was cancelled explicitly by the user. + Comment *string `form:"comment"` + // The customer submitted reason for why they cancelled, if the subscription was cancelled explicitly by the user. + Feedback *string `form:"feedback"` +} + // If specified, payment collection for this subscription will be paused. type SubscriptionPauseCollectionParams struct { // The payment collection behavior for this subscription while paused. One of `keep_as_draft`, `mark_uncollectible`, or `void`. @@ -516,6 +551,14 @@ type SubscriptionPauseCollectionParams struct { ResumesAt *int64 `form:"resumes_at"` } +// Details about why this subscription was cancelled +type SubscriptionCancelCancellationDetailsParams struct { + // Additional comments about why the user canceled the subscription, if the subscription was cancelled explicitly by the user. + Comment *string `form:"comment"` + // The customer submitted reason for why they cancelled, if the subscription was cancelled explicitly by the user. + Feedback *string `form:"feedback"` +} + // Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. // // Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. @@ -523,6 +566,8 @@ type SubscriptionPauseCollectionParams struct { // By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. type SubscriptionCancelParams struct { Params `form:"*"` + // Details about why this subscription was cancelled + CancellationDetails *SubscriptionCancelCancellationDetailsParams `form:"cancellation_details"` // Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items. InvoiceNow *bool `form:"invoice_now"` // Will generate a proration invoice item that credits remaining unused time until the subscription period end. @@ -557,6 +602,16 @@ type SubscriptionBillingThresholds struct { ResetBillingCycleAnchor bool `json:"reset_billing_cycle_anchor"` } +// Details about why this subscription was cancelled +type SubscriptionCancellationDetails struct { + // Additional comments about why the user canceled the subscription, if the subscription was cancelled explicitly by the user. + Comment string `json:"comment"` + // The customer submitted reason for why they cancelled, if the subscription was cancelled explicitly by the user. + Feedback SubscriptionCancellationDetailsFeedback `json:"feedback"` + // Why this subscription was cancelled. + Reason SubscriptionCancellationDetailsReason `json:"reason"` +} + // If specified, payment collection for this subscription will be paused. type SubscriptionPauseCollection struct { // The payment collection behavior for this subscription while paused. One of `keep_as_draft`, `mark_uncollectible`, or `void`. @@ -717,6 +772,8 @@ type Subscription struct { CancelAtPeriodEnd bool `json:"cancel_at_period_end"` // If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with `cancel_at_period_end`, `canceled_at` will reflect the time of the most recent update request, not the end of the subscription period when the subscription is automatically moved to a canceled state. CanceledAt int64 `json:"canceled_at"` + // Details about why this subscription was cancelled + CancellationDetails *SubscriptionCancellationDetails `json:"cancellation_details"` // Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. CollectionMethod SubscriptionCollectionMethod `json:"collection_method"` // Time at which the object was created. Measured in seconds since the Unix epoch. From 2c1cfb770dc547e7548ada2e711b77bdf20fb74f Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 9 Mar 2023 11:55:10 -0800 Subject: [PATCH 2/5] Bump version to 74.11.0 --- CHANGELOG.md | 7 +++++++ VERSION | 2 +- stripe.go | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfe162b08c..68b5baca6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 74.11.0 - 2023-03-09 +* [#1616](https://github.com/stripe/stripe-go/pull/1616) API Updates + * Add support for `CardIssuing` on `IssuingCardholderIndividualParams` + * Add support for new value `requirements.past_due` on enum `IssuingCardholderRequirementsDisabledReason` + * Add support for `CancellationDetails` on `SubscriptionCancelParams`, `SubscriptionParams`, and `Subscription` + + ## 74.10.0 - 2023-03-02 * [#1614](https://github.com/stripe/stripe-go/pull/1614) API Updates * Add support for `ReconciliationStatus` on `Payout` diff --git a/VERSION b/VERSION index 16bb848211..47d76d1c2f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -74.10.0 +74.11.0 diff --git a/stripe.go b/stripe.go index c6fc0194bb..d637d42af5 100644 --- a/stripe.go +++ b/stripe.go @@ -1198,7 +1198,7 @@ func StringSlice(v []string) []*string { // // clientversion is the binding version -const clientversion = "74.10.0" +const clientversion = "74.11.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 4ba7e26b6def7c873f3ccd1c0ea1652a4dea8f33 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 9 Mar 2023 12:02:56 -0800 Subject: [PATCH 3/5] Set version to 74.11.0 to simplify merge --- VERSION | 2 +- stripe.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 5cebe5e8e3..47d76d1c2f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -74.11.0-beta.1 +74.11.0 diff --git a/stripe.go b/stripe.go index 015831b077..2af5d29385 100644 --- a/stripe.go +++ b/stripe.go @@ -1198,7 +1198,7 @@ func StringSlice(v []string) []*string { // // clientversion is the binding version -const clientversion = "74.11.0-beta.1" +const clientversion = "74.11.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 a596890803381dca646488c6952c45c17ef295bb Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 9 Mar 2023 12:02:56 -0800 Subject: [PATCH 4/5] Reset version to 74.11.0-beta.1 --- VERSION | 2 +- stripe.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 47d76d1c2f..5cebe5e8e3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -74.11.0 +74.11.0-beta.1 diff --git a/stripe.go b/stripe.go index 2af5d29385..015831b077 100644 --- a/stripe.go +++ b/stripe.go @@ -1198,7 +1198,7 @@ func StringSlice(v []string) []*string { // // clientversion is the binding version -const clientversion = "74.11.0" +const clientversion = "74.11.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 d518668bb91a5e1bc3db8e95762e39f66b715850 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 9 Mar 2023 12:03:03 -0800 Subject: [PATCH 5/5] Codegen for openapi v249 --- subscription.go | 13 +++++++ subscriptionschedule.go | 76 ++++++++++++++++++++++++++++++++++++--- tax/transaction/client.go | 39 -------------------- tax_calculation.go | 53 +++++++++++++++++---------- tax_settings.go | 14 ++++++++ tax_transaction.go | 24 ++++++------- 6 files changed, 144 insertions(+), 75 deletions(-) diff --git a/subscription.go b/subscription.go index 9796aff7d2..a68af6ac31 100644 --- a/subscription.go +++ b/subscription.go @@ -198,6 +198,15 @@ const ( SubscriptionPendingInvoiceItemIntervalIntervalYear SubscriptionPendingInvoiceItemIntervalInterval = "year" ) +// Whether to cancel or preserve `prebilling` if the subscription is updated during the prebilled period. +type SubscriptionPrebillingUpdateBehavior string + +// List of values that SubscriptionPrebillingUpdateBehavior can take +const ( + SubscriptionPrebillingUpdateBehaviorPrebill SubscriptionPrebillingUpdateBehavior = "prebill" + SubscriptionPrebillingUpdateBehaviorReset SubscriptionPrebillingUpdateBehavior = "reset" +) + // Possible values are `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `canceled`, or `unpaid`. // // For `collection_method=charge_automatically` a subscription moves into `incomplete` if the initial payment attempt fails. A subscription in this state can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an `active` state. If the first invoice is not paid within 23 hours, the subscription transitions to `incomplete_expired`. This is a terminal state, the open invoice will be voided and no further invoices will be generated. @@ -496,6 +505,8 @@ type SubscriptionPendingInvoiceItemIntervalParams struct { type SubscriptionPrebillingParams struct { // This is used to determine the number of billing cycles to prebill. Iterations *int64 `form:"iterations"` + // Whether to cancel or preserve `prebilling` if the subscription is updated during the prebilled period. The default value is `reset`. + UpdateBehavior *string `form:"update_behavior"` } // If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges. @@ -830,6 +841,8 @@ type SubscriptionPrebilling struct { PeriodEnd int64 `json:"period_end"` // The start of the first period for which the invoice pre-bills. PeriodStart int64 `json:"period_start"` + // Whether to cancel or preserve `prebilling` if the subscription is updated during the prebilled period. + UpdateBehavior SubscriptionPrebillingUpdateBehavior `json:"update_behavior"` } // The account (if any) the subscription's payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription's invoices. diff --git a/subscriptionschedule.go b/subscriptionschedule.go index 1b731cc1b0..5430520e5b 100644 --- a/subscriptionschedule.go +++ b/subscriptionschedule.go @@ -118,6 +118,15 @@ const ( SubscriptionSchedulePhaseTrialSettingsEndBehaviorProrateUpFrontInclude SubscriptionSchedulePhaseTrialSettingsEndBehaviorProrateUpFront = "include" ) +// Whether to cancel or preserve `prebilling` if the subscription is updated during the prebilled period. +type SubscriptionSchedulePrebillingUpdateBehavior string + +// List of values that SubscriptionSchedulePrebillingUpdateBehavior can take +const ( + SubscriptionSchedulePrebillingUpdateBehaviorPrebill SubscriptionSchedulePrebillingUpdateBehavior = "prebill" + SubscriptionSchedulePrebillingUpdateBehaviorReset SubscriptionSchedulePrebillingUpdateBehavior = "reset" +) + // The present status of the subscription schedule. Possible values are `not_started`, `active`, `completed`, `released`, and `canceled`. You can read more about the different states in our [behavior guide](https://stripe.com/docs/billing/subscriptions/subscription-schedules). type SubscriptionScheduleStatus string @@ -412,6 +421,8 @@ func (s *SubscriptionSchedulePhaseParams) AppendTo(body *form.Values, keyParts [ type SubscriptionSchedulePrebillingParams struct { // This is used to determine the number of billing cycles to prebill. Iterations *int64 `form:"iterations"` + // Whether to cancel or preserve `prebilling` if the subscription is updated during the prebilled period. The default value is `reset`. + UpdateBehavior *string `form:"update_behavior"` } // Creates a new subscription schedule object. Each customer can have up to 500 active or scheduled subscriptions. @@ -709,6 +720,60 @@ type SubscriptionScheduleAmendAmendmentParams struct { TrialSettings *SubscriptionScheduleAmendAmendmentTrialSettingsParams `form:"trial_settings"` } +// Start the prebilled period when a specified amendment begins. +type SubscriptionScheduleAmendPrebillingBillFromAmendmentStartParams struct { + // The position of the amendment in the `amendments` array with which prebilling should begin. Indexes start from 0 and must be less than the total number of supplied amendments. + Index *int64 `form:"index"` +} + +// The beginning of the prebilled time period. The default value is `now`. +type SubscriptionScheduleAmendPrebillingBillFromParams struct { + // Start the prebilled period when a specified amendment begins. + AmendmentStart *SubscriptionScheduleAmendPrebillingBillFromAmendmentStartParams `form:"amendment_start"` + // Start the prebilled period at a precise integer timestamp, starting from the Unix epoch. + Timestamp *int64 `form:"timestamp"` + // Select one of several ways to pass the `bill_from` value. + Type *string `form:"type"` +} + +// End the prebilled period when a specified amendment ends. +type SubscriptionScheduleAmendPrebillingBillUntilAmendmentEndParams struct { + // The position of the amendment in the `amendments` array at which prebilling should end. Indexes start from 0 and must be less than the total number of supplied amendments. + Index *int64 `form:"index"` +} + +// Time span for prebilling, starting from `bill_from`. +type SubscriptionScheduleAmendPrebillingBillUntilDurationParams 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"` +} + +// The end of the prebilled time period. +type SubscriptionScheduleAmendPrebillingBillUntilParams struct { + // End the prebilled period when a specified amendment ends. + AmendmentEnd *SubscriptionScheduleAmendPrebillingBillUntilAmendmentEndParams `form:"amendment_end"` + // Time span for prebilling, starting from `bill_from`. + Duration *SubscriptionScheduleAmendPrebillingBillUntilDurationParams `form:"duration"` + // End the prebilled period at a precise integer timestamp, starting from the Unix epoch. + Timestamp *int64 `form:"timestamp"` + // Select one of several ways to pass the `bill_until` value. + Type *string `form:"type"` +} + +// Provide any time periods to bill in advance. +type SubscriptionScheduleAmendPrebillingParams struct { + // The beginning of the prebilled time period. The default value is `now`. + BillFrom *SubscriptionScheduleAmendPrebillingBillFromParams `form:"bill_from"` + // The end of the prebilled time period. + BillUntil *SubscriptionScheduleAmendPrebillingBillUntilParams `form:"bill_until"` + // When the prebilling invoice should be created. The default value is `now`. + InvoiceAt *string `form:"invoice_at"` + // Whether to cancel or preserve `prebilling` if the subscription is updated during the prebilled period. The default value is `reset`. + UpdateBehavior *string `form:"update_behavior"` +} + // Changes to apply to the subscription schedule. type SubscriptionScheduleAmendScheduleSettingsParams struct { // Behavior of the subscription schedule and underlying subscription when it ends. @@ -720,6 +785,8 @@ type SubscriptionScheduleAmendParams struct { Params `form:"*"` // Changes to apply to the phases of the subscription schedule, in the order provided. Amendments []*SubscriptionScheduleAmendAmendmentParams `form:"amendments"` + // Provide any time periods to bill in advance. + Prebilling []*SubscriptionScheduleAmendPrebillingParams `form:"prebilling"` // In cases where the amendment changes the currently active phase, // specifies if and how to prorate at the time of the request. ProrationBehavior *string `form:"proration_behavior"` @@ -742,8 +809,6 @@ type SubscriptionScheduleReleaseParams struct { // Keep any cancellation on the subscription that the schedule has set 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"` @@ -956,6 +1021,8 @@ type SubscriptionSchedulePrebilling struct { PeriodEnd int64 `json:"period_end"` // The start of the first period for which the invoice pre-bills. PeriodStart int64 `json:"period_start"` + // Whether to cancel or preserve `prebilling` if the subscription is updated during the prebilled period. + UpdateBehavior SubscriptionSchedulePrebillingUpdateBehavior `json:"update_behavior"` } // A subscription schedule allows you to create and manage the lifecycle of a subscription by predefining expected changes. @@ -964,9 +1031,8 @@ type SubscriptionSchedulePrebilling struct { 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"` + Application *Application `json:"application"` + 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. diff --git a/tax/transaction/client.go b/tax/transaction/client.go index 85fb0ffbb4..07f6a5182b 100644 --- a/tax/transaction/client.go +++ b/tax/transaction/client.go @@ -112,45 +112,6 @@ func (i *LineItemIter) LineItemList() *stripe.LineItemList { return i.List().(*stripe.LineItemList) } -// ListTransactions is the method for the `GET /v1/tax/transactions` API. -func ListTransactions(params *stripe.TaxTransactionListTransactionsParams) *Iter { - return getC().ListTransactions(params) -} - -// ListTransactions is the method for the `GET /v1/tax/transactions` API. -func (c Client) ListTransactions(listParams *stripe.TaxTransactionListTransactionsParams) *Iter { - return &Iter{ - Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) { - list := &stripe.TaxTransactionList{} - err := c.B.CallRaw(http.MethodGet, "/v1/tax/transactions", c.Key, b, p, list) - - ret := make([]interface{}, len(list.Data)) - for i, v := range list.Data { - ret[i] = v - } - - return ret, list, err - }), - } -} - -// Iter is an iterator for tax transactions. -type Iter struct { - *stripe.Iter -} - -// TaxTransaction returns the tax transaction which the iterator is currently pointing to. -func (i *Iter) TaxTransaction() *stripe.TaxTransaction { - return i.Current().(*stripe.TaxTransaction) -} - -// TaxTransactionList 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 *Iter) TaxTransactionList() *stripe.TaxTransactionList { - return i.List().(*stripe.TaxTransactionList) -} - func getC() Client { return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key} } diff --git a/tax_calculation.go b/tax_calculation.go index 19c7d55e67..e75a64af5c 100644 --- a/tax_calculation.go +++ b/tax_calculation.go @@ -74,20 +74,31 @@ const ( TaxCalculationCustomerDetailsTaxIDTypeZAVAT TaxCalculationCustomerDetailsTaxIDType = "za_vat" ) +// The taxability override used for taxation +type TaxCalculationCustomerDetailsTaxabilityOverride string + +// List of values that TaxCalculationCustomerDetailsTaxabilityOverride can take +const ( + TaxCalculationCustomerDetailsTaxabilityOverrideCustomerExempt TaxCalculationCustomerDetailsTaxabilityOverride = "customer_exempt" + TaxCalculationCustomerDetailsTaxabilityOverrideNone TaxCalculationCustomerDetailsTaxabilityOverride = "none" + TaxCalculationCustomerDetailsTaxabilityOverrideReverseCharge TaxCalculationCustomerDetailsTaxabilityOverride = "reverse_charge" +) + // The tax type, such as `vat` or `sales_tax`. -type TaxCalculationTaxBreakdownTaxRateDetailsTaxType string +type TaxCalculationTaxSummaryTaxRateDetailsTaxType string -// List of values that TaxCalculationTaxBreakdownTaxRateDetailsTaxType can take +// List of values that TaxCalculationTaxSummaryTaxRateDetailsTaxType can take const ( - TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeGST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "gst" - TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeHST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "hst" - TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeIGST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "igst" - TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeJCT TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "jct" - TaxCalculationTaxBreakdownTaxRateDetailsTaxTypePST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "pst" - TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeQST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "qst" - TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeRST TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "rst" - TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeSalesTax TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "sales_tax" - TaxCalculationTaxBreakdownTaxRateDetailsTaxTypeVAT TaxCalculationTaxBreakdownTaxRateDetailsTaxType = "vat" + TaxCalculationTaxSummaryTaxRateDetailsTaxTypeGST TaxCalculationTaxSummaryTaxRateDetailsTaxType = "gst" + TaxCalculationTaxSummaryTaxRateDetailsTaxTypeHST TaxCalculationTaxSummaryTaxRateDetailsTaxType = "hst" + TaxCalculationTaxSummaryTaxRateDetailsTaxTypeIGST TaxCalculationTaxSummaryTaxRateDetailsTaxType = "igst" + TaxCalculationTaxSummaryTaxRateDetailsTaxTypeJCT TaxCalculationTaxSummaryTaxRateDetailsTaxType = "jct" + TaxCalculationTaxSummaryTaxRateDetailsTaxTypeLeaseTax TaxCalculationTaxSummaryTaxRateDetailsTaxType = "lease_tax" + TaxCalculationTaxSummaryTaxRateDetailsTaxTypePST TaxCalculationTaxSummaryTaxRateDetailsTaxType = "pst" + TaxCalculationTaxSummaryTaxRateDetailsTaxTypeQST TaxCalculationTaxSummaryTaxRateDetailsTaxType = "qst" + TaxCalculationTaxSummaryTaxRateDetailsTaxTypeRST TaxCalculationTaxSummaryTaxRateDetailsTaxType = "rst" + TaxCalculationTaxSummaryTaxRateDetailsTaxTypeSalesTax TaxCalculationTaxSummaryTaxRateDetailsTaxType = "sales_tax" + TaxCalculationTaxSummaryTaxRateDetailsTaxTypeVAT TaxCalculationTaxSummaryTaxRateDetailsTaxType = "vat" ) // The customer's tax IDs. @@ -106,6 +117,8 @@ type TaxCalculationCustomerDetailsParams struct { AddressSource *string `form:"address_source"` // The customer's IP address (IPv4 or IPv6). IPAddress *string `form:"ip_address"` + // When `reverse_charge` is provided, the reverse charge rule is applied for taxation. When `customer_exempt` is sent, it treats the customer as tax exempt. Defaults to `none`. + TaxabilityOverride *string `form:"taxability_override"` // The customer's tax IDs. TaxIDs []*TaxCalculationCustomerDetailsTaxIDParams `form:"tax_ids"` } @@ -163,10 +176,12 @@ type TaxCalculationCustomerDetails struct { AddressSource TaxCalculationCustomerDetailsAddressSource `json:"address_source"` // The customer's IP address (IPv4 or IPv6). IPAddress string `json:"ip_address"` + // The taxability override used for taxation + TaxabilityOverride TaxCalculationCustomerDetailsTaxabilityOverride `json:"taxability_override"` // The customer's tax IDs (e.g., EU VAT numbers). TaxIDs []*TaxCalculationCustomerDetailsTaxID `json:"tax_ids"` } -type TaxCalculationTaxBreakdownTaxRateDetails struct { +type TaxCalculationTaxSummaryTaxRateDetails 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"`. @@ -174,18 +189,18 @@ type TaxCalculationTaxBreakdownTaxRateDetails struct { // State, county, province, or region. State string `json:"state"` // The tax type, such as `vat` or `sales_tax`. - TaxType TaxCalculationTaxBreakdownTaxRateDetailsTaxType `json:"tax_type"` + TaxType TaxCalculationTaxSummaryTaxRateDetailsTaxType `json:"tax_type"` } -// Breakdown of individual tax amounts that add up to the total. -type TaxCalculationTaxBreakdown struct { +// Summary of individual tax amounts that add up to the total. +type TaxCalculationTaxSummary 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"` + TaxableAmount int64 `json:"taxable_amount"` + TaxRateDetails *TaxCalculationTaxSummaryTaxRateDetails `json:"tax_rate_details"` } // A Tax `Calculation` allows you to calculate the tax to collect from your customer. @@ -212,8 +227,8 @@ type TaxCalculation struct { 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"` + // Summary of individual tax amounts that add up to the total. + TaxSummary []*TaxCalculationTaxSummary `json:"tax_summary"` } diff --git a/tax_settings.go b/tax_settings.go index 8dc5e0cb32..ae841a5196 100644 --- a/tax_settings.go +++ b/tax_settings.go @@ -6,6 +6,16 @@ package stripe +// Default [tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#tax-behavior) used to specify whether the price is considered inclusive of taxes or exclusive of taxes. If the item's price has a tax behavior set, it will take precedence over the default tax behavior. +type TaxSettingsDefaultsTaxBehavior string + +// List of values that TaxSettingsDefaultsTaxBehavior can take +const ( + TaxSettingsDefaultsTaxBehaviorExclusive TaxSettingsDefaultsTaxBehavior = "exclusive" + TaxSettingsDefaultsTaxBehaviorInclusive TaxSettingsDefaultsTaxBehavior = "inclusive" + TaxSettingsDefaultsTaxBehaviorInferredByCurrency TaxSettingsDefaultsTaxBehavior = "inferred_by_currency" +) + // The role of this location address. type TaxSettingsLocationRole string @@ -25,6 +35,8 @@ type TaxSettingsParams struct { // Default configuration to be used on Stripe Tax calculations. type TaxSettingsDefaultsParams struct { + // Specifies the default [tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#tax-behavior) to be used when the item's price has unspecified tax behavior. One of inclusive, exclusive, or inferred_by_currency. Once specified, it cannot be changed back to null. + TaxBehavior *string `form:"tax_behavior"` // A [tax code](https://stripe.com/docs/tax/tax-categories) ID. TaxCode *string `form:"tax_code"` } @@ -37,6 +49,8 @@ type TaxSettingsLocationParams struct { Role *string `form:"role"` } type TaxSettingsDefaults struct { + // Default [tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#tax-behavior) used to specify whether the price is considered inclusive of taxes or exclusive of taxes. If the item's price has a tax behavior set, it will take precedence over the default tax behavior. + TaxBehavior TaxSettingsDefaultsTaxBehavior `json:"tax_behavior"` // Default [tax code](https://stripe.com/docs/tax/tax-categories) used to classify your products and prices. TaxCode string `json:"tax_code"` } diff --git a/tax_transaction.go b/tax_transaction.go index bbbc1907c7..62972e3bb1 100644 --- a/tax_transaction.go +++ b/tax_transaction.go @@ -74,6 +74,16 @@ const ( TaxTransactionCustomerDetailsTaxIDTypeZAVAT TaxTransactionCustomerDetailsTaxIDType = "za_vat" ) +// The taxability override used for taxation +type TaxTransactionCustomerDetailsTaxabilityOverride string + +// List of values that TaxTransactionCustomerDetailsTaxabilityOverride can take +const ( + TaxTransactionCustomerDetailsTaxabilityOverrideCustomerExempt TaxTransactionCustomerDetailsTaxabilityOverride = "customer_exempt" + TaxTransactionCustomerDetailsTaxabilityOverrideNone TaxTransactionCustomerDetailsTaxabilityOverride = "none" + TaxTransactionCustomerDetailsTaxabilityOverrideReverseCharge TaxTransactionCustomerDetailsTaxabilityOverride = "reverse_charge" +) + // If `reversal`, this transaction reverses an earlier transaction. type TaxTransactionType string @@ -92,11 +102,6 @@ type TaxTransactionParams struct { Reference *string `form:"reference"` } -// Lists Tax Transaction objects. -type TaxTransactionListTransactionsParams struct { - ListParams `form:"*"` -} - // The line item amounts to reverse. type TaxTransactionCreateReversalLineItemParams struct { // The amount to reverse, in negative integer cents. @@ -146,6 +151,8 @@ type TaxTransactionCustomerDetails struct { AddressSource TaxTransactionCustomerDetailsAddressSource `json:"address_source"` // The customer's IP address (IPv4 or IPv6). IPAddress string `json:"ip_address"` + // The taxability override used for taxation + TaxabilityOverride TaxTransactionCustomerDetailsTaxabilityOverride `json:"taxability_override"` // The customer's tax IDs (e.g., EU VAT numbers). TaxIDs []*TaxTransactionCustomerDetailsTaxID `json:"tax_ids"` } @@ -185,10 +192,3 @@ type TaxTransaction struct { // If `reversal`, this transaction reverses an earlier transaction. Type TaxTransactionType `json:"type"` } - -// TaxTransactionList is a list of Transactions as retrieved from a list endpoint. -type TaxTransactionList struct { - APIResource - ListMeta - Data []*TaxTransaction `json:"data"` -}