@takeal/cusfront-sdk 0.6.3 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +175 -12
- package/dist/{cards-ofoGRU9v.d.cts → cards-CEFKrVkl.d.cts} +125 -10
- package/dist/{cards-BrqeBqLV.d.ts → cards-ColpW52n.d.ts} +125 -10
- package/dist/index.cjs +160 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.js +159 -12
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +3 -1
- package/dist/react/index.d.ts +3 -1
- package/dist/resources/auth.cjs +39 -0
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +76 -3
- package/dist/resources/auth.d.ts +76 -3
- package/dist/resources/auth.js +39 -0
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +9 -2
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +1 -1
- package/dist/resources/cards.d.ts +1 -1
- package/dist/resources/cards.js +9 -2
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/close-requests.cjs +54 -0
- package/dist/resources/close-requests.cjs.map +1 -0
- package/dist/resources/close-requests.d.cts +155 -0
- package/dist/resources/close-requests.d.ts +155 -0
- package/dist/resources/close-requests.js +52 -0
- package/dist/resources/close-requests.js.map +1 -0
- package/dist/resources/consents.cjs +42 -7
- package/dist/resources/consents.cjs.map +1 -1
- package/dist/resources/consents.d.cts +58 -8
- package/dist/resources/consents.d.ts +58 -8
- package/dist/resources/consents.js +41 -8
- package/dist/resources/consents.js.map +1 -1
- package/dist/resources/debt.cjs +22 -0
- package/dist/resources/debt.cjs.map +1 -0
- package/dist/resources/debt.d.cts +76 -0
- package/dist/resources/debt.d.ts +76 -0
- package/dist/resources/debt.js +20 -0
- package/dist/resources/debt.js.map +1 -0
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +1 -1
- package/dist/resources/deposits.d.ts +1 -1
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +1 -1
- package/dist/resources/funding-options.d.ts +1 -1
- package/dist/resources/history.cjs.map +1 -1
- package/dist/resources/history.d.cts +12 -1
- package/dist/resources/history.d.ts +12 -1
- package/dist/resources/history.js.map +1 -1
- package/dist/resources/me.d.cts +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/telegram.cjs +158 -11
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +3 -1
- package/dist/telegram.d.ts +3 -1
- package/dist/telegram.js +158 -11
- package/dist/telegram.js.map +1 -1
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,54 @@ All notable changes to `@takeal/cusfront-sdk` are documented here. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.6.5] — 2026-10-21
|
|
8
|
+
|
|
9
|
+
Needs platform (TKL) 0.6.11 or newer: `SUPPORTED_MEISTER` is `>=0.6.11, <0.7.0`.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `closeRequests`: close a card that still has money on it
|
|
14
|
+
(`request(cardId)`), follow the refund (`list()`, `get(id)`, `forCard(cardId)`)
|
|
15
|
+
through its statuses, and give an account or a card in the holder's own name
|
|
16
|
+
when the money can't go back the way it was paid (`submitPayoutDetails`).
|
|
17
|
+
- `debt.get()` and `debt.owedIn(currency)`: what the person owes for card fees. Quotes, card orders and the card
|
|
18
|
+
top-up terms show the part of a payment that goes to the debt
|
|
19
|
+
(`debt_withheld`, `debt`).
|
|
20
|
+
- The card catalogue carries each product's `tariff` (fees per payment, per
|
|
21
|
+
declined payment and per cash withdrawal) and `holder_data_required`.
|
|
22
|
+
- `consents.allowHolderData()`, `consents.allowDisputeDocuments({ cardId })`
|
|
23
|
+
and `consents.stands(kind)`, with the `HOLDER_DATA_CONSENT` and
|
|
24
|
+
`DISPUTE_DOCUMENTS_CONSENT` constants. A product with
|
|
25
|
+
`holder_data_required` issues a card only with that consent; send it with
|
|
26
|
+
the order (`consents: ["holder_data_transfer"]`) or give it beforehand.
|
|
27
|
+
- Cards show `in_transit` (a closed card's balance on its way to the card that
|
|
28
|
+
replaced it), `reissued_from_card_id` and `reissued_to_card_id`.
|
|
29
|
+
- History kinds `closed_card_balance`, `card_fee` and `debt_payment`.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- `CardLoadStatus` has every status the platform sends: `waiting`, `stalled`,
|
|
34
|
+
`refunding` and `refunded` besides `pending`, `succeeded` and `failed`. A
|
|
35
|
+
top-up the card never got goes back to where it was paid from.
|
|
36
|
+
- `consents.set()` takes `{ channel, cardId }` as its third argument; a bare
|
|
37
|
+
channel string still works.
|
|
38
|
+
- `types.gen.ts` is regenerated from the platform's spec.
|
|
39
|
+
|
|
40
|
+
## [0.6.4] — 2026-10-20
|
|
41
|
+
|
|
42
|
+
Needs platform (TKL) 0.6.9 or newer: `SUPPORTED_MEISTER` is `>=0.6.9, <0.7.0`.
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- `auth.requestEmailCode({ email })` and `auth.verifyEmailCode({ challengeId,
|
|
47
|
+
code, … })`: signing in with a six-digit code sent to the e-mail, no
|
|
48
|
+
password. An address with no account gets one when the code comes back
|
|
49
|
+
(`account_created: true`); an account that has a password can use either
|
|
50
|
+
way. `verifyEmailCode` takes `cardOrder`, `consents` and `promoCode`, so a
|
|
51
|
+
card bought from the site needs only the address and the code before the
|
|
52
|
+
payment page. The session carries `card_order`, or `card_order_error` when
|
|
53
|
+
no payment was opened.
|
|
54
|
+
|
|
7
55
|
## [0.6.3] — 2026-10-20
|
|
8
56
|
|
|
9
57
|
Needs platform (TKL) 0.6.8 or newer: `SUPPORTED_MEISTER` is `>=0.6.8, <0.7.0`.
|
package/README.md
CHANGED
|
@@ -49,7 +49,8 @@ if (result.stage === "jwt") {
|
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
New users sign up with `register`, which also signs them in
|
|
52
|
+
New users sign up with `register`, which also signs them in (or with no
|
|
53
|
+
password at all, by a code from the e-mail; see below):
|
|
53
54
|
|
|
54
55
|
```ts
|
|
55
56
|
await client.auth.register({
|
|
@@ -147,7 +148,8 @@ switch (card.status) {
|
|
|
147
148
|
}
|
|
148
149
|
break;
|
|
149
150
|
case "terminating":
|
|
150
|
-
// Closing. The balance comes back
|
|
151
|
+
// Closing. The balance comes back when the issuer is done: to the wallet,
|
|
152
|
+
// or to the new card when the card was reissued (`reissued_to_card_id`).
|
|
151
153
|
break;
|
|
152
154
|
}
|
|
153
155
|
|
|
@@ -165,8 +167,27 @@ if (card.topups_held) {
|
|
|
165
167
|
if (card.card_form === "physical") {
|
|
166
168
|
// Plastic: the numbers are on the card, and it takes a PIN (see below).
|
|
167
169
|
}
|
|
170
|
+
if (card.in_transit) {
|
|
171
|
+
// A reissued card: what was left on the old one is on its way here.
|
|
172
|
+
// stage "issuer": the old card's issuer hasn't returned it yet;
|
|
173
|
+
// stage "loading": it has, and the money is being put on this card.
|
|
174
|
+
// Show it next to the balance, not in it.
|
|
175
|
+
}
|
|
176
|
+
if (card.reissued_to_card_id) {
|
|
177
|
+
// This card was replaced; link to the new one.
|
|
178
|
+
}
|
|
168
179
|
```
|
|
169
180
|
|
|
181
|
+
A card that stopped working before its term (the issuer closed its BIN, froze
|
|
182
|
+
or closed the card, the card broke) is reissued for free by support. The user
|
|
183
|
+
gets a new card on the same product with `reissued_from_card_id` pointing at the
|
|
184
|
+
old one, and the old card gets `reissued_to_card_id`. The old card's balance
|
|
185
|
+
follows once its issuer returns it: until then the new card carries it in
|
|
186
|
+
`in_transit`, and the history has a `closed_card_balance` entry, `pending` until
|
|
187
|
+
the money is on the new card. The user is told at each step (`card_reissued`,
|
|
188
|
+
`card_reissue_delivered`; `card_reissue_on_wallet` when the new card could not
|
|
189
|
+
take the money and it went to the wallet instead).
|
|
190
|
+
|
|
170
191
|
`status_source` is `holder`, `operator` or `provider`, or `null` for a card
|
|
171
192
|
whose status never changed. Trying to unfreeze a card the issuer froze answers
|
|
172
193
|
409 `card_locked`.
|
|
@@ -243,16 +264,47 @@ Paying in another currency than the card's needs a quote in the card's
|
|
|
243
264
|
currency first: `deposits.quote({ amount, currency, card_id })`, or
|
|
244
265
|
`target_currency` for a card that doesn't exist yet.
|
|
245
266
|
|
|
267
|
+
## Signing in with a code from the e-mail
|
|
268
|
+
|
|
269
|
+
A user can sign in, or sign up, with nothing but their address: a six-digit
|
|
270
|
+
code goes there, and the code signs them in. An address with no account gets
|
|
271
|
+
one at that moment, with no password. The first call answers the same for
|
|
272
|
+
both, so the form doesn't tell anyone whose addresses the platform has.
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
const { challenge_id, resend_at } = await client.auth.requestEmailCode({ email });
|
|
276
|
+
// show the code field; keep "send again" off until resend_at
|
|
277
|
+
|
|
278
|
+
const session = await client.auth.verifyEmailCode({
|
|
279
|
+
challengeId: challenge_id,
|
|
280
|
+
code, // the six digits the user typed
|
|
281
|
+
remember: true,
|
|
282
|
+
consents: ["terms", "personal_data"],
|
|
283
|
+
});
|
|
284
|
+
session.account_created; // true when the address was new
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
The code works for 10 minutes and takes five tries; a new code replaces the
|
|
288
|
+
old one. One address gets a code at most once a minute and five an hour, so
|
|
289
|
+
handle 429 `resend_too_soon` and `too_many_requests` (the message says when
|
|
290
|
+
to try again). A wrong code is 401 `invalid_code`. An account that already
|
|
291
|
+
has a password signs in either way. Operator accounts can't use codes: they
|
|
292
|
+
get 403 `second_factor_required` and sign in with the password and the
|
|
293
|
+
authenticator.
|
|
294
|
+
|
|
246
295
|
## Buying a card in one step
|
|
247
296
|
|
|
248
297
|
When the user picks a card before they have an account (a "Get the card"
|
|
249
|
-
button on the site), let the sign-
|
|
250
|
-
right after the
|
|
298
|
+
button on the site), let the sign-in order it too. They see the payment page
|
|
299
|
+
right after the code, with nothing to pick twice and no password to make up:
|
|
251
300
|
|
|
252
301
|
```ts
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
302
|
+
const { challenge_id } = await client.auth.requestEmailCode({ email });
|
|
303
|
+
// … the user types the code from the e-mail …
|
|
304
|
+
const session = await client.auth.verifyEmailCode({
|
|
305
|
+
challengeId: challenge_id,
|
|
306
|
+
code,
|
|
307
|
+
promoCode, // the form's promo code, if any
|
|
256
308
|
consents: ["terms", "personal_data"],
|
|
257
309
|
cardOrder: {
|
|
258
310
|
productId, // the card they clicked
|
|
@@ -263,14 +315,19 @@ const session = await client.auth.register({
|
|
|
263
315
|
if (session.card_order) {
|
|
264
316
|
location.href = session.card_order.deposit.redirect_url!;
|
|
265
317
|
} else {
|
|
266
|
-
// session.card_order_error says why
|
|
267
|
-
//
|
|
318
|
+
// session.card_order_error says why no payment was opened (the product
|
|
319
|
+
// is off sale, SBP is down, there's no rate). The user is signed in, so
|
|
320
|
+
// show the reason and open the ordinary card screen.
|
|
268
321
|
}
|
|
269
322
|
```
|
|
270
323
|
|
|
324
|
+
The same works for an address that already has an account: the card goes to
|
|
325
|
+
that account. `auth.register({ email, password, cardOrder })` does it with a
|
|
326
|
+
password instead.
|
|
327
|
+
|
|
271
328
|
The API prices the card in the payment's currency (`card_order.amount`, in
|
|
272
329
|
roubles for SBP) with the rate locked, and opens the top-up that issues it.
|
|
273
|
-
The consents ticked
|
|
330
|
+
The consents ticked on the form go with the order. A user who is already
|
|
274
331
|
signed in gets the same with `client.cards.order({ productId, method,
|
|
275
332
|
idempotencyKey })`. The card shows as `pending_payment` until the payment is
|
|
276
333
|
confirmed and is issued after that.
|
|
@@ -579,6 +636,82 @@ const top = await client.deposits.initiate({ amount: "25", currency: "USD", meth
|
|
|
579
636
|
- In your copy, call bonuses a discount. Keep words like funds, withdraw or
|
|
580
637
|
exchange away from them.
|
|
581
638
|
|
|
639
|
+
## Card fees and debt
|
|
640
|
+
|
|
641
|
+
A card product has a tariff (`product.tariff`): a fee per payment (fixed
|
|
642
|
+
and percent), per decline that was the user's doing (not enough money, wrong
|
|
643
|
+
details, a frozen card, a subscription not cancelled with the merchant), and
|
|
644
|
+
per cash withdrawal. Show it on the product card. A fee comes off the card
|
|
645
|
+
and is a line of its own in the history (`kind: "card_fee"`).
|
|
646
|
+
|
|
647
|
+
What the card can't cover is owed by the user, and the next top-up of any of
|
|
648
|
+
their cards or of the wallet pays it first. Always show that amount before
|
|
649
|
+
the user pays:
|
|
650
|
+
|
|
651
|
+
```ts
|
|
652
|
+
const debt = await client.debt.get(); // { total: [{ amount, currency }], items }
|
|
653
|
+
const owed = await client.debt.owedIn("USD"); // "0.8", or "0"
|
|
654
|
+
|
|
655
|
+
const q = await client.deposits.quote({ amount: "1000", currency: "RUB", card_id });
|
|
656
|
+
// q.debt_withheld "0.8" comes off q.credited_amount; the card gets the rest
|
|
657
|
+
|
|
658
|
+
const order = await client.cards.order({ productId, method: "sbp", idempotencyKey });
|
|
659
|
+
// order.debt_withheld is already in order.card_amount and order.amount
|
|
660
|
+
|
|
661
|
+
const terms = await client.cards.topUpTerms(cardId);
|
|
662
|
+
// terms.debt: { amount, currency } or null; a top-up from the wallet pays it first
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
A deposit carries `debt_quoted` (what it will withhold at most) and, once
|
|
666
|
+
paid, `debt_withheld`. The user is notified when a debt arises and when it is
|
|
667
|
+
paid; a payment against the debt shows in the history as `debt_payment`.
|
|
668
|
+
|
|
669
|
+
## Closing a card with money on it
|
|
670
|
+
|
|
671
|
+
`cards.terminate()` refuses a card that still holds money (409
|
|
672
|
+
`move_balance_first` or `contact_support_to_close`). Offer a close with a
|
|
673
|
+
refund instead: the card is closed at its issuer right away, and once the
|
|
674
|
+
issuer returns what was left on it, the money goes back to the payments the
|
|
675
|
+
card was topped up with, in the currency they were paid in, newest payment
|
|
676
|
+
first. Unspent bonuses are not refunded, and a debt the user was told about
|
|
677
|
+
is withheld first.
|
|
678
|
+
|
|
679
|
+
```ts
|
|
680
|
+
const req = await client.closeRequests.request(cardId); // asking again returns the same request
|
|
681
|
+
// req.status: "accepted" → "awaiting_issuer" → "refunding" → "refunded"
|
|
682
|
+
// req.balance { amount, currency }: what the card held
|
|
683
|
+
// req.bonus_excluded, req.debt_withheld: kept back, in the card's currency
|
|
684
|
+
// req.refund_total { amount, currency }: what goes back in all, once known
|
|
685
|
+
// req.refunded, req.on_the_way, req.refunds[]: what went back so far
|
|
686
|
+
// req.deadline_at: when the refund is due by
|
|
687
|
+
|
|
688
|
+
const mine = await client.closeRequests.list(); // newest first
|
|
689
|
+
const one = await client.closeRequests.forCard(cardId); // or null
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
Show amounts only; the API never gives the exchange rate, and the UI should
|
|
693
|
+
not work one out either.
|
|
694
|
+
|
|
695
|
+
When the money can't go back the way it came, the request turns
|
|
696
|
+
`payout_details_required` and the user is notified. Ask for a bank account
|
|
697
|
+
or a card in their own name:
|
|
698
|
+
|
|
699
|
+
```ts
|
|
700
|
+
await client.closeRequests.submitPayoutDetails(req.id, {
|
|
701
|
+
kind: "account",
|
|
702
|
+
holder_name: "Ivan Petrov",
|
|
703
|
+
account_number: "40817810099910004312",
|
|
704
|
+
bank_code: "044525225",
|
|
705
|
+
});
|
|
706
|
+
// or { kind: "card", holder_name, card_number }
|
|
707
|
+
// → "identity_check" (details can still be corrected) → "manual_payout" → "refunded"
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
Only the last four digits come back (`payout_details.masked`). 409 codes of
|
|
711
|
+
`request()`: `card_locked`, `first_purchase_required`, `card_not_closable`,
|
|
712
|
+
`topup_in_progress`, `card_closing`, `no_balance` (the card holds nothing:
|
|
713
|
+
`cards.terminate()` it), `provider_refused`.
|
|
714
|
+
|
|
582
715
|
## Promo and referral codes
|
|
583
716
|
|
|
584
717
|
A code goes with the operation it is for. At sign-up an unknown or expired
|
|
@@ -715,8 +848,36 @@ await client.consents.setCookies({ analytics: false });
|
|
|
715
848
|
|
|
716
849
|
`terms` covers the offer, the tariffs and the privacy policy. A deployment
|
|
717
850
|
can refuse a sign-up without `terms` and `personal_data`
|
|
718
|
-
(400 `consents_required`). Only `marketing
|
|
719
|
-
|
|
851
|
+
(400 `consents_required`). Only `marketing`, `cookies_analytics`,
|
|
852
|
+
`holder_data_transfer` and `dispute_documents_transfer` can be withdrawn
|
|
853
|
+
later; the required ones go with the account.
|
|
854
|
+
|
|
855
|
+
#### What reaches the card issuer
|
|
856
|
+
|
|
857
|
+
By default the card issuer gets no real details of the user. A product with
|
|
858
|
+
`holder_data_required: true` is different: its cards go out with the user's
|
|
859
|
+
real details, so the cabinet shows a consent screen before the order and
|
|
860
|
+
sends `holder_data_transfer` with it. Without the consent the order fails
|
|
861
|
+
with 409 `holder_data_consent_required`. Once given, the consent stands for
|
|
862
|
+
later cards until the user withdraws it.
|
|
863
|
+
|
|
864
|
+
```ts
|
|
865
|
+
import { HOLDER_DATA_CONSENT, type ConsentKind } from "@takeal/cusfront-sdk";
|
|
866
|
+
|
|
867
|
+
const consents: ConsentKind[] = ["terms"];
|
|
868
|
+
if (product.holder_data_required) {
|
|
869
|
+
if (!(await askHolderDataConsent())) return; // your consent screen
|
|
870
|
+
consents.push(HOLDER_DATA_CONSENT);
|
|
871
|
+
}
|
|
872
|
+
await client.cards.order({ productId: product.id, method: "sbp", consents, idempotencyKey });
|
|
873
|
+
```
|
|
874
|
+
|
|
875
|
+
The user's documents go to the issuer in a dispute only after a consent of
|
|
876
|
+
its own, given for the disputed card:
|
|
877
|
+
|
|
878
|
+
```ts
|
|
879
|
+
await client.consents.allowDisputeDocuments({ cardId: card.id });
|
|
880
|
+
```
|
|
720
881
|
|
|
721
882
|
### From `client.blog`
|
|
722
883
|
|
|
@@ -1126,6 +1287,7 @@ Available now:
|
|
|
1126
1287
|
- `@takeal/cusfront-sdk/cards` — `CardsResource` (cards backed by the wallet balance).
|
|
1127
1288
|
- `@takeal/cusfront-sdk/balance` — `BalanceResource` (per-currency wallet balance).
|
|
1128
1289
|
- `@takeal/cusfront-sdk/bonus` — `BonusResource` (bonuses and a price preview; see [Bonuses](#bonuses)).
|
|
1290
|
+
- `@takeal/cusfront-sdk/close-requests` — `CloseRequestsResource` (close a card with money on it; see [Closing a card with money on it](#closing-a-card-with-money-on-it)).
|
|
1129
1291
|
- `@takeal/cusfront-sdk/documents` — `DocumentsResource` (blog posts, the knowledge base, legal pages; see [Documents](#documents)).
|
|
1130
1292
|
- `@takeal/cusfront-sdk/blog` — `BlogResource` (deprecated: the blog is a category of Documents now).
|
|
1131
1293
|
- `@takeal/cusfront-sdk/subscriptions` — `SubscriptionsResource` (announcement channels; deprecated, see [Preferences](#preferences)).
|
|
@@ -1312,6 +1474,7 @@ Codes worth a wording of their own on the card screens:
|
|
|
1312
1474
|
| `provider_declined` (502) | The issuer refused the move. Nothing was moved. | The issuer would not do it; the wallet is untouched. |
|
|
1313
1475
|
| `provider_refused` (409) | The issuer did not take the PIN. | Try another PIN or later. |
|
|
1314
1476
|
| `card_locked` (409) | Support holds the card, or the issuer froze it. | Only support can change this card. |
|
|
1477
|
+
| `holder_data_consent_required` (409) | The card goes out with the user's real details and they have not agreed to that. | Show the consent screen, then order again with `holder_data_transfer`. |
|
|
1315
1478
|
| `not_supported` (501) | This issuer cannot do that (take money back off a card, reveal, PIN). | Hide the control. |
|
|
1316
1479
|
| `insufficient_funds` (402) | The wallet holds less than that. | Top up the wallet first. |
|
|
1317
1480
|
|
|
@@ -164,8 +164,13 @@ interface CreateQuoteInput {
|
|
|
164
164
|
* a line of its own on the credited amount.
|
|
165
165
|
*/
|
|
166
166
|
type FeeKind = "spread" | "markup" | "commission";
|
|
167
|
-
/**
|
|
168
|
-
|
|
167
|
+
/**
|
|
168
|
+
* How far a top-up meant for a card has got. `waiting`: the card's provider
|
|
169
|
+
* took the load and hasn't done it yet. `stalled`: it has taken longer than
|
|
170
|
+
* the platform waits. `refunding` / `refunded`: the card never got the money,
|
|
171
|
+
* and the payment is going back, or has gone back, to where it was paid from.
|
|
172
|
+
*/
|
|
173
|
+
type CardLoadStatus = "pending" | "waiting" | "stalled" | "succeeded" | "failed" | "refunding" | "refunded";
|
|
169
174
|
/**
|
|
170
175
|
* A card to issue with the top-up: the fields of `cards.create` without
|
|
171
176
|
* its idempotency key (the deposit's covers both). The card's price is
|
|
@@ -205,6 +210,13 @@ interface FundingQuote {
|
|
|
205
210
|
method?: DepositMethod;
|
|
206
211
|
/** The rate is locked until then; the deposit made with it waits for its payment as long. */
|
|
207
212
|
expires_at: string;
|
|
213
|
+
/**
|
|
214
|
+
* What the user owes in card fees, in `credited_currency`, that this
|
|
215
|
+
* top-up pays first: it comes off `credited_amount` and the rest is
|
|
216
|
+
* credited. `"0"` when nothing is owed. Show it before the payment. Older
|
|
217
|
+
* platforms leave it out.
|
|
218
|
+
*/
|
|
219
|
+
debt_withheld?: string;
|
|
208
220
|
}
|
|
209
221
|
interface Deposit {
|
|
210
222
|
id: string;
|
|
@@ -274,6 +286,17 @@ interface Deposit {
|
|
|
274
286
|
* wallet instead (funding connectors in `mixed` mode). The user is told.
|
|
275
287
|
*/
|
|
276
288
|
returned_to_wallet_at?: string | null;
|
|
289
|
+
/**
|
|
290
|
+
* The user's debt in card fees shown before the payment, in the credited
|
|
291
|
+
* currency: the most this top-up pays towards it before the rest is
|
|
292
|
+
* credited. Absent when nothing was owed.
|
|
293
|
+
*/
|
|
294
|
+
debt_quoted?: string | null;
|
|
295
|
+
/**
|
|
296
|
+
* What the top-up did pay towards the debt. For a top-up onto a card,
|
|
297
|
+
* `card_amount` is already net of it.
|
|
298
|
+
*/
|
|
299
|
+
debt_withheld?: string | null;
|
|
277
300
|
created_at: string;
|
|
278
301
|
updated_at: string;
|
|
279
302
|
}
|
|
@@ -368,6 +391,7 @@ interface Refund {
|
|
|
368
391
|
status: string;
|
|
369
392
|
provider_refund_reference?: string;
|
|
370
393
|
failure_reason?: string;
|
|
394
|
+
/** `user`, `operator`, or `system` when the platform refunded by itself. */
|
|
371
395
|
requestor_type: string;
|
|
372
396
|
requestor_id: string;
|
|
373
397
|
created_at: string;
|
|
@@ -543,6 +567,45 @@ interface CardProduct {
|
|
|
543
567
|
starting_balance: CardBalance | null;
|
|
544
568
|
/** True for the product the deployment issues when none is chosen. */
|
|
545
569
|
is_default: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Issuing this card sends the user's real personal details to the card
|
|
572
|
+
* issuer. Show the consent screen before the order and send
|
|
573
|
+
* `holder_data_transfer` in its `consents` (or give it once with
|
|
574
|
+
* `client.consents.allowHolderData()`); without it the order fails with
|
|
575
|
+
* 409 `holder_data_consent_required`. `false`: the issuer gets no real
|
|
576
|
+
* details and no extra consent is asked.
|
|
577
|
+
*/
|
|
578
|
+
holder_data_required: boolean;
|
|
579
|
+
/**
|
|
580
|
+
* What a card on this product costs to use, on top of the payments
|
|
581
|
+
* themselves. A fee the card can't cover is owed and paid from the next
|
|
582
|
+
* top-up (see `client.debt`). Every line is `"0"` when the product
|
|
583
|
+
* charges nothing for it.
|
|
584
|
+
*/
|
|
585
|
+
tariff: CardTariff;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* A card product's fees for using the card. Decimal strings: the fixed
|
|
589
|
+
* amounts are in `currency` (the card's), the shares in percent of the
|
|
590
|
+
* operation's amount.
|
|
591
|
+
*/
|
|
592
|
+
interface CardTariff {
|
|
593
|
+
/** `null` for a product held in several currencies: the card's own then. */
|
|
594
|
+
currency: string | null;
|
|
595
|
+
/** Per settled card payment, fixed. */
|
|
596
|
+
operation_fixed: string;
|
|
597
|
+
/** Per settled card payment, percent of its amount. */
|
|
598
|
+
operation_percent: string;
|
|
599
|
+
/**
|
|
600
|
+
* Per payment declined through the user's own doing: not enough money,
|
|
601
|
+
* wrong card details, a frozen card, a subscription not cancelled with the
|
|
602
|
+
* merchant. A decline caused by the issuer or the platform costs nothing.
|
|
603
|
+
*/
|
|
604
|
+
decline: string;
|
|
605
|
+
/** Per cash withdrawal, fixed; charged instead of the payment fee. */
|
|
606
|
+
cash_withdrawal_fixed: string;
|
|
607
|
+
/** Per cash withdrawal, percent of its amount. */
|
|
608
|
+
cash_withdrawal_percent: string;
|
|
546
609
|
}
|
|
547
610
|
/**
|
|
548
611
|
* A card record as the Takeal API returns it. Mirrors the `cards` table. Note the
|
|
@@ -583,6 +646,19 @@ interface Card {
|
|
|
583
646
|
* support to settle it; say so instead of offering a retry.
|
|
584
647
|
*/
|
|
585
648
|
topups_held: string | null;
|
|
649
|
+
/**
|
|
650
|
+
* The card this one replaced: support reissued it for free because that
|
|
651
|
+
* card stopped working before its term. `null` otherwise.
|
|
652
|
+
*/
|
|
653
|
+
reissued_from_card_id?: string | null;
|
|
654
|
+
/** The card support issued to replace this one, or `null`. */
|
|
655
|
+
reissued_to_card_id?: string | null;
|
|
656
|
+
/**
|
|
657
|
+
* What was left on the card this one replaced, on its way here. Show it as
|
|
658
|
+
* money in transit next to the balance, not as part of it. `null` when
|
|
659
|
+
* nothing is on its way.
|
|
660
|
+
*/
|
|
661
|
+
in_transit?: CardInTransit | null;
|
|
586
662
|
/** The name the user gave the card, or `null`. */
|
|
587
663
|
name: string | null;
|
|
588
664
|
/** The artwork the card is shown with. Always present. */
|
|
@@ -597,6 +673,21 @@ interface Card {
|
|
|
597
673
|
/** Only on the result of `create`, when bonuses paid part of the price. */
|
|
598
674
|
bonus?: IssuanceBonus;
|
|
599
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* The balance of a closed card on its way to the card that replaced it. It
|
|
678
|
+
* waits for the old card's issuer to return the money (`stage: "issuer"`),
|
|
679
|
+
* then it is loaded onto this card (`stage: "loading"`); once it is there,
|
|
680
|
+
* `in_transit` is `null` and the card's balance has it. The move is in the
|
|
681
|
+
* history as a `closed_card_balance` entry.
|
|
682
|
+
*/
|
|
683
|
+
interface CardInTransit {
|
|
684
|
+
/** Decimal string in `currency`. What the issuer returned once it did; before that, what the old card held. */
|
|
685
|
+
amount: string;
|
|
686
|
+
currency: string;
|
|
687
|
+
/** The closed card the money comes from. */
|
|
688
|
+
from_card_id: string;
|
|
689
|
+
stage: "issuer" | "loading" | (string & {});
|
|
690
|
+
}
|
|
600
691
|
/** How bonuses changed a new card's price ("was / now"). Decimal strings in `currency`. */
|
|
601
692
|
interface IssuanceBonus {
|
|
602
693
|
/** Bonuses used. */
|
|
@@ -666,9 +757,10 @@ interface CreateCardInput {
|
|
|
666
757
|
promoCode?: string;
|
|
667
758
|
/**
|
|
668
759
|
* Consents the user gave with the order (`terms`, `personal_data`,
|
|
669
|
-
* `marketing`). Recorded with the card, or with the
|
|
670
|
-
* `deposits.initiate({ issue_card })`, at the version of
|
|
671
|
-
* in force now.
|
|
760
|
+
* `marketing`, `holder_data_transfer`). Recorded with the card, or with the
|
|
761
|
+
* top-up inside `deposits.initiate({ issue_card })`, at the version of
|
|
762
|
+
* their documents in force now. A product with `holder_data_required`
|
|
763
|
+
* needs `holder_data_transfer` here unless it was given before.
|
|
672
764
|
*/
|
|
673
765
|
consents?: ConsentKind[];
|
|
674
766
|
/** Where they were given. Sent as `consent_channel`. */
|
|
@@ -712,7 +804,10 @@ interface CardOrderInput {
|
|
|
712
804
|
promoCode?: string;
|
|
713
805
|
/** Pay part of the price with bonuses; on by default. Sent as `use_bonus`. */
|
|
714
806
|
useBonus?: boolean;
|
|
715
|
-
/**
|
|
807
|
+
/**
|
|
808
|
+
* Consents given with the order. A product with `holder_data_required`
|
|
809
|
+
* needs `holder_data_transfer` here unless it was given before.
|
|
810
|
+
*/
|
|
716
811
|
consents?: ConsentKind[];
|
|
717
812
|
/** Where they were given. Sent as `consent_channel`. */
|
|
718
813
|
consentChannel?: ConsentChannel;
|
|
@@ -726,9 +821,15 @@ interface CardOrder {
|
|
|
726
821
|
/** What the user pays, decimal string, in `currency`. */
|
|
727
822
|
amount: string;
|
|
728
823
|
currency: string;
|
|
729
|
-
/** What
|
|
824
|
+
/** What the payment brings: the card's price, its starting balance and `debt_withheld`, in `card_currency`. */
|
|
730
825
|
card_amount: string;
|
|
731
826
|
card_currency: string;
|
|
827
|
+
/**
|
|
828
|
+
* What the user owes in card fees, in `card_currency`: included in
|
|
829
|
+
* `card_amount` and paid from it first. `"0"` when nothing is owed. Show
|
|
830
|
+
* it before the payment. Older platforms leave it out.
|
|
831
|
+
*/
|
|
832
|
+
debt_withheld?: string;
|
|
732
833
|
}
|
|
733
834
|
/** Why a card ordered with the sign-up was not placed. The account exists all the same. */
|
|
734
835
|
interface CardOrderError {
|
|
@@ -756,6 +857,13 @@ interface TopUpTerms {
|
|
|
756
857
|
min: CardBalance | null;
|
|
757
858
|
/** Largest single top-up the product allows, or `null` for no cap. */
|
|
758
859
|
max: CardBalance | null;
|
|
860
|
+
/**
|
|
861
|
+
* What the user owes in card fees, in the card's currency, or `null` when
|
|
862
|
+
* nothing is. A top-up from a wallet in the same currency pays it first
|
|
863
|
+
* and the card gets the rest: show it before the top-up. Older platforms
|
|
864
|
+
* leave it out.
|
|
865
|
+
*/
|
|
866
|
+
debt?: CardBalance | null;
|
|
759
867
|
}
|
|
760
868
|
interface TopUpInput {
|
|
761
869
|
/** Amount to add, decimal string, in the card's currency. */
|
|
@@ -948,6 +1056,8 @@ declare class CardsResource {
|
|
|
948
1056
|
* `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
|
|
949
1057
|
* to `failed` (never an orphaned active card); inspect `status` /
|
|
950
1058
|
* `failure_reason` on the result.
|
|
1059
|
+
* Errors: 409 `holder_data_consent_required` when the product has
|
|
1060
|
+
* `holder_data_required` and the user has not agreed to it.
|
|
951
1061
|
*/
|
|
952
1062
|
create(input: CreateCardInput): Promise<Card>;
|
|
953
1063
|
/**
|
|
@@ -957,7 +1067,9 @@ declare class CardsResource {
|
|
|
957
1067
|
* `pending_payment` until the payment is confirmed. The same
|
|
958
1068
|
* `idempotencyKey` returns the same order.
|
|
959
1069
|
* Errors: 400 `unknown_product` / `method_not_available` / a limit of the
|
|
960
|
-
* way of paying,
|
|
1070
|
+
* way of paying, 409 `holder_data_consent_required` (the product has
|
|
1071
|
+
* `holder_data_required` and the user has not agreed to it), 503 no
|
|
1072
|
+
* funding connector or no exchange rate.
|
|
961
1073
|
*/
|
|
962
1074
|
order(input: CardOrderInput & {
|
|
963
1075
|
idempotencyKey: string;
|
|
@@ -1071,9 +1183,12 @@ declare class CardsResource {
|
|
|
1071
1183
|
/**
|
|
1072
1184
|
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
1073
1185
|
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
1074
|
-
* already-terminated card.
|
|
1186
|
+
* already-terminated card. A card that still holds money is refused (409
|
|
1187
|
+
* `move_balance_first` or `contact_support_to_close`): close it with
|
|
1188
|
+
* `client.closeRequests.request(id)` instead, and the money goes back the
|
|
1189
|
+
* way it was paid.
|
|
1075
1190
|
*/
|
|
1076
1191
|
terminate(id: string, reason?: string): Promise<Card>;
|
|
1077
1192
|
}
|
|
1078
1193
|
|
|
1079
|
-
export { type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type
|
|
1194
|
+
export { type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type DepositStatus as E, FundingOptionsResource as F, type DepositTarget as G, type FeeKind as H, type FunderMode as I, type FundingOption as J, type FundingQuote as K, type InitiateDepositInput as L, type IssuanceBonus as M, type IssueCardInput as N, type MethodTerms as O, type RevealCardInput as P, type RevealedCard as Q, type Refund as R, type SetPinInput as S, type TopUpInput as T, type TopUpResult as U, type TopUpTerms as V, type TransferInput as W, type TransferResult as X, type UpdateCardInput as Y, cardOrderBody as Z, cardRequestBody as _, type Card as a, DepositsResource as b, CardsResource as c, type CardBalance as d, type CardDesignRef as e, type CardForm as f, type CardInTransit as g, type CardLoadStatus as h, type CardOrder as i, type CardOrderError as j, type CardOrderInput as k, type CardProductPrice as l, type CardStatus as m, type CardStatusSource as n, type CardTariff as o, type CardTopUp as p, type CardTopUpStatus as q, type CardTransfer as r, type CardType as s, type Cardholder as t, type CloseBlockedReason as u, type CreateCardInput as v, type CreateDepositRefundInput as w, type CreateQuoteInput as x, type CustomerInfo as y, type DepositMethod as z };
|