@takeal/cusfront-sdk 0.3.12 → 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 CHANGED
@@ -4,6 +4,37 @@ 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
+
19
+ ## [0.3.18] — 2026-09-20
20
+
21
+ Checked against platform `v0.3.18` (API `0.3.18`).
22
+
23
+ ### Added
24
+
25
+ - `client.cards.catalog()`: the card catalog without a session
26
+ (`GET /card-products`), for a landing page or the cabinet before sign-in.
27
+ Same shape as `listProducts()`, list prices, cacheable for a minute.
28
+
29
+ ### Changed
30
+
31
+ - `InitiateDepositInput.metadata` documents the two cross-connector keys:
32
+ `return_url` for the post-3DS return, and `mock_scenario` on test
33
+ deployments (`happy`, `pending`, `redirect`, `fail`). The `redirect`
34
+ scenario now lands on a hosted page that approves or declines and comes
35
+ back to `return_url`, so the whole redirect path can be built against the
36
+ mock.
37
+
7
38
  ## [0.3.12] — 2026-09-16
8
39
 
9
40
  Checked against platform `v0.3.12`.
package/README.md CHANGED
@@ -67,6 +67,8 @@ walks it from the list to the issued card:
67
67
  ```ts
68
68
  // 1. The catalog: what the user can order, default product first.
69
69
  const products = await client.cards.listProducts();
70
+ // Before sign-in (a landing page), the same list at list prices:
71
+ // const products = await client.cards.catalog();
70
72
 
71
73
  for (const p of products) {
72
74
  // Artwork: `image_url` is absolute for uploaded designs and a path
@@ -120,6 +122,28 @@ the deployment picks the product.
120
122
  `resolveAssetUrl(baseUrl, url)` is the same helper as a standalone function,
121
123
  exported from the package root, for code that has no client at hand.
122
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
+
123
147
  ## Telegram Mini App
124
148
 
125
149
  Run inside a Telegram Mini App? Exchange the Telegram-signed `initData` for a
@@ -504,8 +528,8 @@ the raw body bytes (no timestamp). Comparison is constant-time.
504
528
  > **Card details:** `client.cards.reveal()` returns the full card number and
505
529
  > CVV to the signed-in user; no password or code is asked again, and the API
506
530
  > rate-limits and logs every call. The rest of
507
- > `client.cards` is listProducts, getProduct, create, get, list, update,
508
- > balance, freeze, unfreeze and terminate.
531
+ > `client.cards` is catalog, listProducts, getProduct, create, get, list,
532
+ > update, balance, topUpTerms, topUp, freeze, unfreeze and terminate.
509
533
 
510
534
  ## React hooks (`@takeal/cusfront-sdk/react`)
511
535
 
package/dist/index.cjs CHANGED
@@ -341,6 +341,16 @@ var CardsResource = class {
341
341
  `/me/card-products/${encodeURIComponent(id)}`
342
342
  );
343
343
  }
344
+ /**
345
+ * The public catalog: the same products, order and default as
346
+ * {@link listProducts}, but readable before sign-in, for a landing page or
347
+ * the cabinet's first screen. Prices are list prices (`discount_bps` is
348
+ * always 0); once the user is signed in, {@link listProducts} shows what
349
+ * they pay. The API lets caches keep this response for a minute.
350
+ */
351
+ async catalog() {
352
+ return this.http.get("/card-products");
353
+ }
344
354
  /**
345
355
  * Rename the caller's own card or change its design. Resolves to the
346
356
  * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /
@@ -372,6 +382,31 @@ var CardsResource = class {
372
382
  `/me/cards/${encodeURIComponent(id)}/balance?${q}`
373
383
  );
374
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
+ }
375
410
  /**
376
411
  * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional
377
412
  * `reason` is recorded on the audit trail. Resolves to the updated card.
@@ -754,7 +789,7 @@ var DevicesResource = class {
754
789
  };
755
790
 
756
791
  // src/version.ts
757
- var SDK_VERSION = "0.3.12";
792
+ var SDK_VERSION = "0.3.20";
758
793
 
759
794
  // src/client-platform.ts
760
795
  var CLIENT_HEADER = "X-Takeal-Client";