@takeal/cusfront-sdk 0.6.11 → 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.
Files changed (59) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +54 -2
  3. package/dist/analytics.cjs +44 -6
  4. package/dist/analytics.cjs.map +1 -1
  5. package/dist/analytics.js +44 -6
  6. package/dist/analytics.js.map +1 -1
  7. package/dist/{cards-nXmDP0ei.d.cts → cards-BPu8Ill7.d.cts} +159 -12
  8. package/dist/{cards-CuUdrQ0H.d.ts → cards-DP1fJc_c.d.ts} +159 -12
  9. package/dist/index.cjs +261 -89
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +5 -5
  12. package/dist/index.d.ts +5 -5
  13. package/dist/index.js +257 -90
  14. package/dist/index.js.map +1 -1
  15. package/dist/react/index.d.cts +1 -1
  16. package/dist/react/index.d.ts +1 -1
  17. package/dist/resources/attribution.cjs +99 -4
  18. package/dist/resources/attribution.cjs.map +1 -1
  19. package/dist/resources/attribution.d.cts +58 -1
  20. package/dist/resources/attribution.d.ts +58 -1
  21. package/dist/resources/attribution.js +96 -5
  22. package/dist/resources/attribution.js.map +1 -1
  23. package/dist/resources/auth.cjs +66 -3
  24. package/dist/resources/auth.cjs.map +1 -1
  25. package/dist/resources/auth.d.cts +7 -2
  26. package/dist/resources/auth.d.ts +7 -2
  27. package/dist/resources/auth.js +66 -3
  28. package/dist/resources/auth.js.map +1 -1
  29. package/dist/resources/cards.cjs +111 -3
  30. package/dist/resources/cards.cjs.map +1 -1
  31. package/dist/resources/cards.d.cts +3 -1
  32. package/dist/resources/cards.d.ts +3 -1
  33. package/dist/resources/cards.js +110 -4
  34. package/dist/resources/cards.js.map +1 -1
  35. package/dist/resources/codes.cjs.map +1 -1
  36. package/dist/resources/codes.d.cts +21 -1
  37. package/dist/resources/codes.d.ts +21 -1
  38. package/dist/resources/codes.js.map +1 -1
  39. package/dist/resources/consents.cjs +15 -0
  40. package/dist/resources/consents.cjs.map +1 -1
  41. package/dist/resources/consents.js +15 -0
  42. package/dist/resources/consents.js.map +1 -1
  43. package/dist/resources/deposits.cjs +50 -0
  44. package/dist/resources/deposits.cjs.map +1 -1
  45. package/dist/resources/deposits.d.cts +3 -1
  46. package/dist/resources/deposits.d.ts +3 -1
  47. package/dist/resources/deposits.js +50 -0
  48. package/dist/resources/deposits.js.map +1 -1
  49. package/dist/resources/funding-options.d.cts +3 -1
  50. package/dist/resources/funding-options.d.ts +3 -1
  51. package/dist/resources/me.d.cts +1 -1
  52. package/dist/resources/me.d.ts +1 -1
  53. package/dist/telegram.cjs +253 -69
  54. package/dist/telegram.cjs.map +1 -1
  55. package/dist/telegram.d.cts +35 -4
  56. package/dist/telegram.d.ts +35 -4
  57. package/dist/telegram.js +253 -70
  58. package/dist/telegram.js.map +1 -1
  59. package/package.json +1 -1
@@ -1,6 +1,8 @@
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';
5
+ import { AnalyticsIds } from './resources/attribution.js';
4
6
 
5
7
  /**
6
8
  * Structured customer billing details — shared by the deposits and cards
@@ -369,6 +371,9 @@ interface InitiateDepositInput {
369
371
  * checks it first.
370
372
  */
371
373
  promo_code?: string;
374
+ /** The visitor's analytics ids for the payment's server-side conversions.
375
+ * Leave out to send the ones this browser holds (see `analyticsIds`). */
376
+ analytics_ids?: AnalyticsIds;
372
377
  }
