@takeal/cusfront-sdk 0.6.0 → 0.6.2
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 +67 -0
- package/README.md +221 -1
- package/dist/{cards-B_aNY35J.d.cts → cards-DU2DdhYO.d.cts} +154 -20
- package/dist/{cards-Ba1wZttb.d.ts → cards-DzhPVA9N.d.ts} +154 -20
- package/dist/{deposits-BEc8U80M.d.cts → deposits-BEkNeE-v.d.cts} +71 -8
- package/dist/{deposits-DScyT_D9.d.ts → deposits-Dt6A76MB.d.ts} +71 -8
- package/dist/index.cjs +129 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -8
- package/dist/index.d.ts +16 -8
- package/dist/index.js +129 -14
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +4 -2
- package/dist/react/index.d.ts +4 -2
- package/dist/resources/auth.cjs +25 -4
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +40 -5
- package/dist/resources/auth.d.ts +40 -5
- package/dist/resources/auth.js +25 -4
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +32 -6
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +2 -1
- package/dist/resources/cards.d.ts +2 -1
- package/dist/resources/cards.js +32 -6
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/consents.cjs +91 -0
- package/dist/resources/consents.cjs.map +1 -0
- package/dist/resources/consents.d.cts +83 -0
- package/dist/resources/consents.d.ts +83 -0
- package/dist/resources/consents.js +89 -0
- package/dist/resources/consents.js.map +1 -0
- package/dist/resources/deposits.cjs +6 -1
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +3 -2
- package/dist/resources/deposits.d.ts +3 -2
- package/dist/resources/deposits.js +6 -1
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.cjs.map +1 -1
- package/dist/resources/funding-options.d.cts +3 -2
- package/dist/resources/funding-options.d.ts +3 -2
- package/dist/resources/funding-options.js.map +1 -1
- package/dist/resources/me.d.cts +1 -0
- package/dist/resources/me.d.ts +1 -0
- package/dist/resources/receipts.cjs +22 -0
- package/dist/resources/receipts.cjs.map +1 -0
- package/dist/resources/receipts.d.cts +51 -0
- package/dist/resources/receipts.d.ts +51 -0
- package/dist/resources/receipts.js +20 -0
- package/dist/resources/receipts.js.map +1 -0
- package/dist/telegram.cjs +167 -14
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +4 -2
- package/dist/telegram.d.ts +4 -2
- package/dist/telegram.js +167 -14
- package/dist/telegram.js.map +1 -1
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,73 @@ 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.2] — 2026-10-18
|
|
8
|
+
|
|
9
|
+
Needs platform (TKL) 0.6.7 or newer: `SUPPORTED_MEISTER` is `>=0.6.7, <0.7.0`.
|
|
10
|
+
Everything below talks to endpoints that exist from that version on.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Consents: `auth.register` takes `consents` and `consent_channel`,
|
|
15
|
+
`auth.exchangeTelegram` takes `consents` and `consentChannel` for a new
|
|
16
|
+
account, and `cards.create` (with the `issue_card` block of
|
|
17
|
+
`deposits.initiate`) takes `consents` and `consentChannel`. The server
|
|
18
|
+
records each one with the version of its documents in force.
|
|
19
|
+
- `client.consents`: `get()`, `set(kind, given)` for the optional consents,
|
|
20
|
+
and `setCookies({ analytics })` for the cookie banner, signed in or not.
|
|
21
|
+
Also as `@takeal/cusfront-sdk/consents`.
|
|
22
|
+
- `client.receipts`: `list({ refId })` and `get(id)`, a numbered receipt for
|
|
23
|
+
every payment. Also as `@takeal/cusfront-sdk/receipts`.
|
|
24
|
+
- `auth.requestEmailChange` and `auth.confirmEmailChange`: an email change
|
|
25
|
+
confirmed by a code sent to the new address.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- `auth.linkEmail` is for the first address of an account made in the Mini
|
|
30
|
+
App only; an account with a real address gets 409
|
|
31
|
+
`email_change_needs_code` and changes it in two steps instead.
|
|
32
|
+
- `SUPPORTED_MEISTER` narrowed to `>=0.6.7, <0.7.0`; `client.ready()` warns
|
|
33
|
+
on an older deployment.
|
|
34
|
+
|
|
35
|
+
## [0.6.1] — 2026-10-12
|
|
36
|
+
|
|
37
|
+
Needs platform (TKL) 0.6.4 or newer: `SUPPORTED_MEISTER` is `>=0.6.4, <0.7.0`.
|
|
38
|
+
The card states, the SBP method and the priced quotes below exist from that
|
|
39
|
+
version on.
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- Card states `pending` (the issuer took the order and has not issued the
|
|
44
|
+
card yet) and `terminating` (closing, the balance comes back later), and
|
|
45
|
+
the fields that go with them on `Card`: `status_source` (`holder`,
|
|
46
|
+
`operator` or `provider`; a `provider` freeze is lifted through the
|
|
47
|
+
issuer's support, so the README says not to offer "unfreeze" then),
|
|
48
|
+
`card_form` (`virtual` or `physical`), `close_blocked`, `topups_pending`
|
|
49
|
+
and `topups_held`.
|
|
50
|
+
- Top-up statuses `stalled`, `returned` and `written_off` on `CardTopUp`
|
|
51
|
+
(`CardTopUpStatus`), and what a `pending` top-up means for the balance.
|
|
52
|
+
- `cards.reveal()` may return `reveal_url` instead of the numbers, for
|
|
53
|
+
issuers that show them on a page of their own; `pan` and `cvv` are empty
|
|
54
|
+
then. The README shows the frame. The response also carries the
|
|
55
|
+
`cardholder` the issuer knows.
|
|
56
|
+
- `cards.setPin(id, { pin })` for physical cards (`POST /me/cards/{id}/pin`).
|
|
57
|
+
- README: the `card_otp` notification's `purpose` (`payment` or `wallet`), and
|
|
58
|
+
a table of the error codes the card screens meet, with `provider_unavailable`
|
|
59
|
+
explained as "the action failed, the card itself keeps paying".
|
|
60
|
+
|
|
61
|
+
- Deposits by SBP: the `sbp` method, `fundingOptions()` with `method_terms`
|
|
62
|
+
per method (currency, fee and its kind, quote lifetime, limits),
|
|
63
|
+
`deposits.quote({ amount, currency, connectorSlug, method })` priced on
|
|
64
|
+
the method's terms with `fee_kind` and `fee_bps` in the answer, the
|
|
65
|
+
deposit status `expired` and `expires_at` on the deposit. The README walks
|
|
66
|
+
through a rouble top-up and how to show the rate.
|
|
67
|
+
|
|
68
|
+
### Changed
|
|
69
|
+
|
|
70
|
+
- Types regenerated from the platform API that carries the above.
|
|
71
|
+
- `SUPPORTED_MEISTER` narrowed to `>=0.6.4, <0.7.0`; `client.ready()` warns
|
|
72
|
+
on an older deployment.
|
|
73
|
+
|
|
7
74
|
## [0.6.0] — 2026-10-04
|
|
8
75
|
|
|
9
76
|
### Changed
|
package/README.md
CHANGED
|
@@ -125,6 +125,52 @@ product are rejected with a 400 whose `code` says which check failed
|
|
|
125
125
|
Calls without `productId` keep working as before: `type` is then required and
|
|
126
126
|
the deployment picks the product.
|
|
127
127
|
|
|
128
|
+
### Card states
|
|
129
|
+
|
|
130
|
+
A card is not always ready the moment it comes back from `create()`:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
switch (card.status) {
|
|
134
|
+
case "pending":
|
|
135
|
+
// The issuer took the order and has not issued the card yet. The price is
|
|
136
|
+
// paid. Show "being issued", no numbers, no actions; the card turns
|
|
137
|
+
// `active` by itself, or `failed` with the price back on the wallet.
|
|
138
|
+
break;
|
|
139
|
+
case "frozen":
|
|
140
|
+
// Who froze it decides what the user can do. The issuer's own freeze
|
|
141
|
+
// (a risk check, a lost-card report) is not the holder's to undo.
|
|
142
|
+
if (card.status_source === "provider") {
|
|
143
|
+
hideUnfreezeButton();
|
|
144
|
+
say("The card was frozen by the issuer. The freeze is lifted through the issuer's support.");
|
|
145
|
+
} else {
|
|
146
|
+
showUnfreezeButton(); // cards.unfreeze(card.id)
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
case "terminating":
|
|
150
|
+
// Closing. The balance comes back to the wallet when the issuer is done.
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (card.close_blocked === "first_purchase_required") {
|
|
155
|
+
// Hide "close": this card closes after its first purchase.
|
|
156
|
+
}
|
|
157
|
+
if (card.topups_pending) {
|
|
158
|
+
// Money on its way to the card, in the card's currency. Show it next to the
|
|
159
|
+
// balance; the balance itself has not moved yet.
|
|
160
|
+
}
|
|
161
|
+
if (card.topups_held) {
|
|
162
|
+
// A top-up waited too long. The money is safe and support settles it; say
|
|
163
|
+
// so instead of offering a retry.
|
|
164
|
+
}
|
|
165
|
+
if (card.card_form === "physical") {
|
|
166
|
+
// Plastic: the numbers are on the card, and it takes a PIN (see below).
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`status_source` is `holder`, `operator` or `provider`, or `null` for a card
|
|
171
|
+
whose status never changed. Trying to unfreeze a card the issuer froze answers
|
|
172
|
+
409 `card_locked`.
|
|
173
|
+
|
|
128
174
|
`resolveAssetUrl(baseUrl, url)` is the same helper as a standalone function,
|
|
129
175
|
exported from the package root, for code that has no client at hand.
|
|
130
176
|
|
|
@@ -157,6 +203,15 @@ the wallet (402), amount outside the floor or cap (400), card frozen or still
|
|
|
157
203
|
being issued (409), provider declined or unreachable (502/503, the wallet is
|
|
158
204
|
untouched).
|
|
159
205
|
|
|
206
|
+
Some issuers load a card a little later than they take the order. Then
|
|
207
|
+
`topup.status` comes back as `pending`: the wallet has paid, `card_balance`
|
|
208
|
+
has not moved, and the amount shows in `card.topups_pending`. It turns
|
|
209
|
+
`confirmed` on its own (the user gets a `card_topup` notification), or
|
|
210
|
+
`failed` with the money back on the wallet. A top-up that waits longer than
|
|
211
|
+
the deployment allows is `stalled` and shows in `card.topups_held`: support
|
|
212
|
+
finishes it, either back to the wallet (`returned`) or, when the issuer kept
|
|
213
|
+
the money, closed with a reason (`written_off`).
|
|
214
|
+
|
|
160
215
|
## Topping up a card directly
|
|
161
216
|
|
|
162
217
|
Some deployments let a top-up go straight onto a card, past the wallet, and
|
|
@@ -165,7 +220,7 @@ some have no wallet at all. Ask the API instead of hard-coding it:
|
|
|
165
220
|
```ts
|
|
166
221
|
const options = await client.fundingOptions.list();
|
|
167
222
|
// [{ slug, mode: "wallet" | "spool" | "mixed", targets: ["wallet", "card"],
|
|
168
|
-
// methods: ["card", "crypto"], issue_card: true }]
|
|
223
|
+
// methods: ["card", "crypto"], issue_card: true, method_terms: [...] }]
|
|
169
224
|
const direct = options.find((o) => o.targets.includes("card"));
|
|
170
225
|
```
|
|
171
226
|
|
|
@@ -188,6 +243,67 @@ Paying in another currency than the card's needs a quote in the card's
|
|
|
188
243
|
currency first: `deposits.quote({ amount, currency, card_id })`, or
|
|
189
244
|
`target_currency` for a card that doesn't exist yet.
|
|
190
245
|
|
|
246
|
+
## Topping up by SBP
|
|
247
|
+
|
|
248
|
+
A rouble top-up through Russia's instant payments goes like this: the user
|
|
249
|
+
picks SBP, sees the rate, pays on the bank's page, comes back, and the wallet
|
|
250
|
+
is bigger. The API prices each way of paying on its own terms, so read them
|
|
251
|
+
before drawing the form.
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
// 1. The connector that takes SBP, and what it costs. `method_terms` has
|
|
255
|
+
// one entry per method: the currency to ask for, the fee and its kind,
|
|
256
|
+
// how long a quote lives, the floor, the cap and the day's limit.
|
|
257
|
+
const options = await client.fundingOptions.list();
|
|
258
|
+
const funder = options.find((o) => o.methods.includes("sbp"))!;
|
|
259
|
+
const sbp = funder.method_terms.find((m) => m.method === "sbp")!;
|
|
260
|
+
// sbp.source_currency → "RUB"; sbp.fee_kind → "markup"; sbp.fee_bps → 2000;
|
|
261
|
+
// sbp.quote_ttl_seconds → 300; sbp.min_amount, sbp.max_amount, sbp.daily_limit_per_user
|
|
262
|
+
|
|
263
|
+
// 2. The user types roubles. The quote locks the rate for quote_ttl_seconds.
|
|
264
|
+
const quote = await client.deposits.quote({
|
|
265
|
+
amount: "1000",
|
|
266
|
+
currency: "RUB",
|
|
267
|
+
connectorSlug: funder.slug,
|
|
268
|
+
method: "sbp",
|
|
269
|
+
});
|
|
270
|
+
// quote.credited_amount → "10.41" USD at a bank rate of 80 ₽ and a 20 % markup.
|
|
271
|
+
|
|
272
|
+
// 3. What to show. With `fee_kind === "markup"` the fee sits in the rate: show
|
|
273
|
+
// the rate and the amount credited, no fee line. The rate in the form
|
|
274
|
+
// people know, roubles per unit of the wallet currency:
|
|
275
|
+
const perUnit = Number(quote.source_amount) / Number(quote.credited_amount); // 96.06 ₽ per $
|
|
276
|
+
show(`${quote.credited_amount} ${quote.credited_currency} at ${perUnit.toFixed(2)} ₽/$, until ${quote.expires_at}`);
|
|
277
|
+
// If the user types the wallet amount instead, work the roubles out on the
|
|
278
|
+
// client from the same rate and quote that: roubles = wanted × perUnit,
|
|
279
|
+
// rounded up to the kopeck, then `quote()` again with that amount.
|
|
280
|
+
// With `fee_kind === "commission"` show the fee as its own line:
|
|
281
|
+
// commission = credited × fee_bps / 10000.
|
|
282
|
+
|
|
283
|
+
// 4. Pay. The deposit is a redirect: send the user to the bank's page.
|
|
284
|
+
const deposit = await client.deposits.initiate({
|
|
285
|
+
amount: quote.source_amount,
|
|
286
|
+
currency: "RUB",
|
|
287
|
+
method: "sbp",
|
|
288
|
+
funder_slug: funder.slug,
|
|
289
|
+
quote_id: quote.id,
|
|
290
|
+
metadata: { return_url: `${location.origin}/wallet?deposit=` },
|
|
291
|
+
idempotencyKey: crypto.randomUUID(),
|
|
292
|
+
});
|
|
293
|
+
location.href = deposit.redirect_url!;
|
|
294
|
+
|
|
295
|
+
// 5. Back from the bank: poll until the deposit settles, then redraw the
|
|
296
|
+
// balance. `expires_at` is when the deposit stops waiting for the payment.
|
|
297
|
+
const final = await client.deposits.get(deposit.id);
|
|
298
|
+
// final.status: "confirmed" → balance updated; "expired" → nobody paid in
|
|
299
|
+
// time, offer a new quote; "failed" → the bank refused, final.failure_reason says why.
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
A deposit that expired and is paid after all is still credited, at the rate
|
|
303
|
+
of its quote, and turns `confirmed`. The amount outside the method's floor or
|
|
304
|
+
cap, or over the day's limit, is refused by `quote()` and `initiate()` with
|
|
305
|
+
400 `deposit_limit` and a sentence for the user.
|
|
306
|
+
|
|
191
307
|
The deposit comes back with `target: "card"` and a `card_load_status`. It is
|
|
192
308
|
`pending` until the card provider has loaded the card, then `succeeded`. If
|
|
193
309
|
the card can't take it, the deployment either puts the money on the wallet
|
|
@@ -198,6 +314,37 @@ it for support to finish (`card_load_status: "failed"`). Errors:
|
|
|
198
314
|
`amount_too_small` (a new card's price plus a starting balance don't fit in
|
|
199
315
|
the amount).
|
|
200
316
|
|
|
317
|
+
## Card details and PIN
|
|
318
|
+
|
|
319
|
+
`cards.reveal(id)` returns the full card number and CVV to the signed-in user,
|
|
320
|
+
with the billing address the card is registered at and, when the platform
|
|
321
|
+
keeps one, the `cardholder` (name, phone, address) a checkout asks for. No
|
|
322
|
+
password or code is asked again; the API rate-limits and logs every call.
|
|
323
|
+
Keep the result in memory only and clear it after `expires_in_seconds`.
|
|
324
|
+
|
|
325
|
+
Some issuers do not hand out the numbers and show them on a page of their
|
|
326
|
+
own instead. Then `reveal_url` is set and `pan` and `cvv` are empty:
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
const r = await client.cards.reveal(card.id);
|
|
330
|
+
if (r.reveal_url) {
|
|
331
|
+
// The issuer's page. Open it at once: the address is short-lived and
|
|
332
|
+
// often good for one opening. Never store or log it.
|
|
333
|
+
return <iframe src={r.reveal_url} sandbox="allow-scripts allow-same-origin" title="Card details" />;
|
|
334
|
+
}
|
|
335
|
+
showNumbers(r.pan, r.cvv, r.expiry_month, r.expiry_year);
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
A physical card takes a PIN from the user. Send it once; neither the SDK nor
|
|
339
|
+
the API keeps it, and the user gets a notification that it was set:
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
await client.cards.setPin(card.id, { pin: "4321" }); // four to six digits
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
400 when the PIN is not four to six digits or the card is not active, 409
|
|
346
|
+
`provider_refused` when the issuer did not take it, 501 for a virtual card.
|
|
347
|
+
|
|
201
348
|
## Telegram Mini App
|
|
202
349
|
|
|
203
350
|
Run inside a Telegram Mini App? Exchange the Telegram-signed `initData` for a
|
|
@@ -486,6 +633,59 @@ const v2 = await client.documents.version("offer", 2);
|
|
|
486
633
|
A version dated ahead stays out of `get()` until its day comes, so a new
|
|
487
634
|
redaction can be prepared in advance.
|
|
488
635
|
|
|
636
|
+
### Changing the email
|
|
637
|
+
|
|
638
|
+
A new address proves it is the user's with a code sent there; nothing
|
|
639
|
+
changes before the code comes back, and the old address gets a notice.
|
|
640
|
+
|
|
641
|
+
```ts
|
|
642
|
+
const { challenge_id, destination_hint } = await client.auth.requestEmailChange({ email });
|
|
643
|
+
// "We sent a code to ne***@example.com"
|
|
644
|
+
const user = await client.auth.confirmEmailChange({ challengeId: challenge_id, code });
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
`linkEmail` is only for the first address of an account made in the Mini App.
|
|
648
|
+
|
|
649
|
+
### Receipts
|
|
650
|
+
|
|
651
|
+
Every payment gets a numbered receipt within a minute: a wallet top-up, a
|
|
652
|
+
card top-up and a card's issue price. It is mailed to the user and can be
|
|
653
|
+
shown next to the payment.
|
|
654
|
+
|
|
655
|
+
```ts
|
|
656
|
+
const [receipt] = await client.receipts.list({ refId: deposit.id });
|
|
657
|
+
// receipt.number "R-000123", paid_amount + paid_currency, method,
|
|
658
|
+
// and for a top-up credited_amount + credited_currency and rate
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
### Consents
|
|
662
|
+
|
|
663
|
+
Send the boxes the user ticked with the sign-up and with a card order. The
|
|
664
|
+
server records each one with the version of its documents in force at that
|
|
665
|
+
moment, so the client never sends document versions.
|
|
666
|
+
|
|
667
|
+
```ts
|
|
668
|
+
await client.auth.register({ email, password, consents: ["terms", "personal_data", "marketing"] });
|
|
669
|
+
await client.cards.create({ productId, currency: "USD", consents: ["terms"], idempotencyKey });
|
|
670
|
+
|
|
671
|
+
const { consents } = await client.consents.get(); // where each one stands
|
|
672
|
+
await client.consents.set("marketing", false); // advertising off in every channel
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
The cookie banner reports its choice the same way, signed in or not; before
|
|
676
|
+
sign-in it is kept under the anonymous key and moves to the account at
|
|
677
|
+
sign-up. Declining analytics deletes the visitor's recorded visits and
|
|
678
|
+
analytics ids.
|
|
679
|
+
|
|
680
|
+
```ts
|
|
681
|
+
await client.consents.setCookies({ analytics: false });
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
`terms` covers the offer, the tariffs and the privacy policy. A deployment
|
|
685
|
+
can refuse a sign-up without `terms` and `personal_data`
|
|
686
|
+
(400 `consents_required`). Only `marketing` and `cookies_analytics` can be
|
|
687
|
+
withdrawn later; the required ones go with the account.
|
|
688
|
+
|
|
489
689
|
### From `client.blog`
|
|
490
690
|
|
|
491
691
|
`client.blog` still works for one release and is marked deprecated. Same
|
|
@@ -673,6 +873,13 @@ about the event, and `href`: a path inside your app to open on tap
|
|
|
673
873
|
(`/cards/<id>`, `/deposits/<id>`, `/subscription`, `/settings/sessions`) or
|
|
674
874
|
`null`. Route `href` through your own router; the SDK doesn't navigate.
|
|
675
875
|
|
|
876
|
+
A `card_otp` item carries a code the card issuer sent and could not deliver
|
|
877
|
+
itself; the user needs it right now. `data.purpose` says what for: `payment`
|
|
878
|
+
(a 3-D Secure purchase; `merchant_name`, `amount` and `currency` are there)
|
|
879
|
+
or `wallet` (adding the card to Apple Pay or Google Pay). Show the code large,
|
|
880
|
+
with a copy button and a countdown from `expires_in_minutes`; `isCardOtp(item)`
|
|
881
|
+
narrows the type.
|
|
882
|
+
|
|
676
883
|
A small inbox screen:
|
|
677
884
|
|
|
678
885
|
```tsx
|
|
@@ -897,6 +1104,8 @@ Available now:
|
|
|
897
1104
|
- `@takeal/cusfront-sdk/devices` — `DevicesResource` (Web Push, mobile push tokens, the Telegram Mini App marker).
|
|
898
1105
|
- `@takeal/cusfront-sdk/me` — `MeResource` (link or unlink Telegram for the signed-in user).
|
|
899
1106
|
- `@takeal/cusfront-sdk/history` — `HistoryResource` (the user's money history).
|
|
1107
|
+
- `@takeal/cusfront-sdk/consents` — `ConsentsResource` (what the user agreed to).
|
|
1108
|
+
- `@takeal/cusfront-sdk/receipts` — `ReceiptsResource` (a numbered receipt for every payment).
|
|
900
1109
|
- `@takeal/cusfront-sdk/attribution` — `AttributionResource`, `anonymousKey`, `currentTouch` (where users come from).
|
|
901
1110
|
- `@takeal/cusfront-sdk/webhooks` — HMAC-SHA256 signature verifier (no network, isomorphic).
|
|
902
1111
|
- `@takeal/cusfront-sdk/react` — optional React hooks layer (`ClientProvider` + `useMe` / `useDeposits` / `useCards` / `useCardProducts` / `useBalance` / `useNotifications` / `useUnreadCount`). React is a `peerDependency`, never bundled.
|
|
@@ -1063,6 +1272,17 @@ try {
|
|
|
1063
1272
|
}
|
|
1064
1273
|
```
|
|
1065
1274
|
|
|
1275
|
+
Codes worth a wording of their own on the card screens:
|
|
1276
|
+
|
|
1277
|
+
| `e.code` | What happened | What to tell the user |
|
|
1278
|
+
|---|---|---|
|
|
1279
|
+
| `provider_unavailable` (503) | The card issuer did not answer. Nothing was moved. | Try again in a few minutes. The card itself keeps paying: only the action failed. |
|
|
1280
|
+
| `provider_declined` (502) | The issuer refused the move. Nothing was moved. | The issuer would not do it; the wallet is untouched. |
|
|
1281
|
+
| `provider_refused` (409) | The issuer did not take the PIN. | Try another PIN or later. |
|
|
1282
|
+
| `card_locked` (409) | Support holds the card, or the issuer froze it. | Only support can change this card. |
|
|
1283
|
+
| `not_supported` (501) | This issuer cannot do that (take money back off a card, reveal, PIN). | Hide the control. |
|
|
1284
|
+
| `insufficient_funds` (402) | The wallet holds less than that. | Top up the wallet first. |
|
|
1285
|
+
|
|
1066
1286
|
## Development
|
|
1067
1287
|
|
|
1068
1288
|
```sh
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConsentKind, ConsentChannel } from './resources/consents.cjs';
|
|
1
2
|
import { H as HttpClient } from './http-DeANAoTs.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -52,16 +53,12 @@ interface CustomerInfo {
|
|
|
52
53
|
* POST /me/cards/{id}/unfreeze → unfreeze
|
|
53
54
|
* POST /me/cards/{id}/transfer → transfer (to another of their cards)
|
|
54
55
|
* POST /me/cards/{id}/terminate → terminate (one-way)
|
|
56
|
+
* POST /me/cards/{id}/reveal → reveal (the numbers, or a provider page)
|
|
57
|
+
* POST /me/cards/{id}/pin → setPin (physical cards)
|
|
55
58
|
*
|
|
56
59
|
* The lifecycle actions are ownership-gated server-side: a caller can only
|
|
57
60
|
* freeze / unfreeze / terminate a card that belongs to them (else 404).
|
|
58
61
|
*
|
|
59
|
-
* ## What is intentionally NOT here
|
|
60
|
-
*
|
|
61
|
-
* Card-data reveal (PAN / CVV) is a separate, security-sensitive flow with its
|
|
62
|
-
* own re-auth + rate-limit + audit contract and is intentionally
|
|
63
|
-
* NOT part of this resource (tracked separately).
|
|
64
|
-
*
|
|
65
62
|
* Today only PREPAID is wired end-to-end; CREDIT and GIFT return 400 from
|
|
66
63
|
* the Takeal API until their issuer flows land.
|
|
67
64
|
*/
|
|
@@ -70,11 +67,36 @@ type CardType = "credit" | "prepaid" | "gift";
|
|
|
70
67
|
/**
|
|
71
68
|
* Card lifecycle state.
|
|
72
69
|
*
|
|
73
|
-
* `pending_payment
|
|
74
|
-
*
|
|
75
|
-
*
|
|
70
|
+
* - `pending_payment`: the row exists but the issuance fee has not been
|
|
71
|
+
* paid yet; the provider has not been called and nothing is visible.
|
|
72
|
+
* - `pending`: the issuer accepted the order and has not issued the card
|
|
73
|
+
* yet. The price is charged. Show the card as "being issued" with no
|
|
74
|
+
* numbers; it becomes `active` on its own, or `failed` with the price
|
|
75
|
+
* back on the wallet. Some issuers take minutes, some a day.
|
|
76
|
+
* - `active`, `frozen`: the usual states. Read `status_source` before
|
|
77
|
+
* offering to unfreeze.
|
|
78
|
+
* - `terminating`: the holder (or the issuer) closed the card and the
|
|
79
|
+
* issuer has not finished: the balance comes back to the wallet when it
|
|
80
|
+
* does. Show it as closing; no actions apply.
|
|
81
|
+
* - `terminated`, `redeemed`, `failed`: final.
|
|
76
82
|
*/
|
|
77
|
-
type CardStatus = "pending_payment" | "active" | "frozen" | "terminated" | "redeemed" | "failed";
|
|
83
|
+
type CardStatus = "pending_payment" | "pending" | "active" | "frozen" | "terminating" | "terminated" | "redeemed" | "failed";
|
|
84
|
+
/**
|
|
85
|
+
* Who made the card's last status change. `provider` on a `frozen` card
|
|
86
|
+
* means the issuer froze it (a risk check, a lost-card report): the holder
|
|
87
|
+
* cannot unfreeze it, so do not offer the button; say the freeze is lifted
|
|
88
|
+
* through the issuer's support. `holder` and `operator` freezes are undone
|
|
89
|
+
* with `unfreeze()` as usual.
|
|
90
|
+
*/
|
|
91
|
+
type CardStatusSource = "holder" | "operator" | "provider";
|
|
92
|
+
/** `virtual` cards show their numbers in the app; `physical` cards are plastic and have a PIN. */
|
|
93
|
+
type CardForm = "virtual" | "physical";
|
|
94
|
+
/**
|
|
95
|
+
* Why `terminate()` is refused right now: `first_purchase_required` (the
|
|
96
|
+
* card closes after its first purchase) or `card_locked` (only support can
|
|
97
|
+
* change it).
|
|
98
|
+
*/
|
|
99
|
+
type CloseBlockedReason = "first_purchase_required" | "card_locked";
|
|
78
100
|
/**
|
|
79
101
|
* A card design: the artwork a card is shown with. `image_url` is the front,
|
|
80
102
|
* `image_url_back` the back; both are either absolute URLs or paths relative
|
|
@@ -174,6 +196,24 @@ interface Card {
|
|
|
174
196
|
initial_amount: string | null;
|
|
175
197
|
currency: string;
|
|
176
198
|
failure_reason: string | null;
|
|
199
|
+
/** Who changed the status last; `null` when it never changed. See {@link CardStatusSource}. */
|
|
200
|
+
status_source: CardStatusSource | null;
|
|
201
|
+
/** Virtual or plastic. A `physical` card takes a PIN with {@link CardsResource.setPin}. */
|
|
202
|
+
card_form: CardForm;
|
|
203
|
+
/** Why the card cannot be closed right now, or `null` when it can. */
|
|
204
|
+
close_blocked: CloseBlockedReason | null;
|
|
205
|
+
/**
|
|
206
|
+
* Top-ups the issuer has accepted and not loaded yet, summed, decimal
|
|
207
|
+
* string in `currency`; `null` when there are none. Show it next to the
|
|
208
|
+
* balance as money on its way to the card.
|
|
209
|
+
*/
|
|
210
|
+
topups_pending: string | null;
|
|
211
|
+
/**
|
|
212
|
+
* Top-ups the issuer has held for too long, summed, decimal string in
|
|
213
|
+
* `currency`; `null` when there are none. The money is safe and waits for
|
|
214
|
+
* support to settle it; say so instead of offering a retry.
|
|
215
|
+
*/
|
|
216
|
+
topups_held: string | null;
|
|
177
217
|
/** The name the user gave the card, or `null`. */
|
|
178
218
|
name: string | null;
|
|
179
219
|
/** The artwork the card is shown with. Always present. */
|
|
@@ -255,6 +295,15 @@ interface CreateCardInput {
|
|
|
255
295
|
* `promo_code` on the top-up there.
|
|
256
296
|
*/
|
|
257
297
|
promoCode?: string;
|
|
298
|
+
/**
|
|
299
|
+
* Consents the user gave with the order (`terms`, `personal_data`,
|
|
300
|
+
* `marketing`). Recorded with the card, or with the top-up inside
|
|
301
|
+
* `deposits.initiate({ issue_card })`, at the version of their documents
|
|
302
|
+
* in force now.
|
|
303
|
+
*/
|
|
304
|
+
consents?: ConsentKind[];
|
|
305
|
+
/** Where they were given. Sent as `consent_channel`. */
|
|
306
|
+
consentChannel?: ConsentChannel;
|
|
258
307
|
/**
|
|
259
308
|
* Required by the Takeal API on this write endpoint. Same key + body replays the
|
|
260
309
|
* original card; same key + different body returns 409.
|
|
@@ -299,11 +348,26 @@ interface TopUpInput {
|
|
|
299
348
|
*/
|
|
300
349
|
idempotencyKey: string;
|
|
301
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Where a top-up stands.
|
|
353
|
+
*
|
|
354
|
+
* - `pending`: the issuer accepted it and has not loaded the card yet. The
|
|
355
|
+
* wallet is debited, the card balance is unchanged, the amount shows in
|
|
356
|
+
* `Card.topups_pending`. Most issuers finish within minutes.
|
|
357
|
+
* - `confirmed`: the money is on the card.
|
|
358
|
+
* - `failed`: the issuer refused; the wallet is credited back.
|
|
359
|
+
* - `stalled`: pending for longer than the deployment allows. The money is
|
|
360
|
+
* safe and waits for support; it shows in `Card.topups_held`.
|
|
361
|
+
* - `returned`: support sent the money back to the wallet.
|
|
362
|
+
* - `written_off`: support closed it without the money coming back (the
|
|
363
|
+
* issuer kept it); `failure_reason` says so.
|
|
364
|
+
*/
|
|
365
|
+
type CardTopUpStatus = "pending" | "confirmed" | "failed" | "stalled" | "returned" | "written_off";
|
|
302
366
|
/** One top-up attempt as the API records it. */
|
|
303
367
|
interface CardTopUp {
|
|
304
368
|
id: string;
|
|
305
369
|
card_id: string;
|
|
306
|
-
status:
|
|
370
|
+
status: CardTopUpStatus;
|
|
307
371
|
/** What landed on the card, decimal string, in `currency`. */
|
|
308
372
|
amount: string;
|
|
309
373
|
currency: string;
|
|
@@ -314,7 +378,13 @@ interface CardTopUp {
|
|
|
314
378
|
created_at: string;
|
|
315
379
|
updated_at: string;
|
|
316
380
|
}
|
|
317
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* The outcome of a top-up with the state to redraw: card, its balance, the
|
|
383
|
+
* wallet. When `topup.status` is `pending`, the wallet has paid and
|
|
384
|
+
* `card_balance` has not moved yet: show the amount as on its way
|
|
385
|
+
* (`card.topups_pending`) and refresh the card later or on the
|
|
386
|
+
* `card_topup` notification.
|
|
387
|
+
*/
|
|
318
388
|
interface TopUpResult {
|
|
319
389
|
topup: CardTopUp;
|
|
320
390
|
card: Card;
|
|
@@ -342,16 +412,33 @@ interface RevealCardInput {
|
|
|
342
412
|
totpCode?: string;
|
|
343
413
|
}
|
|
344
414
|
/**
|
|
345
|
-
* Full card data from a successful reveal. **Security**: never persist this
|
|
415
|
+
* Full card data from a successful reveal. **Security**: never persist this,
|
|
346
416
|
* keep it in volatile memory only, clear it within `expires_in_seconds`, and
|
|
347
417
|
* never write it to localStorage / logs (the API marks the response no-store).
|
|
418
|
+
*
|
|
419
|
+
* Some issuers hand out a page that shows the numbers instead of the
|
|
420
|
+
* numbers themselves. Then `reveal_url` is set, `pan` and `cvv` are empty,
|
|
421
|
+
* and the client opens the page in a frame; see the README for the frame.
|
|
348
422
|
*/
|
|
349
423
|
interface RevealedCard {
|
|
424
|
+
/** The card number; empty when `reveal_url` is set. */
|
|
350
425
|
pan: string;
|
|
426
|
+
/** The security code; empty when `reveal_url` is set. */
|
|
351
427
|
cvv: string;
|
|
352
428
|
expiry_month: number;
|
|
353
429
|
expiry_year: number;
|
|
354
430
|
holder_name: string;
|
|
431
|
+
/**
|
|
432
|
+
* A page at the card issuer that shows the details to the holder. Present
|
|
433
|
+
* only for issuers that give a page instead of the numbers. Short-lived,
|
|
434
|
+
* often single use: open it at once in an `<iframe>` and never store it.
|
|
435
|
+
*/
|
|
436
|
+
reveal_url?: string;
|
|
437
|
+
/**
|
|
438
|
+
* The person the card is registered to at its issuer: what a checkout
|
|
439
|
+
* asks for. Absent for cards issued before holders were kept.
|
|
440
|
+
*/
|
|
441
|
+
cardholder?: Cardholder;
|
|
355
442
|
/**
|
|
356
443
|
* The address the card is registered at — what a merchant's checkout asks
|
|
357
444
|
* for, and the postal code some of them decline a payment over. Absent
|
|
@@ -370,6 +457,33 @@ interface BillingAddress {
|
|
|
370
457
|
postal_code?: string;
|
|
371
458
|
country?: string;
|
|
372
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* The cardholder the issuer knows: the details to type into a checkout
|
|
462
|
+
* that asks for the name, phone or address on the card. `source` says
|
|
463
|
+
* whether the platform made them up (`generated`), the user supplied them
|
|
464
|
+
* (`provided`) or both (`mixed`).
|
|
465
|
+
*/
|
|
466
|
+
interface Cardholder {
|
|
467
|
+
id: string;
|
|
468
|
+
first_name: string;
|
|
469
|
+
last_name: string;
|
|
470
|
+
/** `YYYY-MM-DD`. */
|
|
471
|
+
birth_date: string;
|
|
472
|
+
/** E.164. */
|
|
473
|
+
phone: string;
|
|
474
|
+
/** A mailbox the platform owns; mail the issuer sends there reaches the user. */
|
|
475
|
+
email: string;
|
|
476
|
+
address: BillingAddress;
|
|
477
|
+
source: "generated" | "provided" | "mixed";
|
|
478
|
+
}
|
|
479
|
+
/** The new PIN for a physical card. */
|
|
480
|
+
interface SetPinInput {
|
|
481
|
+
/**
|
|
482
|
+
* Four to six digits, as the user typed them. Sent once to the issuer and
|
|
483
|
+
* kept nowhere: not by the SDK, not by the API. Never log it.
|
|
484
|
+
*/
|
|
485
|
+
pin: string;
|
|
486
|
+
}
|
|
373
487
|
/** What to move, and the key that makes a retry safe. */
|
|
374
488
|
interface TransferInput {
|
|
375
489
|
/** The card the money lands on. Must be the caller's, and of the same kind and currency. */
|
|
@@ -482,9 +596,11 @@ declare class CardsResource {
|
|
|
482
596
|
*/
|
|
483
597
|
transfer(fromCardId: string, input: TransferInput): Promise<TransferResult>;
|
|
484
598
|
/**
|
|
485
|
-
* Freeze the caller's own card. Reversible via {@link unfreeze}
|
|
486
|
-
* `
|
|
487
|
-
*
|
|
599
|
+
* Freeze the caller's own card. Reversible via {@link unfreeze} while
|
|
600
|
+
* `status_source` is `holder` or `operator`. The optional `reason` is
|
|
601
|
+
* recorded on the audit trail. Resolves to the updated card. 404 if the
|
|
602
|
+
* card isn't the caller's; 409 `card_locked` when support holds it; 501 if
|
|
603
|
+
* the issuer can't freeze.
|
|
488
604
|
*/
|
|
489
605
|
freeze(id: string, reason?: string): Promise<Card>;
|
|
490
606
|
/**
|
|
@@ -497,12 +613,30 @@ declare class CardsResource {
|
|
|
497
613
|
* keep the result in volatile memory only, never write it to
|
|
498
614
|
* localStorage / logs, and clear it within `expires_in_seconds`.
|
|
499
615
|
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
616
|
+
* The result is the numbers, or `reveal_url` with empty `pan` and `cvv`
|
|
617
|
+
* when the issuer shows them on a page of its own: open that page in a
|
|
618
|
+
* frame right away, it is short-lived.
|
|
619
|
+
*
|
|
620
|
+
* 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
|
|
621
|
+
* has no sensitive-data endpoint · 503 `provider_unavailable`.
|
|
502
622
|
*/
|
|
503
623
|
reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard>;
|
|
504
|
-
/**
|
|
624
|
+
/**
|
|
625
|
+
* Unfreeze a previously-frozen card. Idempotent on an already-active card.
|
|
626
|
+
* A card the issuer froze (`status_source: "provider"`) is not the
|
|
627
|
+
* holder's to unfreeze: the API answers 409 `card_locked`, so hide the
|
|
628
|
+
* button and say the freeze is lifted through the issuer's support.
|
|
629
|
+
*/
|
|
505
630
|
unfreeze(id: string): Promise<Card>;
|
|
631
|
+
/**
|
|
632
|
+
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
633
|
+
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
634
|
+
* Resolves to the card; the user also gets a notification that the PIN
|
|
635
|
+
* was set. 400 not four to six digits or the card is not active · 403 not
|
|
636
|
+
* your card · 409 `card_locked`, or `provider_refused` when the issuer did
|
|
637
|
+
* not take it · 429 too many attempts · 501 a virtual card has no PIN.
|
|
638
|
+
*/
|
|
639
|
+
setPin(id: string, input: SetPinInput): Promise<Card>;
|
|
506
640
|
/**
|
|
507
641
|
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
508
642
|
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
@@ -511,4 +645,4 @@ declare class CardsResource {
|
|
|
511
645
|
terminate(id: string, reason?: string): Promise<Card>;
|
|
512
646
|
}
|
|
513
647
|
|
|
514
|
-
export { type Address as A, type BillingAddress as B, type CardProduct as C, type IssuanceBonus as I, type RevealCardInput as R, type TopUpInput as T, type UpdateCardInput as U, type Card as a, CardsResource as b, type CardBalance as c, type CardDesignRef as d, type
|
|
648
|
+
export { type Address as A, type BillingAddress as B, type CardProduct as C, type IssuanceBonus as I, type RevealCardInput as R, type SetPinInput as S, type TopUpInput as T, type UpdateCardInput as U, type Card as a, CardsResource as b, type CardBalance as c, type CardDesignRef as d, type CardForm as e, type CardProductPrice as f, type CardStatus as g, type CardStatusSource as h, type CardTopUp as i, type CardTopUpStatus as j, type CardTransfer as k, type CardType as l, type Cardholder as m, type CloseBlockedReason as n, type CreateCardInput as o, type CustomerInfo as p, type RevealedCard as q, type TopUpResult as r, type TopUpTerms as s, type TransferInput as t, type TransferResult as u, cardRequestBody as v };
|