-
Notifications
You must be signed in to change notification settings - Fork 1
/
checkouts.go
executable file
·1106 lines (967 loc) · 53.6 KB
/
checkouts.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
// Code generated by `gogenitor`. DO NOT EDIT.
package sumup
import (
"bytes"
"context"
"encoding/json"
"fmt"
"net/http"
"time"
)
// Card is __Required when payment type is `card`.__ Details of the payment card.
type Card struct {
// Three or four-digit card verification value (security code) of the payment card.
Cvv string `json:"cvv"`
// Month from the expiration time of the payment card. Accepted format is `MM`.
ExpiryMonth CardExpiryMonth `json:"expiry_month"`
// Year from the expiration time of the payment card. Accepted formats are `YY` and `YYYY`.
ExpiryYear string `json:"expiry_year"`
// Last 4 digits of the payment card number.
Last4Digits string `json:"last_4_digits"`
// Name of the cardholder as it appears on the payment card.
Name string `json:"name"`
// Number of the payment card (without spaces).
Number string `json:"number"`
// Issuing card network of the payment card.
Type CardType `json:"type"`
// Required five-digit ZIP code. Applicable only to merchant users in the USA.
ZipCode *string `json:"zip_code,omitempty"`
}
// Month from the expiration time of the payment card. Accepted format is `MM`.
type CardExpiryMonth string
const (
CardExpiryMonth01 CardExpiryMonth = "01"
CardExpiryMonth02 CardExpiryMonth = "02"
CardExpiryMonth03 CardExpiryMonth = "03"
CardExpiryMonth04 CardExpiryMonth = "04"
CardExpiryMonth05 CardExpiryMonth = "05"
CardExpiryMonth06 CardExpiryMonth = "06"
CardExpiryMonth07 CardExpiryMonth = "07"
CardExpiryMonth08 CardExpiryMonth = "08"
CardExpiryMonth09 CardExpiryMonth = "09"
CardExpiryMonth10 CardExpiryMonth = "10"
CardExpiryMonth11 CardExpiryMonth = "11"
CardExpiryMonth12 CardExpiryMonth = "12"
)
// Issuing card network of the payment card.
type CardType string
const (
CardTypeAmex CardType = "AMEX"
CardTypeCup CardType = "CUP"
CardTypeDiners CardType = "DINERS"
CardTypeDiscover CardType = "DISCOVER"
CardTypeElo CardType = "ELO"
CardTypeElv CardType = "ELV"
CardTypeHipercard CardType = "HIPERCARD"
CardTypeJcb CardType = "JCB"
CardTypeMaestro CardType = "MAESTRO"
CardTypeMastercard CardType = "MASTERCARD"
CardTypeUnknown CardType = "UNKNOWN"
CardTypeVisa CardType = "VISA"
CardTypeVisaElectron CardType = "VISA_ELECTRON"
CardTypeVisaVpay CardType = "VISA_VPAY"
)
// Checkout is Details of the payment checkout.
type Checkout struct {
// Amount of the payment.
Amount *float64 `json:"amount,omitempty"`
// Unique ID of the payment checkout specified by the client application when creating the checkout resource.
CheckoutReference *string `json:"checkout_reference,omitempty"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported currency values are enumerated above.
Currency *Currency `json:"currency,omitempty"`
// Unique identification of a customer. If specified, the checkout session and payment instrument are associated with the referenced customer.
CustomerId *string `json:"customer_id,omitempty"`
// Date and time of the creation of the payment checkout. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Date *time.Time `json:"date,omitempty"`
// Short description of the checkout visible in the SumUp dashboard. The description can contribute to reporting, allowing easier identification of a checkout.
Description *string `json:"description,omitempty"`
// Unique ID of the checkout resource.
Id *string `json:"id,omitempty"`
// Created mandate
Mandate *MandateResponse `json:"mandate,omitempty"`
// Unique identifying code of the merchant profile.
MerchantCode *string `json:"merchant_code,omitempty"`
// Email address of the registered user (merchant) to whom the payment is made.
PayToEmail *string `json:"pay_to_email,omitempty"`
// URL to which the SumUp platform sends the processing status of the payment checkout.
ReturnUrl *string `json:"return_url,omitempty"`
// Current status of the checkout.
Status *CheckoutStatus `json:"status,omitempty"`
// List of transactions related to the payment.
Transactions *[]CheckoutTransaction `json:"transactions,omitempty"`
// Date and time of the checkout expiration before which the client application needs to send a processing request. If no value is present, the checkout does not have an expiration time.
ValidUntil *time.Time `json:"valid_until,omitempty"`
}
// Current status of the checkout.
type CheckoutStatus string
const (
CheckoutStatusFailed CheckoutStatus = "FAILED"
CheckoutStatusPaid CheckoutStatus = "PAID"
CheckoutStatusPending CheckoutStatus = "PENDING"
)
// Payment type used for the transaction.
type CheckoutTransactionPaymentType string
const (
CheckoutTransactionPaymentTypeBoleto CheckoutTransactionPaymentType = "BOLETO"
CheckoutTransactionPaymentTypeEcom CheckoutTransactionPaymentType = "ECOM"
CheckoutTransactionPaymentTypeRecurring CheckoutTransactionPaymentType = "RECURRING"
)
// Current status of the transaction.
type CheckoutTransactionStatus string
const (
CheckoutTransactionStatusCancelled CheckoutTransactionStatus = "CANCELLED"
CheckoutTransactionStatusFailed CheckoutTransactionStatus = "FAILED"
CheckoutTransactionStatusPending CheckoutTransactionStatus = "PENDING"
CheckoutTransactionStatusSuccessful CheckoutTransactionStatus = "SUCCESSFUL"
)
// Entry mode of the payment details.
type CheckoutTransactionEntryMode string
const (
CheckoutTransactionEntryModeBoleto CheckoutTransactionEntryMode = "BOLETO"
CheckoutTransactionEntryModeCustomerEntry CheckoutTransactionEntryMode = "CUSTOMER_ENTRY"
)
// CheckoutTransaction is the type definition for a CheckoutTransaction.
type CheckoutTransaction struct {
// Total amount of the transaction.
Amount *float64 `json:"amount,omitempty"`
// Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments.
AuthCode *string `json:"auth_code,omitempty"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported currency values are enumerated above.
Currency *Currency `json:"currency,omitempty"`
// Entry mode of the payment details.
EntryMode *CheckoutTransactionEntryMode `json:"entry_mode,omitempty"`
// Unique ID of the transaction.
Id *string `json:"id,omitempty"`
// Current number of the installment for deferred payments.
InstallmentsCount *int `json:"installments_count,omitempty"`
// Internal unique ID of the transaction on the SumUp platform.
InternalId *int `json:"internal_id,omitempty"`
// Unique code of the registered merchant to whom the payment is made.
MerchantCode *string `json:"merchant_code,omitempty"`
// Payment type used for the transaction.
PaymentType *CheckoutTransactionPaymentType `json:"payment_type,omitempty"`
// Current status of the transaction.
Status *CheckoutTransactionStatus `json:"status,omitempty"`
// Date and time of the creation of the transaction. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Timestamp *time.Time `json:"timestamp,omitempty"`
// Amount of the tip (out of the total transaction amount).
TipAmount *float64 `json:"tip_amount,omitempty"`
// Transaction code returned by the acquirer/processing entity after processing the transaction.
TransactionCode *string `json:"transaction_code,omitempty"`
// Amount of the applicable VAT (out of the total transaction amount).
VatAmount *float64 `json:"vat_amount,omitempty"`
}
// CheckoutCreateRequest is Details of the payment checkout.
type CheckoutCreateRequest struct {
// Amount of the payment.
Amount float64 `json:"amount"`
// Unique ID of the payment checkout specified by the client application when creating the checkout resource.
CheckoutReference string `json:"checkout_reference"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported currency values are enumerated above.
Currency Currency `json:"currency"`
// Unique identification of a customer. If specified, the checkout session and payment instrument are associated with the referenced customer.
CustomerId *string `json:"customer_id,omitempty"`
// Date and time of the creation of the payment checkout. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Date *time.Time `json:"date,omitempty"`
// Short description of the checkout visible in the SumUp dashboard. The description can contribute to reporting, allowing easier identification of a checkout.
Description *string `json:"description,omitempty"`
// Unique ID of the checkout resource.
Id *string `json:"id,omitempty"`
// Unique identifying code of the merchant profile.
MerchantCode string `json:"merchant_code"`
// Email address of the registered user (merchant) to whom the payment is made. It is highly recommended to use `merchant_code` instead of `pay_to_email`.
PayToEmail *string `json:"pay_to_email,omitempty"`
// Alternative payment method name
PaymentType *string `json:"payment_type,omitempty"`
// Object containing personal details about the payer, typical for __Boleto__ checkouts
PersonalDetails *CheckoutCreateRequestPersonalDetails `json:"personal_details,omitempty"`
// Purpose of the checkout.
Purpose *CheckoutCreateRequestPurpose `json:"purpose,omitempty"`
// __Required__ for [APMs](https://developer.sumup.com/online-payments/apm/introduction) and __recommended__ for card payments. Refers to a url where the end user is redirected once the payment processing completes. If not specified, the [Payment Widget](https://developer.sumup.com/online-payments/tools/card-widget) renders [3DS challenge](https://developer.sumup.com/online-payments/features/3ds) within an iframe instead of performing a full-page redirect.
RedirectUrl *string `json:"redirect_url,omitempty"`
// URL to which the SumUp platform sends the processing status of the payment checkout.
ReturnUrl *string `json:"return_url,omitempty"`
// Current status of the checkout.
Status *CheckoutCreateRequestStatus `json:"status,omitempty"`
// List of transactions related to the payment.
Transactions *[]CheckoutCreateRequestTransaction `json:"transactions,omitempty"`
// Date and time of the checkout expiration before which the client application needs to send a processing request. If no value is present, the checkout does not have an expiration time.
ValidUntil *time.Time `json:"valid_until,omitempty"`
}
// CheckoutCreateRequestPersonalDetails is Object containing personal details about the payer, typical for __Boleto__ checkouts
type CheckoutCreateRequestPersonalDetails struct {
// Payer's address information
Address *CheckoutCreateRequestPersonalDetailsAddress `json:"address,omitempty"`
// Payer's email address
Email *string `json:"email,omitempty"`
// Payer's first name
FirstName *string `json:"first_name,omitempty"`
// Payer's last name
LastName *string `json:"last_name,omitempty"`
// Payer's tax identification number (CPF)
TaxId *string `json:"tax_id,omitempty"`
}
// CheckoutCreateRequestPersonalDetailsAddress is Payer's address information
type CheckoutCreateRequestPersonalDetailsAddress struct {
// Payer's city
City *string `json:"city,omitempty"`
// Payer's country
Country *string `json:"country,omitempty"`
// Field for address details
Line1 *string `json:"line_1,omitempty"`
// Payer's postal code. Must be eight digits long, however an optional dash could be applied after the 5th digit ([more information about the format available here](https://en.wikipedia.org/wiki/List_of_postal_codes_in_Brazil)). Both options are accepted as correct.
PostalCode *string `json:"postal_code,omitempty"`
// Payer's state code
State *CheckoutCreateRequestPersonalDetailsAddressState `json:"state,omitempty"`
}
// Payer's state code
type CheckoutCreateRequestPersonalDetailsAddressState string
const (
CheckoutCreateRequestPersonalDetailsAddressStateAc CheckoutCreateRequestPersonalDetailsAddressState = "AC"
CheckoutCreateRequestPersonalDetailsAddressStateAl CheckoutCreateRequestPersonalDetailsAddressState = "AL"
CheckoutCreateRequestPersonalDetailsAddressStateAm CheckoutCreateRequestPersonalDetailsAddressState = "AM"
CheckoutCreateRequestPersonalDetailsAddressStateAp CheckoutCreateRequestPersonalDetailsAddressState = "AP"
CheckoutCreateRequestPersonalDetailsAddressStateBa CheckoutCreateRequestPersonalDetailsAddressState = "BA"
CheckoutCreateRequestPersonalDetailsAddressStateCe CheckoutCreateRequestPersonalDetailsAddressState = "CE"
CheckoutCreateRequestPersonalDetailsAddressStateDf CheckoutCreateRequestPersonalDetailsAddressState = "DF"
CheckoutCreateRequestPersonalDetailsAddressStateEs CheckoutCreateRequestPersonalDetailsAddressState = "ES"
CheckoutCreateRequestPersonalDetailsAddressStateGo CheckoutCreateRequestPersonalDetailsAddressState = "GO"
CheckoutCreateRequestPersonalDetailsAddressStateMa CheckoutCreateRequestPersonalDetailsAddressState = "MA"
CheckoutCreateRequestPersonalDetailsAddressStateMg CheckoutCreateRequestPersonalDetailsAddressState = "MG"
CheckoutCreateRequestPersonalDetailsAddressStateMs CheckoutCreateRequestPersonalDetailsAddressState = "MS"
CheckoutCreateRequestPersonalDetailsAddressStateMt CheckoutCreateRequestPersonalDetailsAddressState = "MT"
CheckoutCreateRequestPersonalDetailsAddressStatePa CheckoutCreateRequestPersonalDetailsAddressState = "PA"
CheckoutCreateRequestPersonalDetailsAddressStatePb CheckoutCreateRequestPersonalDetailsAddressState = "PB"
CheckoutCreateRequestPersonalDetailsAddressStatePe CheckoutCreateRequestPersonalDetailsAddressState = "PE"
CheckoutCreateRequestPersonalDetailsAddressStatePi CheckoutCreateRequestPersonalDetailsAddressState = "PI"
CheckoutCreateRequestPersonalDetailsAddressStatePr CheckoutCreateRequestPersonalDetailsAddressState = "PR"
CheckoutCreateRequestPersonalDetailsAddressStateRj CheckoutCreateRequestPersonalDetailsAddressState = "RJ"
CheckoutCreateRequestPersonalDetailsAddressStateRn CheckoutCreateRequestPersonalDetailsAddressState = "RN"
CheckoutCreateRequestPersonalDetailsAddressStateRo CheckoutCreateRequestPersonalDetailsAddressState = "RO"
CheckoutCreateRequestPersonalDetailsAddressStateRr CheckoutCreateRequestPersonalDetailsAddressState = "RR"
CheckoutCreateRequestPersonalDetailsAddressStateRs CheckoutCreateRequestPersonalDetailsAddressState = "RS"
CheckoutCreateRequestPersonalDetailsAddressStateSc CheckoutCreateRequestPersonalDetailsAddressState = "SC"
CheckoutCreateRequestPersonalDetailsAddressStateSe CheckoutCreateRequestPersonalDetailsAddressState = "SE"
CheckoutCreateRequestPersonalDetailsAddressStateSp CheckoutCreateRequestPersonalDetailsAddressState = "SP"
CheckoutCreateRequestPersonalDetailsAddressStateTo CheckoutCreateRequestPersonalDetailsAddressState = "TO"
)
// Purpose of the checkout.
type CheckoutCreateRequestPurpose string
const (
CheckoutCreateRequestPurposeCheckout CheckoutCreateRequestPurpose = "CHECKOUT"
CheckoutCreateRequestPurposeSetupRecurringPayment CheckoutCreateRequestPurpose = "SETUP_RECURRING_PAYMENT"
)
// Current status of the checkout.
type CheckoutCreateRequestStatus string
const (
CheckoutCreateRequestStatusFailed CheckoutCreateRequestStatus = "FAILED"
CheckoutCreateRequestStatusPaid CheckoutCreateRequestStatus = "PAID"
CheckoutCreateRequestStatusPending CheckoutCreateRequestStatus = "PENDING"
)
// Payment type used for the transaction.
type CheckoutCreateRequestTransactionPaymentType string
const (
CheckoutCreateRequestTransactionPaymentTypeBoleto CheckoutCreateRequestTransactionPaymentType = "BOLETO"
CheckoutCreateRequestTransactionPaymentTypeEcom CheckoutCreateRequestTransactionPaymentType = "ECOM"
CheckoutCreateRequestTransactionPaymentTypeRecurring CheckoutCreateRequestTransactionPaymentType = "RECURRING"
)
// Current status of the transaction.
type CheckoutCreateRequestTransactionStatus string
const (
CheckoutCreateRequestTransactionStatusCancelled CheckoutCreateRequestTransactionStatus = "CANCELLED"
CheckoutCreateRequestTransactionStatusFailed CheckoutCreateRequestTransactionStatus = "FAILED"
CheckoutCreateRequestTransactionStatusPending CheckoutCreateRequestTransactionStatus = "PENDING"
CheckoutCreateRequestTransactionStatusSuccessful CheckoutCreateRequestTransactionStatus = "SUCCESSFUL"
)
// Entry mode of the payment details.
type CheckoutCreateRequestTransactionEntryMode string
const (
CheckoutCreateRequestTransactionEntryModeBoleto CheckoutCreateRequestTransactionEntryMode = "BOLETO"
CheckoutCreateRequestTransactionEntryModeCustomerEntry CheckoutCreateRequestTransactionEntryMode = "CUSTOMER_ENTRY"
)
// CheckoutCreateRequestTransaction is the type definition for a CheckoutCreateRequestTransaction.
type CheckoutCreateRequestTransaction struct {
// Total amount of the transaction.
Amount *float64 `json:"amount,omitempty"`
// Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments.
AuthCode *string `json:"auth_code,omitempty"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported currency values are enumerated above.
Currency *Currency `json:"currency,omitempty"`
// Entry mode of the payment details.
EntryMode *CheckoutCreateRequestTransactionEntryMode `json:"entry_mode,omitempty"`
// Unique ID of the transaction.
Id *string `json:"id,omitempty"`
// Current number of the installment for deferred payments.
InstallmentsCount *int `json:"installments_count,omitempty"`
// Internal unique ID of the transaction on the SumUp platform.
InternalId *int `json:"internal_id,omitempty"`
// Unique code of the registered merchant to whom the payment is made.
MerchantCode *string `json:"merchant_code,omitempty"`
// Payment type used for the transaction.
PaymentType *CheckoutCreateRequestTransactionPaymentType `json:"payment_type,omitempty"`
// Current status of the transaction.
Status *CheckoutCreateRequestTransactionStatus `json:"status,omitempty"`
// Date and time of the creation of the transaction. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Timestamp *time.Time `json:"timestamp,omitempty"`
// Amount of the tip (out of the total transaction amount).
TipAmount *float64 `json:"tip_amount,omitempty"`
// Transaction code returned by the acquirer/processing entity after processing the transaction.
TransactionCode *string `json:"transaction_code,omitempty"`
// Amount of the applicable VAT (out of the total transaction amount).
VatAmount *float64 `json:"vat_amount,omitempty"`
}
// CheckoutProcessMixin is Details of the payment instrument for processing the checkout.
type CheckoutProcessMixin struct {
// __Required when payment type is `card`.__ Details of the payment card.
Card *Card `json:"card,omitempty"`
// __Required when `token` is provided.__ Unique ID of the customer.
CustomerId *string `json:"customer_id,omitempty"`
// Number of installments for deferred payments. Available only to merchant users in Brazil.
Installments *int `json:"installments,omitempty"`
// Mandate is passed when a card is to be tokenized
Mandate *MandatePayload `json:"mandate,omitempty"`
PaymentType CheckoutProcessMixinPaymentType `json:"payment_type"`
// __Required when using a tokenized card to process a checkout.__ Unique token identifying the saved payment card for a customer.
Token *string `json:"token,omitempty"`
}
type CheckoutProcessMixinPaymentType string
const (
CheckoutProcessMixinPaymentTypeBancontact CheckoutProcessMixinPaymentType = "bancontact"
CheckoutProcessMixinPaymentTypeBlik CheckoutProcessMixinPaymentType = "blik"
CheckoutProcessMixinPaymentTypeBoleto CheckoutProcessMixinPaymentType = "boleto"
CheckoutProcessMixinPaymentTypeCard CheckoutProcessMixinPaymentType = "card"
CheckoutProcessMixinPaymentTypeIdeal CheckoutProcessMixinPaymentType = "ideal"
)
// Current status of the checkout.
type CheckoutSuccessStatus string
const (
CheckoutSuccessStatusFailed CheckoutSuccessStatus = "FAILED"
CheckoutSuccessStatusPaid CheckoutSuccessStatus = "PAID"
CheckoutSuccessStatusPending CheckoutSuccessStatus = "PENDING"
)
// Payment type used for the transaction.
type CheckoutSuccessTransactionPaymentType string
const (
CheckoutSuccessTransactionPaymentTypeBoleto CheckoutSuccessTransactionPaymentType = "BOLETO"
CheckoutSuccessTransactionPaymentTypeEcom CheckoutSuccessTransactionPaymentType = "ECOM"
CheckoutSuccessTransactionPaymentTypeRecurring CheckoutSuccessTransactionPaymentType = "RECURRING"
)
// Current status of the transaction.
type CheckoutSuccessTransactionStatus string
const (
CheckoutSuccessTransactionStatusCancelled CheckoutSuccessTransactionStatus = "CANCELLED"
CheckoutSuccessTransactionStatusFailed CheckoutSuccessTransactionStatus = "FAILED"
CheckoutSuccessTransactionStatusPending CheckoutSuccessTransactionStatus = "PENDING"
CheckoutSuccessTransactionStatusSuccessful CheckoutSuccessTransactionStatus = "SUCCESSFUL"
)
// Entry mode of the payment details.
type CheckoutSuccessTransactionEntryMode string
const (
CheckoutSuccessTransactionEntryModeBoleto CheckoutSuccessTransactionEntryMode = "BOLETO"
CheckoutSuccessTransactionEntryModeCustomerEntry CheckoutSuccessTransactionEntryMode = "CUSTOMER_ENTRY"
)
// CheckoutSuccessTransaction is the type definition for a CheckoutSuccessTransaction.
type CheckoutSuccessTransaction struct {
// Total amount of the transaction.
Amount *float64 `json:"amount,omitempty"`
// Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments.
AuthCode *string `json:"auth_code,omitempty"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported currency values are enumerated above.
Currency *Currency `json:"currency,omitempty"`
// Entry mode of the payment details.
EntryMode *CheckoutSuccessTransactionEntryMode `json:"entry_mode,omitempty"`
// Unique ID of the transaction.
Id *string `json:"id,omitempty"`
// Current number of the installment for deferred payments.
InstallmentsCount *int `json:"installments_count,omitempty"`
// Internal unique ID of the transaction on the SumUp platform.
InternalId *int `json:"internal_id,omitempty"`
// Unique code of the registered merchant to whom the payment is made.
MerchantCode *string `json:"merchant_code,omitempty"`
// Payment type used for the transaction.
PaymentType *CheckoutSuccessTransactionPaymentType `json:"payment_type,omitempty"`
// Current status of the transaction.
Status *CheckoutSuccessTransactionStatus `json:"status,omitempty"`
// Date and time of the creation of the transaction. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Timestamp *time.Time `json:"timestamp,omitempty"`
// Amount of the tip (out of the total transaction amount).
TipAmount *float64 `json:"tip_amount,omitempty"`
// Transaction code returned by the acquirer/processing entity after processing the transaction.
TransactionCode *string `json:"transaction_code,omitempty"`
// Amount of the applicable VAT (out of the total transaction amount).
VatAmount *float64 `json:"vat_amount,omitempty"`
}
// CheckoutSuccessPaymentInstrument is Object containing token information for the specified payment instrument
type CheckoutSuccessPaymentInstrument struct {
// Token value
Token *string `json:"token,omitempty"`
}
// CheckoutSuccess is the type definition for a CheckoutSuccess.
type CheckoutSuccess struct {
// Amount of the payment.
Amount *float64 `json:"amount,omitempty"`
// Unique ID of the payment checkout specified by the client application when creating the checkout resource.
CheckoutReference *string `json:"checkout_reference,omitempty"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported currency values are enumerated above.
Currency *Currency `json:"currency,omitempty"`
// Unique identification of a customer. If specified, the checkout session and payment instrument are associated with the referenced customer.
CustomerId *string `json:"customer_id,omitempty"`
// Date and time of the creation of the payment checkout. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Date *time.Time `json:"date,omitempty"`
// Short description of the checkout visible in the SumUp dashboard. The description can contribute to reporting, allowing easier identification of a checkout.
Description *string `json:"description,omitempty"`
// Unique ID of the checkout resource.
Id *string `json:"id,omitempty"`
// Created mandate
Mandate *MandateResponse `json:"mandate,omitempty"`
// Unique identifying code of the merchant profile.
MerchantCode *string `json:"merchant_code,omitempty"`
// Name of the merchant
MerchantName *string `json:"merchant_name,omitempty"`
// Email address of the registered user (merchant) to whom the payment is made.
PayToEmail *string `json:"pay_to_email,omitempty"`
// Object containing token information for the specified payment instrument
PaymentInstrument *CheckoutSuccessPaymentInstrument `json:"payment_instrument,omitempty"`
// Refers to a url where the end user is redirected once the payment processing completes.
RedirectUrl *string `json:"redirect_url,omitempty"`
// URL to which the SumUp platform sends the processing status of the payment checkout.
ReturnUrl *string `json:"return_url,omitempty"`
// Current status of the checkout.
Status *CheckoutSuccessStatus `json:"status,omitempty"`
// Transaction code of the successful transaction with which the payment for the checkout is completed.
TransactionCode *string `json:"transaction_code,omitempty"`
// Transaction ID of the successful transaction with which the payment for the checkout is completed.
TransactionId *string `json:"transaction_id,omitempty"`
// List of transactions related to the payment.
Transactions *[]CheckoutSuccessTransaction `json:"transactions,omitempty"`
// Date and time of the checkout expiration before which the client application needs to send a processing request. If no value is present, the checkout does not have an expiration time.
ValidUntil *time.Time `json:"valid_until,omitempty"`
}
// DetailsError is Error message structure.
type DetailsError struct {
// Details of the error.
Details *string `json:"details,omitempty"`
FailedConstraints *[]DetailsErrorFailedConstraint `json:"failed_constraints,omitempty"`
// The status code.
Status *float64 `json:"status,omitempty"`
// Short title of the error.
Title *string `json:"title,omitempty"`
}
// DetailsErrorFailedConstraint is the type definition for a DetailsErrorFailedConstraint.
type DetailsErrorFailedConstraint struct {
Message *string `json:"message,omitempty"`
Reference *string `json:"reference,omitempty"`
}
// ErrorExtended is the type definition for a ErrorExtended.
type ErrorExtended struct {
// Platform code for the error.
ErrorCode *string `json:"error_code,omitempty"`
// Short description of the error.
Message *string `json:"message,omitempty"`
// Parameter name (with relative location) to which the error applies. Parameters from embedded resources are displayed using dot notation. For example, `card.name` refers to the `name` parameter embedded in the `card` object.
Param *string `json:"param,omitempty"`
}
// MandatePayload is Mandate is passed when a card is to be tokenized
type MandatePayload struct {
// Indicates the mandate type
Type MandatePayloadType `json:"type"`
// Operating system and web client used by the end-user
UserAgent string `json:"user_agent"`
// IP address of the end user. Supports IPv4 and IPv6
UserIp *string `json:"user_ip,omitempty"`
}
// Indicates the mandate type
type MandatePayloadType string
const (
MandatePayloadTypeRecurrent MandatePayloadType = "recurrent"
)
// ListCheckoutsParams are query parameters for ListCheckouts
type ListCheckoutsParams struct {
CheckoutReference *string `json:"checkout_reference,omitempty"`
}
// ListCheckoutsResponse is the type definition for a ListCheckoutsResponse.
type ListCheckoutsResponse []CheckoutSuccess
// CreateCheckout request body.
type CreateCheckoutBody struct {
// Amount of the payment.
Amount float64 `json:"amount"`
// Unique ID of the payment checkout specified by the client application when creating the checkout resource.
CheckoutReference string `json:"checkout_reference"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported currency values are enumerated above.
Currency Currency `json:"currency"`
// Unique identification of a customer. If specified, the checkout session and payment instrument are associated with the referenced customer.
CustomerId *string `json:"customer_id,omitempty"`
// Date and time of the creation of the payment checkout. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Date *time.Time `json:"date,omitempty"`
// Short description of the checkout visible in the SumUp dashboard. The description can contribute to reporting, allowing easier identification of a checkout.
Description *string `json:"description,omitempty"`
// Unique ID of the checkout resource.
Id *string `json:"id,omitempty"`
// Unique identifying code of the merchant profile.
MerchantCode string `json:"merchant_code"`
// Email address of the registered user (merchant) to whom the payment is made. It is highly recommended to use `merchant_code` instead of `pay_to_email`.
PayToEmail *string `json:"pay_to_email,omitempty"`
// Alternative payment method name
PaymentType *string `json:"payment_type,omitempty"`
// Object containing personal details about the payer, typical for __Boleto__ checkouts
PersonalDetails *CreateCheckoutBodyPersonalDetails `json:"personal_details,omitempty"`
// Purpose of the checkout.
Purpose *CreateCheckoutBodyPurpose `json:"purpose,omitempty"`
// __Required__ for [APMs](https://developer.sumup.com/online-payments/apm/introduction) and __recommended__ for card payments. Refers to a url where the end user is redirected once the payment processing completes. If not specified, the [Payment Widget](https://developer.sumup.com/online-payments/tools/card-widget) renders [3DS challenge](https://developer.sumup.com/online-payments/features/3ds) within an iframe instead of performing a full-page redirect.
RedirectUrl *string `json:"redirect_url,omitempty"`
// URL to which the SumUp platform sends the processing status of the payment checkout.
ReturnUrl *string `json:"return_url,omitempty"`
// Current status of the checkout.
Status *CreateCheckoutBodyStatus `json:"status,omitempty"`
// List of transactions related to the payment.
Transactions *[]CreateCheckoutBodyTransaction `json:"transactions,omitempty"`
// Date and time of the checkout expiration before which the client application needs to send a processing request. If no value is present, the checkout does not have an expiration time.
ValidUntil *time.Time `json:"valid_until,omitempty"`
}
// CreateCheckoutBodyPersonalDetails is Object containing personal details about the payer, typical for __Boleto__ checkouts
type CreateCheckoutBodyPersonalDetails struct {
// Payer's address information
Address *CreateCheckoutBodyPersonalDetailsAddress `json:"address,omitempty"`
// Payer's email address
Email *string `json:"email,omitempty"`
// Payer's first name
FirstName *string `json:"first_name,omitempty"`
// Payer's last name
LastName *string `json:"last_name,omitempty"`
// Payer's tax identification number (CPF)
TaxId *string `json:"tax_id,omitempty"`
}
// CreateCheckoutBodyPersonalDetailsAddress is Payer's address information
type CreateCheckoutBodyPersonalDetailsAddress struct {
// Payer's city
City *string `json:"city,omitempty"`
// Payer's country
Country *string `json:"country,omitempty"`
// Field for address details
Line1 *string `json:"line_1,omitempty"`
// Payer's postal code. Must be eight digits long, however an optional dash could be applied after the 5th digit ([more information about the format available here](https://en.wikipedia.org/wiki/List_of_postal_codes_in_Brazil)). Both options are accepted as correct.
PostalCode *string `json:"postal_code,omitempty"`
// Payer's state code
State *CreateCheckoutBodyPersonalDetailsAddressState `json:"state,omitempty"`
}
// Payer's state code
type CreateCheckoutBodyPersonalDetailsAddressState string
const (
CreateCheckoutBodyPersonalDetailsAddressStateAc CreateCheckoutBodyPersonalDetailsAddressState = "AC"
CreateCheckoutBodyPersonalDetailsAddressStateAl CreateCheckoutBodyPersonalDetailsAddressState = "AL"
CreateCheckoutBodyPersonalDetailsAddressStateAm CreateCheckoutBodyPersonalDetailsAddressState = "AM"
CreateCheckoutBodyPersonalDetailsAddressStateAp CreateCheckoutBodyPersonalDetailsAddressState = "AP"
CreateCheckoutBodyPersonalDetailsAddressStateBa CreateCheckoutBodyPersonalDetailsAddressState = "BA"
CreateCheckoutBodyPersonalDetailsAddressStateCe CreateCheckoutBodyPersonalDetailsAddressState = "CE"
CreateCheckoutBodyPersonalDetailsAddressStateDf CreateCheckoutBodyPersonalDetailsAddressState = "DF"
CreateCheckoutBodyPersonalDetailsAddressStateEs CreateCheckoutBodyPersonalDetailsAddressState = "ES"
CreateCheckoutBodyPersonalDetailsAddressStateGo CreateCheckoutBodyPersonalDetailsAddressState = "GO"
CreateCheckoutBodyPersonalDetailsAddressStateMa CreateCheckoutBodyPersonalDetailsAddressState = "MA"
CreateCheckoutBodyPersonalDetailsAddressStateMg CreateCheckoutBodyPersonalDetailsAddressState = "MG"
CreateCheckoutBodyPersonalDetailsAddressStateMs CreateCheckoutBodyPersonalDetailsAddressState = "MS"
CreateCheckoutBodyPersonalDetailsAddressStateMt CreateCheckoutBodyPersonalDetailsAddressState = "MT"
CreateCheckoutBodyPersonalDetailsAddressStatePa CreateCheckoutBodyPersonalDetailsAddressState = "PA"
CreateCheckoutBodyPersonalDetailsAddressStatePb CreateCheckoutBodyPersonalDetailsAddressState = "PB"
CreateCheckoutBodyPersonalDetailsAddressStatePe CreateCheckoutBodyPersonalDetailsAddressState = "PE"
CreateCheckoutBodyPersonalDetailsAddressStatePi CreateCheckoutBodyPersonalDetailsAddressState = "PI"
CreateCheckoutBodyPersonalDetailsAddressStatePr CreateCheckoutBodyPersonalDetailsAddressState = "PR"
CreateCheckoutBodyPersonalDetailsAddressStateRj CreateCheckoutBodyPersonalDetailsAddressState = "RJ"
CreateCheckoutBodyPersonalDetailsAddressStateRn CreateCheckoutBodyPersonalDetailsAddressState = "RN"
CreateCheckoutBodyPersonalDetailsAddressStateRo CreateCheckoutBodyPersonalDetailsAddressState = "RO"
CreateCheckoutBodyPersonalDetailsAddressStateRr CreateCheckoutBodyPersonalDetailsAddressState = "RR"
CreateCheckoutBodyPersonalDetailsAddressStateRs CreateCheckoutBodyPersonalDetailsAddressState = "RS"
CreateCheckoutBodyPersonalDetailsAddressStateSc CreateCheckoutBodyPersonalDetailsAddressState = "SC"
CreateCheckoutBodyPersonalDetailsAddressStateSe CreateCheckoutBodyPersonalDetailsAddressState = "SE"
CreateCheckoutBodyPersonalDetailsAddressStateSp CreateCheckoutBodyPersonalDetailsAddressState = "SP"
CreateCheckoutBodyPersonalDetailsAddressStateTo CreateCheckoutBodyPersonalDetailsAddressState = "TO"
)
// Purpose of the checkout.
type CreateCheckoutBodyPurpose string
const (
CreateCheckoutBodyPurposeCheckout CreateCheckoutBodyPurpose = "CHECKOUT"
CreateCheckoutBodyPurposeSetupRecurringPayment CreateCheckoutBodyPurpose = "SETUP_RECURRING_PAYMENT"
)
// Current status of the checkout.
type CreateCheckoutBodyStatus string
const (
CreateCheckoutBodyStatusFailed CreateCheckoutBodyStatus = "FAILED"
CreateCheckoutBodyStatusPaid CreateCheckoutBodyStatus = "PAID"
CreateCheckoutBodyStatusPending CreateCheckoutBodyStatus = "PENDING"
)
// Payment type used for the transaction.
type CreateCheckoutBodyTransactionPaymentType string
const (
CreateCheckoutBodyTransactionPaymentTypeBoleto CreateCheckoutBodyTransactionPaymentType = "BOLETO"
CreateCheckoutBodyTransactionPaymentTypeEcom CreateCheckoutBodyTransactionPaymentType = "ECOM"
CreateCheckoutBodyTransactionPaymentTypeRecurring CreateCheckoutBodyTransactionPaymentType = "RECURRING"
)
// Current status of the transaction.
type CreateCheckoutBodyTransactionStatus string
const (
CreateCheckoutBodyTransactionStatusCancelled CreateCheckoutBodyTransactionStatus = "CANCELLED"
CreateCheckoutBodyTransactionStatusFailed CreateCheckoutBodyTransactionStatus = "FAILED"
CreateCheckoutBodyTransactionStatusPending CreateCheckoutBodyTransactionStatus = "PENDING"
CreateCheckoutBodyTransactionStatusSuccessful CreateCheckoutBodyTransactionStatus = "SUCCESSFUL"
)
// Entry mode of the payment details.
type CreateCheckoutBodyTransactionEntryMode string
const (
CreateCheckoutBodyTransactionEntryModeBoleto CreateCheckoutBodyTransactionEntryMode = "BOLETO"
CreateCheckoutBodyTransactionEntryModeCustomerEntry CreateCheckoutBodyTransactionEntryMode = "CUSTOMER_ENTRY"
)
// CreateCheckoutBodyTransaction is the type definition for a CreateCheckoutBodyTransaction.
type CreateCheckoutBodyTransaction struct {
// Total amount of the transaction.
Amount *float64 `json:"amount,omitempty"`
// Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments.
AuthCode *string `json:"auth_code,omitempty"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported currency values are enumerated above.
Currency *Currency `json:"currency,omitempty"`
// Entry mode of the payment details.
EntryMode *CreateCheckoutBodyTransactionEntryMode `json:"entry_mode,omitempty"`
// Unique ID of the transaction.
Id *string `json:"id,omitempty"`
// Current number of the installment for deferred payments.
InstallmentsCount *int `json:"installments_count,omitempty"`
// Internal unique ID of the transaction on the SumUp platform.
InternalId *int `json:"internal_id,omitempty"`
// Unique code of the registered merchant to whom the payment is made.
MerchantCode *string `json:"merchant_code,omitempty"`
// Payment type used for the transaction.
PaymentType *CreateCheckoutBodyTransactionPaymentType `json:"payment_type,omitempty"`
// Current status of the transaction.
Status *CreateCheckoutBodyTransactionStatus `json:"status,omitempty"`
// Date and time of the creation of the transaction. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Timestamp *time.Time `json:"timestamp,omitempty"`
// Amount of the tip (out of the total transaction amount).
TipAmount *float64 `json:"tip_amount,omitempty"`
// Transaction code returned by the acquirer/processing entity after processing the transaction.
TransactionCode *string `json:"transaction_code,omitempty"`
// Amount of the applicable VAT (out of the total transaction amount).
VatAmount *float64 `json:"vat_amount,omitempty"`
}
// GetPaymentMethodsParams are query parameters for GetPaymentMethods
type GetPaymentMethodsParams struct {
Amount *float64 `json:"amount,omitempty"`
Currency *string `json:"currency,omitempty"`
}
// GetPaymentMethodsResponse is the type definition for a GetPaymentMethodsResponse.
type GetPaymentMethodsResponse struct {
AvailablePaymentMethods *[]GetPaymentMethodsResponseAvailablePaymentMethod `json:"available_payment_methods,omitempty"`
}
// GetPaymentMethodsResponseAvailablePaymentMethod is the type definition for a GetPaymentMethodsResponseAvailablePaymentMethod.
type GetPaymentMethodsResponseAvailablePaymentMethod struct {
// The ID of the payment method.
Id string `json:"id"`
}
// DeactivateCheckoutResponse is Details of the deleted checkout.
type DeactivateCheckoutResponse struct {
// Amount of the payment.
Amount *float64 `json:"amount,omitempty"`
// Unique ID of the payment checkout specified by the client application when creating the checkout resource.
CheckoutReference *string `json:"checkout_reference,omitempty"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported currency values are enumerated above.
Currency *Currency `json:"currency,omitempty"`
// Date and time of the creation of the payment checkout. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Date *time.Time `json:"date,omitempty"`
// Short description of the checkout visible in the SumUp dashboard. The description can contribute to reporting, allowing easier identification of a checkout.
Description *string `json:"description,omitempty"`
// Unique ID of the checkout resource.
Id *string `json:"id,omitempty"`
// Unique identifying code of the merchant profile.
MerchantCode *string `json:"merchant_code,omitempty"`
// The merchant's country
MerchantCountry *string `json:"merchant_country,omitempty"`
// Merchant name
MerchantName *string `json:"merchant_name,omitempty"`
// Email address of the registered user (merchant) to whom the payment is made. It is highly recommended to use `merchant_code` instead of `pay_to_email`.
PayToEmail *string `json:"pay_to_email,omitempty"`
// Purpose of the checkout creation initially
Purpose *DeactivateCheckoutResponsePurpose `json:"purpose,omitempty"`
// Current status of the checkout.
Status *DeactivateCheckoutResponseStatus `json:"status,omitempty"`
// List of transactions related to the payment.
Transactions *[]DeactivateCheckoutResponseTransaction `json:"transactions,omitempty"`
// Date and time of the checkout expiration before which the client application needs to send a processing request. If no value is present, the checkout does not have an expiration time.
ValidUntil *time.Time `json:"valid_until,omitempty"`
}
// Purpose of the checkout creation initially
type DeactivateCheckoutResponsePurpose string
const (
DeactivateCheckoutResponsePurposeCheckout DeactivateCheckoutResponsePurpose = "CHECKOUT"
DeactivateCheckoutResponsePurposeSetupRecurringPayment DeactivateCheckoutResponsePurpose = "SETUP_RECURRING_PAYMENT"
)
// Current status of the checkout.
type DeactivateCheckoutResponseStatus string
const (
DeactivateCheckoutResponseStatusExpired DeactivateCheckoutResponseStatus = "EXPIRED"
)
// Payment type used for the transaction.
type DeactivateCheckoutResponseTransactionPaymentType string
const (
DeactivateCheckoutResponseTransactionPaymentTypeBoleto DeactivateCheckoutResponseTransactionPaymentType = "BOLETO"
DeactivateCheckoutResponseTransactionPaymentTypeEcom DeactivateCheckoutResponseTransactionPaymentType = "ECOM"
DeactivateCheckoutResponseTransactionPaymentTypeRecurring DeactivateCheckoutResponseTransactionPaymentType = "RECURRING"
)
// Current status of the transaction.
type DeactivateCheckoutResponseTransactionStatus string
const (
DeactivateCheckoutResponseTransactionStatusCancelled DeactivateCheckoutResponseTransactionStatus = "CANCELLED"
DeactivateCheckoutResponseTransactionStatusFailed DeactivateCheckoutResponseTransactionStatus = "FAILED"
DeactivateCheckoutResponseTransactionStatusPending DeactivateCheckoutResponseTransactionStatus = "PENDING"
DeactivateCheckoutResponseTransactionStatusSuccessful DeactivateCheckoutResponseTransactionStatus = "SUCCESSFUL"
)
// Entry mode of the payment details.
type DeactivateCheckoutResponseTransactionEntryMode string
const (
DeactivateCheckoutResponseTransactionEntryModeBoleto DeactivateCheckoutResponseTransactionEntryMode = "BOLETO"
DeactivateCheckoutResponseTransactionEntryModeCustomerEntry DeactivateCheckoutResponseTransactionEntryMode = "CUSTOMER_ENTRY"
)
// DeactivateCheckoutResponseTransaction is the type definition for a DeactivateCheckoutResponseTransaction.
type DeactivateCheckoutResponseTransaction struct {
// Total amount of the transaction.
Amount *float64 `json:"amount,omitempty"`
// Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments.
AuthCode *string `json:"auth_code,omitempty"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported currency values are enumerated above.
Currency *Currency `json:"currency,omitempty"`
// Entry mode of the payment details.
EntryMode *DeactivateCheckoutResponseTransactionEntryMode `json:"entry_mode,omitempty"`
// Unique ID of the transaction.
Id *string `json:"id,omitempty"`
// Current number of the installment for deferred payments.
InstallmentsCount *int `json:"installments_count,omitempty"`
// Internal unique ID of the transaction on the SumUp platform.
InternalId *int `json:"internal_id,omitempty"`
// Unique code of the registered merchant to whom the payment is made.
MerchantCode *string `json:"merchant_code,omitempty"`
// Payment type used for the transaction.
PaymentType *DeactivateCheckoutResponseTransactionPaymentType `json:"payment_type,omitempty"`
// Current status of the transaction.
Status *DeactivateCheckoutResponseTransactionStatus `json:"status,omitempty"`
// Date and time of the creation of the transaction. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Timestamp *time.Time `json:"timestamp,omitempty"`
// Amount of the tip (out of the total transaction amount).
TipAmount *float64 `json:"tip_amount,omitempty"`
// Transaction code returned by the acquirer/processing entity after processing the transaction.
TransactionCode *string `json:"transaction_code,omitempty"`
// Amount of the applicable VAT (out of the total transaction amount).
VatAmount *float64 `json:"vat_amount,omitempty"`
}
// ProcessCheckout request body.
type ProcessCheckoutBody struct {
// __Required when payment type is `card`.__ Details of the payment card.
Card *Card `json:"card,omitempty"`
// __Required when `token` is provided.__ Unique ID of the customer.
CustomerId *string `json:"customer_id,omitempty"`
// Number of installments for deferred payments. Available only to merchant users in Brazil.
Installments *int `json:"installments,omitempty"`
// Mandate is passed when a card is to be tokenized
Mandate *MandatePayload `json:"mandate,omitempty"`
PaymentType ProcessCheckoutBodyPaymentType `json:"payment_type"`
// __Required when using a tokenized card to process a checkout.__ Unique token identifying the saved payment card for a customer.
Token *string `json:"token,omitempty"`
}
type ProcessCheckoutBodyPaymentType string
const (
ProcessCheckoutBodyPaymentTypeBancontact ProcessCheckoutBodyPaymentType = "bancontact"
ProcessCheckoutBodyPaymentTypeBlik ProcessCheckoutBodyPaymentType = "blik"
ProcessCheckoutBodyPaymentTypeBoleto ProcessCheckoutBodyPaymentType = "boleto"
ProcessCheckoutBodyPaymentTypeCard ProcessCheckoutBodyPaymentType = "card"
ProcessCheckoutBodyPaymentTypeIdeal ProcessCheckoutBodyPaymentType = "ideal"
)
type CheckoutsService service
// List: List checkouts
// Lists created checkout resources according to the applied `checkout_reference`.
func (s *CheckoutsService) List(ctx context.Context, params ListCheckoutsParams) (*ListCheckoutsResponse, error) {
path := fmt.Sprintf("/v0.1/checkouts")
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 500 {
return nil, fmt.Errorf("invalid response: %d - %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
dec := json.NewDecoder(resp.Body)
if resp.StatusCode >= 400 {
var apiErr APIError
if err := dec.Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
}
var v ListCheckoutsResponse
if err := dec.Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
}
// Create: Create a checkout
// Creates a new payment checkout resource. The unique `checkout_reference` created by this request, is used for further manipulation of the checkout.
//
// For 3DS checkouts, add the `redirect_url` parameter to your request body schema.
//
// Follow by processing a checkout to charge the provided payment instrument.
func (s *CheckoutsService) Create(ctx context.Context, body CreateCheckoutBody) (*Checkout, error) {
buf := new(bytes.Buffer)
if err := json.NewEncoder(buf).Encode(body); err != nil {
return nil, fmt.Errorf("encoding json body request failed: %v", err)
}
path := fmt.Sprintf("/v0.1/checkouts")
req, err := s.client.NewRequest(ctx, http.MethodPost, path, buf)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 500 {
return nil, fmt.Errorf("invalid response: %d - %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
dec := json.NewDecoder(resp.Body)
if resp.StatusCode >= 400 {
var apiErr APIError
if err := dec.Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
}
var v Checkout
if err := dec.Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
}
// ListAvailablePaymentMethods: Get available payment methods
// Get payment methods available for the given merchant to use with a checkout.
func (s *CheckoutsService) ListAvailablePaymentMethods(ctx context.Context, merchantCode string, params GetPaymentMethodsParams) (*GetPaymentMethodsResponse, error) {
path := fmt.Sprintf("/v0.1/merchants/%v/payment-methods", merchantCode)
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 500 {
return nil, fmt.Errorf("invalid response: %d - %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
dec := json.NewDecoder(resp.Body)
if resp.StatusCode >= 400 {
var apiErr APIError
if err := dec.Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
}
var v GetPaymentMethodsResponse
if err := dec.Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
}
// Deactivate: Deactivate a checkout
// Deactivates an identified checkout resource. If the checkout has already been processed it can not be deactivated.
func (s *CheckoutsService) Deactivate(ctx context.Context, id string) (*DeactivateCheckoutResponse, error) {
path := fmt.Sprintf("/v0.1/checkouts/%v", id)
req, err := s.client.NewRequest(ctx, http.MethodDelete, path, http.NoBody)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}