-
Notifications
You must be signed in to change notification settings - Fork 448
/
paymentmethod.go
516 lines (446 loc) · 21.5 KB
/
paymentmethod.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
511
512
513
514
515
516
//
//
// File generated from our OpenAPI spec
//
//
package stripe
import "encoding/json"
// PaymentMethodFPXAccountHolderType is a list of string values that FPX AccountHolderType accepts.
type PaymentMethodFPXAccountHolderType string
// List of values that PaymentMethodFPXAccountHolderType can take
const (
PaymentMethodFPXAccountHolderTypeCompany PaymentMethodFPXAccountHolderType = "company"
PaymentMethodFPXAccountHolderTypeIndividual PaymentMethodFPXAccountHolderType = "individual"
)
// PaymentMethodType is the list of allowed values for the payment method type.
type PaymentMethodType string
// List of values that PaymentMethodType can take.
const (
PaymentMethodTypeACSSDebit PaymentMethodType = "acss_debit"
PaymentMethodTypeAfterpayClearpay PaymentMethodType = "afterpay_clearpay"
PaymentMethodTypeAlipay PaymentMethodType = "alipay"
PaymentMethodTypeAUBECSDebit PaymentMethodType = "au_becs_debit"
PaymentMethodTypeBACSDebit PaymentMethodType = "bacs_debit"
PaymentMethodTypeBancontact PaymentMethodType = "bancontact"
PaymentMethodTypeBoleto PaymentMethodType = "boleto"
PaymentMethodTypeCard PaymentMethodType = "card"
PaymentMethodTypeCardPresent PaymentMethodType = "card_present"
PaymentMethodTypeEPS PaymentMethodType = "eps"
PaymentMethodTypeFPX PaymentMethodType = "fpx"
PaymentMethodTypeGiropay PaymentMethodType = "giropay"
PaymentMethodTypeGrabpay PaymentMethodType = "grabpay"
PaymentMethodTypeIdeal PaymentMethodType = "ideal"
PaymentMethodTypeInteracPresent PaymentMethodType = "interac_present"
PaymentMethodTypeKlarna PaymentMethodType = "klarna"
PaymentMethodTypeOXXO PaymentMethodType = "oxxo"
PaymentMethodTypeP24 PaymentMethodType = "p24"
PaymentMethodTypeSepaDebit PaymentMethodType = "sepa_debit"
PaymentMethodTypeSofort PaymentMethodType = "sofort"
PaymentMethodTypeWechatPay PaymentMethodType = "wechat_pay"
)
// PaymentMethodCardBrand is the list of allowed values for the brand property on a
// Card PaymentMethod.
type PaymentMethodCardBrand string
// List of values that PaymentMethodCardBrand can take.
const (
PaymentMethodCardBrandAmex PaymentMethodCardBrand = "amex"
PaymentMethodCardBrandDiners PaymentMethodCardBrand = "diners"
PaymentMethodCardBrandDiscover PaymentMethodCardBrand = "discover"
PaymentMethodCardBrandJCB PaymentMethodCardBrand = "jcb"
PaymentMethodCardBrandMastercard PaymentMethodCardBrand = "mastercard"
PaymentMethodCardBrandUnionpay PaymentMethodCardBrand = "unionpay"
PaymentMethodCardBrandUnknown PaymentMethodCardBrand = "unknown"
PaymentMethodCardBrandVisa PaymentMethodCardBrand = "visa"
)
// PaymentMethodCardNetwork is the list of allowed values to represent the network
// used for a card-like transaction.
type PaymentMethodCardNetwork string
// List of values that PaymentMethodCardNetwork can take.
const (
PaymentMethodCardNetworkAmex PaymentMethodCardNetwork = "amex"
PaymentMethodCardNetworkDiners PaymentMethodCardNetwork = "diners"
PaymentMethodCardNetworkDiscover PaymentMethodCardNetwork = "discover"
PaymentMethodCardNetworkInterac PaymentMethodCardNetwork = "interac"
PaymentMethodCardNetworkJCB PaymentMethodCardNetwork = "jcb"
PaymentMethodCardNetworkMastercard PaymentMethodCardNetwork = "mastercard"
PaymentMethodCardNetworkUnionpay PaymentMethodCardNetwork = "unionpay"
PaymentMethodCardNetworkUnknown PaymentMethodCardNetwork = "unknown"
PaymentMethodCardNetworkVisa PaymentMethodCardNetwork = "visa"
)
// PaymentMethodCardWalletType is the list of allowed values for the type a wallet can take on
// a Card PaymentMethod.
type PaymentMethodCardWalletType string
// List of values that PaymentMethodCardWalletType can take.
const (
PaymentMethodCardWalletTypeAmexExpressCheckout PaymentMethodCardWalletType = "amex_express_checkout"
PaymentMethodCardWalletTypeApplePay PaymentMethodCardWalletType = "apple_pay"
PaymentMethodCardWalletTypeGooglePay PaymentMethodCardWalletType = "google_pay"
PaymentMethodCardWalletTypeMasterpass PaymentMethodCardWalletType = "masterpass"
PaymentMethodCardWalletTypeSamsungPay PaymentMethodCardWalletType = "samsung_pay"
PaymentMethodCardWalletTypeVisaCheckout PaymentMethodCardWalletType = "visa_checkout"
)
// BillingDetailsParams is the set of parameters that can be used as billing details
// when creating or updating a PaymentMethod
type BillingDetailsParams struct {
Address *AddressParams `form:"address"`
Email *string `form:"email"`
Name *string `form:"name"`
Phone *string `form:"phone"`
}
// PaymentMethodACSSDebitParams TODO
type PaymentMethodACSSDebitParams struct {
AccountNumber *string `form:"account_number"`
InstitutionNumber *string `form:"institution_number"`
TransitNumber *string `form:"transit_number"`
}
// PaymentMethodAfterpayClearpayParams is the set of parameters allowed for the
// `afterpay_clearpay` hash when creating a PaymentMethod of type AfterpayClearpay.
type PaymentMethodAfterpayClearpayParams struct{}
// PaymentMethodAlipayParams is the set of parameters allowed for the `alipay` hash when creating a
// PaymentMethod of type Alipay.
type PaymentMethodAlipayParams struct{}
// PaymentMethodAUBECSDebitParams is the set of parameters allowed for the `AUBECSDebit` hash when creating a
// PaymentMethod of type AUBECSDebit.
type PaymentMethodAUBECSDebitParams struct {
AccountNumber *string `form:"account_number"`
BSBNumber *string `form:"bsb_number"`
}
// PaymentMethodBACSDebitParams is the set of parameters allowed for BACS Debit payment method.
type PaymentMethodBACSDebitParams struct {
AccountNumber *string `form:"account_number"`
SortCode *string `form:"sort_code"`
}
// PaymentMethodBancontactParams is the set of parameters allowed for the `bancontact` hash when creating a
// PaymentMethod of type Bancontact.
type PaymentMethodBancontactParams struct{}
// PaymentMethodBoletoParams is the set of parameters allowed for the `boleto` hash when creating a
// PaymentMethod of type Boleto
type PaymentMethodBoletoParams struct {
TaxID *string `form:"tax_id"`
}
// PaymentMethodCardParams is the set of parameters allowed for the `card` hash when creating a
// PaymentMethod of type card.
type PaymentMethodCardParams struct {
CVC *string `form:"cvc"`
ExpMonth *string `form:"exp_month"`
ExpYear *string `form:"exp_year"`
Number *string `form:"number"`
Token *string `form:"token"`
}
// PaymentMethodEPSParams is the set of parameters allowed for the `eps` hash when creating a
// PaymentMethod of type EPS.
type PaymentMethodEPSParams struct {
Bank *string `form:"bank"`
}
// PaymentMethodFPXParams is the set of parameters allowed for the `fpx` hash when creating a
// PaymentMethod of type fpx.
type PaymentMethodFPXParams struct {
AccountHolderType *string `form:"account_holder_type"`
Bank *string `form:"bank"`
}
// PaymentMethodGiropayParams is the set of parameters allowed for the `giropay` hash when creating a
// PaymentMethod of type Giropay.
type PaymentMethodGiropayParams struct{}
// PaymentMethodGrabpayParams is the set of parameters allowed for the `grabpay` hash when creating a
// PaymentMethod of type Grabpay.
type PaymentMethodGrabpayParams struct{}
// PaymentMethodIdealParams is the set of parameters allowed for the `ideal` hash when creating a
// PaymentMethod of type ideal.
type PaymentMethodIdealParams struct {
Bank *string `form:"bank"`
}
// PaymentMethodInteracPresentParams is the set of parameters allowed for the `interac_present` hash when creating a
// PaymentMethod of type interac_present.
type PaymentMethodInteracPresentParams struct{}
// Customer's date of birth
type PaymentMethodKlarnaDOBParams struct {
Day *int64 `form:"day"`
Month *int64 `form:"month"`
Year *int64 `form:"year"`
}
// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method.
type PaymentMethodKlarnaParams struct {
DOB *PaymentMethodKlarnaDOBParams `form:"dob"`
}
// PaymentMethodOXXOParams is the set of parameters allowed for the `oxxo` hash when creating a
// PaymentMethod of type OXXO.
type PaymentMethodOXXOParams struct{}
// PaymentMethodP24Params is the set of parameters allowed for the `p24` hash when creating a
// PaymentMethod of type P24.
type PaymentMethodP24Params struct {
Bank *string `form:"bank"`
TOSShownAndAccepted *bool `form:"tos_shown_and_accepted"`
}
// PaymentMethodSepaDebitParams is the set of parameters allowed for the `sepa_debit` hash when
// creating a PaymentMethod of type sepa_debit.
type PaymentMethodSepaDebitParams struct {
Iban *string `form:"iban"`
}
// PaymentMethodSofortParams is the set of parameters allowed for the `sofort` hash when
// creating a PaymentMethod of type sofort.
type PaymentMethodSofortParams struct {
Country *string `form:"country"`
}
// PaymentMethodWechatPayParams is the set of parameters allowed for the `wechat_pay` hash when
// creating a PaymentMethod of type wechat_pay.
type PaymentMethodWechatPayParams struct{}
// PaymentMethodParams is the set of parameters that can be used when creating or updating a
// PaymentMethod.
type PaymentMethodParams struct {
Params `form:"*"`
ACSSDebit *PaymentMethodACSSDebitParams `form:"acss_debit"`
AfterpayClearpay *PaymentMethodAfterpayClearpayParams `form:"afterpay_clearpay"`
Alipay *PaymentMethodAlipayParams `form:"alipay"`
AUBECSDebit *PaymentMethodAUBECSDebitParams `form:"au_becs_debit"`
BACSDebit *PaymentMethodBACSDebitParams `form:"bacs_debit"`
Bancontact *PaymentMethodBancontactParams `form:"bancontact"`
BillingDetails *BillingDetailsParams `form:"billing_details"`
Boleto *PaymentMethodBoletoParams `form:"boleto"`
Card *PaymentMethodCardParams `form:"card"`
EPS *PaymentMethodEPSParams `form:"eps"`
FPX *PaymentMethodFPXParams `form:"fpx"`
Giropay *PaymentMethodGiropayParams `form:"giropay"`
Grabpay *PaymentMethodGrabpayParams `form:"grabpay"`
Ideal *PaymentMethodIdealParams `form:"ideal"`
InteracPresent *PaymentMethodInteracPresentParams `form:"interac_present"`
Klarna *PaymentMethodKlarnaParams `form:"klarna"`
OXXO *PaymentMethodOXXOParams `form:"oxxo"`
P24 *PaymentMethodP24Params `form:"p24"`
SepaDebit *PaymentMethodSepaDebitParams `form:"sepa_debit"`
Sofort *PaymentMethodSofortParams `form:"sofort"`
Type *string `form:"type"`
WechatPay *PaymentMethodWechatPayParams `form:"wechat_pay"`
// The following parameters are used when cloning a PaymentMethod to the connected account
Customer *string `form:"customer"`
PaymentMethod *string `form:"payment_method"`
}
// PaymentMethodAttachParams is the set of parameters that can be used when attaching a
// PaymentMethod to a Customer.
type PaymentMethodAttachParams struct {
Params `form:"*"`
Customer *string `form:"customer"`
}
// PaymentMethodDetachParams is the set of parameters that can be used when detaching a
// PaymentMethod.
type PaymentMethodDetachParams struct {
Params `form:"*"`
}
// PaymentMethodListParams is the set of parameters that can be used when listing PaymentMethods.
type PaymentMethodListParams struct {
ListParams `form:"*"`
Customer *string `form:"customer"`
Type *string `form:"type"`
}
// BillingDetails represents the billing details associated with a PaymentMethod.
type BillingDetails struct {
Address *Address `json:"address"`
Email string `json:"email"`
Name string `json:"name"`
Phone string `json:"phone"`
}
// PaymentMethodACSSDebit TODO
type PaymentMethodACSSDebit struct {
BankName string `json:"bank_name"`
Fingerprint string `json:"fingerprint"`
InstitutionNumber string `json:"institution_number"`
Last4 string `json:"last4"`
TransitNumber string `json:"transit_number"`
}
// PaymentMethodAfterpayClearpay represents the AfterpayClearpay properties.
type PaymentMethodAfterpayClearpay struct{}
// PaymentMethodAlipay represents the Alipay properties.
type PaymentMethodAlipay struct{}
// PaymentMethodAUBECSDebit represents AUBECSDebit-specific properties (Australia Only).
type PaymentMethodAUBECSDebit struct {
BSBNumber string `json:"bsb_number"`
Fingerprint string `json:"fingerprint"`
Last4 string `json:"last4"`
}
// PaymentMethodBACSDebit represents the BACS Debit properties.
type PaymentMethodBACSDebit struct {
Fingerprint string `json:"fingerprint"`
Last4 string `json:"last4"`
SortCode string `json:"sort_code"`
}
// PaymentMethodBancontact represents the Bancontact properties.
type PaymentMethodBancontact struct{}
// PaymentMethodBoleto represents the Boleto properties.
type PaymentMethodBoleto struct {
TaxID string `json:"tax_id"`
}
// PaymentMethodCardChecks represents the checks associated with a Card PaymentMethod.
type PaymentMethodCardChecks struct {
AddressLine1Check CardVerification `json:"address_line1_check"`
AddressPostalCodeCheck CardVerification `json:"address_postal_code_check"`
CVCCheck CardVerification `json:"cvc_check"`
}
// PaymentMethodCardNetworks represents the card networks that can be used to process the payment.
type PaymentMethodCardNetworks struct {
Available []PaymentMethodCardNetwork `json:"available"`
Preferred PaymentMethodCardNetwork `json:"preferred"`
}
// PaymentMethodCardThreeDSecureUsage represents the 3DS usage for that Card PaymentMethod.
type PaymentMethodCardThreeDSecureUsage struct {
Supported bool `json:"supported"`
}
type PaymentMethodCardWalletAmexExpressCheckout struct{}
type PaymentMethodCardWalletApplePay struct{}
type PaymentMethodCardWalletGooglePay struct{}
type PaymentMethodCardWalletMasterpass struct {
BillingAddress *Address `json:"billing_address"`
Email string `json:"email"`
Name string `json:"name"`
ShippingAddress *Address `json:"shipping_address"`
}
type PaymentMethodCardWalletSamsungPay struct{}
type PaymentMethodCardWalletVisaCheckout struct {
BillingAddress *Address `json:"billing_address"`
Email string `json:"email"`
Name string `json:"name"`
ShippingAddress *Address `json:"shipping_address"`
}
// PaymentMethodCardWallet represents the details of the card wallet if this Card PaymentMethod
// is part of a card wallet.
type PaymentMethodCardWallet struct {
AmexExpressCheckout *PaymentMethodCardWalletAmexExpressCheckout `json:"amex_express_checkout"`
ApplePay *PaymentMethodCardWalletApplePay `json:"apple_pay"`
DynamicLast4 string `json:"dynamic_last4"`
GooglePay *PaymentMethodCardWalletGooglePay `json:"google_pay"`
Masterpass *PaymentMethodCardWalletMasterpass `json:"masterpass"`
SamsungPay *PaymentMethodCardWalletSamsungPay `json:"samsung_pay"`
Type PaymentMethodCardWalletType `json:"type"`
VisaCheckout *PaymentMethodCardWalletVisaCheckout `json:"visa_checkout"`
}
// PaymentMethodCard represents the card-specific properties.
type PaymentMethodCard struct {
Brand PaymentMethodCardBrand `json:"brand"`
Checks *PaymentMethodCardChecks `json:"checks"`
Country string `json:"country"`
ExpMonth uint64 `json:"exp_month"`
ExpYear uint64 `json:"exp_year"`
Fingerprint string `json:"fingerprint"`
Funding CardFunding `json:"funding"`
Last4 string `json:"last4"`
Networks *PaymentMethodCardNetworks `json:"networks"`
ThreeDSecureUsage *PaymentMethodCardThreeDSecureUsage `json:"three_d_secure_usage"`
Wallet *PaymentMethodCardWallet `json:"wallet"`
// Please note that the fields below are for internal use only and are not returned
// as part of standard API requests.
Description string `json:"description"`
IIN string `json:"iin"`
Issuer string `json:"issuer"`
}
// PaymentMethodCardPresent represents the card-present-specific properties.
type PaymentMethodCardPresent struct{}
// PaymentMethodEPS represents the EPS properties.
type PaymentMethodEPS struct {
Bank string `json:"bank"`
}
// PaymentMethodFPX represents FPX-specific properties (Malaysia Only).
type PaymentMethodFPX struct {
AccountHolderType PaymentMethodFPXAccountHolderType `json:"account_holder_type"`
Bank string `json:"bank"`
TransactionID string `json:"transaction_id"`
}
// PaymentMethodGiropay represents the Giropay properties.
type PaymentMethodGiropay struct{}
// PaymentMethodGrabpay represents the Grabpay properties.
type PaymentMethodGrabpay struct{}
// PaymentMethodIdeal represents the iDEAL-specific properties.
type PaymentMethodIdeal struct {
Bank string `json:"bank"`
Bic string `json:"bic"`
}
// PaymentMethodInteracPresent represents the interac present properties.
type PaymentMethodInteracPresent struct{}
// The customer's date of birth, if provided.
type PaymentMethodKlarnaDOB struct {
Day int64 `json:"day"`
Month int64 `json:"month"`
Year int64 `json:"year"`
}
type PaymentMethodKlarna struct {
DOB *PaymentMethodKlarnaDOB `json:"dob"`
}
// PaymentMethodOXXO represents the OXXO-specific properties.
type PaymentMethodOXXO struct{}
// PaymentMethodP24 represents the P24 properties.
type PaymentMethodP24 struct {
Bank string `json:"bank"`
}
// PaymentMethodSepaDebitGeneratedFrom represents information about the object
// that generated this PaymentMethod
type PaymentMethodSepaDebitGeneratedFrom struct {
Charge *Charge `json:"charge"`
SetupAttempt *SetupAttempt `json:"setup_attempt"`
}
// PaymentMethodSepaDebit represents the SEPA-debit-specific properties.
type PaymentMethodSepaDebit struct {
BankCode string `json:"bank_code"`
BranchCode string `json:"branch_code"`
Country string `json:"country"`
Fingerprint string `json:"fingerprint"`
GeneratedFrom *PaymentMethodSepaDebitGeneratedFrom `json:"generated_from"`
Last4 string `json:"last4"`
}
// PaymentMethodSofort represents the Sofort-specific properties.
type PaymentMethodSofort struct {
Country string `json:"country"`
}
// PaymentMethodWechatPay represents the WeChatPay-specific properties.
type PaymentMethodWechatPay struct{}
// PaymentMethod is the resource representing a PaymentMethod.
type PaymentMethod struct {
APIResource
ACSSDebit *PaymentMethodACSSDebit `json:"acss_debit"`
AfterpayClearpay *PaymentMethodAfterpayClearpay `json:"afterpay_clearpay"`
Alipay *PaymentMethodAlipay `json:"alipay"`
AUBECSDebit *PaymentMethodAUBECSDebit `json:"au_becs_debit"`
BACSDebit *PaymentMethodBACSDebit `json:"bacs_debit"`
Bancontact *PaymentMethodBancontact `json:"bancontact"`
BillingDetails *BillingDetails `json:"billing_details"`
Boleto *PaymentMethodBoleto `json:"boleto"`
Card *PaymentMethodCard `json:"card"`
CardPresent *PaymentMethodCardPresent `json:"card_present"`
Created int64 `json:"created"`
Customer *Customer `json:"customer"`
EPS *PaymentMethodEPS `json:"eps"`
FPX *PaymentMethodFPX `json:"fpx"`
Giropay *PaymentMethodGiropay `json:"giropay"`
Grabpay *PaymentMethodGrabpay `json:"grabpay"`
ID string `json:"id"`
Ideal *PaymentMethodIdeal `json:"ideal"`
InteracPresent *PaymentMethodInteracPresent `json:"interac_present"`
Klarna *PaymentMethodKlarna `json:"klarna"`
Livemode bool `json:"livemode"`
Metadata map[string]string `json:"metadata"`
Object string `json:"object"`
OXXO *PaymentMethodOXXO `json:"oxxo"`
P24 *PaymentMethodP24 `json:"p24"`
SepaDebit *PaymentMethodSepaDebit `json:"sepa_debit"`
Sofort *PaymentMethodSofort `json:"sofort"`
Type PaymentMethodType `json:"type"`
WechatPay *PaymentMethodWechatPay `json:"wechat_pay"`
}
// PaymentMethodList is a list of PaymentMethods as retrieved from a list endpoint.
type PaymentMethodList struct {
APIResource
ListMeta
Data []*PaymentMethod `json:"data"`
}
// UnmarshalJSON handles deserialization of a PaymentMethod.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (p *PaymentMethod) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type paymentMethod PaymentMethod
var v paymentMethod
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = PaymentMethod(v)
return nil
}