Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Updates for beta branch #1493

Merged
merged 18 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 72.118.0 - 2022-07-07
* [#1492](https://github.com/stripe/stripe-go/pull/1492) API Updates
* Add support for `Currency` on `CheckoutSessionParams`, `InvoiceUpcomingLinesParams`, `InvoiceUpcomingParams`, `PaymentLinkParams`, `SubscriptionParams`, `SubscriptionSchedulePhasesParams`, `SubscriptionSchedulePhases`, and `Subscription`
* Add support for `CurrencyOptions` on `CheckoutSessionShippingOptionsShippingRateDataFixedAmountParams`, `CouponParams`, `Coupon`, `OrderShippingCostShippingRateDataFixedAmountParams`, `PriceParams`, `Price`, `ProductDefaultPriceDataParams`, `PromotionCodeRestrictionsParams`, `PromotionCodeRestrictions`, `ShippingRateFixedAmountParams`, and `ShippingRateFixedAmount`
* Add support for `Restrictions` on `PromotionCodeParams`
* Add support for `FixedAmount` and `TaxBehavior` on `ShippingRateParams`
* [#1491](https://github.com/stripe/stripe-go/pull/1491) API Updates
* Add support for `Customer` on `CheckoutSessionListParams` and `RefundParams`
* Add support for `Currency` and `Origin` on `RefundParams`

## 72.117.0 - 2022-06-29
* [#1487](https://github.com/stripe/stripe-go/pull/1487) API Updates
* Add support for `DeliverCard`, `FailCard`, `ReturnCard`, and `ShipCard` test helper methods on resource `Issuing.Card`
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v161
v163
2 changes: 1 addition & 1 deletion api_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
package stripe

const (
apiVersion string = "2020-08-27"
apiVersion string = "2020-08-27; server_side_confirmation_beta=v1"
)
16 changes: 6 additions & 10 deletions cashbalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@ const (

// Retrieves a customer's cash balance.
type CashBalanceParams struct {
Params `form:"*"`
Params `form:"*"`
// A hash of settings for this cash balance.
Settings *CashBalanceSettingsParams `form:"settings"`
Customer *string `form:"-"` // Included in URL
}

// A hash of settings for this cash balance.
type CashBalanceSettingsParams struct {
// Method for using the customer balance to pay outstanding
// `customer_balance` PaymentIntents. If set to `automatic`, all available
// funds will automatically be used to pay any outstanding PaymentIntent.
// If set to `manual`, only customer balance funds from bank transfers
// with a reference code matching
// `payment_intent.next_action.display_bank_transfer_intructions.reference_code` will
// automatically be used to pay the corresponding outstanding
// PaymentIntent.
// Controls how funds transferred by the customer are applied to payment intents and invoices. Valid options are `automatic` or `manual`. For more information about these reconciliation modes, see [Reconciliation](https://stripe.com/docs/payments/customer-balance/reconciliation).
ReconciliationMode *string `form:"reconciliation_mode"`
}
type CashBalanceSettings struct {
Expand All @@ -40,7 +36,7 @@ type CashBalanceSettings struct {
// A customer's `Cash balance` represents real funds. Customers can add funds to their cash balance by sending a bank transfer. These funds can be used for payment and can eventually be paid out to your bank account.
type CashBalance struct {
APIResource
// A hash of all cash balances available to this customer. You cannot delete a customer with any cash balances, even if the balance is 0.
// A hash of all cash balances available to this customer. You cannot delete a customer with any cash balances, even if the balance is 0. Amounts are represented in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
Available map[string]int64 `json:"available"`
// The ID of the customer whose cash balance this object represents.
Customer string `json:"customer"`
Expand Down
30 changes: 22 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 @@ -504,6 +504,8 @@ const (
// Returns a list of Checkout Sessions.
type CheckoutSessionListParams struct {
ListParams `form:"*"`
// Only return the Checkout Sessions for the Customer specified.
Customer *string `form:"customer"`
// Only return the Checkout Session for the PaymentIntent specified.
PaymentIntent *string `form:"payment_intent"`
// Only return the Checkout Session for the subscription specified.
Expand Down Expand Up @@ -1088,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 @@ -1198,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 @@ -1340,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 @@ -1350,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
9 changes: 1 addition & 8 deletions customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,7 @@ type CustomerListParams struct {
// Settings controlling the behavior of the customer's cash balance,
// such as reconciliation of funds received.
type CustomerCashBalanceSettingsParams struct {
// Method for using the customer balance to pay outstanding
// `customer_balance` PaymentIntents. If set to `automatic`, all available
// funds will automatically be used to pay any outstanding PaymentIntent.
// If set to `manual`, only customer balance funds from bank transfers
// with a reference code matching
// `payment_intent.next_action.display_bank_transfer_intructions.reference_code` will
// automatically be used to pay the corresponding outstanding
// PaymentIntent.
// Controls how funds transferred by the customer are applied to payment intents and invoices. Valid options are `automatic` or `manual`. For more information about these reconciliation modes, see [Reconciliation](https://stripe.com/docs/payments/customer-balance/reconciliation).
ReconciliationMode *string `form:"reconciliation_mode"`
}

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
Loading