forked from stripe/stripe-go
/
checkout_session.go
510 lines (449 loc) · 29.2 KB
/
checkout_session.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
package stripe
import (
"encoding/json"
)
// CheckoutSessionCustomerDetailsTaxIDsType is the list of allowed values for type
// on the tax_ids inside customer_details of a checkout session.
type CheckoutSessionCustomerDetailsTaxIDsType string
// List of values that CheckoutSessionCustomerDetailsTaxIDsType can take.
const (
CheckoutSessionCustomerDetailsTaxIDsTypeAETRN CheckoutSessionCustomerDetailsTaxIDsType = "ae_trn"
CheckoutSessionCustomerDetailsTaxIDsTypeAUABN CheckoutSessionCustomerDetailsTaxIDsType = "au_abn"
CheckoutSessionCustomerDetailsTaxIDsTypeBRCNPJ CheckoutSessionCustomerDetailsTaxIDsType = "br_cnpj"
CheckoutSessionCustomerDetailsTaxIDsTypeBRCPF CheckoutSessionCustomerDetailsTaxIDsType = "br_cpf"
CheckoutSessionCustomerDetailsTaxIDsTypeCABN CheckoutSessionCustomerDetailsTaxIDsType = "ca_bn"
CheckoutSessionCustomerDetailsTaxIDsTypeCAGSTHST CheckoutSessionCustomerDetailsTaxIDsType = "ca_gst_hst"
CheckoutSessionCustomerDetailsTaxIDsTypeCAPSTBC CheckoutSessionCustomerDetailsTaxIDsType = "ca_pst_bc"
CheckoutSessionCustomerDetailsTaxIDsTypeCAPSTMB CheckoutSessionCustomerDetailsTaxIDsType = "ca_pst_mb"
CheckoutSessionCustomerDetailsTaxIDsTypeCAPSTSK CheckoutSessionCustomerDetailsTaxIDsType = "ca_pst_sk"
CheckoutSessionCustomerDetailsTaxIDsTypeCAQST CheckoutSessionCustomerDetailsTaxIDsType = "ca_qst"
CheckoutSessionCustomerDetailsTaxIDsTypeCHVAT CheckoutSessionCustomerDetailsTaxIDsType = "ch_vat"
CheckoutSessionCustomerDetailsTaxIDsTypeCLTIN CheckoutSessionCustomerDetailsTaxIDsType = "cl_tin"
CheckoutSessionCustomerDetailsTaxIDsTypeESCIF CheckoutSessionCustomerDetailsTaxIDsType = "es_cif"
CheckoutSessionCustomerDetailsTaxIDsTypeEUVAT CheckoutSessionCustomerDetailsTaxIDsType = "eu_vat"
CheckoutSessionCustomerDetailsTaxIDsTypeGBVAT CheckoutSessionCustomerDetailsTaxIDsType = "gb_vat"
CheckoutSessionCustomerDetailsTaxIDsTypeHKBR CheckoutSessionCustomerDetailsTaxIDsType = "hk_br"
CheckoutSessionCustomerDetailsTaxIDsTypeIDNPWP CheckoutSessionCustomerDetailsTaxIDsType = "id_npwp"
CheckoutSessionCustomerDetailsTaxIDsTypeILVAT CheckoutSessionCustomerDetailsTaxIDsType = "il_vat"
CheckoutSessionCustomerDetailsTaxIDsTypeINGST CheckoutSessionCustomerDetailsTaxIDsType = "in_gst"
CheckoutSessionCustomerDetailsTaxIDsTypeJPCN CheckoutSessionCustomerDetailsTaxIDsType = "jp_cn"
CheckoutSessionCustomerDetailsTaxIDsTypeJPRN CheckoutSessionCustomerDetailsTaxIDsType = "jp_rn"
CheckoutSessionCustomerDetailsTaxIDsTypeKRBRN CheckoutSessionCustomerDetailsTaxIDsType = "kr_brn"
CheckoutSessionCustomerDetailsTaxIDsTypeLIUID CheckoutSessionCustomerDetailsTaxIDsType = "li_uid"
CheckoutSessionCustomerDetailsTaxIDsTypeMXRFC CheckoutSessionCustomerDetailsTaxIDsType = "mx_rfc"
CheckoutSessionCustomerDetailsTaxIDsTypeMYFRP CheckoutSessionCustomerDetailsTaxIDsType = "my_frp"
CheckoutSessionCustomerDetailsTaxIDsTypeMYITN CheckoutSessionCustomerDetailsTaxIDsType = "my_itn"
CheckoutSessionCustomerDetailsTaxIDsTypeMYSST CheckoutSessionCustomerDetailsTaxIDsType = "my_sst"
CheckoutSessionCustomerDetailsTaxIDsTypeNOVAT CheckoutSessionCustomerDetailsTaxIDsType = "no_vat"
CheckoutSessionCustomerDetailsTaxIDsTypeNZGST CheckoutSessionCustomerDetailsTaxIDsType = "nz_gst"
CheckoutSessionCustomerDetailsTaxIDsTypeRUINN CheckoutSessionCustomerDetailsTaxIDsType = "ru_inn"
CheckoutSessionCustomerDetailsTaxIDsTypeRUKPP CheckoutSessionCustomerDetailsTaxIDsType = "ru_kpp"
CheckoutSessionCustomerDetailsTaxIDsTypeSAVAT CheckoutSessionCustomerDetailsTaxIDsType = "sa_vat"
CheckoutSessionCustomerDetailsTaxIDsTypeSGGST CheckoutSessionCustomerDetailsTaxIDsType = "sg_gst"
CheckoutSessionCustomerDetailsTaxIDsTypeSGUEN CheckoutSessionCustomerDetailsTaxIDsType = "sg_uen"
CheckoutSessionCustomerDetailsTaxIDsTypeTHVAT CheckoutSessionCustomerDetailsTaxIDsType = "th_vat"
CheckoutSessionCustomerDetailsTaxIDsTypeTWVAT CheckoutSessionCustomerDetailsTaxIDsType = "tw_vat"
CheckoutSessionCustomerDetailsTaxIDsTypeUnknown CheckoutSessionCustomerDetailsTaxIDsType = "unknown"
CheckoutSessionCustomerDetailsTaxIDsTypeUSEIN CheckoutSessionCustomerDetailsTaxIDsType = "us_ein"
CheckoutSessionCustomerDetailsTaxIDsTypeZAVAT CheckoutSessionCustomerDetailsTaxIDsType = "za_vat"
)
type CheckoutSessionAutomaticTaxStatus string
const (
CheckoutSessionAutomaticTaxStatusComplete CheckoutSessionAutomaticTaxStatus = "complete"
CheckoutSessionAutomaticTaxStatusFailed CheckoutSessionAutomaticTaxStatus = "failed"
CheckoutSessionAutomaticTaxStatusRequiresLocationInputs CheckoutSessionAutomaticTaxStatus = "requires_location_inputs"
)
// CheckoutSessionCustomerDetailsTaxExempt is the list of allowed values for
// tax_exempt inside customer_details of a checkout session.
type CheckoutSessionCustomerDetailsTaxExempt string
// List of values that CheckoutSessionCustomerDetailsTaxExempt can take.
const (
CheckoutSessionCustomerDetailsTaxExemptExempt CheckoutSessionCustomerDetailsTaxExempt = "exempt"
CheckoutSessionCustomerDetailsTaxExemptNone CheckoutSessionCustomerDetailsTaxExempt = "none"
CheckoutSessionCustomerDetailsTaxExemptReverse CheckoutSessionCustomerDetailsTaxExempt = "reverse"
)
// CheckoutSessionMode is the list of allowed values for the mode on a Session.
type CheckoutSessionMode string
// List of values that CheckoutSessionMode can take.
const (
CheckoutSessionModePayment CheckoutSessionMode = "payment"
CheckoutSessionModeSetup CheckoutSessionMode = "setup"
CheckoutSessionModeSubscription CheckoutSessionMode = "subscription"
)
// CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule is the list of allowed values for payment_schedule
type CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule string
// List of values that CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule can take
const (
CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsPaymentScheduleCombined CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule = "combined"
CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsPaymentScheduleInterval CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule = "interval"
CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsPaymentScheduleSporadic CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule = "sporadic"
)
// CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsTransactionType is the list of allowed values for transaction_type
type CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsTransactionType string
// List of values that CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsTransactionType can take
const (
CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypeBusiness CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "business"
CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypePersonal CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "personal"
)
// CheckoutSessionPaymentMethodOptionsACSSDebitVerificationMethod is the list of allowed values for verification_method
type CheckoutSessionPaymentMethodOptionsACSSDebitVerificationMethod string
// List of values that CheckoutSessionPaymentMethodOptionsACSSDebitVerificationMethod can take
const (
CheckoutSessionPaymentMethodOptionsACSSDebitVerificationMethodAutomatic CheckoutSessionPaymentMethodOptionsACSSDebitVerificationMethod = "automatic"
CheckoutSessionPaymentMethodOptionsACSSDebitVerificationMethodInstant CheckoutSessionPaymentMethodOptionsACSSDebitVerificationMethod = "instant"
CheckoutSessionPaymentMethodOptionsACSSDebitVerificationMethodMicrodeposits CheckoutSessionPaymentMethodOptionsACSSDebitVerificationMethod = "microdeposits"
)
// CheckoutSessionPaymentStatus is the list of allowed values for the payment status on a Session.`
type CheckoutSessionPaymentStatus string
// List of values that CheckoutSessionPaymentStatus can take.
const (
CheckoutSessionPaymentStatusNoPaymentRequired CheckoutSessionPaymentStatus = "no_payment_required"
CheckoutSessionPaymentStatusPaid CheckoutSessionPaymentStatus = "paid"
CheckoutSessionPaymentStatusUnpaid CheckoutSessionPaymentStatus = "unpaid"
)
// CheckoutSessionSubmitType is the list of allowed values for the submit type on a Session.
type CheckoutSessionSubmitType string
// List of values that CheckoutSessionSubmitType can take.
const (
CheckoutSessionSubmitTypeAuto CheckoutSessionSubmitType = "auto"
CheckoutSessionSubmitTypeBook CheckoutSessionSubmitType = "book"
CheckoutSessionSubmitTypeDonate CheckoutSessionSubmitType = "donate"
CheckoutSessionSubmitTypePay CheckoutSessionSubmitType = "pay"
)
// CheckoutSessionLineItemAdjustableQuantityParams represents the parameters for
// an adjustable quantity on a checkout session's line items.
type CheckoutSessionLineItemAdjustableQuantityParams struct {
Enabled *bool `form:"enabled"`
Maximum *int64 `form:"maximum"`
Minimum *int64 `form:"minimum"`
}
// CheckoutSessionLineItemPriceDataProductDataParams is the set of parameters that can be used when
// creating a product created inline for a line item.
type CheckoutSessionLineItemPriceDataProductDataParams struct {
Description *string `form:"description"`
Images []*string `form:"images"`
Metadata map[string]string `form:"metadata"`
Name *string `form:"name"`
TaxCode *string `form:"tax_code"`
}
// CheckoutSessionLineItemPriceDataRecurringParams is the set of parameters for the recurring
// components of a price created inline for a line item.
type CheckoutSessionLineItemPriceDataRecurringParams struct {
AggregateUsage *string `form:"aggregate_usage"`
Interval *string `form:"interval"`
IntervalCount *int64 `form:"interval_count"`
TrialPeriodDays *int64 `form:"trial_period_days"`
UsageType *string `form:"usage_type"`
}
// CheckoutSessionLineItemPriceDataParams is a structure representing the parameters to create
// an inline price for a line item.
type CheckoutSessionLineItemPriceDataParams struct {
Currency *string `form:"currency"`
Product *string `form:"product"`
ProductData *CheckoutSessionLineItemPriceDataProductDataParams `form:"product_data"`
Recurring *CheckoutSessionLineItemPriceDataRecurringParams `form:"recurring"`
TaxBehavior *string `form:"tax_behavior"`
UnitAmount *int64 `form:"unit_amount"`
UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"`
}
type CheckoutSessionAutomaticTaxParams struct {
Enabled *bool `form:"enabled"`
}
type CheckoutSessionCustomerUpdateParams struct {
Address *string `form:"address"`
Name *string `form:"name"`
Shipping *string `form:"shipping"`
}
// CheckoutSessionDiscountParams is the set of parameters allowed for discounts on
// a checkout session.
type CheckoutSessionDiscountParams struct {
Coupon *string `form:"coupon"`
PromotionCode *string `form:"promotion_code"`
}
// CheckoutSessionLineItemParams is the set of parameters allowed for a line item
// on a checkout session.
type CheckoutSessionLineItemParams struct {
AdjustableQuantity *CheckoutSessionLineItemAdjustableQuantityParams `form:"adjustable_quantity"`
Amount *int64 `form:"amount"`
Currency *string `form:"currency"`
Description *string `form:"description"`
DynamicTaxRates []*string `form:"dynamic_tax_rates"`
Images []*string `form:"images"`
Name *string `form:"name"`
Price *string `form:"price"`
PriceData *CheckoutSessionLineItemPriceDataParams `form:"price_data"`
Quantity *int64 `form:"quantity"`
TaxRates []*string `form:"tax_rates"`
}
// CheckoutSessionPaymentIntentDataTransferDataParams is the set of parameters allowed for the
// transfer_data hash.
type CheckoutSessionPaymentIntentDataTransferDataParams struct {
Amount *int64 `form:"amount"`
Destination *string `form:"destination"`
}
// CheckoutSessionPaymentIntentDataParams is the set of parameters allowed for the
// payment intent creation on a checkout session.
type CheckoutSessionPaymentIntentDataParams struct {
Params `form:"*"`
ApplicationFeeAmount *int64 `form:"application_fee_amount"`
CaptureMethod *string `form:"capture_method"`
Description *string `form:"description"`
Metadata map[string]string `form:"metadata"`
OnBehalfOf *string `form:"on_behalf_of"`
ReceiptEmail *string `form:"receipt_email"`
SetupFutureUsage *string `form:"setup_future_usage"`
Shipping *ShippingDetailsParams `form:"shipping"`
StatementDescriptor *string `form:"statement_descriptor"`
StatementDescriptorSuffix *string `form:"statement_descriptor_suffix"`
TransferData *CheckoutSessionPaymentIntentDataTransferDataParams `form:"transfer_data"`
TransferGroup *string `form:"transfer_group"`
}
// CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsParams is the set of parameters allowed for mandate_options for acss debit.
type CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsParams struct {
CustomMandateURL *string `form:"custom_mandate_url"`
IntervalDescription *string `form:"interval_description"`
PaymentSchedule *string `form:"payment_schedule"`
TransactionType *string `form:"transaction_type"`
}
// CheckoutSessionPaymentMethodOptionsACSSDebitParams is the set of parameters allowed for acss_debit on payment_method_options.
type CheckoutSessionPaymentMethodOptionsACSSDebitParams struct {
Currency *string `form:"currency"`
MandateOptions *CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsParams `form:"mandate_options"`
VerificationMethod *string `form:"verification_method"`
}
// CheckoutSessionPaymentMethodOptionsBoletoParams is the set of parameters allowed for boleto on payment_method_options.
type CheckoutSessionPaymentMethodOptionsBoletoParams struct {
ExpiresAfterDays *int64 `form:"expires_after_days"`
}
// CheckoutSessionPaymentMethodOptionsOXXOParams is the set of parameters allowed for oxxo on payment_method_options.
type CheckoutSessionPaymentMethodOptionsOXXOParams struct {
ExpiresAfterDays *int64 `form:"expires_after_days"`
}
// CheckoutSessionPaymentMethodOptionsWechatPayParams is the set of parameters allowed for wechat_pay on payment_method_options.
type CheckoutSessionPaymentMethodOptionsWechatPayParams struct {
AppID *string `form:"app_id"`
Client *string `form:"client"`
}
// CheckoutSessionPaymentMethodOptionsParams is the set of allowed parameters for payment_method_options on a checkout session.
type CheckoutSessionPaymentMethodOptionsParams struct {
ACSSDebit *CheckoutSessionPaymentMethodOptionsACSSDebitParams `form:"acss_debit"`
Boleto *CheckoutSessionPaymentMethodOptionsBoletoParams `form:"boleto"`
OXXO *CheckoutSessionPaymentMethodOptionsOXXOParams `form:"oxxo"`
WechatPay *CheckoutSessionPaymentMethodOptionsWechatPayParams `form:"wechat_pay"`
}
// CheckoutSessionSetupIntentDataParams is the set of parameters allowed for the setup intent
// creation on a checkout session.
type CheckoutSessionSetupIntentDataParams struct {
Params `form:"*"`
Description *string `form:"description"`
OnBehalfOf *string `form:"on_behalf_of"`
}
// CheckoutSessionShippingAddressCollectionParams is the set of parameters allowed for the
// shipping address collection.
type CheckoutSessionShippingAddressCollectionParams struct {
AllowedCountries []*string `form:"allowed_countries"`
}
// CheckoutSessionSubscriptionDataItemsParams is the set of parameters allowed for one item on a
// checkout session associated with a subscription.
type CheckoutSessionSubscriptionDataItemsParams struct {
Plan *string `form:"plan"`
Quantity *int64 `form:"quantity"`
TaxRates []*string `form:"tax_rates"`
}
// CheckoutSessionSubscriptionDataTransferDataParams is the set of parameters allowed
// for the transfer_data hash.
type CheckoutSessionSubscriptionDataTransferDataParams struct {
AmountPercent *float64 `form:"amount_percent"`
Destination *string `form:"destination"`
}
// CheckoutSessionSubscriptionDataParams is the set of parameters allowed for the subscription
// creation on a checkout session.
type CheckoutSessionSubscriptionDataParams struct {
Params `form:"*"`
ApplicationFeePercent *float64 `form:"application_fee_percent"`
Coupon *string `form:"coupon"`
DefaultTaxRates []*string `form:"default_tax_rates"`
Items []*CheckoutSessionSubscriptionDataItemsParams `form:"items"`
Metadata map[string]string `form:"metadata"`
TransferData *CheckoutSessionSubscriptionDataTransferDataParams `form:"transfer_data"`
TrialEnd *int64 `form:"trial_end"`
TrialFromPlan *bool `form:"trial_from_plan"`
TrialPeriodDays *int64 `form:"trial_period_days"`
}
type CheckoutSessionTaxIDCollectionParams struct {
Enabled *bool `form:"enabled"`
}
// CheckoutSessionParams is the set of parameters that can be used when creating
// a checkout session.
// For more details see https://stripe.com/docs/api/checkout/sessions/create
type CheckoutSessionParams struct {
Params `form:"*"`
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"`
Customer *string `form:"customer"`
CustomerEmail *string `form:"customer_email"`
CustomerUpdate *CheckoutSessionCustomerUpdateParams `form:"customer_update"`
Discounts []*CheckoutSessionDiscountParams `form:"discounts"`
LineItems []*CheckoutSessionLineItemParams `form:"line_items"`
Locale *string `form:"locale"`
Mode *string `form:"mode"`
PaymentIntentData *CheckoutSessionPaymentIntentDataParams `form:"payment_intent_data"`
PaymentMethodOptions *CheckoutSessionPaymentMethodOptionsParams `form:"payment_method_options"`
PaymentMethodTypes []*string `form:"payment_method_types"`
SetupIntentData *CheckoutSessionSetupIntentDataParams `form:"setup_intent_data"`
ShippingAddressCollection *CheckoutSessionShippingAddressCollectionParams `form:"shipping_address_collection"`
ShippingRates []*string `form:"shipping_rates"`
SubmitType *string `form:"submit_type"`
SubscriptionData *CheckoutSessionSubscriptionDataParams `form:"subscription_data"`
SuccessURL *string `form:"success_url"`
TaxIDCollection *CheckoutSessionTaxIDCollectionParams `form:"tax_id_collection"`
}
type CheckoutSessionAutomaticTax struct {
Enabled bool `json:"enabled"`
Status CheckoutSessionAutomaticTaxStatus `json:"status"`
}
// CheckoutSessionListLineItemsParams is the set of parameters that can be
// used when listing line items on a session.
type CheckoutSessionListLineItemsParams struct {
ListParams `form:"*"`
Session *string `form:"-"` // Included in URL
}
// CheckoutSessionListParams is the set of parameters that can be
// used when listing sessions.
// For more details see: https://stripe.com/docs/api/checkout/sessions/list
type CheckoutSessionListParams struct {
ListParams `form:"*"`
PaymentIntent *string `form:"payment_intent"`
Subscription *string `form:"subscription"`
}
// CheckoutSessionCustomerDetailsTaxIDs represent customer's tax IDs at the
// time of checkout.
type CheckoutSessionCustomerDetailsTaxIDs struct {
Type CheckoutSessionCustomerDetailsTaxIDsType `json:"type"`
Value string `json:"value"`
}
// CheckoutSessionCustomerDetails represent the customer details including
// the tax exempt status and the customer's tax IDs.
type CheckoutSessionCustomerDetails struct {
Email string `json:"email"`
TaxExempt CheckoutSessionCustomerDetailsTaxExempt `json:"tax_exempt"`
TaxIDs []*CheckoutSessionCustomerDetailsTaxIDs `json:"tax_ids"`
}
// CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptions represent mandate options for acss debit.
type CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptions struct {
CustomMandateURL string `json:"custom_mandate_url"`
IntervalDescription string `json:"interval_description"`
PaymentSchedule CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule `json:"payment_schedule"`
TransactionType CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptionsTransactionType `json:"transaction_type"`
}
// CheckoutSessionPaymentMethodOptionsACSSDebit represent the options for acss debit on payment_method_options.
type CheckoutSessionPaymentMethodOptionsACSSDebit struct {
Currency string `json:"currency"`
MandateOptions *CheckoutSessionPaymentMethodOptionsACSSDebitMandateOptions `json:"mandate_options"`
VerificationMethod CheckoutSessionPaymentMethodOptionsACSSDebitVerificationMethod `json:"verification_method"`
}
// CheckoutSessionPaymentMethodOptionsBoleto represent the options for boleto on payment_method_options.
type CheckoutSessionPaymentMethodOptionsBoleto struct {
ExpiresAfterDays int64 `json:"expires_after_days"`
}
// CheckoutSessionPaymentMethodOptionsOXXO represent the options for oxxo on payment_method_options.
type CheckoutSessionPaymentMethodOptionsOXXO struct {
ExpiresAfterDays int64 `json:"expires_after_days"`
}
// CheckoutSessionPaymentMethodOptions represent payment-method-specific options for a checkout session.
type CheckoutSessionPaymentMethodOptions struct {
ACSSDebit *CheckoutSessionPaymentMethodOptionsACSSDebit `json:"acss_debit"`
Boleto *CheckoutSessionPaymentMethodOptionsBoleto `json:"boleto"`
OXXO *CheckoutSessionPaymentMethodOptionsOXXO `json:"oxxo"`
}
// CheckoutSessionShippingAddressCollection is the set of parameters allowed for the
// shipping address collection.
type CheckoutSessionShippingAddressCollection struct {
AllowedCountries []string `json:"allowed_countries"`
}
type CheckoutSessionTaxIDCollection struct {
Enabled bool `json:"enabled"`
}
// CheckoutSessionTotalDetailsBreakdownDiscount represent the details of one discount applied to a session.
type CheckoutSessionTotalDetailsBreakdownDiscount struct {
Amount int64 `json:"amount"`
Discount *Discount `json:"discount"`
}
// CheckoutSessionTotalDetailsBreakdownTax represent the details of tax rate applied to a session.
type CheckoutSessionTotalDetailsBreakdownTax struct {
Amount int64 `json:"amount"`
TaxRate *TaxRate `json:"tax_rate"`
}
// CheckoutSessionTotalDetailsBreakdown is the set of properties detailing a breakdown of taxes and discounts applied to a session if any.
type CheckoutSessionTotalDetailsBreakdown struct {
Discounts []*CheckoutSessionTotalDetailsBreakdownDiscount `json:"discounts"`
Taxes []*CheckoutSessionTotalDetailsBreakdownTax `json:"taxes"`
}
// CheckoutSessionTotalDetails is the set of properties detailing how the amounts were calculated.
type CheckoutSessionTotalDetails struct {
AmountDiscount int64 `json:"amount_discount"`
AmountShipping int64 `json:"amount_shipping"`
AmountTax int64 `json:"amount_tax"`
Breakdown *CheckoutSessionTotalDetailsBreakdown `json:"breakdown"`
}
// CheckoutSession is the resource representing a Stripe checkout session.
// For more details see https://stripe.com/docs/api/checkout/sessions/object
type CheckoutSession struct {
APIResource
AllowPromotionCodes bool `json:"allow_promotion_codes"`
CancelURL string `json:"cancel_url"`
CustomerDetails *CheckoutSessionCustomerDetails `json:"customer_details"`
AmountSubtotal int64 `json:"amount_subtotal"`
AmountTotal int64 `json:"amount_total"`
AutomaticTax *CheckoutSessionAutomaticTax `json:"automatic_tax"`
ClientReferenceID string `json:"client_reference_id"`
Currency Currency `json:"currency"`
Customer *Customer `json:"customer"`
CustomerEmail string `json:"customer_email"`
Deleted bool `json:"deleted"`
ID string `json:"id"`
LineItems *LineItemList `json:"line_items"`
Livemode bool `json:"livemode"`
Locale string `json:"locale"`
Metadata map[string]string `json:"metadata"`
Mode CheckoutSessionMode `json:"mode"`
Object string `json:"object"`
PaymentIntent *PaymentIntent `json:"payment_intent"`
PaymentMethodOptions *CheckoutSessionPaymentMethodOptions `json:"payment_method_options"`
PaymentMethodTypes []string `json:"payment_method_types"`
PaymentStatus CheckoutSessionPaymentStatus `json:"payment_status"`
SetupIntent *SetupIntent `json:"setup_intent"`
Shipping *ShippingDetails `json:"shipping"`
ShippingAddressCollection *CheckoutSessionShippingAddressCollection `json:"shipping_address_collection"`
Subscription *Subscription `json:"subscription"`
SubmitType CheckoutSessionSubmitType `json:"submit_type"`
SuccessURL string `json:"success_url"`
TaxIDCollection *CheckoutSessionTaxIDCollection `json:"tax_id_collection"`
TotalDetails *CheckoutSessionTotalDetails `json:"total_details"`
URL string `json:"url"`
}
// CheckoutSessionList is a list of sessions as retrieved from a list endpoint.
type CheckoutSessionList struct {
APIResource
ListMeta
Data []*CheckoutSession `json:"data"`
}
// UnmarshalJSON handles deserialization of a checkout session.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (p *CheckoutSession) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type session CheckoutSession
var v session
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = CheckoutSession(v)
return nil
}