Skip to content

Commit

Permalink
Codegen for openapi v163
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym-stripe committed Jul 7, 2022
1 parent 6cbd4bb commit 4ad1a1d
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 12 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v162
v163
28 changes: 20 additions & 8 deletions checkout_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"`
Expand All @@ -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 {
Expand Down
18 changes: 17 additions & 1 deletion coupon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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).
Expand All @@ -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`.
Expand Down
19 changes: 18 additions & 1 deletion example/generated_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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)),
Expand Down
2 changes: 2 additions & 0 deletions invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions paymentlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 4ad1a1d

Please sign in to comment.