diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index b164d836dc..1f7b99f730 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v162 \ No newline at end of file +v163 \ No newline at end of file diff --git a/checkout_session.go b/checkout_session.go index b5942f0245..ac119405fc 100644 --- a/checkout_session.go +++ b/checkout_session.go @@ -56,7 +56,7 @@ const ( CheckoutSessionCustomerCreationIfRequired CheckoutSessionCustomerCreation = "if_required" ) -// The customer's tax exempt status at time of checkout. +// The customer's tax exempt status after a completed Checkout Session. type CheckoutSessionCustomerDetailsTaxExempt string // List of values that CheckoutSessionCustomerDetailsTaxExempt can take @@ -1090,12 +1090,22 @@ type CheckoutSessionShippingOptionShippingRateDataDeliveryEstimateParams struct Minimum *CheckoutSessionShippingOptionShippingRateDataDeliveryEstimateMinimumParams `form:"minimum"` } +// Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type CheckoutSessionShippingOptionShippingRateDataFixedAmountCurrencyOptionsParams struct { + // A non-negative integer in cents representing how much to charge. + Amount *int64 `form:"amount"` + // Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. + TaxBehavior *string `form:"tax_behavior"` +} + // Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. type CheckoutSessionShippingOptionShippingRateDataFixedAmountParams struct { // A non-negative integer in cents representing how much to charge. Amount *int64 `form:"amount"` // 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"` + // Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*CheckoutSessionShippingOptionShippingRateDataFixedAmountCurrencyOptionsParams `form:"currency_options"` } // Parameters to be passed to Shipping Rate creation for this shipping option @@ -1200,6 +1210,8 @@ type CheckoutSessionParams struct { ClientReferenceID *string `form:"client_reference_id"` // Configure fields for the Checkout Session to gather active consent from customers. ConsentCollection *CheckoutSessionConsentCollectionParams `form:"consent_collection"` + // 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"` // ID of an existing Customer, if one exists. In `payment` mode, the customer's most recent card // payment method will be used to prefill the email, name, card details, and billing address // on the Checkout page. In `subscription` mode, the customer's [default payment method](https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method) @@ -1342,7 +1354,7 @@ type CheckoutSessionConsentCollection struct { Promotions CheckoutSessionConsentCollectionPromotions `json:"promotions"` } -// The customer's tax IDs at time of checkout. +// The customer's tax IDs after a completed Checkout Session. type CheckoutSessionCustomerDetailsTaxIDs 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`, `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`, or `unknown` Type CheckoutSessionCustomerDetailsTaxIDsType `json:"type"` @@ -1352,18 +1364,18 @@ type CheckoutSessionCustomerDetailsTaxIDs struct { // The customer details including the customer's tax exempt status and the customer's tax IDs. Only the customer's email is present on Sessions in `setup` mode. type CheckoutSessionCustomerDetails struct { - // The customer's address at the time of checkout. Note: This property is populated only for sessions on or after March 30, 2022. + // The customer's address after a completed Checkout Session. Note: This property is populated only for sessions on or after March 30, 2022. Address *Address `json:"address"` - // The email associated with the Customer, if one exists, on the Checkout Session at the time of checkout or at time of session expiry. + // The email associated with the Customer, if one exists, on the Checkout Session after a completed Checkout Session or at time of session expiry. // Otherwise, if the customer has consented to promotional content, this value is the most recent valid email provided by the customer on the Checkout form. Email string `json:"email"` - // The customer's name at the time of checkout. Note: This property is populated only for sessions on or after March 30, 2022. + // The customer's name after a completed Checkout Session. Note: This property is populated only for sessions on or after March 30, 2022. Name string `json:"name"` - // The customer's phone number at the time of checkout + // The customer's phone number after a completed Checkout Session. Phone string `json:"phone"` - // The customer's tax exempt status at time of checkout. + // The customer's tax exempt status after a completed Checkout Session. TaxExempt CheckoutSessionCustomerDetailsTaxExempt `json:"tax_exempt"` - // The customer's tax IDs at time of checkout. + // The customer's tax IDs after a completed Checkout Session. TaxIDs []*CheckoutSessionCustomerDetailsTaxIDs `json:"tax_ids"` } type CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptions struct { diff --git a/coupon.go b/coupon.go index e03a7a8ced..247160247d 100644 --- a/coupon.go +++ b/coupon.go @@ -33,6 +33,12 @@ type CouponAppliesToParams struct { Products []*string `form:"products"` } +// Coupons defined in each available currency option (only supported if `amount_off` is passed). Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type CouponCurrencyOptionsParams struct { + // A positive integer representing the amount to subtract from an invoice total. + AmountOff *int64 `form:"amount_off"` +} + // You can create coupons easily via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. Coupon creation is also accessible via the API if you need to create coupons on the fly. // // A coupon has either a percent_off or an amount_off and currency. If you set an amount_off, that amount will be subtracted from any invoice's subtotal. For example, an invoice with a subtotal of 100 will have a final total of 0 if a coupon with an amount_off of 200 is applied to it and an invoice with a subtotal of 300 will have a final total of 100 if a coupon with an amount_off of 200 is applied to it. @@ -44,6 +50,8 @@ type CouponParams struct { AppliesTo *CouponAppliesToParams `form:"applies_to"` // Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) of the `amount_off` parameter (required if `amount_off` is passed). Currency *string `form:"currency"` + // Coupons defined in each available currency option (only supported if the coupon is amount-based). Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*CouponCurrencyOptionsParams `form:"currency_options"` // Specifies how long the discount will be in effect if used on a subscription. Can be `forever`, `once`, or `repeating`. Defaults to `once`. Duration *string `form:"duration"` // Required only if `duration` is `repeating`, in which case it must be a positive integer that specifies the number of months the discount will be in effect. @@ -64,6 +72,12 @@ type CouponAppliesTo struct { Products []string `json:"products"` } +// Coupons defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type CouponCurrencyOptions struct { + // Amount (in the `currency` specified) that will be taken off the subtotal of any invoices for this customer. + AmountOff int64 `json:"amount_off"` +} + // A coupon contains information about a percent-off or amount-off discount you // might want to apply to a customer. Coupons may be applied to [subscriptions](https://stripe.com/docs/api#subscriptions), [invoices](https://stripe.com/docs/api#invoices), // [checkout sessions](https://stripe.com/docs/api/checkout/sessions), [quotes](https://stripe.com/docs/api#quotes), and more. Coupons do not work with conventional one-off [charges](https://stripe.com/docs/api#create_charge) or [payment intents](https://stripe.com/docs/api/payment_intents). @@ -76,7 +90,9 @@ type Coupon struct { Created int64 `json:"created"` // If `amount_off` has been set, the three-letter [ISO code for the currency](https://stripe.com/docs/currencies) of the amount to take off. Currency Currency `json:"currency"` - Deleted bool `json:"deleted"` + // Coupons defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*CouponCurrencyOptions `json:"currency_options"` + Deleted bool `json:"deleted"` // One of `forever`, `once`, and `repeating`. Describes how long a customer who applies this coupon will get the discount. Duration CouponDuration `json:"duration"` // If `duration` is `repeating`, the number of months the coupon applies. Null if coupon `duration` is `forever` or `once`. diff --git a/example/generated_examples_test.go b/example/generated_examples_test.go index ccf9e41671..7549a68663 100644 --- a/example/generated_examples_test.go +++ b/example/generated_examples_test.go @@ -282,6 +282,23 @@ func TestPaymentLinkListLineItems(t *testing.T) { assert.Nil(t, result.Err()) } +func TestPriceCreate(t *testing.T) { + params := &stripe.PriceParams{ + UnitAmount: stripe.Int64(2000), + Currency: stripe.String(string(stripe.CurrencyUSD)), + CurrencyOptions: map[string]*stripe.PriceCurrencyOptionsParams{ + "uah": &stripe.PriceCurrencyOptionsParams{UnitAmount: stripe.Int64(5000)}, + "eur": &stripe.PriceCurrencyOptionsParams{UnitAmount: stripe.Int64(1800)}, + }, + Recurring: &stripe.PriceRecurringParams{ + Interval: stripe.String(string(stripe.PriceRecurringIntervalMonth)), + }, + Product: stripe.String("prod_xxxxxxxxxxxxx"), + } + result, _ := price.New(params) + assert.NotNil(t, result) +} + func TestSetupAttemptList(t *testing.T) { params := &stripe.SetupAttemptListParams{ SetupIntent: stripe.String("si_xyz"), @@ -1625,7 +1642,7 @@ func TestPriceList(t *testing.T) { assert.Nil(t, result.Err()) } -func TestPriceCreate(t *testing.T) { +func TestPriceCreate2(t *testing.T) { params := &stripe.PriceParams{ UnitAmount: stripe.Int64(2000), Currency: stripe.String(string(stripe.CurrencyUSD)), diff --git a/invoice.go b/invoice.go index 06e0699042..dad1c8d623 100644 --- a/invoice.go +++ b/invoice.go @@ -309,6 +309,8 @@ type InvoiceParams struct { AutomaticTax *InvoiceAutomaticTaxParams `form:"automatic_tax"` // Either `charge_automatically` or `send_invoice`. This field can be updated only on `draft` invoices. CollectionMethod *string `form:"collection_method"` + // The currency to preview this invoice in. Defaults to that of `customer` if not specified. + Currency *string `form:"currency"` // The identifier of the customer whose upcoming invoice you'd like to retrieve. Customer *string `form:"customer"` // A list of up to 4 custom fields to be displayed on the invoice. If a value for `custom_fields` is specified, the list specified will replace the existing custom field list on this invoice. Pass an empty string to remove previously-defined fields. diff --git a/paymentlink.go b/paymentlink.go index 54800196dc..ac2fa38b4b 100644 --- a/paymentlink.go +++ b/paymentlink.go @@ -248,6 +248,8 @@ type PaymentLinkParams struct { BillingAddressCollection *string `form:"billing_address_collection"` // Configure fields to gather active consent from customers. ConsentCollection *PaymentLinkConsentCollectionParams `form:"consent_collection"` + // 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) and supported by each line item's price. + Currency *string `form:"currency"` // Configures whether [checkout sessions](https://stripe.com/docs/api/checkout/sessions) created by this payment link create a [Customer](https://stripe.com/docs/api/customers). CustomerCreation *string `form:"customer_creation"` // The line items representing what is being sold. Each line item represents an item being sold. Up to 20 line items are supported. diff --git a/price.go b/price.go index a6c7dddd14..f9cc46e3b0 100644 --- a/price.go +++ b/price.go @@ -20,6 +20,16 @@ const ( PriceBillingSchemeTiered PriceBillingScheme = "tiered" ) +// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. +type PriceCurrencyOptionsTaxBehavior string + +// List of values that PriceCurrencyOptionsTaxBehavior can take +const ( + PriceCurrencyOptionsTaxBehaviorExclusive PriceCurrencyOptionsTaxBehavior = "exclusive" + PriceCurrencyOptionsTaxBehaviorInclusive PriceCurrencyOptionsTaxBehavior = "inclusive" + PriceCurrencyOptionsTaxBehaviorUnspecified PriceCurrencyOptionsTaxBehavior = "unspecified" +) + // Specifies a usage aggregation strategy for prices of `usage_type=metered`. Allowed values are `sum` for summing up all usage during a period, `last_during_period` for using the last usage record reported within a period, `last_ever` for using the last usage record ever (across period bounds) or `max` which uses the usage record with the maximum reported usage during a period. Defaults to `sum`. type PriceRecurringAggregateUsage string @@ -127,6 +137,54 @@ type PriceListParams struct { Type *string `form:"type"` } +// When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. +type PriceCurrencyOptionsCustomUnitAmountParams struct { + // Pass in `true` to enable `custom_unit_amount`, otherwise omit `custom_unit_amount`. + Enabled *bool `form:"enabled"` + // The maximum unit amount the customer can specify for this item. + Maximum *int64 `form:"maximum"` + // The minimum unit amount the customer can specify for this item. Must be at least the minimum charge amount. + Minimum *int64 `form:"minimum"` + // The starting unit amount which can be updated by the customer. + Preset *int64 `form:"preset"` +} + +// Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. +type PriceCurrencyOptionsTierParams struct { + // The flat billing amount for an entire tier, regardless of the number of units in the tier. + FlatAmount *int64 `form:"flat_amount"` + // Same as `flat_amount`, but accepts a decimal value representing an integer in the minor units of the currency. Only one of `flat_amount` and `flat_amount_decimal` can be set. + FlatAmountDecimal *float64 `form:"flat_amount_decimal,high_precision"` + // The per unit billing amount for each individual unit for which this tier applies. + UnitAmount *int64 `form:"unit_amount"` + // Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. + UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` + // Specifies the upper bound of this tier. The lower bound of a tier is the upper bound of the previous tier adding one. Use `inf` to define a fallback tier. + UpTo *int64 `form:"up_to"` + UpToInf *bool `form:"-"` // See custom AppendTo +} + +// AppendTo implements custom encoding logic for PriceCurrencyOptionsTierParams. +func (p *PriceCurrencyOptionsTierParams) AppendTo(body *form.Values, keyParts []string) { + if BoolValue(p.UpToInf) { + body.Add(form.FormatKey(append(keyParts, "up_to")), "inf") + } +} + +// Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type PriceCurrencyOptionsParams struct { + // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. + CustomUnitAmount *PriceCurrencyOptionsCustomUnitAmountParams `form:"custom_unit_amount"` + // Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. + TaxBehavior *string `form:"tax_behavior"` + // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. + Tiers []*PriceCurrencyOptionsTierParams `form:"tiers"` + // A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. + UnitAmount *int64 `form:"unit_amount"` + // Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. + UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` +} + // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. type PriceCustomUnitAmountParams struct { // Pass in `true` to enable `custom_unit_amount`, otherwise omit `custom_unit_amount`. @@ -212,6 +270,8 @@ type PriceParams struct { BillingScheme *string `form:"billing_scheme"` // 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"` + // Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*PriceCurrencyOptionsParams `form:"currency_options"` // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. CustomUnitAmount *PriceCustomUnitAmountParams `form:"custom_unit_amount"` // A lookup key used to retrieve prices dynamically from a static string. This may be up to 200 characters. @@ -240,6 +300,44 @@ type PriceParams struct { UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` } +// When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. +type PriceCurrencyOptionsCustomUnitAmount struct { + // The maximum unit amount the customer can specify for this item. + Maximum int64 `json:"maximum"` + // The minimum unit amount the customer can specify for this item. Must be at least the minimum charge amount. + Minimum int64 `json:"minimum"` + // The starting unit amount which can be updated by the customer. + Preset int64 `json:"preset"` +} + +// Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. +type PriceCurrencyOptionsTier struct { + // Price for the entire tier. + FlatAmount int64 `json:"flat_amount"` + // Same as `flat_amount`, but contains a decimal value with at most 12 decimal places. + FlatAmountDecimal float64 `json:"flat_amount_decimal,string"` + // Per unit price for units relevant to the tier. + UnitAmount int64 `json:"unit_amount"` + // Same as `unit_amount`, but contains a decimal value with at most 12 decimal places. + UnitAmountDecimal float64 `json:"unit_amount_decimal,string"` + // Up to and including to this quantity will be contained in the tier. + UpTo int64 `json:"up_to"` +} + +// Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type PriceCurrencyOptions struct { + // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. + CustomUnitAmount *PriceCurrencyOptionsCustomUnitAmount `json:"custom_unit_amount"` + // Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. + TaxBehavior PriceCurrencyOptionsTaxBehavior `json:"tax_behavior"` + // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. + Tiers []*PriceCurrencyOptionsTier `json:"tiers"` + // The unit amount in %s to be charged, represented as a whole integer if possible. Only set if `billing_scheme=per_unit`. + UnitAmount int64 `json:"unit_amount"` + // The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places. Only set if `billing_scheme=per_unit`. + UnitAmountDecimal float64 `json:"unit_amount_decimal,string"` +} + // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. type PriceCustomUnitAmount struct { // The maximum unit amount the customer can specify for this item. @@ -302,6 +400,8 @@ type Price struct { 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"` + // Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*PriceCurrencyOptions `json:"currency_options"` // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. CustomUnitAmount *PriceCustomUnitAmount `json:"custom_unit_amount"` Deleted bool `json:"deleted"` diff --git a/product.go b/product.go index 3be57e6ad3..3904247056 100644 --- a/product.go +++ b/product.go @@ -6,7 +6,10 @@ package stripe -import "encoding/json" +import ( + "encoding/json" + "github.com/stripe/stripe-go/v72/form" +) // The type of the product. The product is either of type `good`, which is eligible for use with Orders and SKUs, or `service`, which is eligible for use with Subscriptions and Plans. type ProductType string @@ -27,6 +30,54 @@ type ProductSearchParams struct { Page *string `form:"page"` } +// When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. +type ProductDefaultPriceDataCurrencyOptionsCustomUnitAmountParams struct { + // Pass in `true` to enable `custom_unit_amount`, otherwise omit `custom_unit_amount`. + Enabled *bool `form:"enabled"` + // The maximum unit amount the customer can specify for this item. + Maximum *int64 `form:"maximum"` + // The minimum unit amount the customer can specify for this item. Must be at least the minimum charge amount. + Minimum *int64 `form:"minimum"` + // The starting unit amount which can be updated by the customer. + Preset *int64 `form:"preset"` +} + +// Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. +type ProductDefaultPriceDataCurrencyOptionsTierParams struct { + // The flat billing amount for an entire tier, regardless of the number of units in the tier. + FlatAmount *int64 `form:"flat_amount"` + // Same as `flat_amount`, but accepts a decimal value representing an integer in the minor units of the currency. Only one of `flat_amount` and `flat_amount_decimal` can be set. + FlatAmountDecimal *float64 `form:"flat_amount_decimal,high_precision"` + // The per unit billing amount for each individual unit for which this tier applies. + UnitAmount *int64 `form:"unit_amount"` + // Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. + UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` + // Specifies the upper bound of this tier. The lower bound of a tier is the upper bound of the previous tier adding one. Use `inf` to define a fallback tier. + UpTo *int64 `form:"up_to"` + UpToInf *bool `form:"-"` // See custom AppendTo +} + +// AppendTo implements custom encoding logic for ProductDefaultPriceDataCurrencyOptionsTierParams. +func (p *ProductDefaultPriceDataCurrencyOptionsTierParams) AppendTo(body *form.Values, keyParts []string) { + if BoolValue(p.UpToInf) { + body.Add(form.FormatKey(append(keyParts, "up_to")), "inf") + } +} + +// Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type ProductDefaultPriceDataCurrencyOptionsParams struct { + // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. + CustomUnitAmount *ProductDefaultPriceDataCurrencyOptionsCustomUnitAmountParams `form:"custom_unit_amount"` + // Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. + TaxBehavior *string `form:"tax_behavior"` + // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. + Tiers []*ProductDefaultPriceDataCurrencyOptionsTierParams `form:"tiers"` + // A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. + UnitAmount *int64 `form:"unit_amount"` + // Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. + UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` +} + // The recurring components of a price such as `interval` and `interval_count`. type ProductDefaultPriceDataRecurringParams struct { // Specifies billing frequency. Either `day`, `week`, `month` or `year`. @@ -39,6 +90,8 @@ type ProductDefaultPriceDataRecurringParams struct { type ProductDefaultPriceDataParams struct { // 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"` + // Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*ProductDefaultPriceDataCurrencyOptionsParams `form:"currency_options"` // The recurring components of a price such as `interval` and `interval_count`. Recurring *ProductDefaultPriceDataRecurringParams `form:"recurring"` // Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. diff --git a/promotioncode.go b/promotioncode.go index 37aa87eb8d..2e26cde6f6 100644 --- a/promotioncode.go +++ b/promotioncode.go @@ -27,8 +27,16 @@ type PromotionCodeParams struct { Restrictions *PromotionCodeRestrictionsParams `form:"restrictions"` } +// Promotion codes defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type PromotionCodeRestrictionsCurrencyOptionsParams struct { + // Minimum amount required to redeem this Promotion Code into a Coupon (e.g., a purchase must be $100 or more to work). + MinimumAmount *int64 `form:"minimum_amount"` +} + // Settings that restrict the redemption of the promotion code. type PromotionCodeRestrictionsParams struct { + // Promotion codes defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*PromotionCodeRestrictionsCurrencyOptionsParams `form:"currency_options"` // A Boolean indicating if the Promotion Code should only be redeemed for Customers without any successful payments or invoices FirstTimeTransaction *bool `form:"first_time_transaction"` // Minimum amount required to redeem this Promotion Code into a Coupon (e.g., a purchase must be $100 or more to work). @@ -53,7 +61,15 @@ type PromotionCodeListParams struct { // Only return promotion codes that are restricted to this customer. Customer *string `form:"customer"` } + +// Promotion code restrictions defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type PromotionCodeRestrictionsCurrencyOptions struct { + // Minimum amount required to redeem this Promotion Code into a Coupon (e.g., a purchase must be $100 or more to work). + MinimumAmount int64 `json:"minimum_amount"` +} type PromotionCodeRestrictions struct { + // Promotion code restrictions defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*PromotionCodeRestrictionsCurrencyOptions `json:"currency_options"` // A Boolean indicating if the Promotion Code should only be redeemed for Customers without any successful payments or invoices FirstTimeTransaction bool `json:"first_time_transaction"` // Minimum amount required to redeem this Promotion Code into a Coupon (e.g., a purchase must be $100 or more to work). diff --git a/shippingrate.go b/shippingrate.go index 68cd471075..e4d3ed976d 100644 --- a/shippingrate.go +++ b/shippingrate.go @@ -32,6 +32,16 @@ const ( ShippingRateDeliveryEstimateMinimumUnitWeek ShippingRateDeliveryEstimateMinimumUnit = "week" ) +// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. +type ShippingRateFixedAmountCurrencyOptionsTaxBehavior string + +// List of values that ShippingRateFixedAmountCurrencyOptionsTaxBehavior can take +const ( + ShippingRateFixedAmountCurrencyOptionsTaxBehaviorExclusive ShippingRateFixedAmountCurrencyOptionsTaxBehavior = "exclusive" + ShippingRateFixedAmountCurrencyOptionsTaxBehaviorInclusive ShippingRateFixedAmountCurrencyOptionsTaxBehavior = "inclusive" + ShippingRateFixedAmountCurrencyOptionsTaxBehaviorUnspecified ShippingRateFixedAmountCurrencyOptionsTaxBehavior = "unspecified" +) + // Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. type ShippingRateTaxBehavior string @@ -87,12 +97,22 @@ type ShippingRateDeliveryEstimateParams struct { Minimum *ShippingRateDeliveryEstimateMinimumParams `form:"minimum"` } +// Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type ShippingRateFixedAmountCurrencyOptionsParams struct { + // A non-negative integer in cents representing how much to charge. + Amount *int64 `form:"amount"` + // Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. + TaxBehavior *string `form:"tax_behavior"` +} + // Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. type ShippingRateFixedAmountParams struct { // A non-negative integer in cents representing how much to charge. Amount *int64 `form:"amount"` // 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"` + // Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*ShippingRateFixedAmountCurrencyOptionsParams `form:"currency_options"` } // Creates a new shipping rate object. @@ -137,11 +157,21 @@ type ShippingRateDeliveryEstimate struct { // The lower bound of the estimated range. If empty, represents no lower bound. Minimum *ShippingRateDeliveryEstimateMinimum `json:"minimum"` } + +// Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +type ShippingRateFixedAmountCurrencyOptions struct { + // A non-negative integer in cents representing how much to charge. + Amount int64 `json:"amount"` + // Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. + TaxBehavior ShippingRateFixedAmountCurrencyOptionsTaxBehavior `json:"tax_behavior"` +} type ShippingRateFixedAmount struct { // A non-negative integer in cents representing how much to charge. Amount int64 `json:"amount"` // 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"` + // Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + CurrencyOptions map[string]*ShippingRateFixedAmountCurrencyOptions `json:"currency_options"` } // Shipping rates describe the price of shipping presented to your customers and can be diff --git a/sub.go b/sub.go index 993f35081a..52c568b5cd 100644 --- a/sub.go +++ b/sub.go @@ -423,6 +423,8 @@ type SubscriptionParams struct { 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. Coupon *string `form:"coupon"` + // 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 identifier of the customer to subscribe. Customer *string `form:"customer"` // Number of days a customer has to pay invoices generated by this subscription. Valid only for subscriptions where `collection_method` is set to `send_invoice`. @@ -669,6 +671,8 @@ type Subscription struct { CollectionMethod SubscriptionCollectionMethod `json:"collection_method"` // 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"` // End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created. CurrentPeriodEnd int64 `json:"current_period_end"` // Start of the current period that the subscription has been invoiced for. diff --git a/subschedule.go b/subschedule.go index 876e6868f2..11b89d75f6 100644 --- a/subschedule.go +++ b/subschedule.go @@ -176,6 +176,8 @@ type SubscriptionSchedulePhaseParams struct { CollectionMethod *string `form:"collection_method"` // The identifier of the coupon to apply to this phase of the subscription schedule. Coupon *string `form:"coupon"` + // 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"` // ID of the default payment method for the subscription schedule. It must belong to the customer associated with the subscription schedule. If not set, invoices will use the default payment method in the customer's invoice settings. DefaultPaymentMethod *string `form:"default_payment_method"` // A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. These Tax Rates will set the Subscription's [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates), which means they will be the Invoice's [`default_tax_rates`](https://stripe.com/docs/api/invoices/create#create_invoice-default_tax_rates) for any Invoices issued by the Subscription during this Phase. @@ -331,6 +333,8 @@ type SubscriptionSchedulePhase struct { CollectionMethod SubscriptionCollectionMethod `json:"collection_method"` // ID of the coupon to use during this phase of the subscription schedule. Coupon *Coupon `json:"coupon"` + // 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"` // ID of the default payment method for the subscription schedule. It must belong to the customer associated with the subscription schedule. If not set, invoices will use the default payment method in the customer's invoice settings. DefaultPaymentMethod *PaymentMethod `json:"default_payment_method"` // The default tax rates to apply to the subscription during this phase of the subscription schedule.