373
378
  interface CreateDepositRefundInput {
374
379
  /** Omit for a full refund of the original confirmed amount; same currency. */
@@ -413,6 +418,11 @@ declare class DepositsResource {
413
418
  * API answers 400 `no_quote_needed`).
414
419
  */
415
420
  quote(input: CreateQuoteInput): Promise<FundingQuote>;
421
+ /**
422
+ * Start a top-up. 409 `payments_on_hold`: a payment on this account was
423
+ * not accepted and new ones wait until support sorts it out. Show the
424
+ * message as it comes and point the user to support.
425
+ */
416
426
  initiate(input: InitiateDepositInput): Promise<Deposit>;
417
427
  /** Fetch one deposit by id — the poll target while a redirect resolves. */
418
428
  get(id: string): Promise<Deposit>;
@@ -462,8 +472,10 @@ type CardType = "credit" | "prepaid" | "gift";
462
472
  /**
463
473
  * Card lifecycle state.
464
474
  *
465
- * - `pending_payment`: the row exists but the issuance fee has not been
466
- * paid yet; the provider has not been called and nothing is visible.
475
+ * - `pending_payment`: an order waiting for its payment, not a card yet.
476
+ * It has no digits and no expiry, and nothing can be done with it:
477
+ * revealing, freezing, closing or renaming it answers 409 `card_pending`.
478
+ * Show it as "waiting for payment", without a way into the card's page.
467
479
  * - `pending`: the issuer accepted the order and has not issued the card
468
480
  * yet. The price is charged. Show the card as "being issued" with no
469
481
  * numbers; it becomes `active` on its own, or `failed` with the price
@@ -520,10 +532,10 @@ interface CardProductPrice {
520
532
  /** What the user pays, decimal string, after their subscription discount. */
521
533
  amount: string;
522
534
  /**
523
- * ISO 4217 code: the currency the buyer pays in. A signed-in user sees
524
- * their wallet currency, converted the way issuance will charge it; the
525
- * public catalog shows the currency the operator priced the card in. It
526
- * is not necessarily the currency the card is held in (`CardProduct.currency`).
535
+ * ISO 4217 code: the currency the operator priced the card in, the same
536
+ * before and after sign-in. A card order paid in this currency costs
537
+ * exactly `amount`. It is not necessarily the currency the card is held
538
+ * in (`CardProduct.currency`).
527
539
  */
528
540
  currency: string;
529
541
  /** Wording for the fee line, e.g. "Card issuance". */
@@ -532,6 +544,15 @@ interface CardProductPrice {
532
544
  base_amount: string;
533
545
  /** Discount applied, in basis points (1000 = 10%). */
534
546
  discount_bps: number;
547
+ /**
548
+ * What issuing costs when paid from the wallet, converted the way that
549
+ * purchase charges it. Only for a signed-in user whose wallet holds another
550
+ * currency than the price; absent otherwise, and when there is no rate.
551
+ */
552
+ from_wallet?: {
553
+ amount: string;
554
+ currency: string;
555
+ } | null;
535
556
  }
536
557
  /**
537
558
  * A card the user can order, as listed by `GET /me/card-products`. The id is
@@ -620,7 +641,7 @@ interface Card {
620
641
  user_id: string;
621
642
  card_type: CardType;
622
643
  status: CardStatus;
623
- /** Last four digits of the PAN — safe to display. */
644
+ /** Last four digits of the PAN — safe to display. Null until the card is paid for and issued. */
624
645
  last4: string | null;
625
646
  expiry_month: number | null;
626
647
  expiry_year: number | null;
@@ -824,6 +845,95 @@ interface CardOrderInput {
824
845
  consentChannel?: ConsentChannel;
825
846
  /** Passed to the payment provider; `return_url` is where the payment page sends the user back. */
826
847
  metadata?: Record<string, string>;
848
+ /** The visitor's analytics ids for the order's server-side conversions.
849
+ * Leave out to send the ones this browser holds (see `analyticsIds`). */
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;
827
937
  }
828
938
  /** What {@link CardsResource.order} returns: the top-up to pay and its price. */
829
939
  interface CardOrder {
@@ -832,7 +942,7 @@ interface CardOrder {
832
942
  /** What the user pays, decimal string, in `currency`. */
833
943
  amount: string;
834
944
  currency: string;
835
- /** What the payment brings: the card's price, its starting balance and `debt_withheld`, in `card_currency`. */
945
+ /** What the payment brings: the card's price, what goes onto the card and `debt_withheld`, in `card_currency`. A payment in the price's own currency pays the price as it is set; only the rest is converted. */
836
946
  card_amount: string;
837
947
  card_currency: string;
838
948
  /**
@@ -846,7 +956,19 @@ interface CardOrder {
846
956
  interface CardOrderError {
847
957
  code: string;
848
958
  message: string;
959
+ /** With `code: "price_changed"`: what the card costs now. */
960
+ quote?: CardOrderQuote;
849
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>;
850
972
  /** Build the API body of a card order. */
851
973
  declare function cardOrderBody(input: CardOrderInput): Record<string, unknown>;
852
974
  /** Remaining balance of a prepaid card. */
@@ -1107,18 +1229,43 @@ declare class CardsResource {
1107
1229
  * `idempotencyKey` returns the same order.
1108
1230
  * Errors: 400 `unknown_product` / `method_not_available` / a limit of the
1109
1231
  * way of paying, 409 `holder_data_consent_required` (the product has
1110
- * `holder_data_required` and the user has not agreed to it), 503 no
1111
- * funding connector or no exchange rate.
1232
+ * `holder_data_required` and the user has not agreed to it), 409
1233
+ * `payments_on_hold` (a payment on this account was not accepted and new
1234
+ * ones wait until support sorts it out: show the message and point the
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.
1112
1239
  */
1113
1240
  order(input: CardOrderInput & {
1114
1241
  idempotencyKey: string;
1115
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>;
1116
1261
  /**
1117
1262
  * The cards the caller can order, in the order the storefront shows them
1118
1263
  * (`is_default` marks the one issued when none is chosen). Each item
1119
1264
  * carries its product card (name, tagline, benefits, tile picture),
1120
1265
  * artwork, and the issuance price after the caller's subscription
1121
- * discount, in the caller's wallet currency. Pass an item's `id` as
1266
+ * discount, in the currency the operator set it in (`price.from_wallet`
1267
+ * is the same price from the wallet, when that holds another currency).
1268
+ * Pass an item's `id` as
1122
1269
  * `productId` to {@link create}.
1123
1270
  */
1124
1271
  listProducts(): Promise<CardProduct[]>;
@@ -1249,4 +1396,4 @@ declare class CardsResource {
1249
1396
  terminate(id: string, reason?: string): Promise<Card>;
1250
1397
  }
1251
1398
 
1252
- export { cardOrderBody as $, 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 RevealState as Q, type Refund as R, type RevealedCard as S, type SetPinInput as T, type TopUpInput as U, type TopUpResult as V, type TopUpTerms as W, type TransferInput as X, type TransferResult as Y, type UpdateCardInput as Z, revealState as _, type Card as a, cardRequestBody as a0, 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 };
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 };