@takeal/cusfront-sdk 0.6.14 → 0.8.0
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 +24 -0
- package/README.md +51 -0
- package/dist/{cards-D_krTWzr.d.cts → cards-BPu8Ill7.d.cts} +122 -2
- package/dist/{cards-DPlgx76p.d.ts → cards-DP1fJc_c.d.ts} +122 -2
- package/dist/index.cjs +56 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +56 -4
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/resources/auth.cjs +2 -0
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +7 -2
- package/dist/resources/auth.d.ts +7 -2
- package/dist/resources/auth.js +2 -0
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +60 -1
- 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 +59 -2
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +2 -1
- package/dist/resources/deposits.d.ts +2 -1
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +2 -1
- package/dist/resources/funding-options.d.ts +2 -1
- package/dist/resources/me.d.cts +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/telegram.cjs +48 -3
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +2 -2
- package/dist/telegram.d.ts +2 -2
- package/dist/telegram.js +48 -3
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,30 @@ 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.8.0] — 2026-11-21
|
|
8
|
+
|
|
9
|
+
The SDK now carries the same minor version as the platform it targets.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `cards.quotePublic(input)` prices a card order before sign-in: product,
|
|
14
|
+
payment method, currency, an extra load and a promo code go in; the price,
|
|
15
|
+
the discount, the amount to pay and what the code does come back. Nothing
|
|
16
|
+
is reserved and the code isn't used up. `cards.quote(input)` does the same
|
|
17
|
+
for a signed-in person, with every condition of the code checked and bonus
|
|
18
|
+
points counted.
|
|
19
|
+
- `expectedAmount` / `expectedCurrency` on a card order, in `cards.order`
|
|
20
|
+
and in the `cardOrder` of a sign-in or sign-up. If the price changed since
|
|
21
|
+
the person saw it, no payment is opened: the call fails with
|
|
22
|
+
`price_changed`, and `priceChangedQuote(error)` returns the new price to
|
|
23
|
+
show before they confirm again.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- Works with platform (TKL) 0.8.0 and newer. `client.ready()` reports an
|
|
28
|
+
older platform as incompatible.
|
|
29
|
+
- Types regenerated from platform 0.8.0.
|
|
30
|
+
|
|
7
31
|
## [0.6.14] — 2026-11-20
|
|
8
32
|
|
|
9
33
|
### Added
|
package/README.md
CHANGED
|
@@ -333,6 +333,57 @@ signed in gets the same with `client.cards.order({ productId, method,
|
|
|
333
333
|
idempotencyKey })`. The card shows as `pending_payment` until the payment is
|
|
334
334
|
confirmed and is issued after that.
|
|
335
335
|
|
|
336
|
+
## The price before the payment
|
|
337
|
+
|
|
338
|
+
The form can show what the card costs with the promo code before the user
|
|
339
|
+
signs in. `cards.quotePublic` takes the same fields as the order and no
|
|
340
|
+
e-mail, and answers with the price, the discount and the amount to pay:
|
|
341
|
+
|
|
342
|
+
```ts
|
|
343
|
+
const q = await client.cards.quotePublic({ productId, method: "sbp", promoCode });
|
|
344
|
+
// q.price "1949", q.discount "500", q.amount "1449", q.currency "RUB"
|
|
345
|
+
// q.promo_code.status: "applied" | "conditional" | "rejected" | "unavailable"
|
|
346
|
+
if (q.preliminary) {
|
|
347
|
+
// A code with a condition only checked after sign-in, such as first card
|
|
348
|
+
// only: show q.amount as provisional, next to q.promo_code.message.
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
A quote reserves nothing. Drop a `rejected` code from the order: an order
|
|
353
|
+
that keeps it is refused.
|
|
354
|
+
|
|
355
|
+
Send the amount the user saw with the order. If the order comes to something
|
|
356
|
+
else (the code was for first cards only and this user has one, or the rate
|
|
357
|
+
moved), no payment is opened and the new quote comes back:
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
import { priceChangedQuote } from "@takeal/cusfront-sdk";
|
|
361
|
+
|
|
362
|
+
const session = await client.auth.verifyEmailCode({
|
|
363
|
+
challengeId: challenge_id,
|
|
364
|
+
code,
|
|
365
|
+
consents: ["terms", "personal_data"],
|
|
366
|
+
cardOrder: { productId, method: "sbp", promoCode, expectedAmount: q.amount, expectedCurrency: q.currency },
|
|
367
|
+
});
|
|
368
|
+
const changed = priceChangedQuote(session.card_order_error);
|
|
369
|
+
if (changed) {
|
|
370
|
+
// Show changed.amount. Once the user agrees:
|
|
371
|
+
await client.cards.order({
|
|
372
|
+
productId,
|
|
373
|
+
method: "sbp",
|
|
374
|
+
promoCode: changed.promo_code?.status === "rejected" ? undefined : promoCode,
|
|
375
|
+
expectedAmount: changed.amount,
|
|
376
|
+
expectedCurrency: changed.currency,
|
|
377
|
+
idempotencyKey,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
A signed-in user gets the confirmed amount from `cards.quote`, with their
|
|
383
|
+
bonuses and anything they owe. `cards.order` with an `expectedAmount` that no
|
|
384
|
+
longer holds throws 409 `price_changed`, and `priceChangedQuote(error)` reads
|
|
385
|
+
the new quote from it. Without `expectedAmount` an order works as before.
|
|
386
|
+
|
|
336
387
|
## Topping up by SBP
|
|
337
388
|
|
|
338
389
|
A rouble top-up through Russia's instant payments goes like this: the user
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Claim } from './resources/claims.cjs';
|
|
2
|
+
import { CodeRejection, CodeDiscount, CodeEffect } from './resources/codes.cjs';
|
|
2
3
|
import { ConsentKind, ConsentChannel } from './resources/consents.cjs';
|
|
3
4
|
import { H as HttpClient } from './http-CL97TjMO.cjs';
|
|
4
5
|
import { AnalyticsIds } from './resources/attribution.cjs';
|
|
@@ -847,6 +848,92 @@ interface CardOrderInput {
|
|
|
847
848
|
/** The visitor's analytics ids for the order's server-side conversions.
|
|
848
849
|
* Leave out to send the ones this browser holds (see `analyticsIds`). */
|
|
849
850
|
analyticsIds?: AnalyticsIds;
|
|
851
|
+
/**
|
|
852
|
+
* The amount the user was shown and agreed to pay: `amount` of the
|
|
853
|
+
* quote. If the order comes to anything else, no payment is opened and
|
|
854
|
+
* the API answers 409 `price_changed` with the new quote (see
|
|
855
|
+
* {@link priceChangedQuote}). Leave it out and the payment opens for
|
|
856
|
+
* whatever the order comes to. Sent as `expected_amount`.
|
|
857
|
+
*/
|
|
858
|
+
expectedAmount?: string;
|
|
859
|
+
/** `currency` of the same quote. Sent as `expected_currency`. */
|
|
860
|
+
expectedCurrency?: string;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* A card order to price with {@link CardsResource.quote} or
|
|
864
|
+
* {@link CardsResource.quotePublic}: the same fields as the order.
|
|
865
|
+
*/
|
|
866
|
+
interface CardOrderQuoteInput {
|
|
867
|
+
/** Sent as `product_id`. */
|
|
868
|
+
productId: string;
|
|
869
|
+
/** Sent as `design_id`. */
|
|
870
|
+
designId?: string;
|
|
871
|
+
method: DepositMethod;
|
|
872
|
+
/** Sent as `funder_slug`. */
|
|
873
|
+
funderSlug?: string;
|
|
874
|
+
currency?: string;
|
|
875
|
+
/** Sent as `extra_load`. */
|
|
876
|
+
extraLoad?: string;
|
|
877
|
+
/** The code the user typed. Sent as `promo_code`. */
|
|
878
|
+
promoCode?: string;
|
|
879
|
+
/** Signed in only: pay part of the price with bonuses, on by default. Sent as `use_bonus`. */
|
|
880
|
+
useBonus?: boolean;
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Where a promo code stands in a quote. `applied`: its discount is in the
|
|
884
|
+
* amount. `conditional` (before sign-in only): it works for someone who
|
|
885
|
+
* meets `conditions`, which are checked after sign-in, and the amount is
|
|
886
|
+
* provisional. `rejected`: it can't be used, for `reason`; an order that
|
|
887
|
+
* keeps the code is refused, so drop it from the order. `unavailable`: it
|
|
888
|
+
* couldn't be checked right now; the amount is without it.
|
|
889
|
+
*/
|
|
890
|
+
type PromoCodeStatus = "applied" | "conditional" | "rejected" | "unavailable";
|
|
891
|
+
/** What a promo code does to a card order. */
|
|
892
|
+
interface PromoCodeQuote {
|
|
893
|
+
/** The code as stored, or as typed when it wasn't found. */
|
|
894
|
+
code: string;
|
|
895
|
+
status: PromoCodeStatus;
|
|
896
|
+
/** For `rejected`. */
|
|
897
|
+
reason: CodeRejection | null;
|
|
898
|
+
/**
|
|
899
|
+
* For `conditional`: `not_first_operation` (first card only) or
|
|
900
|
+
* `own_code` (not for the person it belongs to).
|
|
901
|
+
*/
|
|
902
|
+
conditions: CodeRejection[];
|
|
903
|
+
/** A sentence to show next to the code, in English. Null when the discount says it all. */
|
|
904
|
+
message: string | null;
|
|
905
|
+
/**
|
|
906
|
+
* The discount and what it comes off: `card_issuance` (the card's price,
|
|
907
|
+
* in `discount` of the quote) or `funding_commission` (the payment's
|
|
908
|
+
* commission: the amount stays the same and more goes onto the card).
|
|
909
|
+
*/
|
|
910
|
+
discount: CodeDiscount | null;
|
|
911
|
+
/** What else the code gives, once the card is issued. */
|
|
912
|
+
effects: CodeEffect[];
|
|
913
|
+
/** The code the user signed up with, applied without being typed. */
|
|
914
|
+
from_sign_up: boolean;
|
|
915
|
+
}
|
|
916
|
+
/** What a card order would cost now, from {@link CardsResource.quote} or {@link CardsResource.quotePublic}. */
|
|
917
|
+
interface CardOrderQuote {
|
|
918
|
+
/** What the user pays, decimal string, in `currency`. Pass it to the order as `expectedAmount`. */
|
|
919
|
+
amount: string;
|
|
920
|
+
/** Pass it to the order as `expectedCurrency`. */
|
|
921
|
+
currency: string;
|
|
922
|
+
/** The same order without the promo code, decimal string, in `currency`. */
|
|
923
|
+
price: string;
|
|
924
|
+
/** `price` less `amount`: what the code takes off. `"0"` without one. */
|
|
925
|
+
discount: string;
|
|
926
|
+
/** What the payment brings, in `card_currency`, as in {@link CardOrder}. */
|
|
927
|
+
card_amount: string;
|
|
928
|
+
card_currency: string;
|
|
929
|
+
/** Card fees owed, in `card_currency`, included in `card_amount`. Always `"0"` before sign-in. */
|
|
930
|
+
debt_withheld: string;
|
|
931
|
+
/** Bonuses that pay part of the price; null before sign-in. */
|
|
932
|
+
bonus_units: string | null;
|
|
933
|
+
/** The amount may still change after sign-in: show it as provisional. */
|
|
934
|
+
preliminary: boolean;
|
|
935
|
+
/** Null when no code was typed and none applies by itself. */
|
|
936
|
+
promo_code: PromoCodeQuote | null;
|
|
850
937
|
}
|
|
851
938
|
/** What {@link CardsResource.order} returns: the top-up to pay and its price. */
|
|
852
939
|
interface CardOrder {
|
|
@@ -869,7 +956,19 @@ interface CardOrder {
|
|
|
869
956
|
interface CardOrderError {
|
|
870
957
|
code: string;
|
|
871
958
|
message: string;
|
|
959
|
+
/** With `code: "price_changed"`: what the card costs now. */
|
|
960
|
+
quote?: CardOrderQuote;
|
|
872
961
|
}
|
|
962
|
+
/**
|
|
963
|
+
* The new quote of an order that opened no payment because its price
|
|
964
|
+
* changed (`price_changed`), from either a thrown {@link ApiError} of
|
|
965
|
+
* {@link CardsResource.order} or the `card_order_error` of a sign-in.
|
|
966
|
+
* Show its amount; once the user agrees, send the order again with
|
|
967
|
+
* `expectedAmount` set to it. `undefined` for any other error.
|
|
968
|
+
*/
|
|
969
|
+
declare function priceChangedQuote(error: unknown): CardOrderQuote | undefined;
|
|
970
|
+
/** Build the API body of a card order quote. */
|
|
971
|
+
declare function cardOrderQuoteBody(input: CardOrderQuoteInput): Record<string, unknown>;
|
|
873
972
|
/** Build the API body of a card order. */
|
|
874
973
|
declare function cardOrderBody(input: CardOrderInput): Record<string, unknown>;
|
|
875
974
|
/** Remaining balance of a prepaid card. */
|
|
@@ -1133,11 +1232,32 @@ declare class CardsResource {
|
|
|
1133
1232
|
* `holder_data_required` and the user has not agreed to it), 409
|
|
1134
1233
|
* `payments_on_hold` (a payment on this account was not accepted and new
|
|
1135
1234
|
* ones wait until support sorts it out: show the message and point the
|
|
1136
|
-
* user to support),
|
|
1235
|
+
* user to support), 409 `price_changed` (the order came to another amount
|
|
1236
|
+
* than `expectedAmount`; no payment was opened, and
|
|
1237
|
+
* {@link priceChangedQuote} gives the new quote), 503 no funding connector
|
|
1238
|
+
* or no exchange rate.
|
|
1137
1239
|
*/
|
|
1138
1240
|
order(input: CardOrderInput & {
|
|
1139
1241
|
idempotencyKey: string;
|
|
1140
1242
|
}): Promise<CardOrder>;
|
|
1243
|
+
/**
|
|
1244
|
+
* What an order of this card would cost the signed-in user now, with the
|
|
1245
|
+
* promo code: the same calculation {@link order} makes, with every
|
|
1246
|
+
* condition of the code checked. Nothing is reserved or used up. Pass
|
|
1247
|
+
* `amount` and `currency` to the order as `expectedAmount` and
|
|
1248
|
+
* `expectedCurrency`.
|
|
1249
|
+
*/
|
|
1250
|
+
quote(input: CardOrderQuoteInput): Promise<CardOrderQuote>;
|
|
1251
|
+
/**
|
|
1252
|
+
* The same quote before sign-in, for a landing page or the purchase form
|
|
1253
|
+
* before the e-mail code. Prices are list prices, and a code whose
|
|
1254
|
+
* conditions depend on the person (first card only, say) comes back
|
|
1255
|
+
* `conditional`, with `preliminary` set. Send `expectedAmount` with the
|
|
1256
|
+
* order placed at sign-in: if the price turns out different, no payment
|
|
1257
|
+
* is opened and `card_order_error` carries the new quote. The API limits
|
|
1258
|
+
* how often one address can ask (429 `too_many_requests`).
|
|
1259
|
+
*/
|
|
1260
|
+
quotePublic(input: Omit<CardOrderQuoteInput, "useBonus">): Promise<CardOrderQuote>;
|
|
1141
1261
|
/**
|
|
1142
1262
|
* The cards the caller can order, in the order the storefront shows them
|
|
1143
1263
|
* (`is_default` marks the one issued when none is chosen). Each item
|
|
@@ -1276,4 +1396,4 @@ declare class CardsResource {
|
|
|
1276
1396
|
terminate(id: string, reason?: string): Promise<Card>;
|
|
1277
1397
|
}
|
|
1278
1398
|
|
|
1279
|
-
export {
|
|
1399
|
+
export { type TransferInput as $, type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type CustomerInfo as E, FundingOptionsResource as F, type DepositMethod as G, type DepositStatus as H, type DepositTarget as I, type FeeKind as J, type FunderMode as K, type FundingOption as L, type FundingQuote as M, type InitiateDepositInput as N, type IssuanceBonus as O, type IssueCardInput as P, type MethodTerms as Q, type PromoCodeQuote as R, type PromoCodeStatus as S, type Refund as T, type RevealCardInput as U, type RevealState as V, type RevealedCard as W, type SetPinInput as X, type TopUpInput as Y, type TopUpResult as Z, type TopUpTerms as _, type Card as a, type TransferResult as a0, type UpdateCardInput as a1, priceChangedQuote as a2, revealState as a3, cardOrderBody as a4, cardOrderQuoteBody as a5, cardRequestBody as a6, 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 CardOrderQuote as l, type CardOrderQuoteInput as m, type CardProductPrice as n, type CardStatus as o, type CardStatusSource as p, type CardTariff as q, type CardTopUp as r, type CardTopUpStatus as s, type CardTransfer as t, type CardType as u, type Cardholder as v, type CloseBlockedReason as w, type CreateCardInput as x, type CreateDepositRefundInput as y, type CreateQuoteInput as z };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Claim } from './resources/claims.js';
|
|
2
|
+
import { CodeRejection, CodeDiscount, CodeEffect } from './resources/codes.js';
|
|
2
3
|
import { ConsentKind, ConsentChannel } from './resources/consents.js';
|
|
3
4
|
import { H as HttpClient } from './http-CL97TjMO.js';
|
|
4
5
|
import { AnalyticsIds } from './resources/attribution.js';
|
|
@@ -847,6 +848,92 @@ interface CardOrderInput {
|
|
|
847
848
|
/** The visitor's analytics ids for the order's server-side conversions.
|
|
848
849
|
* Leave out to send the ones this browser holds (see `analyticsIds`). */
|
|
849
850
|
analyticsIds?: AnalyticsIds;
|
|
851
|
+
/**
|
|
852
|
+
* The amount the user was shown and agreed to pay: `amount` of the
|
|
853
|
+
* quote. If the order comes to anything else, no payment is opened and
|
|
854
|
+
* the API answers 409 `price_changed` with the new quote (see
|
|
855
|
+
* {@link priceChangedQuote}). Leave it out and the payment opens for
|
|
856
|
+
* whatever the order comes to. Sent as `expected_amount`.
|
|
857
|
+
*/
|
|
858
|
+
expectedAmount?: string;
|
|
859
|
+
/** `currency` of the same quote. Sent as `expected_currency`. */
|
|
860
|
+
expectedCurrency?: string;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* A card order to price with {@link CardsResource.quote} or
|
|
864
|
+
* {@link CardsResource.quotePublic}: the same fields as the order.
|
|
865
|
+
*/
|
|
866
|
+
interface CardOrderQuoteInput {
|
|
867
|
+
/** Sent as `product_id`. */
|
|
868
|
+
productId: string;
|
|
869
|
+
/** Sent as `design_id`. */
|
|
870
|
+
designId?: string;
|
|
871
|
+
method: DepositMethod;
|
|
872
|
+
/** Sent as `funder_slug`. */
|
|
873
|
+
funderSlug?: string;
|
|
874
|
+
currency?: string;
|
|
875
|
+
/** Sent as `extra_load`. */
|
|
876
|
+
extraLoad?: string;
|
|
877
|
+
/** The code the user typed. Sent as `promo_code`. */
|
|
878
|
+
promoCode?: string;
|
|
879
|
+
/** Signed in only: pay part of the price with bonuses, on by default. Sent as `use_bonus`. */
|
|
880
|
+
useBonus?: boolean;
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Where a promo code stands in a quote. `applied`: its discount is in the
|
|
884
|
+
* amount. `conditional` (before sign-in only): it works for someone who
|
|
885
|
+
* meets `conditions`, which are checked after sign-in, and the amount is
|
|
886
|
+
* provisional. `rejected`: it can't be used, for `reason`; an order that
|
|
887
|
+
* keeps the code is refused, so drop it from the order. `unavailable`: it
|
|
888
|
+
* couldn't be checked right now; the amount is without it.
|
|
889
|
+
*/
|
|
890
|
+
type PromoCodeStatus = "applied" | "conditional" | "rejected" | "unavailable";
|
|
891
|
+
/** What a promo code does to a card order. */
|
|
892
|
+
interface PromoCodeQuote {
|
|
893
|
+
/** The code as stored, or as typed when it wasn't found. */
|
|
894
|
+
code: string;
|
|
895
|
+
status: PromoCodeStatus;
|
|
896
|
+
/** For `rejected`. */
|
|
897
|
+
reason: CodeRejection | null;
|
|
898
|
+
/**
|
|
899
|
+
* For `conditional`: `not_first_operation` (first card only) or
|
|
900
|
+
* `own_code` (not for the person it belongs to).
|
|
901
|
+
*/
|
|
902
|
+
conditions: CodeRejection[];
|
|
903
|
+
/** A sentence to show next to the code, in English. Null when the discount says it all. */
|
|
904
|
+
message: string | null;
|
|
905
|
+
/**
|
|
906
|
+
* The discount and what it comes off: `card_issuance` (the card's price,
|
|
907
|
+
* in `discount` of the quote) or `funding_commission` (the payment's
|
|
908
|
+
* commission: the amount stays the same and more goes onto the card).
|
|
909
|
+
*/
|
|
910
|
+
discount: CodeDiscount | null;
|
|
911
|
+
/** What else the code gives, once the card is issued. */
|
|
912
|
+
effects: CodeEffect[];
|
|
913
|
+
/** The code the user signed up with, applied without being typed. */
|
|
914
|
+
from_sign_up: boolean;
|
|
915
|
+
}
|
|
916
|
+
/** What a card order would cost now, from {@link CardsResource.quote} or {@link CardsResource.quotePublic}. */
|
|
917
|
+
interface CardOrderQuote {
|
|
918
|
+
/** What the user pays, decimal string, in `currency`. Pass it to the order as `expectedAmount`. */
|
|
919
|
+
amount: string;
|
|
920
|
+
/** Pass it to the order as `expectedCurrency`. */
|
|
921
|
+
currency: string;
|
|
922
|
+
/** The same order without the promo code, decimal string, in `currency`. */
|
|
923
|
+
price: string;
|
|
924
|
+
/** `price` less `amount`: what the code takes off. `"0"` without one. */
|
|
925
|
+
discount: string;
|
|
926
|
+
/** What the payment brings, in `card_currency`, as in {@link CardOrder}. */
|
|
927
|
+
card_amount: string;
|
|
928
|
+
card_currency: string;
|
|
929
|
+
/** Card fees owed, in `card_currency`, included in `card_amount`. Always `"0"` before sign-in. */
|
|
930
|
+
debt_withheld: string;
|
|
931
|
+
/** Bonuses that pay part of the price; null before sign-in. */
|
|
932
|
+
bonus_units: string | null;
|
|
933
|
+
/** The amount may still change after sign-in: show it as provisional. */
|
|
934
|
+
preliminary: boolean;
|
|
935
|
+
/** Null when no code was typed and none applies by itself. */
|
|
936
|
+
promo_code: PromoCodeQuote | null;
|
|
850
937
|
}
|
|
851
938
|
/** What {@link CardsResource.order} returns: the top-up to pay and its price. */
|
|
852
939
|
interface CardOrder {
|
|
@@ -869,7 +956,19 @@ interface CardOrder {
|
|
|
869
956
|
interface CardOrderError {
|
|
870
957
|
code: string;
|
|
871
958
|
message: string;
|
|
959
|
+
/** With `code: "price_changed"`: what the card costs now. */
|
|
960
|
+
quote?: CardOrderQuote;
|
|
872
961
|
}
|
|
962
|
+
/**
|
|
963
|
+
* The new quote of an order that opened no payment because its price
|
|
964
|
+
* changed (`price_changed`), from either a thrown {@link ApiError} of
|
|
965
|
+
* {@link CardsResource.order} or the `card_order_error` of a sign-in.
|
|
966
|
+
* Show its amount; once the user agrees, send the order again with
|
|
967
|
+
* `expectedAmount` set to it. `undefined` for any other error.
|
|
968
|
+
*/
|
|
969
|
+
declare function priceChangedQuote(error: unknown): CardOrderQuote | undefined;
|
|
970
|
+
/** Build the API body of a card order quote. */
|
|
971
|
+
declare function cardOrderQuoteBody(input: CardOrderQuoteInput): Record<string, unknown>;
|
|
873
972
|
/** Build the API body of a card order. */
|
|
874
973
|
declare function cardOrderBody(input: CardOrderInput): Record<string, unknown>;
|
|
875
974
|
/** Remaining balance of a prepaid card. */
|
|
@@ -1133,11 +1232,32 @@ declare class CardsResource {
|
|
|
1133
1232
|
* `holder_data_required` and the user has not agreed to it), 409
|
|
1134
1233
|
* `payments_on_hold` (a payment on this account was not accepted and new
|
|
1135
1234
|
* ones wait until support sorts it out: show the message and point the
|
|
1136
|
-
* user to support),
|
|
1235
|
+
* user to support), 409 `price_changed` (the order came to another amount
|
|
1236
|
+
* than `expectedAmount`; no payment was opened, and
|
|
1237
|
+
* {@link priceChangedQuote} gives the new quote), 503 no funding connector
|
|
1238
|
+
* or no exchange rate.
|
|
1137
1239
|
*/
|
|
1138
1240
|
order(input: CardOrderInput & {
|
|
1139
1241
|
idempotencyKey: string;
|
|
1140
1242
|
}): Promise<CardOrder>;
|
|
1243
|
+
/**
|
|
1244
|
+
* What an order of this card would cost the signed-in user now, with the
|
|
1245
|
+
* promo code: the same calculation {@link order} makes, with every
|
|
1246
|
+
* condition of the code checked. Nothing is reserved or used up. Pass
|
|
1247
|
+
* `amount` and `currency` to the order as `expectedAmount` and
|
|
1248
|
+
* `expectedCurrency`.
|
|
1249
|
+
*/
|
|
1250
|
+
quote(input: CardOrderQuoteInput): Promise<CardOrderQuote>;
|
|
1251
|
+
/**
|
|
1252
|
+
* The same quote before sign-in, for a landing page or the purchase form
|
|
1253
|
+
* before the e-mail code. Prices are list prices, and a code whose
|
|
1254
|
+
* conditions depend on the person (first card only, say) comes back
|
|
1255
|
+
* `conditional`, with `preliminary` set. Send `expectedAmount` with the
|
|
1256
|
+
* order placed at sign-in: if the price turns out different, no payment
|
|
1257
|
+
* is opened and `card_order_error` carries the new quote. The API limits
|
|
1258
|
+
* how often one address can ask (429 `too_many_requests`).
|
|
1259
|
+
*/
|
|
1260
|
+
quotePublic(input: Omit<CardOrderQuoteInput, "useBonus">): Promise<CardOrderQuote>;
|
|
1141
1261
|
/**
|
|
1142
1262
|
* The cards the caller can order, in the order the storefront shows them
|
|
1143
1263
|
* (`is_default` marks the one issued when none is chosen). Each item
|
|
@@ -1276,4 +1396,4 @@ declare class CardsResource {
|
|
|
1276
1396
|
terminate(id: string, reason?: string): Promise<Card>;
|
|
1277
1397
|
}
|
|
1278
1398
|
|
|
1279
|
-
export {
|
|
1399
|
+
export { type TransferInput as $, type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type CustomerInfo as E, FundingOptionsResource as F, type DepositMethod as G, type DepositStatus as H, type DepositTarget as I, type FeeKind as J, type FunderMode as K, type FundingOption as L, type FundingQuote as M, type InitiateDepositInput as N, type IssuanceBonus as O, type IssueCardInput as P, type MethodTerms as Q, type PromoCodeQuote as R, type PromoCodeStatus as S, type Refund as T, type RevealCardInput as U, type RevealState as V, type RevealedCard as W, type SetPinInput as X, type TopUpInput as Y, type TopUpResult as Z, type TopUpTerms as _, type Card as a, type TransferResult as a0, type UpdateCardInput as a1, priceChangedQuote as a2, revealState as a3, cardOrderBody as a4, cardOrderQuoteBody as a5, cardRequestBody as a6, 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 CardOrderQuote as l, type CardOrderQuoteInput as m, type CardProductPrice as n, type CardStatus as o, type CardStatusSource as p, type CardTariff as q, type CardTopUp as r, type CardTopUpStatus as s, type CardTransfer as t, type CardType as u, type Cardholder as v, type CloseBlockedReason as w, type CreateCardInput as x, type CreateDepositRefundInput as y, type CreateQuoteInput as z };
|
package/dist/index.cjs
CHANGED
|
@@ -336,6 +336,26 @@ function cardRequestBody(input) {
|
|
|
336
336
|
if (consentChannel !== void 0) body["consent_channel"] = consentChannel;
|
|
337
337
|
return body;
|
|
338
338
|
}
|
|
339
|
+
function priceChangedQuote(error) {
|
|
340
|
+
const body = isApiError(error) ? error.body : error;
|
|
341
|
+
if (typeof body !== "object" || body === null) return void 0;
|
|
342
|
+
const { code, quote } = body;
|
|
343
|
+
if (code !== "price_changed" || typeof quote !== "object" || quote === null) return void 0;
|
|
344
|
+
return quote;
|
|
345
|
+
}
|
|
346
|
+
function cardOrderQuoteBody(input) {
|
|
347
|
+
const body = {
|
|
348
|
+
product_id: input.productId,
|
|
349
|
+
method: input.method
|
|
350
|
+
};
|
|
351
|
+
if (input.designId !== void 0) body["design_id"] = input.designId;
|
|
352
|
+
if (input.funderSlug !== void 0) body["funder_slug"] = input.funderSlug;
|
|
353
|
+
if (input.currency !== void 0) body["currency"] = input.currency;
|
|
354
|
+
if (input.extraLoad !== void 0) body["extra_load"] = input.extraLoad;
|
|
355
|
+
if (input.promoCode !== void 0) body["promo_code"] = input.promoCode;
|
|
356
|
+
if (input.useBonus !== void 0) body["use_bonus"] = input.useBonus;
|
|
357
|
+
return body;
|
|
358
|
+
}
|
|
339
359
|
function cardOrderBody(input) {
|
|
340
360
|
const body = {
|
|
341
361
|
product_id: input.productId,
|
|
@@ -353,6 +373,8 @@ function cardOrderBody(input) {
|
|
|
353
373
|
if (input.metadata !== void 0) body["metadata"] = input.metadata;
|
|
354
374
|
const ids = input.analyticsIds ?? analyticsIds();
|
|
355
375
|
if (ids !== void 0) body["analytics_ids"] = ids;
|
|
376
|
+
if (input.expectedAmount !== void 0) body["expected_amount"] = input.expectedAmount;
|
|
377
|
+
if (input.expectedCurrency !== void 0) body["expected_currency"] = input.expectedCurrency;
|
|
356
378
|
return body;
|
|
357
379
|
}
|
|
358
380
|
function revealState(r) {
|
|
@@ -390,7 +412,10 @@ var CardsResource = class {
|
|
|
390
412
|
* `holder_data_required` and the user has not agreed to it), 409
|
|
391
413
|
* `payments_on_hold` (a payment on this account was not accepted and new
|
|
392
414
|
* ones wait until support sorts it out: show the message and point the
|
|
393
|
-
* user to support),
|
|
415
|
+
* user to support), 409 `price_changed` (the order came to another amount
|
|
416
|
+
* than `expectedAmount`; no payment was opened, and
|
|
417
|
+
* {@link priceChangedQuote} gives the new quote), 503 no funding connector
|
|
418
|
+
* or no exchange rate.
|
|
394
419
|
*/
|
|
395
420
|
async order(input) {
|
|
396
421
|
const { idempotencyKey, ...order } = input;
|
|
@@ -399,6 +424,33 @@ var CardsResource = class {
|
|
|
399
424
|
idempotencyKey
|
|
400
425
|
});
|
|
401
426
|
}
|
|
427
|
+
/**
|
|
428
|
+
* What an order of this card would cost the signed-in user now, with the
|
|
429
|
+
* promo code: the same calculation {@link order} makes, with every
|
|
430
|
+
* condition of the code checked. Nothing is reserved or used up. Pass
|
|
431
|
+
* `amount` and `currency` to the order as `expectedAmount` and
|
|
432
|
+
* `expectedCurrency`.
|
|
433
|
+
*/
|
|
434
|
+
async quote(input) {
|
|
435
|
+
return this.http.post("/me/card-orders/quote", {
|
|
436
|
+
body: cardOrderQuoteBody(input)
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* The same quote before sign-in, for a landing page or the purchase form
|
|
441
|
+
* before the e-mail code. Prices are list prices, and a code whose
|
|
442
|
+
* conditions depend on the person (first card only, say) comes back
|
|
443
|
+
* `conditional`, with `preliminary` set. Send `expectedAmount` with the
|
|
444
|
+
* order placed at sign-in: if the price turns out different, no payment
|
|
445
|
+
* is opened and `card_order_error` carries the new quote. The API limits
|
|
446
|
+
* how often one address can ask (429 `too_many_requests`).
|
|
447
|
+
*/
|
|
448
|
+
async quotePublic(input) {
|
|
449
|
+
return this.http.post("/card-orders/quote", {
|
|
450
|
+
body: cardOrderQuoteBody(input),
|
|
451
|
+
skipAuth: true
|
|
452
|
+
});
|
|
453
|
+
}
|
|
402
454
|
/**
|
|
403
455
|
* The cards the caller can order, in the order the storefront shows them
|
|
404
456
|
* (`is_default` marks the one issued when none is chosen). Each item
|
|
@@ -1699,7 +1751,7 @@ var FundingOptionsResource = class {
|
|
|
1699
1751
|
};
|
|
1700
1752
|
|
|
1701
1753
|
// src/version.ts
|
|
1702
|
-
var SDK_VERSION = "0.
|
|
1754
|
+
var SDK_VERSION = "0.8.0";
|
|
1703
1755
|
|
|
1704
1756
|
// src/client-platform.ts
|
|
1705
1757
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1774,7 +1826,7 @@ function isAbsolute(url) {
|
|
|
1774
1826
|
}
|
|
1775
1827
|
|
|
1776
1828
|
// src/compat.ts
|
|
1777
|
-
var SUPPORTED_MEISTER = ">=0.
|
|
1829
|
+
var SUPPORTED_MEISTER = ">=0.8.0, <1.0.0";
|
|
1778
1830
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1779
1831
|
function parse(v) {
|
|
1780
1832
|
const m = SEMVER.exec(v.trim());
|
|
@@ -2353,6 +2405,7 @@ exports.isCardOtp = isCardOtp;
|
|
|
2353
2405
|
exports.isNetworkError = isNetworkError;
|
|
2354
2406
|
exports.page = page;
|
|
2355
2407
|
exports.posthogDistinctId = posthogDistinctId;
|
|
2408
|
+
exports.priceChangedQuote = priceChangedQuote;
|
|
2356
2409
|
exports.rememberAnalyticsIds = rememberAnalyticsIds;
|
|
2357
2410
|
exports.resetAnalytics = resetAnalytics;
|
|
2358
2411
|
exports.resolveAssetUrl = resolveAssetUrl;
|