From d82624f18d3d4df1d16a0fac5caf86c575c9233c Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 31 Aug 2021 18:02:25 -0400 Subject: [PATCH 1/3] Codegen for openapi 944e56f --- checkout_session.go | 57 +++++++++++++++++++++++++++++++++++++++++++++ client/api.go | 1 + 2 files changed, 58 insertions(+) diff --git a/checkout_session.go b/checkout_session.go index 1535de7dfa..19b36e4717 100644 --- a/checkout_session.go +++ b/checkout_session.go @@ -74,6 +74,16 @@ const ( CheckoutSessionBillingAddressCollectionRequired CheckoutSessionBillingAddressCollection = "required" ) +// If `opt_in`, the customer consents to receiving promotional communications +// from the merchant about this Checkout Session. +type CheckoutSessionConsentPromotions string + +// List of values that CheckoutSessionConsentPromotions can take +const ( + CheckoutSessionConsentPromotionsOptIn CheckoutSessionConsentPromotions = "opt_in" + CheckoutSessionConsentPromotionsOptOut CheckoutSessionConsentPromotions = "opt_out" +) + // CheckoutSessionCustomerDetailsTaxExempt is the list of allowed values for // tax_exempt inside customer_details of a checkout session. type CheckoutSessionCustomerDetailsTaxExempt string @@ -185,11 +195,27 @@ type CheckoutSessionLineItemPriceDataParams struct { UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` } +// Configure a Checkout Session that can be used to recover an expired session. +type CheckoutSessionAfterExpirationRecoveryParams struct { + AllowPromotionCodes *bool `form:"allow_promotion_codes"` + Enabled *bool `form:"enabled"` +} + +// Configure actions after a Checkout Session has expired. +type CheckoutSessionAfterExpirationParams struct { + Recovery *CheckoutSessionAfterExpirationRecoveryParams `form:"recovery"` +} + // Settings for automatic tax lookup for this session and resulting payments, invoices, and subscriptions. type CheckoutSessionAutomaticTaxParams struct { Enabled *bool `form:"enabled"` } +// Configure fields for the Checkout Session to gather active consent from customers. +type CheckoutSessionConsentCollectionParams struct { + Promotions *string `form:"promotions"` +} + // Controls what fields on Customer can be updated by the Checkout Session. Can only be provided when `customer` is provided. type CheckoutSessionCustomerUpdateParams struct { Address *string `form:"address"` @@ -338,15 +364,18 @@ type CheckoutSessionTaxIDCollectionParams struct { // For more details see https://stripe.com/docs/api/checkout/sessions/create type CheckoutSessionParams struct { Params `form:"*"` + AfterExpiration *CheckoutSessionAfterExpirationParams `form:"after_expiration"` AllowPromotionCodes *bool `form:"allow_promotion_codes"` AutomaticTax *CheckoutSessionAutomaticTaxParams `form:"automatic_tax"` BillingAddressCollection *string `form:"billing_address_collection"` CancelURL *string `form:"cancel_url"` ClientReferenceID *string `form:"client_reference_id"` + ConsentCollection *CheckoutSessionConsentCollectionParams `form:"consent_collection"` Customer *string `form:"customer"` CustomerEmail *string `form:"customer_email"` CustomerUpdate *CheckoutSessionCustomerUpdateParams `form:"customer_update"` Discounts []*CheckoutSessionDiscountParams `form:"discounts"` + ExpiresAt *int64 `form:"expires_at"` LineItems []*CheckoutSessionLineItemParams `form:"line_items"` Locale *string `form:"locale"` Mode *string `form:"mode"` @@ -377,11 +406,34 @@ type CheckoutSessionListParams struct { PaymentIntent *string `form:"payment_intent"` Subscription *string `form:"subscription"` } + +// When set, configuration used to recover the Checkout Session on expiry. +type CheckoutSessionAfterExpirationRecovery struct { + AllowPromotionCodes bool `json:"allow_promotion_codes"` + Enabled bool `json:"enabled"` + ExpiresAt int64 `json:"expires_at"` + URL string `json:"url"` +} + +// When set, provides configuration for actions to take if this Checkout Session expires. +type CheckoutSessionAfterExpiration struct { + Recovery *CheckoutSessionAfterExpirationRecovery `json:"recovery"` +} type CheckoutSessionAutomaticTax struct { Enabled bool `json:"enabled"` Status CheckoutSessionAutomaticTaxStatus `json:"status"` } +// Results of `consent_collection` for this session. +type CheckoutSessionConsent struct { + Promotions CheckoutSessionConsentPromotions `json:"promotions"` +} + +// When set, provides configuration for the Checkout Session to gather active consent from customers. +type CheckoutSessionConsentCollection struct { + Promotions *string `json:"promotions"` +} + // CheckoutSessionCustomerDetailsTaxIDs represent customer's tax IDs at the // time of checkout. type CheckoutSessionCustomerDetailsTaxIDs struct { @@ -469,6 +521,7 @@ type CheckoutSessionTotalDetails struct { // For more details see https://stripe.com/docs/api/checkout/sessions/object type CheckoutSession struct { APIResource + AfterExpiration *CheckoutSessionAfterExpiration `json:"after_expiration"` AllowPromotionCodes bool `json:"allow_promotion_codes"` AmountSubtotal int64 `json:"amount_subtotal"` AmountTotal int64 `json:"amount_total"` @@ -476,11 +529,14 @@ type CheckoutSession struct { BillingAddressCollection CheckoutSessionBillingAddressCollection `json:"billing_address_collection"` CancelURL string `json:"cancel_url"` ClientReferenceID string `json:"client_reference_id"` + Consent *CheckoutSessionConsent `json:"consent"` + ConsentCollection *CheckoutSessionConsentCollection `json:"consent_collection"` Currency Currency `json:"currency"` Customer *Customer `json:"customer"` CustomerDetails *CheckoutSessionCustomerDetails `json:"customer_details"` CustomerEmail string `json:"customer_email"` Deleted bool `json:"deleted"` + ExpiresAt int64 `json:"expires_at"` ID string `json:"id"` LineItems *LineItemList `json:"line_items"` Livemode bool `json:"livemode"` @@ -492,6 +548,7 @@ type CheckoutSession struct { PaymentMethodOptions *CheckoutSessionPaymentMethodOptions `json:"payment_method_options"` PaymentMethodTypes []string `json:"payment_method_types"` PaymentStatus CheckoutSessionPaymentStatus `json:"payment_status"` + RecoveredFrom string `json:"recovered_from"` SetupIntent *SetupIntent `json:"setup_intent"` Shipping *ShippingDetails `json:"shipping"` ShippingAddressCollection *CheckoutSessionShippingAddressCollection `json:"shipping_address_collection"` diff --git a/client/api.go b/client/api.go index a2a6d70578..e6b7d08436 100644 --- a/client/api.go +++ b/client/api.go @@ -43,6 +43,7 @@ import ( issuingcardholder "github.com/stripe/stripe-go/v72/issuing/cardholder" issuingdispute "github.com/stripe/stripe-go/v72/issuing/dispute" issuingtransaction "github.com/stripe/stripe-go/v72/issuing/transaction" + "github.com/stripe/stripe-go/v72/lineitem" "github.com/stripe/stripe-go/v72/loginlink" "github.com/stripe/stripe-go/v72/mandate" "github.com/stripe/stripe-go/v72/oauth" From 1e804922030d4dfcac51c78fdd7d135d54c33ba1 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com> Date: Tue, 31 Aug 2021 18:13:08 -0400 Subject: [PATCH 2/3] Update client/api.go --- client/api.go | 1 - 1 file changed, 1 deletion(-) diff --git a/client/api.go b/client/api.go index e6b7d08436..a2a6d70578 100644 --- a/client/api.go +++ b/client/api.go @@ -43,7 +43,6 @@ import ( issuingcardholder "github.com/stripe/stripe-go/v72/issuing/cardholder" issuingdispute "github.com/stripe/stripe-go/v72/issuing/dispute" issuingtransaction "github.com/stripe/stripe-go/v72/issuing/transaction" - "github.com/stripe/stripe-go/v72/lineitem" "github.com/stripe/stripe-go/v72/loginlink" "github.com/stripe/stripe-go/v72/mandate" "github.com/stripe/stripe-go/v72/oauth" From 6765d32cdb69bf0e5a9c894bb9472129ce7ff420 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 31 Aug 2021 19:28:16 -0400 Subject: [PATCH 3/3] Fix checkout_session literal --- checkout_session.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/checkout_session.go b/checkout_session.go index 19b36e4717..615ceb5c19 100644 --- a/checkout_session.go +++ b/checkout_session.go @@ -84,6 +84,16 @@ const ( CheckoutSessionConsentPromotionsOptOut CheckoutSessionConsentPromotions = "opt_out" ) +// If set to `auto`, enables the collection of customer consent for promotional communications. The Checkout +// Session will determine whether to display an option to opt into promotional communication +// from the merchant depending on the customer's locale. Only available to US merchants. +type CheckoutSessionConsentCollectionPromotions string + +// List of values that CheckoutSessionConsentCollectionPromotions can take +const ( + CheckoutSessionConsentCollectionPromotionsAuto CheckoutSessionConsentCollectionPromotions = "auto" +) + // CheckoutSessionCustomerDetailsTaxExempt is the list of allowed values for // tax_exempt inside customer_details of a checkout session. type CheckoutSessionCustomerDetailsTaxExempt string @@ -431,7 +441,7 @@ type CheckoutSessionConsent struct { // When set, provides configuration for the Checkout Session to gather active consent from customers. type CheckoutSessionConsentCollection struct { - Promotions *string `json:"promotions"` + Promotions CheckoutSessionConsentCollectionPromotions `json:"promotions"` } // CheckoutSessionCustomerDetailsTaxIDs represent customer's tax IDs at the