@takeal/cusfront-sdk 0.3.18 → 0.3.20
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 +12 -0
- package/README.md +23 -1
- package/dist/index.cjs +26 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/cards.cjs +25 -0
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +67 -1
- package/dist/resources/cards.d.ts +67 -1
- package/dist/resources/cards.js +25 -0
- package/dist/resources/cards.js.map +1 -1
- package/dist/telegram.cjs +26 -1
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.js +26 -1
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ 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.3.20] — 2026-09-21
|
|
8
|
+
|
|
9
|
+
Checked against platform `v0.3.20`.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `client.cards.topUpTerms(id)` and `client.cards.topUp(id, { amount, idempotencyKey })`:
|
|
14
|
+
a user moves money from the wallet onto their own card
|
|
15
|
+
(`GET` / `POST /me/cards/{id}/topup`). The result carries the card, its new
|
|
16
|
+
balance and the wallet balance. Types `TopUpTerms`, `TopUpInput`,
|
|
17
|
+
`CardTopUp`, `TopUpResult`.
|
|
18
|
+
|
|
7
19
|
## [0.3.18] — 2026-09-20
|
|
8
20
|
|
|
9
21
|
Checked against platform `v0.3.18` (API `0.3.18`).
|
package/README.md
CHANGED
|
@@ -122,6 +122,28 @@ the deployment picks the product.
|
|
|
122
122
|
`resolveAssetUrl(baseUrl, url)` is the same helper as a standalone function,
|
|
123
123
|
exported from the package root, for code that has no client at hand.
|
|
124
124
|
|
|
125
|
+
|
|
126
|
+
## Topping up a card
|
|
127
|
+
|
|
128
|
+
Money moves from the wallet onto the user's own card in one call. Read the
|
|
129
|
+
terms first: they say whether the card can be topped up now, what the wallet
|
|
130
|
+
holds and the product's floor and cap for one top-up.
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
const terms = await client.cards.topUpTerms(card.id);
|
|
134
|
+
if (!terms.available) showError(terms.reason);
|
|
135
|
+
|
|
136
|
+
const { card: updated, card_balance, wallet } = await client.cards.topUp(card.id, {
|
|
137
|
+
amount: "15.00", // in terms.currency
|
|
138
|
+
idempotencyKey: crypto.randomUUID(),
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Every error is a sentence the user can read (`error.message`): not enough in
|
|
143
|
+
the wallet (402), amount outside the floor or cap (400), card frozen or still
|
|
144
|
+
being issued (409), provider declined or unreachable (502/503, the wallet is
|
|
145
|
+
untouched).
|
|
146
|
+
|
|
125
147
|
## Telegram Mini App
|
|
126
148
|
|
|
127
149
|
Run inside a Telegram Mini App? Exchange the Telegram-signed `initData` for a
|
|
@@ -507,7 +529,7 @@ the raw body bytes (no timestamp). Comparison is constant-time.
|
|
|
507
529
|
> CVV to the signed-in user; no password or code is asked again, and the API
|
|
508
530
|
> rate-limits and logs every call. The rest of
|
|
509
531
|
> `client.cards` is catalog, listProducts, getProduct, create, get, list,
|
|
510
|
-
> update, balance, freeze, unfreeze and terminate.
|
|
532
|
+
> update, balance, topUpTerms, topUp, freeze, unfreeze and terminate.
|
|
511
533
|
|
|
512
534
|
## React hooks (`@takeal/cusfront-sdk/react`)
|
|
513
535
|
|
package/dist/index.cjs
CHANGED
|
@@ -382,6 +382,31 @@ var CardsResource = class {
|
|
|
382
382
|
`/me/cards/${encodeURIComponent(id)}/balance?${q}`
|
|
383
383
|
);
|
|
384
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* What a top-up of this card can be right now: whether it is possible, the
|
|
387
|
+
* currency, the wallet balance, and the product's floor and cap for one
|
|
388
|
+
* top-up. Read it before drawing the form. 404 if the card isn't the caller's.
|
|
389
|
+
*/
|
|
390
|
+
async topUpTerms(id) {
|
|
391
|
+
return this.http.get(`/me/cards/${encodeURIComponent(id)}/topup`);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Move money from the wallet onto the caller's own card. The wallet is
|
|
395
|
+
* debited first, then the card's provider loads the card; if the provider
|
|
396
|
+
* refuses, the money is back on the wallet and the error says so. Resolves
|
|
397
|
+
* to the card, its new balance and the wallet balance, so no second call
|
|
398
|
+
* is needed. Errors carry a sentence the user can read: 400 outside the
|
|
399
|
+
* floor or cap · 402 not enough in the wallet · 404 not the caller's card ·
|
|
400
|
+
* 409 card frozen, closed or still being issued · 501 provider can't top
|
|
401
|
+
* up · 502/503 provider declined or unreachable (wallet untouched).
|
|
402
|
+
*/
|
|
403
|
+
async topUp(id, input) {
|
|
404
|
+
const { idempotencyKey, amount } = input;
|
|
405
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/topup`, {
|
|
406
|
+
body: { amount },
|
|
407
|
+
idempotencyKey
|
|
408
|
+
});
|
|
409
|
+
}
|
|
385
410
|
/**
|
|
386
411
|
* Freeze the caller's own card. Reversible via {@link unfreeze}. The optional
|
|
387
412
|
* `reason` is recorded on the audit trail. Resolves to the updated card.
|
|
@@ -764,7 +789,7 @@ var DevicesResource = class {
|
|
|
764
789
|
};
|
|
765
790
|
|
|
766
791
|
// src/version.ts
|
|
767
|
-
var SDK_VERSION = "0.3.
|
|
792
|
+
var SDK_VERSION = "0.3.20";
|
|
768
793
|
|
|
769
794
|
// src/client-platform.ts
|
|
770
795
|
var CLIENT_HEADER = "X-Takeal-Client";
|