Skip to content

Commit

Permalink
Codegen for openapi v249
Browse files Browse the repository at this point in the history
  • Loading branch information
anniel-stripe committed Mar 9, 2023
1 parent a596890 commit d518668
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 75 deletions.
13 changes: 13 additions & 0 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
76 changes: 71 additions & 5 deletions subscriptionschedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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"`
Expand All @@ -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"`
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
39 changes: 0 additions & 39 deletions tax/transaction/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
53 changes: 34 additions & 19 deletions tax_calculation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"`
}
Expand Down Expand Up @@ -163,29 +176,31 @@ 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"`.
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"`
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.
Expand All @@ -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"`
}
14 changes: 14 additions & 0 deletions tax_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"`
}
Expand All @@ -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"`
}
Expand Down
Loading

0 comments on commit d518668

Please sign in to comment.