-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcard.go
More file actions
1590 lines (1362 loc) · 66.5 KB
/
card.go
File metadata and controls
1590 lines (1362 loc) · 66.5 KB
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package increase
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"time"
"github.com/Increase/increase-go/internal/apijson"
"github.com/Increase/increase-go/internal/apiquery"
"github.com/Increase/increase-go/internal/param"
"github.com/Increase/increase-go/internal/requestconfig"
"github.com/Increase/increase-go/option"
"github.com/Increase/increase-go/packages/pagination"
)
// CardService contains methods and other services that help with interacting with
// the increase API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewCardService] method instead.
type CardService struct {
Options []option.RequestOption
}
// NewCardService generates a new service that applies the given options to each
// request. These options are applied after the parent client's options (if there
// is one), and before any request-specific options.
func NewCardService(opts ...option.RequestOption) (r *CardService) {
r = &CardService{}
r.Options = opts
return
}
// Create a Card
func (r *CardService) New(ctx context.Context, body CardNewParams, opts ...option.RequestOption) (res *Card, err error) {
opts = slices.Concat(r.Options, opts)
path := "cards"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// Retrieve a Card
func (r *CardService) Get(ctx context.Context, cardID string, opts ...option.RequestOption) (res *Card, err error) {
opts = slices.Concat(r.Options, opts)
if cardID == "" {
err = errors.New("missing required card_id parameter")
return nil, err
}
path := fmt.Sprintf("cards/%s", cardID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Update a Card
func (r *CardService) Update(ctx context.Context, cardID string, body CardUpdateParams, opts ...option.RequestOption) (res *Card, err error) {
opts = slices.Concat(r.Options, opts)
if cardID == "" {
err = errors.New("missing required card_id parameter")
return nil, err
}
path := fmt.Sprintf("cards/%s", cardID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return res, err
}
// List Cards
func (r *CardService) List(ctx context.Context, query CardListParams, opts ...option.RequestOption) (res *pagination.Page[Card], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "cards"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// List Cards
func (r *CardService) ListAutoPaging(ctx context.Context, query CardListParams, opts ...option.RequestOption) *pagination.PageAutoPager[Card] {
return pagination.NewPageAutoPager(r.List(ctx, query, opts...))
}
// Create an iframe URL for a Card to display the card details. More details about
// styling and usage can be found in the
// [documentation](/documentation/embedded-card-component).
func (r *CardService) NewDetailsIframe(ctx context.Context, cardID string, body CardNewDetailsIframeParams, opts ...option.RequestOption) (res *CardIframeURL, err error) {
opts = slices.Concat(r.Options, opts)
if cardID == "" {
err = errors.New("missing required card_id parameter")
return nil, err
}
path := fmt.Sprintf("cards/%s/create_details_iframe", cardID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// Sensitive details for a Card include the primary account number, expiry, card
// verification code, and PIN.
func (r *CardService) Details(ctx context.Context, cardID string, opts ...option.RequestOption) (res *CardDetails, err error) {
opts = slices.Concat(r.Options, opts)
if cardID == "" {
err = errors.New("missing required card_id parameter")
return nil, err
}
path := fmt.Sprintf("cards/%s/details", cardID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Update a Card's PIN
func (r *CardService) UpdatePin(ctx context.Context, cardID string, body CardUpdatePinParams, opts ...option.RequestOption) (res *CardDetails, err error) {
opts = slices.Concat(r.Options, opts)
if cardID == "" {
err = errors.New("missing required card_id parameter")
return nil, err
}
path := fmt.Sprintf("cards/%s/update_pin", cardID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// Cards may operate on credit, debit, or prepaid BINs. They’ll immediately work
// for online purchases after you create them. All cards work on a good funds
// model, and maintain a maximum limit of 100% of the Account’s available balance
// at the time of transaction. Funds are deducted from the Account upon transaction
// settlement.
type Card struct {
// The card identifier.
ID string `json:"id" api:"required"`
// The identifier for the account this card belongs to.
AccountID string `json:"account_id" api:"required"`
// Controls that restrict how this card can be used.
AuthorizationControls CardAuthorizationControls `json:"authorization_controls" api:"required,nullable"`
// The Card's billing address.
BillingAddress CardBillingAddress `json:"billing_address" api:"required"`
// The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which
// the Card was created.
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
// The card's description for display purposes.
Description string `json:"description" api:"required,nullable"`
// The contact information used in the two-factor steps for digital wallet card
// creation. At least one field must be present to complete the digital wallet
// steps.
DigitalWallet CardDigitalWallet `json:"digital_wallet" api:"required,nullable"`
// The identifier for the entity associated with this card.
EntityID string `json:"entity_id" api:"required,nullable"`
// The month the card expires in M format (e.g., August is 8).
ExpirationMonth int64 `json:"expiration_month" api:"required"`
// The year the card expires in YYYY format (e.g., 2025).
ExpirationYear int64 `json:"expiration_year" api:"required"`
// The idempotency key you chose for this object. This value is unique across
// Increase and is used to ensure that a request is only processed once. Learn more
// about [idempotency](https://increase.com/documentation/idempotency-keys).
IdempotencyKey string `json:"idempotency_key" api:"required,nullable"`
// The last 4 digits of the Card's Primary Account Number.
Last4 string `json:"last4" api:"required"`
// This indicates if payments can be made with the card.
Status CardStatus `json:"status" api:"required"`
// A constant representing the object's type. For this resource it will always be
// `card`.
Type CardType `json:"type" api:"required"`
ExtraFields map[string]interface{} `json:"-" api:"extrafields"`
JSON cardJSON `json:"-"`
}
// cardJSON contains the JSON metadata for the struct [Card]
type cardJSON struct {
ID apijson.Field
AccountID apijson.Field
AuthorizationControls apijson.Field
BillingAddress apijson.Field
CreatedAt apijson.Field
Description apijson.Field
DigitalWallet apijson.Field
EntityID apijson.Field
ExpirationMonth apijson.Field
ExpirationYear apijson.Field
IdempotencyKey apijson.Field
Last4 apijson.Field
Status apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *Card) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardJSON) RawJSON() string {
return r.raw
}
// Controls that restrict how this card can be used.
type CardAuthorizationControls struct {
// Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations
// on this card.
MerchantAcceptorIdentifier CardAuthorizationControlsMerchantAcceptorIdentifier `json:"merchant_acceptor_identifier" api:"required,nullable"`
// Restricts which Merchant Category Codes are allowed or blocked for
// authorizations on this card.
MerchantCategoryCode CardAuthorizationControlsMerchantCategoryCode `json:"merchant_category_code" api:"required,nullable"`
// Restricts which merchant countries are allowed or blocked for authorizations on
// this card.
MerchantCountry CardAuthorizationControlsMerchantCountry `json:"merchant_country" api:"required,nullable"`
// Controls how many times this card can be used.
Usage CardAuthorizationControlsUsage `json:"usage" api:"required,nullable"`
JSON cardAuthorizationControlsJSON `json:"-"`
}
// cardAuthorizationControlsJSON contains the JSON metadata for the struct
// [CardAuthorizationControls]
type cardAuthorizationControlsJSON struct {
MerchantAcceptorIdentifier apijson.Field
MerchantCategoryCode apijson.Field
MerchantCountry apijson.Field
Usage apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControls) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsJSON) RawJSON() string {
return r.raw
}
// Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations
// on this card.
type CardAuthorizationControlsMerchantAcceptorIdentifier struct {
// The Merchant Acceptor IDs that are allowed for authorizations on this card.
Allowed []CardAuthorizationControlsMerchantAcceptorIdentifierAllowed `json:"allowed" api:"required,nullable"`
// The Merchant Acceptor IDs that are blocked for authorizations on this card.
Blocked []CardAuthorizationControlsMerchantAcceptorIdentifierBlocked `json:"blocked" api:"required,nullable"`
JSON cardAuthorizationControlsMerchantAcceptorIdentifierJSON `json:"-"`
}
// cardAuthorizationControlsMerchantAcceptorIdentifierJSON contains the JSON
// metadata for the struct [CardAuthorizationControlsMerchantAcceptorIdentifier]
type cardAuthorizationControlsMerchantAcceptorIdentifierJSON struct {
Allowed apijson.Field
Blocked apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsMerchantAcceptorIdentifier) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsMerchantAcceptorIdentifierJSON) RawJSON() string {
return r.raw
}
type CardAuthorizationControlsMerchantAcceptorIdentifierAllowed struct {
// The Merchant Acceptor ID.
Identifier string `json:"identifier" api:"required"`
JSON cardAuthorizationControlsMerchantAcceptorIdentifierAllowedJSON `json:"-"`
}
// cardAuthorizationControlsMerchantAcceptorIdentifierAllowedJSON contains the JSON
// metadata for the struct
// [CardAuthorizationControlsMerchantAcceptorIdentifierAllowed]
type cardAuthorizationControlsMerchantAcceptorIdentifierAllowedJSON struct {
Identifier apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsMerchantAcceptorIdentifierAllowed) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsMerchantAcceptorIdentifierAllowedJSON) RawJSON() string {
return r.raw
}
type CardAuthorizationControlsMerchantAcceptorIdentifierBlocked struct {
// The Merchant Acceptor ID.
Identifier string `json:"identifier" api:"required"`
JSON cardAuthorizationControlsMerchantAcceptorIdentifierBlockedJSON `json:"-"`
}
// cardAuthorizationControlsMerchantAcceptorIdentifierBlockedJSON contains the JSON
// metadata for the struct
// [CardAuthorizationControlsMerchantAcceptorIdentifierBlocked]
type cardAuthorizationControlsMerchantAcceptorIdentifierBlockedJSON struct {
Identifier apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsMerchantAcceptorIdentifierBlocked) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsMerchantAcceptorIdentifierBlockedJSON) RawJSON() string {
return r.raw
}
// Restricts which Merchant Category Codes are allowed or blocked for
// authorizations on this card.
type CardAuthorizationControlsMerchantCategoryCode struct {
// The Merchant Category Codes that are allowed for authorizations on this card.
Allowed []CardAuthorizationControlsMerchantCategoryCodeAllowed `json:"allowed" api:"required,nullable"`
// The Merchant Category Codes that are blocked for authorizations on this card.
Blocked []CardAuthorizationControlsMerchantCategoryCodeBlocked `json:"blocked" api:"required,nullable"`
JSON cardAuthorizationControlsMerchantCategoryCodeJSON `json:"-"`
}
// cardAuthorizationControlsMerchantCategoryCodeJSON contains the JSON metadata for
// the struct [CardAuthorizationControlsMerchantCategoryCode]
type cardAuthorizationControlsMerchantCategoryCodeJSON struct {
Allowed apijson.Field
Blocked apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsMerchantCategoryCode) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsMerchantCategoryCodeJSON) RawJSON() string {
return r.raw
}
type CardAuthorizationControlsMerchantCategoryCodeAllowed struct {
// The Merchant Category Code (MCC).
Code string `json:"code" api:"required"`
JSON cardAuthorizationControlsMerchantCategoryCodeAllowedJSON `json:"-"`
}
// cardAuthorizationControlsMerchantCategoryCodeAllowedJSON contains the JSON
// metadata for the struct [CardAuthorizationControlsMerchantCategoryCodeAllowed]
type cardAuthorizationControlsMerchantCategoryCodeAllowedJSON struct {
Code apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsMerchantCategoryCodeAllowed) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsMerchantCategoryCodeAllowedJSON) RawJSON() string {
return r.raw
}
type CardAuthorizationControlsMerchantCategoryCodeBlocked struct {
// The Merchant Category Code (MCC).
Code string `json:"code" api:"required"`
JSON cardAuthorizationControlsMerchantCategoryCodeBlockedJSON `json:"-"`
}
// cardAuthorizationControlsMerchantCategoryCodeBlockedJSON contains the JSON
// metadata for the struct [CardAuthorizationControlsMerchantCategoryCodeBlocked]
type cardAuthorizationControlsMerchantCategoryCodeBlockedJSON struct {
Code apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsMerchantCategoryCodeBlocked) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsMerchantCategoryCodeBlockedJSON) RawJSON() string {
return r.raw
}
// Restricts which merchant countries are allowed or blocked for authorizations on
// this card.
type CardAuthorizationControlsMerchantCountry struct {
// The merchant countries that are allowed for authorizations on this card.
Allowed []CardAuthorizationControlsMerchantCountryAllowed `json:"allowed" api:"required,nullable"`
// The merchant countries that are blocked for authorizations on this card.
Blocked []CardAuthorizationControlsMerchantCountryBlocked `json:"blocked" api:"required,nullable"`
JSON cardAuthorizationControlsMerchantCountryJSON `json:"-"`
}
// cardAuthorizationControlsMerchantCountryJSON contains the JSON metadata for the
// struct [CardAuthorizationControlsMerchantCountry]
type cardAuthorizationControlsMerchantCountryJSON struct {
Allowed apijson.Field
Blocked apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsMerchantCountry) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsMerchantCountryJSON) RawJSON() string {
return r.raw
}
type CardAuthorizationControlsMerchantCountryAllowed struct {
// The ISO 3166-1 alpha-2 country code.
Country string `json:"country" api:"required"`
JSON cardAuthorizationControlsMerchantCountryAllowedJSON `json:"-"`
}
// cardAuthorizationControlsMerchantCountryAllowedJSON contains the JSON metadata
// for the struct [CardAuthorizationControlsMerchantCountryAllowed]
type cardAuthorizationControlsMerchantCountryAllowedJSON struct {
Country apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsMerchantCountryAllowed) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsMerchantCountryAllowedJSON) RawJSON() string {
return r.raw
}
type CardAuthorizationControlsMerchantCountryBlocked struct {
// The ISO 3166-1 alpha-2 country code.
Country string `json:"country" api:"required"`
JSON cardAuthorizationControlsMerchantCountryBlockedJSON `json:"-"`
}
// cardAuthorizationControlsMerchantCountryBlockedJSON contains the JSON metadata
// for the struct [CardAuthorizationControlsMerchantCountryBlocked]
type cardAuthorizationControlsMerchantCountryBlockedJSON struct {
Country apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsMerchantCountryBlocked) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsMerchantCountryBlockedJSON) RawJSON() string {
return r.raw
}
// Controls how many times this card can be used.
type CardAuthorizationControlsUsage struct {
// Whether the card is for a single use or multiple uses.
Category CardAuthorizationControlsUsageCategory `json:"category" api:"required"`
// Controls for multi-use cards. Required if and only if `category` is `multi_use`.
MultiUse CardAuthorizationControlsUsageMultiUse `json:"multi_use" api:"required,nullable"`
// Controls for single-use cards. Required if and only if `category` is
// `single_use`.
SingleUse CardAuthorizationControlsUsageSingleUse `json:"single_use" api:"required,nullable"`
JSON cardAuthorizationControlsUsageJSON `json:"-"`
}
// cardAuthorizationControlsUsageJSON contains the JSON metadata for the struct
// [CardAuthorizationControlsUsage]
type cardAuthorizationControlsUsageJSON struct {
Category apijson.Field
MultiUse apijson.Field
SingleUse apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsUsage) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsUsageJSON) RawJSON() string {
return r.raw
}
// Whether the card is for a single use or multiple uses.
type CardAuthorizationControlsUsageCategory string
const (
CardAuthorizationControlsUsageCategorySingleUse CardAuthorizationControlsUsageCategory = "single_use"
CardAuthorizationControlsUsageCategoryMultiUse CardAuthorizationControlsUsageCategory = "multi_use"
)
func (r CardAuthorizationControlsUsageCategory) IsKnown() bool {
switch r {
case CardAuthorizationControlsUsageCategorySingleUse, CardAuthorizationControlsUsageCategoryMultiUse:
return true
}
return false
}
// Controls for multi-use cards. Required if and only if `category` is `multi_use`.
type CardAuthorizationControlsUsageMultiUse struct {
// Spending limits for this card. The most restrictive limit applies if multiple
// limits match.
SpendingLimits []CardAuthorizationControlsUsageMultiUseSpendingLimit `json:"spending_limits" api:"required,nullable"`
JSON cardAuthorizationControlsUsageMultiUseJSON `json:"-"`
}
// cardAuthorizationControlsUsageMultiUseJSON contains the JSON metadata for the
// struct [CardAuthorizationControlsUsageMultiUse]
type cardAuthorizationControlsUsageMultiUseJSON struct {
SpendingLimits apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsUsageMultiUse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsUsageMultiUseJSON) RawJSON() string {
return r.raw
}
type CardAuthorizationControlsUsageMultiUseSpendingLimit struct {
// The interval at which the spending limit is enforced.
Interval CardAuthorizationControlsUsageMultiUseSpendingLimitsInterval `json:"interval" api:"required"`
// The Merchant Category Codes (MCCs) this spending limit applies to. If not set,
// the limit applies to all transactions.
MerchantCategoryCodes []CardAuthorizationControlsUsageMultiUseSpendingLimitsMerchantCategoryCode `json:"merchant_category_codes" api:"required,nullable"`
// The maximum settlement amount permitted in the given interval.
SettlementAmount int64 `json:"settlement_amount" api:"required"`
JSON cardAuthorizationControlsUsageMultiUseSpendingLimitJSON `json:"-"`
}
// cardAuthorizationControlsUsageMultiUseSpendingLimitJSON contains the JSON
// metadata for the struct [CardAuthorizationControlsUsageMultiUseSpendingLimit]
type cardAuthorizationControlsUsageMultiUseSpendingLimitJSON struct {
Interval apijson.Field
MerchantCategoryCodes apijson.Field
SettlementAmount apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsUsageMultiUseSpendingLimit) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsUsageMultiUseSpendingLimitJSON) RawJSON() string {
return r.raw
}
// The interval at which the spending limit is enforced.
type CardAuthorizationControlsUsageMultiUseSpendingLimitsInterval string
const (
CardAuthorizationControlsUsageMultiUseSpendingLimitsIntervalAllTime CardAuthorizationControlsUsageMultiUseSpendingLimitsInterval = "all_time"
CardAuthorizationControlsUsageMultiUseSpendingLimitsIntervalPerTransaction CardAuthorizationControlsUsageMultiUseSpendingLimitsInterval = "per_transaction"
CardAuthorizationControlsUsageMultiUseSpendingLimitsIntervalPerDay CardAuthorizationControlsUsageMultiUseSpendingLimitsInterval = "per_day"
CardAuthorizationControlsUsageMultiUseSpendingLimitsIntervalPerWeek CardAuthorizationControlsUsageMultiUseSpendingLimitsInterval = "per_week"
CardAuthorizationControlsUsageMultiUseSpendingLimitsIntervalPerMonth CardAuthorizationControlsUsageMultiUseSpendingLimitsInterval = "per_month"
)
func (r CardAuthorizationControlsUsageMultiUseSpendingLimitsInterval) IsKnown() bool {
switch r {
case CardAuthorizationControlsUsageMultiUseSpendingLimitsIntervalAllTime, CardAuthorizationControlsUsageMultiUseSpendingLimitsIntervalPerTransaction, CardAuthorizationControlsUsageMultiUseSpendingLimitsIntervalPerDay, CardAuthorizationControlsUsageMultiUseSpendingLimitsIntervalPerWeek, CardAuthorizationControlsUsageMultiUseSpendingLimitsIntervalPerMonth:
return true
}
return false
}
type CardAuthorizationControlsUsageMultiUseSpendingLimitsMerchantCategoryCode struct {
// The Merchant Category Code (MCC).
Code string `json:"code" api:"required"`
JSON cardAuthorizationControlsUsageMultiUseSpendingLimitsMerchantCategoryCodeJSON `json:"-"`
}
// cardAuthorizationControlsUsageMultiUseSpendingLimitsMerchantCategoryCodeJSON
// contains the JSON metadata for the struct
// [CardAuthorizationControlsUsageMultiUseSpendingLimitsMerchantCategoryCode]
type cardAuthorizationControlsUsageMultiUseSpendingLimitsMerchantCategoryCodeJSON struct {
Code apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsUsageMultiUseSpendingLimitsMerchantCategoryCode) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsUsageMultiUseSpendingLimitsMerchantCategoryCodeJSON) RawJSON() string {
return r.raw
}
// Controls for single-use cards. Required if and only if `category` is
// `single_use`.
type CardAuthorizationControlsUsageSingleUse struct {
// The settlement amount constraint for this single-use card.
SettlementAmount CardAuthorizationControlsUsageSingleUseSettlementAmount `json:"settlement_amount" api:"required"`
JSON cardAuthorizationControlsUsageSingleUseJSON `json:"-"`
}
// cardAuthorizationControlsUsageSingleUseJSON contains the JSON metadata for the
// struct [CardAuthorizationControlsUsageSingleUse]
type cardAuthorizationControlsUsageSingleUseJSON struct {
SettlementAmount apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsUsageSingleUse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsUsageSingleUseJSON) RawJSON() string {
return r.raw
}
// The settlement amount constraint for this single-use card.
type CardAuthorizationControlsUsageSingleUseSettlementAmount struct {
// The operator used to compare the settlement amount.
Comparison CardAuthorizationControlsUsageSingleUseSettlementAmountComparison `json:"comparison" api:"required"`
// The settlement amount value.
Value int64 `json:"value" api:"required"`
JSON cardAuthorizationControlsUsageSingleUseSettlementAmountJSON `json:"-"`
}
// cardAuthorizationControlsUsageSingleUseSettlementAmountJSON contains the JSON
// metadata for the struct
// [CardAuthorizationControlsUsageSingleUseSettlementAmount]
type cardAuthorizationControlsUsageSingleUseSettlementAmountJSON struct {
Comparison apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardAuthorizationControlsUsageSingleUseSettlementAmount) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardAuthorizationControlsUsageSingleUseSettlementAmountJSON) RawJSON() string {
return r.raw
}
// The operator used to compare the settlement amount.
type CardAuthorizationControlsUsageSingleUseSettlementAmountComparison string
const (
CardAuthorizationControlsUsageSingleUseSettlementAmountComparisonEquals CardAuthorizationControlsUsageSingleUseSettlementAmountComparison = "equals"
CardAuthorizationControlsUsageSingleUseSettlementAmountComparisonLessThanOrEquals CardAuthorizationControlsUsageSingleUseSettlementAmountComparison = "less_than_or_equals"
)
func (r CardAuthorizationControlsUsageSingleUseSettlementAmountComparison) IsKnown() bool {
switch r {
case CardAuthorizationControlsUsageSingleUseSettlementAmountComparisonEquals, CardAuthorizationControlsUsageSingleUseSettlementAmountComparisonLessThanOrEquals:
return true
}
return false
}
// The Card's billing address.
type CardBillingAddress struct {
// The city of the billing address.
City string `json:"city" api:"required,nullable"`
// The first line of the billing address.
Line1 string `json:"line1" api:"required,nullable"`
// The second line of the billing address.
Line2 string `json:"line2" api:"required,nullable"`
// The postal code of the billing address.
PostalCode string `json:"postal_code" api:"required,nullable"`
// The US state of the billing address.
State string `json:"state" api:"required,nullable"`
JSON cardBillingAddressJSON `json:"-"`
}
// cardBillingAddressJSON contains the JSON metadata for the struct
// [CardBillingAddress]
type cardBillingAddressJSON struct {
City apijson.Field
Line1 apijson.Field
Line2 apijson.Field
PostalCode apijson.Field
State apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardBillingAddress) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardBillingAddressJSON) RawJSON() string {
return r.raw
}
// The contact information used in the two-factor steps for digital wallet card
// creation. At least one field must be present to complete the digital wallet
// steps.
type CardDigitalWallet struct {
// The digital card profile assigned to this digital card. Card profiles may also
// be assigned at the program level.
DigitalCardProfileID string `json:"digital_card_profile_id" api:"required,nullable"`
// An email address that can be used to verify the cardholder via one-time passcode
// over email.
Email string `json:"email" api:"required,nullable"`
// A phone number that can be used to verify the cardholder via one-time passcode
// over SMS.
Phone string `json:"phone" api:"required,nullable"`
JSON cardDigitalWalletJSON `json:"-"`
}
// cardDigitalWalletJSON contains the JSON metadata for the struct
// [CardDigitalWallet]
type cardDigitalWalletJSON struct {
DigitalCardProfileID apijson.Field
Email apijson.Field
Phone apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardDigitalWallet) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardDigitalWalletJSON) RawJSON() string {
return r.raw
}
// This indicates if payments can be made with the card.
type CardStatus string
const (
CardStatusActive CardStatus = "active"
CardStatusDisabled CardStatus = "disabled"
CardStatusCanceled CardStatus = "canceled"
)
func (r CardStatus) IsKnown() bool {
switch r {
case CardStatusActive, CardStatusDisabled, CardStatusCanceled:
return true
}
return false
}
// A constant representing the object's type. For this resource it will always be
// `card`.
type CardType string
const (
CardTypeCard CardType = "card"
)
func (r CardType) IsKnown() bool {
switch r {
case CardTypeCard:
return true
}
return false
}
// An object containing the sensitive details (card number, CVC, PIN, etc) for a
// Card. These details are not included in the Card object. If you'd prefer to
// never access these details directly, you can use the
// [embedded iframe](/documentation/embedded-card-component) to display the
// information to your users.
type CardDetails struct {
// The identifier for the Card for which sensitive details have been returned.
CardID string `json:"card_id" api:"required"`
// The month the card expires in M format (e.g., August is 8).
ExpirationMonth int64 `json:"expiration_month" api:"required"`
// The year the card expires in YYYY format (e.g., 2025).
ExpirationYear int64 `json:"expiration_year" api:"required"`
// The 4-digit PIN for the card, for use with ATMs.
Pin string `json:"pin" api:"required"`
// The card number.
PrimaryAccountNumber string `json:"primary_account_number" api:"required"`
// A constant representing the object's type. For this resource it will always be
// `card_details`.
Type CardDetailsType `json:"type" api:"required"`
// The three-digit verification code for the card. It's also known as the Card
// Verification Code (CVC), the Card Verification Value (CVV), or the Card
// Identification (CID).
VerificationCode string `json:"verification_code" api:"required"`
JSON cardDetailsJSON `json:"-"`
}
// cardDetailsJSON contains the JSON metadata for the struct [CardDetails]
type cardDetailsJSON struct {
CardID apijson.Field
ExpirationMonth apijson.Field
ExpirationYear apijson.Field
Pin apijson.Field
PrimaryAccountNumber apijson.Field
Type apijson.Field
VerificationCode apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardDetails) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardDetailsJSON) RawJSON() string {
return r.raw
}
// A constant representing the object's type. For this resource it will always be
// `card_details`.
type CardDetailsType string
const (
CardDetailsTypeCardDetails CardDetailsType = "card_details"
)
func (r CardDetailsType) IsKnown() bool {
switch r {
case CardDetailsTypeCardDetails:
return true
}
return false
}
// An object containing the iframe URL for a Card.
type CardIframeURL struct {
// The time the iframe URL will expire.
ExpiresAt time.Time `json:"expires_at" api:"required" format:"date-time"`
// The iframe URL for the Card. Treat this as an opaque URL.
IframeURL string `json:"iframe_url" api:"required"`
// A constant representing the object's type. For this resource it will always be
// `card_iframe_url`.
Type CardIframeURLType `json:"type" api:"required"`
JSON cardIframeURLJSON `json:"-"`
}
// cardIframeURLJSON contains the JSON metadata for the struct [CardIframeURL]
type cardIframeURLJSON struct {
ExpiresAt apijson.Field
IframeURL apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardIframeURL) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardIframeURLJSON) RawJSON() string {
return r.raw
}
// A constant representing the object's type. For this resource it will always be
// `card_iframe_url`.
type CardIframeURLType string
const (
CardIframeURLTypeCardIframeURL CardIframeURLType = "card_iframe_url"
)
func (r CardIframeURLType) IsKnown() bool {
switch r {
case CardIframeURLTypeCardIframeURL:
return true
}
return false
}
type CardNewParams struct {
// The Account the card should belong to.
AccountID param.Field[string] `json:"account_id" api:"required"`
// Controls that restrict how this card can be used.
AuthorizationControls param.Field[CardNewParamsAuthorizationControls] `json:"authorization_controls"`
// The card's billing address.
BillingAddress param.Field[CardNewParamsBillingAddress] `json:"billing_address"`
// The description you choose to give the card.
Description param.Field[string] `json:"description"`
// The contact information used in the two-factor steps for digital wallet card
// creation. To add the card to a digital wallet, you may supply an email or phone
// number with this request. Otherwise, subscribe and then action a Real Time
// Decision with the category `digital_wallet_token_requested` or
// `digital_wallet_authentication_requested`.
DigitalWallet param.Field[CardNewParamsDigitalWallet] `json:"digital_wallet"`
// The Entity the card belongs to. You only need to supply this in rare situations
// when the card is not for the Account holder.
EntityID param.Field[string] `json:"entity_id"`
}
func (r CardNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Controls that restrict how this card can be used.
type CardNewParamsAuthorizationControls struct {
// Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations
// on this card.
MerchantAcceptorIdentifier param.Field[CardNewParamsAuthorizationControlsMerchantAcceptorIdentifier] `json:"merchant_acceptor_identifier"`
// Restricts which Merchant Category Codes are allowed or blocked for
// authorizations on this card.
MerchantCategoryCode param.Field[CardNewParamsAuthorizationControlsMerchantCategoryCode] `json:"merchant_category_code"`
// Restricts which merchant countries are allowed or blocked for authorizations on
// this card.
MerchantCountry param.Field[CardNewParamsAuthorizationControlsMerchantCountry] `json:"merchant_country"`
// Controls how many times this card can be used.
Usage param.Field[CardNewParamsAuthorizationControlsUsage] `json:"usage"`
}
func (r CardNewParamsAuthorizationControls) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations
// on this card.
type CardNewParamsAuthorizationControlsMerchantAcceptorIdentifier struct {
// The Merchant Acceptor IDs that are allowed for authorizations on this card.
// Authorizations with Merchant Acceptor IDs not in this list will be declined.
Allowed param.Field[[]CardNewParamsAuthorizationControlsMerchantAcceptorIdentifierAllowed] `json:"allowed"`
// The Merchant Acceptor IDs that are blocked for authorizations on this card.
// Authorizations with Merchant Acceptor IDs in this list will be declined.
Blocked param.Field[[]CardNewParamsAuthorizationControlsMerchantAcceptorIdentifierBlocked] `json:"blocked"`
}
func (r CardNewParamsAuthorizationControlsMerchantAcceptorIdentifier) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type CardNewParamsAuthorizationControlsMerchantAcceptorIdentifierAllowed struct {
// The Merchant Acceptor ID.
Identifier param.Field[string] `json:"identifier" api:"required"`
}
func (r CardNewParamsAuthorizationControlsMerchantAcceptorIdentifierAllowed) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type CardNewParamsAuthorizationControlsMerchantAcceptorIdentifierBlocked struct {
// The Merchant Acceptor ID.
Identifier param.Field[string] `json:"identifier" api:"required"`
}
func (r CardNewParamsAuthorizationControlsMerchantAcceptorIdentifierBlocked) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Restricts which Merchant Category Codes are allowed or blocked for
// authorizations on this card.
type CardNewParamsAuthorizationControlsMerchantCategoryCode struct {
// The Merchant Category Codes that are allowed for authorizations on this card.
// Authorizations with Merchant Category Codes not in this list will be declined.
Allowed param.Field[[]CardNewParamsAuthorizationControlsMerchantCategoryCodeAllowed] `json:"allowed"`
// The Merchant Category Codes that are blocked for authorizations on this card.
// Authorizations with Merchant Category Codes in this list will be declined.
Blocked param.Field[[]CardNewParamsAuthorizationControlsMerchantCategoryCodeBlocked] `json:"blocked"`
}
func (r CardNewParamsAuthorizationControlsMerchantCategoryCode) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type CardNewParamsAuthorizationControlsMerchantCategoryCodeAllowed struct {
// The Merchant Category Code.
Code param.Field[string] `json:"code" api:"required"`
}
func (r CardNewParamsAuthorizationControlsMerchantCategoryCodeAllowed) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type CardNewParamsAuthorizationControlsMerchantCategoryCodeBlocked struct {
// The Merchant Category Code.
Code param.Field[string] `json:"code" api:"required"`
}
func (r CardNewParamsAuthorizationControlsMerchantCategoryCodeBlocked) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Restricts which merchant countries are allowed or blocked for authorizations on
// this card.
type CardNewParamsAuthorizationControlsMerchantCountry struct {
// The merchant countries that are allowed for authorizations on this card.
// Authorizations with merchant countries not in this list will be declined.
Allowed param.Field[[]CardNewParamsAuthorizationControlsMerchantCountryAllowed] `json:"allowed"`
// The merchant countries that are blocked for authorizations on this card.
// Authorizations with merchant countries in this list will be declined.
Blocked param.Field[[]CardNewParamsAuthorizationControlsMerchantCountryBlocked] `json:"blocked"`
}
func (r CardNewParamsAuthorizationControlsMerchantCountry) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type CardNewParamsAuthorizationControlsMerchantCountryAllowed struct {
// The ISO 3166-1 alpha-2 country code.