-
Notifications
You must be signed in to change notification settings - Fork 1
/
payments.go
2479 lines (2223 loc) · 78.7 KB
/
payments.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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file was auto-generated by Fern from our API Definition.
package square
import (
json "encoding/json"
fmt "fmt"
internal "github.com/square/square-go-sdk/internal"
)
type PaymentsCancelRequest struct {
// The ID of the payment to cancel.
PaymentID string `json:"-" url:"-"`
}
type CompletePaymentRequest struct {
// The unique ID identifying the payment to be completed.
PaymentID string `json:"-" url:"-"`
// Used for optimistic concurrency. This opaque token identifies the current `Payment`
// version that the caller expects. If the server has a different version of the Payment,
// the update fails and a response with a VERSION_MISMATCH error is returned.
VersionToken *string `json:"version_token,omitempty" url:"-"`
}
type CreatePaymentRequest struct {
// The ID for the source of funds for this payment.
// This could be a payment token generated by the Web Payments SDK for any of its
// [supported methods](https://developer.squareup.com/docs/web-payments/overview#explore-payment-methods),
// including cards, bank transfers, Afterpay or Cash App Pay. If recording a payment
// that the seller received outside of Square, specify either "CASH" or "EXTERNAL".
// For more information, see
// [Take Payments](https://developer.squareup.com/docs/payments-api/take-payments).
SourceID string `json:"source_id" url:"-"`
// A unique string that identifies this `CreatePayment` request. Keys can be any valid string
// but must be unique for every `CreatePayment` request.
//
// Note: The number of allowed characters might be less than the stated maximum, if multi-byte
// characters are used.
//
// For more information, see [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency).
IdempotencyKey string `json:"idempotency_key" url:"-"`
// The amount of money to accept for this payment, not including `tip_money`.
//
// The amount must be specified in the smallest denomination of the applicable currency
// (for example, US dollar amounts are specified in cents). For more information, see
// [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).
//
// The currency code must match the currency associated with the business
// that is accepting the payment.
AmountMoney *Money `json:"amount_money,omitempty" url:"-"`
// The amount designated as a tip, in addition to `amount_money`.
//
// The amount must be specified in the smallest denomination of the applicable currency
// (for example, US dollar amounts are specified in cents). For more information, see
// [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).
//
// The currency code must match the currency associated with the business
// that is accepting the payment.
TipMoney *Money `json:"tip_money,omitempty" url:"-"`
// The amount of money that the developer is taking as a fee
// for facilitating the payment on behalf of the seller.
//
// The amount cannot be more than 90% of the total amount of the payment.
//
// The amount must be specified in the smallest denomination of the applicable currency
// (for example, US dollar amounts are specified in cents). For more information, see
// [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).
//
// The fee currency code must match the currency associated with the seller
// that is accepting the payment. The application must be from a developer
// account in the same country and using the same currency code as the seller.
//
// For more information about the application fee scenario, see
// [Take Payments and Collect Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees).
//
// To set this field, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required.
// For more information, see [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions).
AppFeeMoney *Money `json:"app_fee_money,omitempty" url:"-"`
// The duration of time after the payment's creation when Square automatically
// either completes or cancels the payment depending on the `delay_action` field value.
// For more information, see
// [Time threshold](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/delayed-capture#time-threshold).
//
// This parameter should be specified as a time duration, in RFC 3339 format.
//
// Note: This feature is only supported for card payments. This parameter can only be set for a delayed
// capture payment (`autocomplete=false`).
//
// Default:
//
// - Card-present payments: "PT36H" (36 hours) from the creation time.
// - Card-not-present payments: "P7D" (7 days) from the creation time.
DelayDuration *string `json:"delay_duration,omitempty" url:"-"`
// The action to be applied to the payment when the `delay_duration` has elapsed. The action must be
// CANCEL or COMPLETE. For more information, see
// [Time Threshold](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/delayed-capture#time-threshold).
//
// Default: CANCEL
DelayAction *string `json:"delay_action,omitempty" url:"-"`
// If set to `true`, this payment will be completed when possible. If
// set to `false`, this payment is held in an approved state until either
// explicitly completed (captured) or canceled (voided). For more information, see
// [Delayed capture](https://developer.squareup.com/docs/payments-api/take-payments/card-payments#delayed-capture-of-a-card-payment).
//
// Default: true
Autocomplete *bool `json:"autocomplete,omitempty" url:"-"`
// Associates a previously created order with this payment.
OrderID *string `json:"order_id,omitempty" url:"-"`
// The [Customer](entity:Customer) ID of the customer associated with the payment.
//
// This is required if the `source_id` refers to a card on file created using the Cards API.
CustomerID *string `json:"customer_id,omitempty" url:"-"`
// The location ID to associate with the payment. If not specified, the [main location](https://developer.squareup.com/docs/locations-api#about-the-main-location) is
// used.
LocationID *string `json:"location_id,omitempty" url:"-"`
// An optional [TeamMember](entity:TeamMember) ID to associate with
// this payment.
TeamMemberID *string `json:"team_member_id,omitempty" url:"-"`
// A user-defined ID to associate with the payment.
//
// You can use this field to associate the payment to an entity in an external system
// (for example, you might specify an order ID that is generated by a third-party shopping cart).
ReferenceID *string `json:"reference_id,omitempty" url:"-"`
// An identifying token generated by [payments.verifyBuyer()](https://developer.squareup.com/reference/sdks/web/payments/objects/Payments#Payments.verifyBuyer).
// Verification tokens encapsulate customer device information and 3-D Secure
// challenge results to indicate that Square has verified the buyer identity.
//
// For more information, see [SCA Overview](https://developer.squareup.com/docs/sca-overview).
VerificationToken *string `json:"verification_token,omitempty" url:"-"`
// If set to `true` and charging a Square Gift Card, a payment might be returned with
// `amount_money` equal to less than what was requested. For example, a request for $20 when charging
// a Square Gift Card with a balance of $5 results in an APPROVED payment of $5. You might choose
// to prompt the buyer for an additional payment to cover the remainder or cancel the Gift Card
// payment. This field cannot be `true` when `autocomplete = true`.
//
// For more information, see
// [Partial amount with Square Gift Cards](https://developer.squareup.com/docs/payments-api/take-payments#partial-payment-gift-card).
//
// Default: false
AcceptPartialAuthorization *bool `json:"accept_partial_authorization,omitempty" url:"-"`
// The buyer's email address.
BuyerEmailAddress *string `json:"buyer_email_address,omitempty" url:"-"`
// The buyer's phone number.
// Must follow the following format:
// 1. A leading + symbol (followed by a country code)
// 2. The phone number can contain spaces and the special characters `(` , `)` , `-` , and `.`.
// Alphabetical characters aren't allowed.
// 3. The phone number must contain between 9 and 16 digits.
BuyerPhoneNumber *string `json:"buyer_phone_number,omitempty" url:"-"`
// The buyer's billing address.
BillingAddress *Address `json:"billing_address,omitempty" url:"-"`
// The buyer's shipping address.
ShippingAddress *Address `json:"shipping_address,omitempty" url:"-"`
// An optional note to be entered by the developer when creating a payment.
Note *string `json:"note,omitempty" url:"-"`
// Optional additional payment information to include on the customer's card statement
// as part of the statement description. This can be, for example, an invoice number, ticket number,
// or short description that uniquely identifies the purchase.
//
// Note that the `statement_description_identifier` might get truncated on the statement description
// to fit the required information including the Square identifier (SQ *) and name of the
// seller taking the payment.
StatementDescriptionIdentifier *string `json:"statement_description_identifier,omitempty" url:"-"`
// Additional details required when recording a cash payment (`source_id` is CASH).
CashDetails *CashPaymentDetails `json:"cash_details,omitempty" url:"-"`
// Additional details required when recording an external payment (`source_id` is EXTERNAL).
ExternalDetails *ExternalPaymentDetails `json:"external_details,omitempty" url:"-"`
// Details about the customer making the payment.
CustomerDetails *CustomerDetails `json:"customer_details,omitempty" url:"-"`
// An optional field for specifying the offline payment details. This is intended for
// internal 1st-party callers only.
OfflinePaymentDetails *OfflinePaymentDetails `json:"offline_payment_details,omitempty" url:"-"`
}
type PaymentsGetRequest struct {
// A unique ID for the desired payment.
PaymentID string `json:"-" url:"-"`
}
type PaymentsListRequest struct {
// Indicates the start of the time range to retrieve payments for, in RFC 3339 format.
// The range is determined using the `created_at` field for each Payment.
// Inclusive. Default: The current time minus one year.
BeginTime *string `json:"-" url:"begin_time,omitempty"`
// Indicates the end of the time range to retrieve payments for, in RFC 3339 format. The
// range is determined using the `created_at` field for each Payment.
//
// Default: The current time.
EndTime *string `json:"-" url:"end_time,omitempty"`
// The order in which results are listed by `ListPaymentsRequest.sort_field`:
// - `ASC` - Oldest to newest.
// - `DESC` - Newest to oldest (default).
SortOrder *string `json:"-" url:"sort_order,omitempty"`
// A pagination cursor returned by a previous call to this endpoint.
// Provide this cursor to retrieve the next set of results for the original query.
//
// For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
Cursor *string `json:"-" url:"cursor,omitempty"`
// Limit results to the location supplied. By default, results are returned
// for the default (main) location associated with the seller.
LocationID *string `json:"-" url:"location_id,omitempty"`
// The exact amount in the `total_money` for a payment.
Total *int64 `json:"-" url:"total,omitempty"`
// The last four digits of a payment card.
Last4 *string `json:"-" url:"last_4,omitempty"`
// The brand of the payment card (for example, VISA).
CardBrand *string `json:"-" url:"card_brand,omitempty"`
// The maximum number of results to be returned in a single page.
// It is possible to receive fewer results than the specified limit on a given page.
//
// The default value of 100 is also the maximum allowed value. If the provided value is
// greater than 100, it is ignored and the default value is used instead.
//
// Default: `100`
Limit *int `json:"-" url:"limit,omitempty"`
// Whether the payment was taken offline or not.
IsOfflinePayment *bool `json:"-" url:"is_offline_payment,omitempty"`
// Indicates the start of the time range for which to retrieve offline payments, in RFC 3339
// format for timestamps. The range is determined using the
// `offline_payment_details.client_created_at` field for each Payment. If set, payments without a
// value set in `offline_payment_details.client_created_at` will not be returned.
//
// Default: The current time.
OfflineBeginTime *string `json:"-" url:"offline_begin_time,omitempty"`
// Indicates the end of the time range for which to retrieve offline payments, in RFC 3339
// format for timestamps. The range is determined using the
// `offline_payment_details.client_created_at` field for each Payment. If set, payments without a
// value set in `offline_payment_details.client_created_at` will not be returned.
//
// Default: The current time.
OfflineEndTime *string `json:"-" url:"offline_end_time,omitempty"`
// Indicates the start of the time range to retrieve payments for, in RFC 3339 format. The
// range is determined using the `updated_at` field for each Payment.
UpdatedAtBeginTime *string `json:"-" url:"updated_at_begin_time,omitempty"`
// Indicates the end of the time range to retrieve payments for, in RFC 3339 format. The
// range is determined using the `updated_at` field for each Payment.
UpdatedAtEndTime *string `json:"-" url:"updated_at_end_time,omitempty"`
// The field used to sort results by. The default is `CREATED_AT`.
SortField *PaymentSortField `json:"-" url:"sort_field,omitempty"`
}
// ACH-specific details about `BANK_ACCOUNT` type payments with the `transfer_type` of `ACH`.
type AchDetails struct {
// The routing number for the bank account.
RoutingNumber *string `json:"routing_number,omitempty" url:"routing_number,omitempty"`
// The last few digits of the bank account number.
AccountNumberSuffix *string `json:"account_number_suffix,omitempty" url:"account_number_suffix,omitempty"`
// The type of the bank account performing the transfer. The account type can be `CHECKING`,
// `SAVINGS`, or `UNKNOWN`.
AccountType *string `json:"account_type,omitempty" url:"account_type,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (a *AchDetails) GetRoutingNumber() *string {
if a == nil {
return nil
}
return a.RoutingNumber
}
func (a *AchDetails) GetAccountNumberSuffix() *string {
if a == nil {
return nil
}
return a.AccountNumberSuffix
}
func (a *AchDetails) GetAccountType() *string {
if a == nil {
return nil
}
return a.AccountType
}
func (a *AchDetails) GetExtraProperties() map[string]interface{} {
return a.extraProperties
}
func (a *AchDetails) UnmarshalJSON(data []byte) error {
type unmarshaler AchDetails
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AchDetails(value)
extraProperties, err := internal.ExtractExtraProperties(data, *a)
if err != nil {
return err
}
a.extraProperties = extraProperties
a.rawJSON = json.RawMessage(data)
return nil
}
func (a *AchDetails) String() string {
if len(a.rawJSON) > 0 {
if value, err := internal.StringifyJSON(a.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
// Additional details about Afterpay payments.
type AfterpayDetails struct {
// Email address on the buyer's Afterpay account.
EmailAddress *string `json:"email_address,omitempty" url:"email_address,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (a *AfterpayDetails) GetEmailAddress() *string {
if a == nil {
return nil
}
return a.EmailAddress
}
func (a *AfterpayDetails) GetExtraProperties() map[string]interface{} {
return a.extraProperties
}
func (a *AfterpayDetails) UnmarshalJSON(data []byte) error {
type unmarshaler AfterpayDetails
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AfterpayDetails(value)
extraProperties, err := internal.ExtractExtraProperties(data, *a)
if err != nil {
return err
}
a.extraProperties = extraProperties
a.rawJSON = json.RawMessage(data)
return nil
}
func (a *AfterpayDetails) String() string {
if len(a.rawJSON) > 0 {
if value, err := internal.StringifyJSON(a.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
// Details about the application that took the payment.
type ApplicationDetails struct {
// The Square product, such as Square Point of Sale (POS),
// Square Invoices, or Square Virtual Terminal.
// See [ExternalSquareProduct](#type-externalsquareproduct) for possible values
SquareProduct *ApplicationDetailsExternalSquareProduct `json:"square_product,omitempty" url:"square_product,omitempty"`
// The Square ID assigned to the application used to take the payment.
// Application developers can use this information to identify payments that
// their application processed.
// For example, if a developer uses a custom application to process payments,
// this field contains the application ID from the Developer Dashboard.
// If a seller uses a [Square App Marketplace](https://developer.squareup.com/docs/app-marketplace)
// application to process payments, the field contains the corresponding application ID.
ApplicationID *string `json:"application_id,omitempty" url:"application_id,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (a *ApplicationDetails) GetSquareProduct() *ApplicationDetailsExternalSquareProduct {
if a == nil {
return nil
}
return a.SquareProduct
}
func (a *ApplicationDetails) GetApplicationID() *string {
if a == nil {
return nil
}
return a.ApplicationID
}
func (a *ApplicationDetails) GetExtraProperties() map[string]interface{} {
return a.extraProperties
}
func (a *ApplicationDetails) UnmarshalJSON(data []byte) error {
type unmarshaler ApplicationDetails
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = ApplicationDetails(value)
extraProperties, err := internal.ExtractExtraProperties(data, *a)
if err != nil {
return err
}
a.extraProperties = extraProperties
a.rawJSON = json.RawMessage(data)
return nil
}
func (a *ApplicationDetails) String() string {
if len(a.rawJSON) > 0 {
if value, err := internal.StringifyJSON(a.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
// A list of products to return to external callers.
type ApplicationDetailsExternalSquareProduct string
const (
ApplicationDetailsExternalSquareProductAppointments ApplicationDetailsExternalSquareProduct = "APPOINTMENTS"
ApplicationDetailsExternalSquareProductEcommerceAPI ApplicationDetailsExternalSquareProduct = "ECOMMERCE_API"
ApplicationDetailsExternalSquareProductInvoices ApplicationDetailsExternalSquareProduct = "INVOICES"
ApplicationDetailsExternalSquareProductOnlineStore ApplicationDetailsExternalSquareProduct = "ONLINE_STORE"
ApplicationDetailsExternalSquareProductOther ApplicationDetailsExternalSquareProduct = "OTHER"
ApplicationDetailsExternalSquareProductRestaurants ApplicationDetailsExternalSquareProduct = "RESTAURANTS"
ApplicationDetailsExternalSquareProductRetail ApplicationDetailsExternalSquareProduct = "RETAIL"
ApplicationDetailsExternalSquareProductSquarePos ApplicationDetailsExternalSquareProduct = "SQUARE_POS"
ApplicationDetailsExternalSquareProductTerminalAPI ApplicationDetailsExternalSquareProduct = "TERMINAL_API"
ApplicationDetailsExternalSquareProductVirtualTerminal ApplicationDetailsExternalSquareProduct = "VIRTUAL_TERMINAL"
)
func NewApplicationDetailsExternalSquareProductFromString(s string) (ApplicationDetailsExternalSquareProduct, error) {
switch s {
case "APPOINTMENTS":
return ApplicationDetailsExternalSquareProductAppointments, nil
case "ECOMMERCE_API":
return ApplicationDetailsExternalSquareProductEcommerceAPI, nil
case "INVOICES":
return ApplicationDetailsExternalSquareProductInvoices, nil
case "ONLINE_STORE":
return ApplicationDetailsExternalSquareProductOnlineStore, nil
case "OTHER":
return ApplicationDetailsExternalSquareProductOther, nil
case "RESTAURANTS":
return ApplicationDetailsExternalSquareProductRestaurants, nil
case "RETAIL":
return ApplicationDetailsExternalSquareProductRetail, nil
case "SQUARE_POS":
return ApplicationDetailsExternalSquareProductSquarePos, nil
case "TERMINAL_API":
return ApplicationDetailsExternalSquareProductTerminalAPI, nil
case "VIRTUAL_TERMINAL":
return ApplicationDetailsExternalSquareProductVirtualTerminal, nil
}
var t ApplicationDetailsExternalSquareProduct
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (a ApplicationDetailsExternalSquareProduct) Ptr() *ApplicationDetailsExternalSquareProduct {
return &a
}
// Additional details about BANK_ACCOUNT type payments.
type BankAccountPaymentDetails struct {
// The name of the bank associated with the bank account.
BankName *string `json:"bank_name,omitempty" url:"bank_name,omitempty"`
// The type of the bank transfer. The type can be `ACH` or `UNKNOWN`.
TransferType *string `json:"transfer_type,omitempty" url:"transfer_type,omitempty"`
// The ownership type of the bank account performing the transfer.
// The type can be `INDIVIDUAL`, `COMPANY`, or `ACCOUNT_TYPE_UNKNOWN`.
AccountOwnershipType *string `json:"account_ownership_type,omitempty" url:"account_ownership_type,omitempty"`
// Uniquely identifies the bank account for this seller and can be used
// to determine if payments are from the same bank account.
Fingerprint *string `json:"fingerprint,omitempty" url:"fingerprint,omitempty"`
// The two-letter ISO code representing the country the bank account is located in.
Country *string `json:"country,omitempty" url:"country,omitempty"`
// The statement description as sent to the bank.
StatementDescription *string `json:"statement_description,omitempty" url:"statement_description,omitempty"`
// ACH-specific information about the transfer. The information is only populated
// if the `transfer_type` is `ACH`.
AchDetails *AchDetails `json:"ach_details,omitempty" url:"ach_details,omitempty"`
// Information about errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (b *BankAccountPaymentDetails) GetBankName() *string {
if b == nil {
return nil
}
return b.BankName
}
func (b *BankAccountPaymentDetails) GetTransferType() *string {
if b == nil {
return nil
}
return b.TransferType
}
func (b *BankAccountPaymentDetails) GetAccountOwnershipType() *string {
if b == nil {
return nil
}
return b.AccountOwnershipType
}
func (b *BankAccountPaymentDetails) GetFingerprint() *string {
if b == nil {
return nil
}
return b.Fingerprint
}
func (b *BankAccountPaymentDetails) GetCountry() *string {
if b == nil {
return nil
}
return b.Country
}
func (b *BankAccountPaymentDetails) GetStatementDescription() *string {
if b == nil {
return nil
}
return b.StatementDescription
}
func (b *BankAccountPaymentDetails) GetAchDetails() *AchDetails {
if b == nil {
return nil
}
return b.AchDetails
}
func (b *BankAccountPaymentDetails) GetErrors() []*Error {
if b == nil {
return nil
}
return b.Errors
}
func (b *BankAccountPaymentDetails) GetExtraProperties() map[string]interface{} {
return b.extraProperties
}
func (b *BankAccountPaymentDetails) UnmarshalJSON(data []byte) error {
type unmarshaler BankAccountPaymentDetails
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*b = BankAccountPaymentDetails(value)
extraProperties, err := internal.ExtractExtraProperties(data, *b)
if err != nil {
return err
}
b.extraProperties = extraProperties
b.rawJSON = json.RawMessage(data)
return nil
}
func (b *BankAccountPaymentDetails) String() string {
if len(b.rawJSON) > 0 {
if value, err := internal.StringifyJSON(b.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(b); err == nil {
return value
}
return fmt.Sprintf("%#v", b)
}
// Additional details about a Buy Now Pay Later payment type.
type BuyNowPayLaterDetails struct {
// The brand used for the Buy Now Pay Later payment.
// The brand can be `AFTERPAY`, `CLEARPAY` or `UNKNOWN`.
Brand *string `json:"brand,omitempty" url:"brand,omitempty"`
// Details about an Afterpay payment. These details are only populated if the `brand` is
// `AFTERPAY`.
AfterpayDetails *AfterpayDetails `json:"afterpay_details,omitempty" url:"afterpay_details,omitempty"`
// Details about a Clearpay payment. These details are only populated if the `brand` is
// `CLEARPAY`.
ClearpayDetails *ClearpayDetails `json:"clearpay_details,omitempty" url:"clearpay_details,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (b *BuyNowPayLaterDetails) GetBrand() *string {
if b == nil {
return nil
}
return b.Brand
}
func (b *BuyNowPayLaterDetails) GetAfterpayDetails() *AfterpayDetails {
if b == nil {
return nil
}
return b.AfterpayDetails
}
func (b *BuyNowPayLaterDetails) GetClearpayDetails() *ClearpayDetails {
if b == nil {
return nil
}
return b.ClearpayDetails
}
func (b *BuyNowPayLaterDetails) GetExtraProperties() map[string]interface{} {
return b.extraProperties
}
func (b *BuyNowPayLaterDetails) UnmarshalJSON(data []byte) error {
type unmarshaler BuyNowPayLaterDetails
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*b = BuyNowPayLaterDetails(value)
extraProperties, err := internal.ExtractExtraProperties(data, *b)
if err != nil {
return err
}
b.extraProperties = extraProperties
b.rawJSON = json.RawMessage(data)
return nil
}
func (b *BuyNowPayLaterDetails) String() string {
if len(b.rawJSON) > 0 {
if value, err := internal.StringifyJSON(b.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(b); err == nil {
return value
}
return fmt.Sprintf("%#v", b)
}
// Defines the response returned by [CancelPayment](api-endpoint:Payments-CancelPayment).
type CancelPaymentResponse struct {
// Information about errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The successfully canceled `Payment` object.
Payment *Payment `json:"payment,omitempty" url:"payment,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CancelPaymentResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CancelPaymentResponse) GetPayment() *Payment {
if c == nil {
return nil
}
return c.Payment
}
func (c *CancelPaymentResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CancelPaymentResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CancelPaymentResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CancelPaymentResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CancelPaymentResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// Reflects the current status of a card payment. Contains only non-confidential information.
type CardPaymentDetails struct {
// The card payment's current state. The state can be AUTHORIZED, CAPTURED, VOIDED, or
// FAILED.
Status *string `json:"status,omitempty" url:"status,omitempty"`
// The credit card's non-confidential details.
Card *Card `json:"card,omitempty" url:"card,omitempty"`
// The method used to enter the card's details for the payment. The method can be
// `KEYED`, `SWIPED`, `EMV`, `ON_FILE`, or `CONTACTLESS`.
EntryMethod *string `json:"entry_method,omitempty" url:"entry_method,omitempty"`
// The status code returned from the Card Verification Value (CVV) check. The code can be
// `CVV_ACCEPTED`, `CVV_REJECTED`, or `CVV_NOT_CHECKED`.
CvvStatus *string `json:"cvv_status,omitempty" url:"cvv_status,omitempty"`
// The status code returned from the Address Verification System (AVS) check. The code can be
// `AVS_ACCEPTED`, `AVS_REJECTED`, or `AVS_NOT_CHECKED`.
AvsStatus *string `json:"avs_status,omitempty" url:"avs_status,omitempty"`
// The status code returned by the card issuer that describes the payment's
// authorization status.
AuthResultCode *string `json:"auth_result_code,omitempty" url:"auth_result_code,omitempty"`
// For EMV payments, the application ID identifies the EMV application used for the payment.
ApplicationIdentifier *string `json:"application_identifier,omitempty" url:"application_identifier,omitempty"`
// For EMV payments, the human-readable name of the EMV application used for the payment.
ApplicationName *string `json:"application_name,omitempty" url:"application_name,omitempty"`
// For EMV payments, the cryptogram generated for the payment.
ApplicationCryptogram *string `json:"application_cryptogram,omitempty" url:"application_cryptogram,omitempty"`
// For EMV payments, the method used to verify the cardholder's identity. The method can be
// `PIN`, `SIGNATURE`, `PIN_AND_SIGNATURE`, `ON_DEVICE`, or `NONE`.
VerificationMethod *string `json:"verification_method,omitempty" url:"verification_method,omitempty"`
// For EMV payments, the results of the cardholder verification. The result can be
// `SUCCESS`, `FAILURE`, or `UNKNOWN`.
VerificationResults *string `json:"verification_results,omitempty" url:"verification_results,omitempty"`
// The statement description sent to the card networks.
//
// Note: The actual statement description varies and is likely to be truncated and appended with
// additional information on a per issuer basis.
StatementDescription *string `json:"statement_description,omitempty" url:"statement_description,omitempty"`
// __Deprecated__: Use `Payment.device_details` instead.
//
// Details about the device that took the payment.
DeviceDetails *DeviceDetails `json:"device_details,omitempty" url:"device_details,omitempty"`
// The timeline for card payments.
CardPaymentTimeline *CardPaymentTimeline `json:"card_payment_timeline,omitempty" url:"card_payment_timeline,omitempty"`
// Whether the card must be physically present for the payment to
// be refunded. If set to `true`, the card must be present.
RefundRequiresCardPresence *bool `json:"refund_requires_card_presence,omitempty" url:"refund_requires_card_presence,omitempty"`
// Information about errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CardPaymentDetails) GetStatus() *string {
if c == nil {
return nil
}
return c.Status
}
func (c *CardPaymentDetails) GetCard() *Card {
if c == nil {
return nil
}
return c.Card
}
func (c *CardPaymentDetails) GetEntryMethod() *string {
if c == nil {
return nil
}
return c.EntryMethod
}
func (c *CardPaymentDetails) GetCvvStatus() *string {
if c == nil {
return nil
}
return c.CvvStatus
}
func (c *CardPaymentDetails) GetAvsStatus() *string {
if c == nil {
return nil
}
return c.AvsStatus
}
func (c *CardPaymentDetails) GetAuthResultCode() *string {
if c == nil {
return nil
}
return c.AuthResultCode
}
func (c *CardPaymentDetails) GetApplicationIdentifier() *string {
if c == nil {
return nil
}
return c.ApplicationIdentifier
}
func (c *CardPaymentDetails) GetApplicationName() *string {
if c == nil {
return nil
}
return c.ApplicationName
}
func (c *CardPaymentDetails) GetApplicationCryptogram() *string {
if c == nil {
return nil
}
return c.ApplicationCryptogram
}
func (c *CardPaymentDetails) GetVerificationMethod() *string {
if c == nil {
return nil
}
return c.VerificationMethod
}
func (c *CardPaymentDetails) GetVerificationResults() *string {
if c == nil {
return nil
}
return c.VerificationResults
}
func (c *CardPaymentDetails) GetStatementDescription() *string {
if c == nil {
return nil
}
return c.StatementDescription
}
func (c *CardPaymentDetails) GetDeviceDetails() *DeviceDetails {
if c == nil {
return nil
}
return c.DeviceDetails
}
func (c *CardPaymentDetails) GetCardPaymentTimeline() *CardPaymentTimeline {
if c == nil {
return nil
}
return c.CardPaymentTimeline
}
func (c *CardPaymentDetails) GetRefundRequiresCardPresence() *bool {
if c == nil {
return nil
}
return c.RefundRequiresCardPresence
}
func (c *CardPaymentDetails) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CardPaymentDetails) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CardPaymentDetails) UnmarshalJSON(data []byte) error {
type unmarshaler CardPaymentDetails
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CardPaymentDetails(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CardPaymentDetails) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// The timeline for card payments.
type CardPaymentTimeline struct {
// The timestamp when the payment was authorized, in RFC 3339 format.
AuthorizedAt *string `json:"authorized_at,omitempty" url:"authorized_at,omitempty"`
// The timestamp when the payment was captured, in RFC 3339 format.
CapturedAt *string `json:"captured_at,omitempty" url:"captured_at,omitempty"`
// The timestamp when the payment was voided, in RFC 3339 format.
VoidedAt *string `json:"voided_at,omitempty" url:"voided_at,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CardPaymentTimeline) GetAuthorizedAt() *string {
if c == nil {
return nil
}
return c.AuthorizedAt
}
func (c *CardPaymentTimeline) GetCapturedAt() *string {
if c == nil {
return nil
}
return c.CapturedAt
}
func (c *CardPaymentTimeline) GetVoidedAt() *string {
if c == nil {
return nil
}
return c.VoidedAt
}
func (c *CardPaymentTimeline) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CardPaymentTimeline) UnmarshalJSON(data []byte) error {
type unmarshaler CardPaymentTimeline
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CardPaymentTimeline(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CardPaymentTimeline) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// Additional details about `WALLET` type payments with the `brand` of `CASH_APP`.
type CashAppDetails struct {
// The name of the Cash App account holder.
BuyerFullName *string `json:"buyer_full_name,omitempty" url:"buyer_full_name,omitempty"`
// The country of the Cash App account holder, in ISO 3166-1-alpha-2 format.
//
// For possible values, see [Country](entity:Country).
BuyerCountryCode *string `json:"buyer_country_code,omitempty" url:"buyer_country_code,omitempty"`
// $Cashtag of the Cash App account holder.
BuyerCashtag *string `json:"buyer_cashtag,omitempty" url:"buyer_cashtag,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CashAppDetails) GetBuyerFullName() *string {
if c == nil {
return nil
}
return c.BuyerFullName
}
func (c *CashAppDetails) GetBuyerCountryCode() *string {
if c == nil {
return nil
}
return c.BuyerCountryCode
}
func (c *CashAppDetails) GetBuyerCashtag() *string {