-
Notifications
You must be signed in to change notification settings - Fork 1
/
card.go
1346 lines (1235 loc) · 56 KB
/
card.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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package lithic
import (
"context"
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"errors"
"fmt"
"net/http"
"net/url"
"time"
"github.com/lithic-com/lithic-go/internal/apijson"
"github.com/lithic-com/lithic-go/internal/apiquery"
"github.com/lithic-com/lithic-go/internal/param"
"github.com/lithic-com/lithic-go/internal/requestconfig"
"github.com/lithic-com/lithic-go/option"
"github.com/lithic-com/lithic-go/packages/pagination"
"github.com/lithic-com/lithic-go/shared"
)
// CardService contains methods and other services that help with interacting with
// the lithic 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
AggregateBalances *CardAggregateBalanceService
Balances *CardBalanceService
FinancialTransactions *CardFinancialTransactionService
}
// 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
r.AggregateBalances = NewCardAggregateBalanceService(opts...)
r.Balances = NewCardBalanceService(opts...)
r.FinancialTransactions = NewCardFinancialTransactionService(opts...)
return
}
// Create a new virtual or physical card. Parameters `pin`, `shipping_address`, and
// `product_id` only apply to physical cards.
func (r *CardService) New(ctx context.Context, body CardNewParams, opts ...option.RequestOption) (res *Card, err error) {
opts = append(r.Options[:], opts...)
path := "v1/cards"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Get card configuration such as spend limit and state.
func (r *CardService) Get(ctx context.Context, cardToken string, opts ...option.RequestOption) (res *Card, err error) {
opts = append(r.Options[:], opts...)
if cardToken == "" {
err = errors.New("missing required card_token parameter")
return
}
path := fmt.Sprintf("v1/cards/%s", cardToken)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// Update the specified properties of the card. Unsupplied properties will remain
// unchanged. `pin` parameter only applies to physical cards.
//
// _Note: setting a card to a `CLOSED` state is a final action that cannot be
// undone._
func (r *CardService) Update(ctx context.Context, cardToken string, body CardUpdateParams, opts ...option.RequestOption) (res *Card, err error) {
opts = append(r.Options[:], opts...)
if cardToken == "" {
err = errors.New("missing required card_token parameter")
return
}
path := fmt.Sprintf("v1/cards/%s", cardToken)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return
}
// List cards.
func (r *CardService) List(ctx context.Context, query CardListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Card], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "v1/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.CursorPageAutoPager[Card] {
return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...))
}
// Handling full card PANs and CVV codes requires that you comply with the Payment
// Card Industry Data Security Standards (PCI DSS). Some clients choose to reduce
// their compliance obligations by leveraging our embedded card UI solution
// documented below.
//
// In this setup, PANs and CVV codes are presented to the end-user via a card UI
// that we provide, optionally styled in the customer's branding using a specified
// css stylesheet. A user's browser makes the request directly to api.lithic.com,
// so card PANs and CVVs never touch the API customer's servers while full card
// data is displayed to their end-users. The response contains an HTML document.
// This means that the url for the request can be inserted straight into the `src`
// attribute of an iframe.
//
// ```html
// <iframe
//
// id="card-iframe"
// src="https://sandbox.lithic.com/v1/embed/card?embed_request=eyJjc3MiO...;hmac=r8tx1..."
// allow="clipboard-write"
// class="content"
//
// ></iframe>
// ```
//
// You should compute the request payload on the server side. You can render it (or
// the whole iframe) on the server or make an ajax call from your front end code,
// but **do not ever embed your API key into front end code, as doing so introduces
// a serious security vulnerability**.
func (r *CardService) Embed(ctx context.Context, query CardEmbedParams, opts ...option.RequestOption) (res *string, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("Accept", "text/html")}, opts...)
path := "v1/embed/card"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
func (r *CardService) GetEmbedHTML(ctx context.Context, params CardGetEmbedHTMLParams, opts ...option.RequestOption) (res []byte, err error) {
opts = append(r.Options, opts...)
buf, err := params.MarshalJSON()
if err != nil {
return nil, err
}
cfg, err := requestconfig.NewRequestConfig(ctx, "GET", "v1/embed/card", nil, &res, opts...)
if err != nil {
return nil, err
}
mac := hmac.New(sha256.New, []byte(cfg.APIKey))
mac.Write(buf)
sign := mac.Sum(nil)
err = cfg.Apply(
option.WithHeader("Accept", "text/html"),
option.WithQuery("hmac", base64.StdEncoding.EncodeToString(sign)),
option.WithQuery("embed_request", base64.StdEncoding.EncodeToString(buf)),
)
if err != nil {
return nil, err
}
err = cfg.Execute()
return
}
// Handling full card PANs and CVV codes requires that you comply with the Payment
// Card Industry Data Security Standards (PCI DSS). Some clients choose to reduce
// their compliance obligations by leveraging our embedded card UI solution
// documented below.
//
// In this setup, PANs and CVV codes are presented to the end-user via a card UI
// that we provide, optionally styled in the customer's branding using a specified
// css stylesheet. A user's browser makes the request directly to api.lithic.com,
// so card PANs and CVVs never touch the API customer's servers while full card
// data is displayed to their end-users. The response contains an HTML document.
// This means that the url for the request can be inserted straight into the `src`
// attribute of an iframe.
//
// ```html
// <iframe
//
// id="card-iframe"
// src="https://sandbox.lithic.com/v1/embed/card?embed_request=eyJjc3MiO...;hmac=r8tx1..."
// allow="clipboard-write"
// class="content"
//
// ></iframe>
// ```
//
// You should compute the request payload on the server side. You can render it (or
// the whole iframe) on the server or make an ajax call from your front end code,
// but **do not ever embed your API key into front end code, as doing so introduces
// a serious security vulnerability**.
func (r *CardService) GetEmbedURL(ctx context.Context, params CardGetEmbedURLParams, opts ...option.RequestOption) (res *url.URL, err error) {
buf, err := params.MarshalJSON()
if err != nil {
return nil, err
}
cfg, err := requestconfig.NewRequestConfig(ctx, "GET", "v1/embed/card", nil, &res, opts...)
if err != nil {
return nil, err
}
mac := hmac.New(sha256.New, []byte(cfg.APIKey))
mac.Write(buf)
sign := mac.Sum(nil)
err = cfg.Apply(
option.WithQuery("hmac", base64.StdEncoding.EncodeToString(sign)),
option.WithQuery("embed_request", base64.StdEncoding.EncodeToString(buf)),
)
if err != nil {
return nil, err
}
return cfg.Request.URL, nil
}
// Allow your cardholders to directly add payment cards to the device's digital
// wallet (e.g. Apple Pay) with one touch from your app.
//
// This requires some additional setup and configuration. Please
// [Contact Us](https://lithic.com/contact) or your Customer Success representative
// for more information.
func (r *CardService) Provision(ctx context.Context, cardToken string, body CardProvisionParams, opts ...option.RequestOption) (res *CardProvisionResponse, err error) {
opts = append(r.Options[:], opts...)
if cardToken == "" {
err = errors.New("missing required card_token parameter")
return
}
path := fmt.Sprintf("v1/cards/%s/provision", cardToken)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Initiate print and shipment of a duplicate physical card.
//
// Only applies to cards of type `PHYSICAL`.
func (r *CardService) Reissue(ctx context.Context, cardToken string, body CardReissueParams, opts ...option.RequestOption) (res *Card, err error) {
opts = append(r.Options[:], opts...)
if cardToken == "" {
err = errors.New("missing required card_token parameter")
return
}
path := fmt.Sprintf("v1/cards/%s/reissue", cardToken)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Initiate print and shipment of a renewed physical card.
//
// Only applies to cards of type `PHYSICAL`.
func (r *CardService) Renew(ctx context.Context, cardToken string, body CardRenewParams, opts ...option.RequestOption) (res *Card, err error) {
opts = append(r.Options[:], opts...)
if cardToken == "" {
err = errors.New("missing required card_token parameter")
return
}
path := fmt.Sprintf("v1/cards/%s/renew", cardToken)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Get a Card's available spend limit, which is based on the spend limit configured
// on the Card and the amount already spent over the spend limit's duration. For
// example, if the Card has a monthly spend limit of $1000 configured, and has
// spent $600 in the last month, the available spend limit returned would be $400.
func (r *CardService) GetSpendLimits(ctx context.Context, cardToken string, opts ...option.RequestOption) (res *CardSpendLimits, err error) {
opts = append(r.Options[:], opts...)
if cardToken == "" {
err = errors.New("missing required card_token parameter")
return
}
path := fmt.Sprintf("v1/cards/%s/spend_limits", cardToken)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// Get card configuration such as spend limit and state. Customers must be PCI
// compliant to use this endpoint. Please contact
// [[email protected]](mailto:[email protected]) for questions. _Note: this is a
// `POST` endpoint because it is more secure to send sensitive data in a request
// body than in a URL._
func (r *CardService) SearchByPan(ctx context.Context, body CardSearchByPanParams, opts ...option.RequestOption) (res *Card, err error) {
opts = append(r.Options[:], opts...)
path := "v1/cards/search_by_pan"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
type Card struct {
// Globally unique identifier.
Token string `json:"token,required" format:"uuid"`
// Globally unique identifier for the account to which the card belongs.
AccountToken string `json:"account_token,required" format:"uuid"`
// Globally unique identifier for the card program on which the card exists.
CardProgramToken string `json:"card_program_token,required" format:"uuid"`
// An RFC 3339 timestamp for when the card was created. UTC time zone.
Created time.Time `json:"created,required" format:"date-time"`
// Deprecated: Funding account for the card.
Funding CardFunding `json:"funding,required"`
// Last four digits of the card number.
LastFour string `json:"last_four,required"`
// Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect
// attempts).
PinStatus CardPinStatus `json:"pin_status,required"`
// Amount (in cents) to limit approved authorizations. Transaction requests above
// the spend limit will be declined.
SpendLimit int64 `json:"spend_limit,required"`
// Spend limit duration values:
//
// - `ANNUALLY` - Card will authorize transactions up to spend limit for the
// trailing year.
// - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime
// of the card.
// - `MONTHLY` - Card will authorize transactions up to spend limit for the
// trailing month. To support recurring monthly payments, which can occur on
// different day every month, the time window we consider for monthly velocity
// starts 6 days after the current calendar date one month prior.
// - `TRANSACTION` - Card will authorize multiple transactions if each individual
// transaction is under the spend limit.
SpendLimitDuration SpendLimitDuration `json:"spend_limit_duration,required"`
// Card state values:
//
// - `CLOSED` - Card will no longer approve authorizations. Closing a card cannot
// be undone.
// - `OPEN` - Card will approve authorizations (if they match card and account
// parameters).
// - `PAUSED` - Card will decline authorizations, but can be resumed at a later
// time.
// - `PENDING_FULFILLMENT` - The initial state for cards of type `PHYSICAL`. The
// card is provisioned pending manufacturing and fulfillment. Cards in this state
// can accept authorizations for e-commerce purchases, but not for "Card Present"
// purchases where the physical card itself is present.
// - `PENDING_ACTIVATION` - At regular intervals, cards of type `PHYSICAL` in state
// `PENDING_FULFILLMENT` are sent to the card production warehouse and updated to
// state `PENDING_ACTIVATION` . Similar to `PENDING_FULFILLMENT`, cards in this
// state can be used for e-commerce transactions. API clients should update the
// card's state to `OPEN` only after the cardholder confirms receipt of the card.
//
// In sandbox, the same daily batch fulfillment occurs, but no cards are actually
// manufactured.
State CardState `json:"state,required"`
// Card types:
//
// - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital
// wallet like Apple Pay or Google Pay (if the card program is digital
// wallet-enabled).
// - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label
// branding, credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality.
// Reach out at [lithic.com/contact](https://lithic.com/contact) for more
// information.
// - `SINGLE_USE` - Card is closed upon first successful authorization.
// - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
// successfully authorizes the card.
Type CardType `json:"type,required"`
// List of identifiers for the Auth Rule(s) that are applied on the card. This
// field is deprecated and will no longer be populated in the `Card` object. The
// key will be removed from the schema in a future release. Use the `/auth_rules`
// endpoints to fetch Auth Rule information instead.
AuthRuleTokens []string `json:"auth_rule_tokens"`
// 3-digit alphabetic ISO 4217 code for the currency of the cardholder.
CardholderCurrency string `json:"cardholder_currency"`
// Three digit cvv printed on the back of the card.
Cvv string `json:"cvv"`
// Specifies the digital card art to be displayed in the user’s digital wallet
// after tokenization. This artwork must be approved by Mastercard and configured
// by Lithic to use. See
// [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art).
DigitalCardArtToken string `json:"digital_card_art_token" format:"uuid"`
// Two digit (MM) expiry month.
ExpMonth string `json:"exp_month"`
// Four digit (yyyy) expiry year.
ExpYear string `json:"exp_year"`
// Hostname of card’s locked merchant (will be empty if not applicable).
Hostname string `json:"hostname"`
// Friendly name to identify the card.
Memo string `json:"memo"`
// Primary Account Number (PAN) (i.e. the card number). Customers must be PCI
// compliant to have PAN returned as a field in production. Please contact
// [[email protected]](mailto:[email protected]) for questions.
Pan string `json:"pan"`
// Indicates if there are offline PIN changes pending card interaction with an
// offline PIN terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable
// only to cards issued in markets supporting offline PINs.
PendingCommands []string `json:"pending_commands"`
// Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic
// before use. Specifies the configuration (i.e., physical card art) that the card
// should be manufactured with.
ProductID string `json:"product_id"`
JSON cardJSON `json:"-"`
}
// cardJSON contains the JSON metadata for the struct [Card]
type cardJSON struct {
Token apijson.Field
AccountToken apijson.Field
CardProgramToken apijson.Field
Created apijson.Field
Funding apijson.Field
LastFour apijson.Field
PinStatus apijson.Field
SpendLimit apijson.Field
SpendLimitDuration apijson.Field
State apijson.Field
Type apijson.Field
AuthRuleTokens apijson.Field
CardholderCurrency apijson.Field
Cvv apijson.Field
DigitalCardArtToken apijson.Field
ExpMonth apijson.Field
ExpYear apijson.Field
Hostname apijson.Field
Memo apijson.Field
Pan apijson.Field
PendingCommands apijson.Field
ProductID 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
}
// Deprecated: Funding account for the card.
type CardFunding struct {
// A globally unique identifier for this FundingAccount.
Token string `json:"token,required" format:"uuid"`
// An RFC 3339 string representing when this funding source was added to the Lithic
// account. This may be `null`. UTC time zone.
Created time.Time `json:"created,required" format:"date-time"`
// The last 4 digits of the account (e.g. bank account, debit card) associated with
// this FundingAccount. This may be null.
LastFour string `json:"last_four,required"`
// State of funding source.
//
// Funding source states:
//
// - `ENABLED` - The funding account is available to use for card creation and
// transactions.
// - `PENDING` - The funding account is still being verified e.g. bank
// micro-deposits verification.
// - `DELETED` - The founding account has been deleted.
State CardFundingState `json:"state,required"`
// Types of funding source:
//
// - `DEPOSITORY_CHECKING` - Bank checking account.
// - `DEPOSITORY_SAVINGS` - Bank savings account.
Type CardFundingType `json:"type,required"`
// Account name identifying the funding source. This may be `null`.
AccountName string `json:"account_name"`
// The nickname given to the `FundingAccount` or `null` if it has no nickname.
Nickname string `json:"nickname"`
JSON cardFundingJSON `json:"-"`
}
// cardFundingJSON contains the JSON metadata for the struct [CardFunding]
type cardFundingJSON struct {
Token apijson.Field
Created apijson.Field
LastFour apijson.Field
State apijson.Field
Type apijson.Field
AccountName apijson.Field
Nickname apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardFunding) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardFundingJSON) RawJSON() string {
return r.raw
}
// State of funding source.
//
// Funding source states:
//
// - `ENABLED` - The funding account is available to use for card creation and
// transactions.
// - `PENDING` - The funding account is still being verified e.g. bank
// micro-deposits verification.
// - `DELETED` - The founding account has been deleted.
type CardFundingState string
const (
CardFundingStateDeleted CardFundingState = "DELETED"
CardFundingStateEnabled CardFundingState = "ENABLED"
CardFundingStatePending CardFundingState = "PENDING"
)
func (r CardFundingState) IsKnown() bool {
switch r {
case CardFundingStateDeleted, CardFundingStateEnabled, CardFundingStatePending:
return true
}
return false
}
// Types of funding source:
//
// - `DEPOSITORY_CHECKING` - Bank checking account.
// - `DEPOSITORY_SAVINGS` - Bank savings account.
type CardFundingType string
const (
CardFundingTypeDepositoryChecking CardFundingType = "DEPOSITORY_CHECKING"
CardFundingTypeDepositorySavings CardFundingType = "DEPOSITORY_SAVINGS"
)
func (r CardFundingType) IsKnown() bool {
switch r {
case CardFundingTypeDepositoryChecking, CardFundingTypeDepositorySavings:
return true
}
return false
}
// Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect
// attempts).
type CardPinStatus string
const (
CardPinStatusOk CardPinStatus = "OK"
CardPinStatusBlocked CardPinStatus = "BLOCKED"
CardPinStatusNotSet CardPinStatus = "NOT_SET"
)
func (r CardPinStatus) IsKnown() bool {
switch r {
case CardPinStatusOk, CardPinStatusBlocked, CardPinStatusNotSet:
return true
}
return false
}
// Card state values:
//
// - `CLOSED` - Card will no longer approve authorizations. Closing a card cannot
// be undone.
// - `OPEN` - Card will approve authorizations (if they match card and account
// parameters).
// - `PAUSED` - Card will decline authorizations, but can be resumed at a later
// time.
// - `PENDING_FULFILLMENT` - The initial state for cards of type `PHYSICAL`. The
// card is provisioned pending manufacturing and fulfillment. Cards in this state
// can accept authorizations for e-commerce purchases, but not for "Card Present"
// purchases where the physical card itself is present.
// - `PENDING_ACTIVATION` - At regular intervals, cards of type `PHYSICAL` in state
// `PENDING_FULFILLMENT` are sent to the card production warehouse and updated to
// state `PENDING_ACTIVATION` . Similar to `PENDING_FULFILLMENT`, cards in this
// state can be used for e-commerce transactions. API clients should update the
// card's state to `OPEN` only after the cardholder confirms receipt of the card.
//
// In sandbox, the same daily batch fulfillment occurs, but no cards are actually
// manufactured.
type CardState string
const (
CardStateClosed CardState = "CLOSED"
CardStateOpen CardState = "OPEN"
CardStatePaused CardState = "PAUSED"
CardStatePendingActivation CardState = "PENDING_ACTIVATION"
CardStatePendingFulfillment CardState = "PENDING_FULFILLMENT"
)
func (r CardState) IsKnown() bool {
switch r {
case CardStateClosed, CardStateOpen, CardStatePaused, CardStatePendingActivation, CardStatePendingFulfillment:
return true
}
return false
}
// Card types:
//
// - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital
// wallet like Apple Pay or Google Pay (if the card program is digital
// wallet-enabled).
// - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label
// branding, credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality.
// Reach out at [lithic.com/contact](https://lithic.com/contact) for more
// information.
// - `SINGLE_USE` - Card is closed upon first successful authorization.
// - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
// successfully authorizes the card.
type CardType string
const (
CardTypeMerchantLocked CardType = "MERCHANT_LOCKED"
CardTypePhysical CardType = "PHYSICAL"
CardTypeSingleUse CardType = "SINGLE_USE"
CardTypeVirtual CardType = "VIRTUAL"
)
func (r CardType) IsKnown() bool {
switch r {
case CardTypeMerchantLocked, CardTypePhysical, CardTypeSingleUse, CardTypeVirtual:
return true
}
return false
}
type CardSpendLimits struct {
AvailableSpendLimit CardSpendLimitsAvailableSpendLimit `json:"available_spend_limit,required"`
SpendLimit CardSpendLimitsSpendLimit `json:"spend_limit"`
SpendVelocity CardSpendLimitsSpendVelocity `json:"spend_velocity"`
JSON cardSpendLimitsJSON `json:"-"`
}
// cardSpendLimitsJSON contains the JSON metadata for the struct [CardSpendLimits]
type cardSpendLimitsJSON struct {
AvailableSpendLimit apijson.Field
SpendLimit apijson.Field
SpendVelocity apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardSpendLimits) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardSpendLimitsJSON) RawJSON() string {
return r.raw
}
type CardSpendLimitsAvailableSpendLimit struct {
// The available spend limit (in cents) relative to the annual limit configured on
// the Card.
Annually int64 `json:"annually"`
// The available spend limit (in cents) relative to the forever limit configured on
// the Card.
Forever int64 `json:"forever"`
// The available spend limit (in cents) relative to the monthly limit configured on
// the Card.
Monthly int64 `json:"monthly"`
JSON cardSpendLimitsAvailableSpendLimitJSON `json:"-"`
}
// cardSpendLimitsAvailableSpendLimitJSON contains the JSON metadata for the struct
// [CardSpendLimitsAvailableSpendLimit]
type cardSpendLimitsAvailableSpendLimitJSON struct {
Annually apijson.Field
Forever apijson.Field
Monthly apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardSpendLimitsAvailableSpendLimit) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardSpendLimitsAvailableSpendLimitJSON) RawJSON() string {
return r.raw
}
type CardSpendLimitsSpendLimit struct {
// The configured annual spend limit (in cents) on the Card.
Annually int64 `json:"annually"`
// The configured forever spend limit (in cents) on the Card.
Forever int64 `json:"forever"`
// The configured monthly spend limit (in cents) on the Card.
Monthly int64 `json:"monthly"`
JSON cardSpendLimitsSpendLimitJSON `json:"-"`
}
// cardSpendLimitsSpendLimitJSON contains the JSON metadata for the struct
// [CardSpendLimitsSpendLimit]
type cardSpendLimitsSpendLimitJSON struct {
Annually apijson.Field
Forever apijson.Field
Monthly apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardSpendLimitsSpendLimit) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardSpendLimitsSpendLimitJSON) RawJSON() string {
return r.raw
}
type CardSpendLimitsSpendVelocity struct {
// Current annual spend velocity (in cents) on the Card. Present if annual spend
// limit is set.
Annually int64 `json:"annually"`
// Current forever spend velocity (in cents) on the Card. Present if forever spend
// limit is set.
Forever int64 `json:"forever"`
// Current monthly spend velocity (in cents) on the Card. Present if monthly spend
// limit is set.
Monthly int64 `json:"monthly"`
JSON cardSpendLimitsSpendVelocityJSON `json:"-"`
}
// cardSpendLimitsSpendVelocityJSON contains the JSON metadata for the struct
// [CardSpendLimitsSpendVelocity]
type cardSpendLimitsSpendVelocityJSON struct {
Annually apijson.Field
Forever apijson.Field
Monthly apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardSpendLimitsSpendVelocity) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardSpendLimitsSpendVelocityJSON) RawJSON() string {
return r.raw
}
// Spend limit duration values:
//
// - `ANNUALLY` - Card will authorize transactions up to spend limit for the
// trailing year.
// - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime
// of the card.
// - `MONTHLY` - Card will authorize transactions up to spend limit for the
// trailing month. To support recurring monthly payments, which can occur on
// different day every month, the time window we consider for monthly velocity
// starts 6 days after the current calendar date one month prior.
// - `TRANSACTION` - Card will authorize multiple transactions if each individual
// transaction is under the spend limit.
type SpendLimitDuration string
const (
SpendLimitDurationAnnually SpendLimitDuration = "ANNUALLY"
SpendLimitDurationForever SpendLimitDuration = "FOREVER"
SpendLimitDurationMonthly SpendLimitDuration = "MONTHLY"
SpendLimitDurationTransaction SpendLimitDuration = "TRANSACTION"
)
func (r SpendLimitDuration) IsKnown() bool {
switch r {
case SpendLimitDurationAnnually, SpendLimitDurationForever, SpendLimitDurationMonthly, SpendLimitDurationTransaction:
return true
}
return false
}
type CardProvisionResponse struct {
ProvisioningPayload string `json:"provisioning_payload"`
JSON cardProvisionResponseJSON `json:"-"`
}
// cardProvisionResponseJSON contains the JSON metadata for the struct
// [CardProvisionResponse]
type cardProvisionResponseJSON struct {
ProvisioningPayload apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CardProvisionResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r cardProvisionResponseJSON) RawJSON() string {
return r.raw
}
type CardNewParams struct {
// Card types:
//
// - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital
// wallet like Apple Pay or Google Pay (if the card program is digital
// wallet-enabled).
// - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label
// branding, credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality.
// Reach out at [lithic.com/contact](https://lithic.com/contact) for more
// information.
// - `SINGLE_USE` - Card is closed upon first successful authorization.
// - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
// successfully authorizes the card.
Type param.Field[CardNewParamsType] `json:"type,required"`
// Globally unique identifier for the account that the card will be associated
// with. Required for programs enrolling users using the
// [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc).
// See [Managing Your Program](doc:managing-your-program) for more information.
AccountToken param.Field[string] `json:"account_token" format:"uuid"`
// For card programs with more than one BIN range. This must be configured with
// Lithic before use. Identifies the card program/BIN range under which to create
// the card. If omitted, will utilize the program's default `card_program_token`.
// In Sandbox, use 00000000-0000-0000-1000-000000000000 and
// 00000000-0000-0000-2000-000000000000 to test creating cards on specific card
// programs.
CardProgramToken param.Field[string] `json:"card_program_token" format:"uuid"`
Carrier param.Field[shared.CarrierParam] `json:"carrier"`
// Specifies the digital card art to be displayed in the user’s digital wallet
// after tokenization. This artwork must be approved by Mastercard and configured
// by Lithic to use. See
// [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art).
DigitalCardArtToken param.Field[string] `json:"digital_card_art_token" format:"uuid"`
// Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided,
// an expiration date will be generated.
ExpMonth param.Field[string] `json:"exp_month"`
// Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is
// provided, an expiration date will be generated.
ExpYear param.Field[string] `json:"exp_year"`
// Friendly name to identify the card.
Memo param.Field[string] `json:"memo"`
// Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and
// `VIRTUAL`. See
// [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block).
Pin param.Field[string] `json:"pin"`
// Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic
// before use. Specifies the configuration (i.e., physical card art) that the card
// should be manufactured with.
ProductID param.Field[string] `json:"product_id"`
// Restricted field limited to select use cases. Lithic will reach out directly if
// this field should be used. Globally unique identifier for the replacement card's
// account. If this field is specified, `replacement_for` must also be specified.
// If `replacement_for` is specified and this field is omitted, the replacement
// card's account will be inferred from the card being replaced.
ReplacementAccountToken param.Field[string] `json:"replacement_account_token" format:"uuid"`
// Only applicable to cards of type `PHYSICAL`. Globally unique identifier for the
// card that this physical card will replace.
ReplacementFor param.Field[string] `json:"replacement_for" format:"uuid"`
ShippingAddress param.Field[shared.ShippingAddressParam] `json:"shipping_address"`
// Shipping method for the card. Only applies to cards of type PHYSICAL. Use of
// options besides `STANDARD` require additional permissions.
//
// - `STANDARD` - USPS regular mail or similar international option, with no
// tracking
// - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option,
// with tracking
// - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking
// - `EXPRESS` - FedEx Express, 3-day shipping, with tracking
// - `2_DAY` - FedEx 2-day shipping, with tracking
// - `EXPEDITED` - FedEx Standard Overnight or similar international option, with
// tracking
ShippingMethod param.Field[CardNewParamsShippingMethod] `json:"shipping_method"`
// Amount (in cents) to limit approved authorizations. Transaction requests above
// the spend limit will be declined. Note that a spend limit of 0 is effectively no
// limit, and should only be used to reset or remove a prior limit. Only a limit of
// 1 or above will result in declined transactions due to checks against the card
// limit.
SpendLimit param.Field[int64] `json:"spend_limit"`
// Spend limit duration values:
//
// - `ANNUALLY` - Card will authorize transactions up to spend limit for the
// trailing year.
// - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime
// of the card.
// - `MONTHLY` - Card will authorize transactions up to spend limit for the
// trailing month. To support recurring monthly payments, which can occur on
// different day every month, the time window we consider for monthly velocity
// starts 6 days after the current calendar date one month prior.
// - `TRANSACTION` - Card will authorize multiple transactions if each individual
// transaction is under the spend limit.
SpendLimitDuration param.Field[SpendLimitDuration] `json:"spend_limit_duration"`
// Card state values:
//
// - `OPEN` - Card will approve authorizations (if they match card and account
// parameters).
// - `PAUSED` - Card will decline authorizations, but can be resumed at a later
// time.
State param.Field[CardNewParamsState] `json:"state"`
}
func (r CardNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Card types:
//
// - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital
// wallet like Apple Pay or Google Pay (if the card program is digital
// wallet-enabled).
// - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label
// branding, credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality.
// Reach out at [lithic.com/contact](https://lithic.com/contact) for more
// information.
// - `SINGLE_USE` - Card is closed upon first successful authorization.
// - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
// successfully authorizes the card.
type CardNewParamsType string
const (
CardNewParamsTypeMerchantLocked CardNewParamsType = "MERCHANT_LOCKED"
CardNewParamsTypePhysical CardNewParamsType = "PHYSICAL"
CardNewParamsTypeSingleUse CardNewParamsType = "SINGLE_USE"
CardNewParamsTypeVirtual CardNewParamsType = "VIRTUAL"
)
func (r CardNewParamsType) IsKnown() bool {
switch r {
case CardNewParamsTypeMerchantLocked, CardNewParamsTypePhysical, CardNewParamsTypeSingleUse, CardNewParamsTypeVirtual:
return true
}
return false
}
// Shipping method for the card. Only applies to cards of type PHYSICAL. Use of
// options besides `STANDARD` require additional permissions.
//
// - `STANDARD` - USPS regular mail or similar international option, with no
// tracking
// - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option,
// with tracking
// - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking
// - `EXPRESS` - FedEx Express, 3-day shipping, with tracking
// - `2_DAY` - FedEx 2-day shipping, with tracking
// - `EXPEDITED` - FedEx Standard Overnight or similar international option, with
// tracking
type CardNewParamsShippingMethod string
const (
CardNewParamsShippingMethod2Day CardNewParamsShippingMethod = "2_DAY"
CardNewParamsShippingMethodExpedited CardNewParamsShippingMethod = "EXPEDITED"
CardNewParamsShippingMethodExpress CardNewParamsShippingMethod = "EXPRESS"
CardNewParamsShippingMethodPriority CardNewParamsShippingMethod = "PRIORITY"
CardNewParamsShippingMethodStandard CardNewParamsShippingMethod = "STANDARD"
CardNewParamsShippingMethodStandardWithTracking CardNewParamsShippingMethod = "STANDARD_WITH_TRACKING"
)
func (r CardNewParamsShippingMethod) IsKnown() bool {
switch r {
case CardNewParamsShippingMethod2Day, CardNewParamsShippingMethodExpedited, CardNewParamsShippingMethodExpress, CardNewParamsShippingMethodPriority, CardNewParamsShippingMethodStandard, CardNewParamsShippingMethodStandardWithTracking:
return true
}
return false
}
// Card state values:
//
// - `OPEN` - Card will approve authorizations (if they match card and account
// parameters).
// - `PAUSED` - Card will decline authorizations, but can be resumed at a later
// time.
type CardNewParamsState string
const (
CardNewParamsStateOpen CardNewParamsState = "OPEN"
CardNewParamsStatePaused CardNewParamsState = "PAUSED"
)
func (r CardNewParamsState) IsKnown() bool {
switch r {
case CardNewParamsStateOpen, CardNewParamsStatePaused:
return true
}
return false
}
type CardUpdateParams struct {
// Specifies the digital card art to be displayed in the user’s digital wallet
// after tokenization. This artwork must be approved by Mastercard and configured
// by Lithic to use. See
// [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art).
DigitalCardArtToken param.Field[string] `json:"digital_card_art_token" format:"uuid"`
// Friendly name to identify the card.
Memo param.Field[string] `json:"memo"`
// Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and
// `VIRTUAL`. Changing PIN also resets PIN status to `OK`. See
// [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block).
Pin param.Field[string] `json:"pin"`
// Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect
// attempts). Can only be set to `OK` to unblock a card.
PinStatus param.Field[CardUpdateParamsPinStatus] `json:"pin_status"`
// Amount (in cents) to limit approved authorizations. Transaction requests above
// the spend limit will be declined. Note that a spend limit of 0 is effectively no
// limit, and should only be used to reset or remove a prior limit. Only a limit of
// 1 or above will result in declined transactions due to checks against the card
// limit.
SpendLimit param.Field[int64] `json:"spend_limit"`
// Spend limit duration values:
//
// - `ANNUALLY` - Card will authorize transactions up to spend limit for the
// trailing year.
// - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime
// of the card.
// - `MONTHLY` - Card will authorize transactions up to spend limit for the
// trailing month. To support recurring monthly payments, which can occur on
// different day every month, the time window we consider for monthly velocity
// starts 6 days after the current calendar date one month prior.
// - `TRANSACTION` - Card will authorize multiple transactions if each individual
// transaction is under the spend limit.
SpendLimitDuration param.Field[SpendLimitDuration] `json:"spend_limit_duration"`
// Card state values:
//
// - `CLOSED` - Card will no longer approve authorizations. Closing a card cannot
// be undone.
// - `OPEN` - Card will approve authorizations (if they match card and account