@takeal/cusfront-sdk 0.6.4 → 0.6.5
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 +33 -0
- package/README.md +129 -3
- package/dist/{cards-ofoGRU9v.d.cts → cards-CEFKrVkl.d.cts} +125 -10
- package/dist/{cards-BrqeBqLV.d.ts → cards-ColpW52n.d.ts} +125 -10
- package/dist/index.cjs +121 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +120 -12
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +3 -1
- package/dist/react/index.d.ts +3 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +1 -1
- package/dist/resources/auth.d.ts +1 -1
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +9 -2
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +1 -1
- package/dist/resources/cards.d.ts +1 -1
- package/dist/resources/cards.js +9 -2
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/close-requests.cjs +54 -0
- package/dist/resources/close-requests.cjs.map +1 -0
- package/dist/resources/close-requests.d.cts +155 -0
- package/dist/resources/close-requests.d.ts +155 -0
- package/dist/resources/close-requests.js +52 -0
- package/dist/resources/close-requests.js.map +1 -0
- package/dist/resources/consents.cjs +42 -7
- package/dist/resources/consents.cjs.map +1 -1
- package/dist/resources/consents.d.cts +58 -8
- package/dist/resources/consents.d.ts +58 -8
- package/dist/resources/consents.js +41 -8
- package/dist/resources/consents.js.map +1 -1
- package/dist/resources/debt.cjs +22 -0
- package/dist/resources/debt.cjs.map +1 -0
- package/dist/resources/debt.d.cts +76 -0
- package/dist/resources/debt.d.ts +76 -0
- package/dist/resources/debt.js +20 -0
- package/dist/resources/debt.js.map +1 -0
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +1 -1
- package/dist/resources/deposits.d.ts +1 -1
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +1 -1
- package/dist/resources/funding-options.d.ts +1 -1
- package/dist/resources/history.cjs.map +1 -1
- package/dist/resources/history.d.cts +12 -1
- package/dist/resources/history.d.ts +12 -1
- package/dist/resources/history.js.map +1 -1
- package/dist/resources/me.d.cts +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/telegram.cjs +119 -11
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +3 -1
- package/dist/telegram.d.ts +3 -1
- package/dist/telegram.js +119 -11
- package/dist/telegram.js.map +1 -1
- package/package.json +11 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resources/cards.ts"],"names":[],"mappings":";;;AAiTO,SAAS,gBACd,KAAA,EACyB;AACzB,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA,EAAgB,QAAA;AAAA,IAChB,GAAG;AAAA,GACL,GAAI,KAAA;AACJ,EAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,EAAK;AAChD,EAAA,IAAI,SAAA,KAAc,MAAA,EAAW,IAAA,CAAK,YAAY,CAAA,GAAI,SAAA;AAClD,EAAA,IAAI,IAAA,KAAS,MAAA,EAAW,IAAA,CAAK,MAAM,CAAA,GAAI,IAAA;AACvC,EAAA,IAAI,QAAA,KAAa,MAAA,EAAW,IAAA,CAAK,WAAW,CAAA,GAAI,QAAA;AAChD,EAAA,IAAI,QAAA,KAAa,MAAA,EAAW,IAAA,CAAK,WAAW,CAAA,GAAI,QAAA;AAChD,EAAA,IAAI,WAAA,KAAgB,MAAA,EAAW,IAAA,CAAK,cAAc,CAAA,GAAI,WAAA;AACtD,EAAA,IAAI,SAAA,KAAc,MAAA,EAAW,IAAA,CAAK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AS,CAAA;AAAA,EAClF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,SAAS,EAAA,EAA2B;AACxC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAW,CAAA,UAAA,EAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,SAAA,CAAA,EAAa,EAAE,IAAA,EAAM,EAAC,EAAG,CAAA;AAAA,EAC1F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,MAAA,CAAO,EAAA,EAAY,KAAA,EAAmC;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAW,aAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,IAAA,CAAA,EAAQ;AAAA,MACrE,IAAA,EAAM,EAAE,GAAA,EAAK,KAAA,CAAM,GAAA;AAAI,KACxB,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,SAAA,CAAU,EAAA,EAAY,MAAA,EAAgC;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAW,aAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,UAAA,CAAA,EAAc;AAAA,MAC3E,IAAA,EAAM,EAAE,MAAA;AAAO,KAChB,CAAA;AAAA,EACH;AACF","file":"cards.cjs","sourcesContent":["import type { ConsentChannel, ConsentKind } from \"./consents.js\";\nimport type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\nimport type { Deposit, DepositMethod } from \"./deposits.js\";\n\n/**\n * Cards resource — `client.cards.*`.\n *\n * The end-user \"money OUT\" surface: a user issues themselves a card backed by\n * their wallet balance via an issuer connector. Mirrors the Takeal API's\n * `/me/cards` routes:\n *\n * GET /card-products → catalog (public, before sign-in)\n * GET /me/card-products → listProducts (the catalog, personal price)\n * GET /me/card-products/{id} → getProduct\n * GET /me/cards/{id}/topup → topUpTerms\n * POST /me/cards/{id}/topup → topUp\n * POST /me/cards → create\n * GET /me/cards → list (most recent first)\n * GET /me/cards/{id} → get\n * PATCH /me/cards/{id} → update (name, design)\n * GET /me/cards/{id}/balance → balance (prepaid remaining)\n * POST /me/cards/{id}/freeze → freeze\n * POST /me/cards/{id}/unfreeze → unfreeze\n * POST /me/cards/{id}/transfer → transfer (to another of their cards)\n * POST /me/cards/{id}/terminate → terminate (one-way)\n * POST /me/cards/{id}/reveal → reveal (the numbers, or a provider page)\n * POST /me/cards/{id}/pin → setPin (physical cards)\n *\n * The lifecycle actions are ownership-gated server-side: a caller can only\n * freeze / unfreeze / terminate a card that belongs to them (else 404).\n *\n * Today only PREPAID is wired end-to-end; CREDIT and GIFT return 400 from\n * the Takeal API until their issuer flows land.\n */\n\n/** Card product. Only `prepaid` is fully implemented today. */\nexport type CardType = \"credit\" | \"prepaid\" | \"gift\";\n\n/**\n * Card lifecycle state.\n *\n * - `pending_payment`: the row exists but the issuance fee has not been\n * paid yet; the provider has not been called and nothing is visible.\n * - `pending`: the issuer accepted the order and has not issued the card\n * yet. The price is charged. Show the card as \"being issued\" with no\n * numbers; it becomes `active` on its own, or `failed` with the price\n * back on the wallet. Some issuers take minutes, some a day.\n * - `active`, `frozen`: the usual states. Read `status_source` before\n * offering to unfreeze.\n * - `terminating`: the holder (or the issuer) closed the card and the\n * issuer has not finished: the balance comes back to the wallet when it\n * does. Show it as closing; no actions apply.\n * - `terminated`, `redeemed`, `failed`: final.\n */\nexport type CardStatus =\n | \"pending_payment\"\n | \"pending\"\n | \"active\"\n | \"frozen\"\n | \"terminating\"\n | \"terminated\"\n | \"redeemed\"\n | \"failed\";\n\n/**\n * Who made the card's last status change. `provider` on a `frozen` card\n * means the issuer froze it (a risk check, a lost-card report): the holder\n * cannot unfreeze it, so do not offer the button; say the freeze is lifted\n * through the issuer's support. `holder` and `operator` freezes are undone\n * with `unfreeze()` as usual.\n */\nexport type CardStatusSource = \"holder\" | \"operator\" | \"provider\";\n\n/** `virtual` cards show their numbers in the app; `physical` cards are plastic and have a PIN. */\nexport type CardForm = \"virtual\" | \"physical\";\n\n/**\n * Why `terminate()` is refused right now: `first_purchase_required` (the\n * card closes after its first purchase) or `card_locked` (only support can\n * change it).\n */\nexport type CloseBlockedReason = \"first_purchase_required\" | \"card_locked\";\n\n/**\n * A card design: the artwork a card is shown with. `image_url` is the front,\n * `image_url_back` the back; both are either absolute URLs or paths relative\n * to the API origin (the deployment's default design is\n * `/card-designs/default.svg`, its back `/card-designs/default.svg?side=back`)\n * — pass them through `client.assetUrl()` before rendering. `image_url_back`\n * is `null` or absent for a one-sided design: show the front on both sides.\n * The picture is in the proportions of a plastic card (1586×1000) and draws\n * no chip or card data; the client renders the number, name and expiry on\n * top. `id` is `null` for the deployment default, which is rendered from the\n * branding settings.\n */\nexport interface CardDesignRef {\n id: string | null;\n name?: string;\n image_url: string;\n image_url_back?: string | null;\n}\n\n/**\n * What issuing a card costs the caller. `amount` is the price after the\n * user's subscription discount; `base_amount` is the list price and\n * `discount_bps` the discount in basis points (1000 = 10 %). `label` is the\n * operator's wording for the fee line (\"Card issuance\").\n */\nexport interface CardProductPrice {\n /** What the user pays, decimal string, after their subscription discount. */\n amount: string;\n /**\n * ISO 4217 code: the currency the buyer pays in. A signed-in user sees\n * their wallet currency, converted the way issuance will charge it; the\n * public catalog shows the currency the operator priced the card in. It\n * is not necessarily the currency the card is held in (`CardProduct.currency`).\n */\n currency: string;\n /** Wording for the fee line, e.g. \"Card issuance\". */\n label: string;\n /** The list price before the discount, decimal string, in the same currency. */\n base_amount: string;\n /** Discount applied, in basis points (1000 = 10%). */\n discount_bps: number;\n}\n\n/**\n * A card the user can order, as listed by `GET /me/card-products`. The id is\n * opaque — it names a product, never a provider. The list comes in the\n * order the operator arranged the storefront; `is_default` marks the\n * product issued when none is chosen, wherever it sits. `designs` is the\n * set the user may pick from (may be empty when only the default applies);\n * `design` is what the card gets when no choice is made. `price` is `null`\n * for a free card. `features` is an operator-defined object (scheme, wallet\n * support, load limits, …) with no fixed keys.\n */\nexport interface CardProduct {\n id: string;\n name: string;\n /** One line under the name on the tile, or `null`. */\n tagline: string | null;\n description: string | null;\n /** Selling points to list on the product card, in order. May be empty. */\n benefits: string[];\n /**\n * Picture for the product tile, absolute URL, or `null`: show the card\n * design (`design.image_url`) then.\n */\n tile_image_url: string | null;\n card_type: CardType;\n currency: string | null;\n features: Record<string, unknown>;\n design: CardDesignRef;\n designs: CardDesignRef[];\n price: CardProductPrice | null;\n /**\n * The balance a new card comes with, already included in `price`; `null`\n * when the card starts empty and is funded with `topUp()` afterwards.\n */\n starting_balance: CardBalance | null;\n /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\n}\n\n/**\n * A card record as the Takeal API returns it. Mirrors the `cards` table. Note the\n * SDK never receives the full PAN or CVV here — only `last4` + expiry. The\n * gift-card `redemption_code` is returned exactly once (on create) and\n * scrubbed from subsequent list/get responses.\n */\nexport interface Card {\n id: string;\n user_id: string;\n card_type: CardType;\n status: CardStatus;\n /** Last four digits of the PAN — safe to display. */\n last4: string | null;\n expiry_month: number | null;\n expiry_year: number | null;\n /** Gift cards only, present once on create then scrubbed. */\n redemption_code?: string;\n /** The balance the card was issued with, decimal string; `null` or `\"0\"` for a card issued empty. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | null;\n /** Who changed the status last; `null` when it never changed. See {@link CardStatusSource}. */\n status_source: CardStatusSource | null;\n /** Virtual or plastic. A `physical` card takes a PIN with {@link CardsResource.setPin}. */\n card_form: CardForm;\n /** Why the card cannot be closed right now, or `null` when it can. */\n close_blocked: CloseBlockedReason | null;\n /**\n * Top-ups the issuer has accepted and not loaded yet, summed, decimal\n * string in `currency`; `null` when there are none. Show it next to the\n * balance as money on its way to the card.\n */\n topups_pending: string | null;\n /**\n * Top-ups the issuer has held for too long, summed, decimal string in\n * `currency`; `null` when there are none. The money is safe and waits for\n * support to settle it; say so instead of offering a retry.\n */\n topups_held: string | null;\n /** The name the user gave the card, or `null`. */\n name: string | null;\n /** The artwork the card is shown with. Always present. */\n design: CardDesignRef;\n /** The product the card was issued from; `null` for cards issued without one. */\n product: { id: string; name: string } | null;\n created_at: string;\n updated_at: string;\n /** Only on the result of `create`, when bonuses paid part of the price. */\n bonus?: IssuanceBonus;\n}\n\n/** How bonuses changed a new card's price (\"was / now\"). Decimal strings in `currency`. */\nexport interface IssuanceBonus {\n /** Bonuses used. */\n units: string;\n /** The price before bonuses (\"was\"). */\n price: string;\n /** What the bonuses covered. */\n covered: string;\n /** What the wallet paid (\"now\"). */\n paid: string;\n currency: string;\n}\n\nexport interface CreateCardInput {\n /**\n * A product id from {@link CardsResource.listProducts}. Sent as\n * `product_id`. When given, `type` and `issuer_slug` may be omitted; when\n * both are given they must agree with the product (400 `product_mismatch`).\n * Unknown, disabled or hidden product → 400 `unknown_product`.\n */\n productId?: string;\n /** A name for the card, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * One of the product's `designs`. Sent as `design_id`. `null` or omitted\n * picks the product's default design; a design outside the product's set →\n * 400 `design_not_allowed`.\n */\n designId?: string | null;\n /**\n * `prepaid` (the only fully-wired type today), `credit`, or `gift`.\n * Optional when `productId` is given, required otherwise.\n */\n type?: CardType;\n /**\n * @deprecated Ignored since 0.3.21. A card is issued for its product price;\n * the balance it starts with, if the product includes one, is part of that\n * price (see `CardProduct.starting_balance`). Money is added afterwards\n * with {@link CardsResource.topUp}. The field is no longer sent.\n */\n initial_amount?: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n /**\n * Optional. Slug of a specific issuer to mint with. Omit to let\n * the Takeal API pick the first active issuer. Unknown slug → 400; empty issuer\n * list → 503.\n */\n issuer_slug?: string;\n metadata?: Record<string, string>;\n /** Structured billing details — real issuers require these for 3DS / KYC. */\n customer?: CustomerInfo;\n /**\n * Pay part of the price with bonuses. Sent as `use_bonus`. On by default\n * whenever the user has bonuses; `false` pays it all from the wallet.\n */\n useBonus?: boolean;\n /** The most bonuses to use, decimal string. Sent as `bonus_amount`. */\n bonusAmount?: string;\n /**\n * A promo code for the card's price. Sent as `promo_code`. Its discount\n * comes off before bonuses; `client.codes.validate` shows it first. A code\n * that can't be used fails the request with 400 `promo_code_*` and the\n * reason. Without one, the code the user signed up with applies when it\n * covers cards. Ignored inside `deposits.initiate({ issue_card })`: send\n * `promo_code` on the top-up there.\n */\n promoCode?: string;\n /**\n * Consents the user gave with the order (`terms`, `personal_data`,\n * `marketing`). Recorded with the card, or with the top-up inside\n * `deposits.initiate({ issue_card })`, at the version of their documents\n * in force now.\n */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original card; same key + different body returns 409.\n */\n idempotencyKey: string;\n}\n\n/**\n * The wire body of a card request: the camelCase fields renamed to what\n * the API reads. Shared by {@link CardsResource.create} and the\n * `issue_card` block of `deposits.initiate`.\n */\nexport function cardRequestBody(\n input: Omit<CreateCardInput, \"idempotencyKey\" | \"currency\"> & { currency?: string },\n): Record<string, unknown> {\n const {\n productId,\n name,\n designId,\n useBonus,\n bonusAmount,\n promoCode,\n consentChannel,\n initial_amount: _ignored,\n ...rest\n } = input;\n const body: Record<string, unknown> = { ...rest };\n if (productId !== undefined) body[\"product_id\"] = productId;\n if (name !== undefined) body[\"name\"] = name;\n if (designId !== undefined) body[\"design_id\"] = designId;\n if (useBonus !== undefined) body[\"use_bonus\"] = useBonus;\n if (bonusAmount !== undefined) body[\"bonus_amount\"] = bonusAmount;\n if (promoCode !== undefined) body[\"promo_code\"] = promoCode;\n if (consentChannel !== undefined) body[\"consent_channel\"] = consentChannel;\n return body;\n}\n\n/**\n * A card bought in one step with {@link CardsResource.order}: the product and\n * how the user pays. The platform works out the amount to pay in the\n * payment's currency, locks the rate and opens the top-up that issues the\n * card.\n */\nexport interface CardOrderInput {\n /** A product id from {@link CardsResource.listProducts}. Sent as `product_id`. */\n productId: string;\n /** One of the product's designs; omit for its default. Sent as `design_id`. */\n designId?: string;\n /** A name for the card, 1 to 40 characters; defaults to the product name. */\n name?: string;\n /** How the user pays, e.g. `\"sbp\"`. */\n method: DepositMethod;\n /** The funding connector to pay through; omit to let the API pick one that takes `method`. Sent as `funder_slug`. */\n funderSlug?: string;\n /** ISO 4217 code of the payment; defaults to the currency the method is priced in. */\n currency?: string;\n /** Money to put on the card on top of its price, decimal string in the card's currency. Sent as `extra_load`. */\n extraLoad?: string;\n /** A promo code for the payment. Sent as `promo_code`. */\n promoCode?: string;\n /** Pay part of the price with bonuses; on by default. Sent as `use_bonus`. */\n useBonus?: boolean;\n /** Consents given with the order. */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /** Passed to the payment provider; `return_url` is where the payment page sends the user back. */\n metadata?: Record<string, string>;\n}\n\n/** What {@link CardsResource.order} returns: the top-up to pay and its price. */\nexport interface CardOrder {\n /** Send the user to `deposit.redirect_url` when `deposit.status` is `redirect_required`. The card is issued once the payment is confirmed. */\n deposit: Deposit;\n /** What the user pays, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What reaches the card: its price plus its starting balance, in `card_currency`. */\n card_amount: string;\n card_currency: string;\n}\n\n/** Why a card ordered with the sign-up was not placed. The account exists all the same. */\nexport interface CardOrderError {\n code: string;\n message: string;\n}\n\n/** Build the API body of a card order. */\nexport function cardOrderBody(input: CardOrderInput): Record<string, unknown> {\n const body: Record<string, unknown> = {\n product_id: input.productId,\n method: input.method,\n };\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.funderSlug !== undefined) body[\"funder_slug\"] = input.funderSlug;\n if (input.currency !== undefined) body[\"currency\"] = input.currency;\n if (input.extraLoad !== undefined) body[\"extra_load\"] = input.extraLoad;\n if (input.promoCode !== undefined) body[\"promo_code\"] = input.promoCode;\n if (input.useBonus !== undefined) body[\"use_bonus\"] = input.useBonus;\n if (input.consents !== undefined) body[\"consents\"] = input.consents;\n if (input.consentChannel !== undefined) body[\"consent_channel\"] = input.consentChannel;\n if (input.metadata !== undefined) body[\"metadata\"] = input.metadata;\n return body;\n}\n\n/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\n}\n\n/** What a top-up of a card can be right now, from `GET /me/cards/{id}/topup`. */\nexport interface TopUpTerms {\n /** Whether the card can be topped up at this moment. */\n available: boolean;\n /** Why not, in plain words, when `available` is false. */\n reason: string | null;\n /** Currency top-ups are made in: the card's. */\n currency: string;\n /** What the wallet holds right now, in the wallet's currency. */\n wallet_available: CardBalance;\n /** Smallest single top-up the product allows, or `null` for no floor. */\n min: CardBalance | null;\n /** Largest single top-up the product allows, or `null` for no cap. */\n max: CardBalance | null;\n}\n\nexport interface TopUpInput {\n /** Amount to add, decimal string, in the card's currency. */\n amount: string;\n /**\n * Required. Same key + same amount replays the first outcome; same key +\n * different amount is 409. Use a stable UUID per attempt so a retried\n * network call cannot move the money twice.\n */\n idempotencyKey: string;\n}\n\n/**\n * Where a top-up stands.\n *\n * - `pending`: the issuer accepted it and has not loaded the card yet. The\n * wallet is debited, the card balance is unchanged, the amount shows in\n * `Card.topups_pending`. Most issuers finish within minutes.\n * - `confirmed`: the money is on the card.\n * - `failed`: the issuer refused; the wallet is credited back.\n * - `stalled`: pending for longer than the deployment allows. The money is\n * safe and waits for support; it shows in `Card.topups_held`.\n * - `returned`: support sent the money back to the wallet.\n * - `written_off`: support closed it without the money coming back (the\n * issuer kept it); `failure_reason` says so.\n */\nexport type CardTopUpStatus =\n \"pending\" | \"confirmed\" | \"failed\" | \"stalled\" | \"returned\" | \"written_off\";\n\n/** One top-up attempt as the API records it. */\nexport interface CardTopUp {\n id: string;\n card_id: string;\n status: CardTopUpStatus;\n /** What landed on the card, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the wallet paid, decimal string, in `wallet_currency`. */\n wallet_amount: string;\n wallet_currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/**\n * The outcome of a top-up with the state to redraw: card, its balance, the\n * wallet. When `topup.status` is `pending`, the wallet has paid and\n * `card_balance` has not moved yet: show the amount as on its way\n * (`card.topups_pending`) and refresh the card later or on the\n * `card_topup` notification.\n */\nexport interface TopUpResult {\n topup: CardTopUp;\n card: Card;\n card_balance: CardBalance;\n wallet: CardBalance;\n}\n\n/** Fields a user can change on their own card. Omitted fields are left as they are. */\nexport interface UpdateCardInput {\n /** New name, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * New design (one of the product's `designs`), or `null` for the product's\n * default. Sent as `design_id`.\n */\n designId?: string | null;\n}\n\n/**\n * Kept for callers written against 0.3.x: the API no longer asks for a\n * password or a code on reveal, the session is enough. Both fields are\n * ignored and will be dropped in the next major.\n * @deprecated\n */\nexport interface RevealCardInput {\n password?: string;\n totpCode?: string;\n}\n\n/**\n * Full card data from a successful reveal. **Security**: never persist this,\n * keep it in volatile memory only, clear it within `expires_in_seconds`, and\n * never write it to localStorage / logs (the API marks the response no-store).\n *\n * Some issuers hand out a page that shows the numbers instead of the\n * numbers themselves. Then `reveal_url` is set, `pan` and `cvv` are empty,\n * and the client opens the page in a frame; see the README for the frame.\n */\nexport interface RevealedCard {\n /** The card number; empty when `reveal_url` is set. */\n pan: string;\n /** The security code; empty when `reveal_url` is set. */\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /**\n * A page at the card issuer that shows the details to the holder. Present\n * only for issuers that give a page instead of the numbers. Short-lived,\n * often single use: open it at once in an `<iframe>` and never store it.\n */\n reveal_url?: string;\n /**\n * The person the card is registered to at its issuer: what a checkout\n * asks for. Absent for cards issued before holders were kept.\n */\n cardholder?: Cardholder;\n /**\n * The address the card is registered at — what a merchant's checkout asks\n * for, and the postal code some of them decline a payment over. Absent\n * when the deployment has not set one.\n */\n billing_address?: BillingAddress;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\n}\n\n/** Postal address a card is registered at. Which parts exist depends on the country. */\nexport interface BillingAddress {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postal_code?: string;\n country?: string;\n}\n\n/**\n * The cardholder the issuer knows: the details to type into a checkout\n * that asks for the name, phone or address on the card. `source` says\n * whether the platform made them up (`generated`), the user supplied them\n * (`provided`) or both (`mixed`).\n */\nexport interface Cardholder {\n id: string;\n first_name: string;\n last_name: string;\n /** `YYYY-MM-DD`. */\n birth_date: string;\n /** E.164. */\n phone: string;\n /** A mailbox the platform owns; mail the issuer sends there reaches the user. */\n email: string;\n address: BillingAddress;\n source: \"generated\" | \"provided\" | \"mixed\";\n}\n\n/** The new PIN for a physical card. */\nexport interface SetPinInput {\n /**\n * Four to six digits, as the user typed them. Sent once to the issuer and\n * kept nowhere: not by the SDK, not by the API. Never log it.\n */\n pin: string;\n}\n\n/** What to move, and the key that makes a retry safe. */\nexport interface TransferInput {\n /** The card the money lands on. Must be the caller's, and of the same kind and currency. */\n toCardId: string;\n /** Amount to move, decimal string, in the cards' currency. */\n amount: string;\n /**\n * Required. The same key with the same body replays the first outcome; a\n * different body on the same key is 409.\n */\n idempotencyKey: string;\n}\n\n/** One transfer attempt as the API records it. */\nexport interface CardTransfer {\n id: string;\n from_card_id: string;\n to_card_id: string;\n /**\n * `confirmed` — the money is on the other card. `on_wallet` — it came off\n * the first card but the second did not take it, so it is on the wallet\n * and `failure_reason` says so in words. `pending` / `failed` otherwise.\n */\n status: \"pending\" | \"confirmed\" | \"on_wallet\" | \"failed\";\n amount: string;\n currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/** A finished transfer with the balances to redraw both cards and the wallet. */\nexport interface TransferResult {\n transfer: CardTransfer;\n from_balance: CardBalance;\n to_balance: CardBalance;\n /** Holds the money when `transfer.status` is `on_wallet`. */\n wallet: CardBalance;\n}\n\nexport class CardsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Issue a card backed by the user's wallet balance. Resolves to the new\n * `Card`. On a ledger failure after provider creation, the Takeal API rolls the row\n * to `failed` (never an orphaned active card); inspect `status` /\n * `failure_reason` on the result.\n */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, ...card } = input;\n return this.http.post<Card>(\"/me/cards\", {\n body: cardRequestBody(card),\n idempotencyKey,\n });\n }\n\n /**\n * Buy a card in one step: the API prices the product in the payment's\n * currency, locks the rate and opens the top-up that issues the card.\n * Send the user to `order.deposit.redirect_url`; the card shows as\n * `pending_payment` until the payment is confirmed. The same\n * `idempotencyKey` returns the same order.\n * Errors: 400 `unknown_product` / `method_not_available` / a limit of the\n * way of paying, 503 no funding connector or no exchange rate.\n */\n async order(input: CardOrderInput & { idempotencyKey: string }): Promise<CardOrder> {\n const { idempotencyKey, ...order } = input;\n return this.http.post<CardOrder>(\"/me/card-orders\", {\n body: cardOrderBody(order),\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the storefront shows them\n * (`is_default` marks the one issued when none is chosen). Each item\n * carries its product card (name, tagline, benefits, tile picture),\n * artwork, and the issuance price after the caller's subscription\n * discount, in the caller's wallet currency. Pass an item's `id` as\n * `productId` to {@link create}.\n */\n async listProducts(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/me/card-products\");\n }\n\n /** One product from the catalog. 404 when unknown, disabled or hidden. */\n async getProduct(id: string): Promise<CardProduct> {\n return this.http.get<CardProduct>(`/me/card-products/${encodeURIComponent(id)}`);\n }\n\n /**\n * The public catalog: the same products, order and default as\n * {@link listProducts}, but readable before sign-in, for a landing page or\n * the cabinet's first screen. Prices are list prices (`discount_bps` is\n * always 0); once the user is signed in, {@link listProducts} shows what\n * they pay. The API lets caches keep this response for a minute.\n */\n async catalog(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/card-products\");\n }\n\n /**\n * Rename the caller's own card or change its design. Resolves to the\n * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /\n * `design_not_allowed` on a bad value.\n */\n async update(id: string, input: UpdateCardInput): Promise<Card> {\n const body: Record<string, unknown> = {};\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n return this.http.patch<Card>(`/me/cards/${encodeURIComponent(id)}`, {\n body,\n });\n }\n\n /** Fetch one card by id. */\n async get(id: string): Promise<Card> {\n return this.http.get<Card>(`/me/cards/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's cards, most recent first. */\n async list(): Promise<Card[]> {\n return this.http.get<Card[]>(\"/me/cards\");\n }\n\n /**\n * Remaining balance of a prepaid card. `currency` is required by the Takeal API and\n * forwarded as a query param.\n */\n async balance(id: string, currency: string): Promise<CardBalance> {\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<CardBalance>(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);\n }\n\n /**\n * What a top-up of this card can be right now: whether it is possible, the\n * currency, the wallet balance, and the product's floor and cap for one\n * top-up. Read it before drawing the form. 404 if the card isn't the caller's.\n */\n async topUpTerms(id: string): Promise<TopUpTerms> {\n return this.http.get<TopUpTerms>(`/me/cards/${encodeURIComponent(id)}/topup`);\n }\n\n /**\n * Move money from the wallet onto the caller's own card. The wallet is\n * debited first, then the card's provider loads the card; if the provider\n * refuses, the money is back on the wallet and the error says so. Resolves\n * to the card, its new balance and the wallet balance, so no second call\n * is needed. Errors carry a sentence the user can read: 400 outside the\n * floor or cap · 402 not enough in the wallet · 404 not the caller's card ·\n * 409 card frozen, closed or still being issued · 501 provider can't top\n * up · 502/503 provider declined or unreachable (wallet untouched).\n */\n async topUp(id: string, input: TopUpInput): Promise<TopUpResult> {\n const { idempotencyKey, amount } = input;\n return this.http.post<TopUpResult>(`/me/cards/${encodeURIComponent(id)}/topup`, {\n body: { amount },\n idempotencyKey,\n });\n }\n\n /**\n * Move money from one of the caller's cards to another. Both must be\n * theirs, active, in the same currency and of the same kind. The money\n * travels through the wallet one leg at a time: when the second leg does\n * not go through, the call still resolves, `transfer.status` is\n * `on_wallet` and the money is on the wallet — never between two cards.\n * Errors carry a sentence the user can read: 400 the same card twice,\n * different currencies or different kinds · 402 the card holds less than\n * that · 404 one of the cards isn't theirs · 409 a card is frozen, closed\n * or still being issued, or the key was reused with a different body ·\n * 501/502/503 the provider cannot or will not move it.\n */\n async transfer(fromCardId: string, input: TransferInput): Promise<TransferResult> {\n const { toCardId, amount, idempotencyKey } = input;\n return this.http.post<TransferResult>(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {\n body: { to_card_id: toCardId, amount },\n idempotencyKey,\n });\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze} while\n * `status_source` is `holder` or `operator`. The optional `reason` is\n * recorded on the audit trail. Resolves to the updated card. 404 if the\n * card isn't the caller's; 409 `card_locked` when support holds it; 501 if\n * the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });\n }\n\n /**\n * Reveal the FULL PAN + CVV for the caller's own card. The signed-in\n * session is all the API asks for; the call is rate-limited and audited\n * server-side. The Takeal API never persists this data and marks the\n * response no-store; the SDK returns it verbatim and holds nothing.\n *\n * **Consumer security duties** (the SDK can't enforce these for you):\n * keep the result in volatile memory only, never write it to\n * localStorage / logs, and clear it within `expires_in_seconds`.\n *\n * The result is the numbers, or `reveal_url` with empty `pan` and `cvv`\n * when the issuer shows them on a page of its own: open that page in a\n * frame right away, it is short-lived.\n *\n * 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 `provider_unavailable`.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n return this.http.post<RevealedCard>(`/me/cards/${encodeURIComponent(id)}/reveal`);\n }\n\n /**\n * Unfreeze a previously-frozen card. Idempotent on an already-active card.\n * A card the issuer froze (`status_source: \"provider\"`) is not the\n * holder's to unfreeze: the API answers 409 `card_locked`, so hide the\n * button and say the freeze is lifted through the issuer's support.\n */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });\n }\n\n /**\n * Set the PIN of the caller's own physical card. The session is enough; the\n * call is rate-limited like {@link reveal} and the PIN is kept nowhere.\n * Resolves to the card; the user also gets a notification that the PIN\n * was set. 400 not four to six digits or the card is not active · 403 not\n * your card · 409 `card_locked`, or `provider_refused` when the issuer did\n * not take it · 429 too many attempts · 501 a virtual card has no PIN.\n */\n async setPin(id: string, input: SetPinInput): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/pin`, {\n body: { pin: input.pin },\n });\n }\n\n /**\n * Terminate the caller's own card. **One-way** — a terminated card cannot be\n * reactivated. The optional `reason` is audited. Idempotent on an\n * already-terminated card.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/terminate`, {\n body: { reason },\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/resources/cards.ts"],"names":[],"mappings":";;;AAuXO,SAAS,gBACd,KAAA,EACyB;AACzB,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA,EAAgB,QAAA;AAAA,IAChB,GAAG;AAAA,GACL,GAAI,KAAA;AACJ,EAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,EAAK;AAChD,EAAA,IAAI,SAAA,KAAc,MAAA,EAAW,IAAA,CAAK,YAAY,CAAA,GAAI,SAAA;AAClD,EAAA,IAAI,IAAA,KAAS,MAAA,EAAW,IAAA,CAAK,MAAM,CAAA,GAAI,IAAA;AACvC,EAAA,IAAI,QAAA,KAAa,MAAA,EAAW,IAAA,CAAK,WAAW,CAAA,GAAI,QAAA;AAChD,EAAA,IAAI,QAAA,KAAa,MAAA,EAAW,IAAA,CAAK,WAAW,CAAA,GAAI,QAAA;AAChD,EAAA,IAAI,WAAA,KAAg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CAAO,EAAA,EAAY,MAAA,EAAiD;AACxE,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,aAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,OAAA,CAAS,CAAA;AAAA,EAClF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,SAAS,EAAA,EAA2B;AACxC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAW,CAAA,UAAA,EAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,SAAA,CAAA,EAAa,EAAE,IAAA,EAAM,EAAC,EAAG,CAAA;AAAA,EAC1F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,MAAA,CAAO,EAAA,EAAY,KAAA,EAAmC;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAW,aAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,IAAA,CAAA,EAAQ;AAAA,MACrE,IAAA,EAAM,EAAE,GAAA,EAAK,KAAA,CAAM,GAAA;AAAI,KACxB,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,SAAA,CAAU,EAAA,EAAY,MAAA,EAAgC;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAW,aAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,UAAA,CAAA,EAAc;AAAA,MAC3E,IAAA,EAAM,EAAE,MAAA;AAAO,KAChB,CAAA;AAAA,EACH;AACF","file":"cards.cjs","sourcesContent":["import type { ConsentChannel, ConsentKind } from \"./consents.js\";\nimport type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\nimport type { Deposit, DepositMethod } from \"./deposits.js\";\n\n/**\n * Cards resource — `client.cards.*`.\n *\n * The end-user \"money OUT\" surface: a user issues themselves a card backed by\n * their wallet balance via an issuer connector. Mirrors the Takeal API's\n * `/me/cards` routes:\n *\n * GET /card-products → catalog (public, before sign-in)\n * GET /me/card-products → listProducts (the catalog, personal price)\n * GET /me/card-products/{id} → getProduct\n * GET /me/cards/{id}/topup → topUpTerms\n * POST /me/cards/{id}/topup → topUp\n * POST /me/cards → create\n * GET /me/cards → list (most recent first)\n * GET /me/cards/{id} → get\n * PATCH /me/cards/{id} → update (name, design)\n * GET /me/cards/{id}/balance → balance (prepaid remaining)\n * POST /me/cards/{id}/freeze → freeze\n * POST /me/cards/{id}/unfreeze → unfreeze\n * POST /me/cards/{id}/transfer → transfer (to another of their cards)\n * POST /me/cards/{id}/terminate → terminate (one-way)\n * POST /me/cards/{id}/reveal → reveal (the numbers, or a provider page)\n * POST /me/cards/{id}/pin → setPin (physical cards)\n *\n * The lifecycle actions are ownership-gated server-side: a caller can only\n * freeze / unfreeze / terminate a card that belongs to them (else 404).\n *\n * Today only PREPAID is wired end-to-end; CREDIT and GIFT return 400 from\n * the Takeal API until their issuer flows land.\n */\n\n/** Card product. Only `prepaid` is fully implemented today. */\nexport type CardType = \"credit\" | \"prepaid\" | \"gift\";\n\n/**\n * Card lifecycle state.\n *\n * - `pending_payment`: the row exists but the issuance fee has not been\n * paid yet; the provider has not been called and nothing is visible.\n * - `pending`: the issuer accepted the order and has not issued the card\n * yet. The price is charged. Show the card as \"being issued\" with no\n * numbers; it becomes `active` on its own, or `failed` with the price\n * back on the wallet. Some issuers take minutes, some a day.\n * - `active`, `frozen`: the usual states. Read `status_source` before\n * offering to unfreeze.\n * - `terminating`: the holder (or the issuer) closed the card and the\n * issuer has not finished: the balance comes back to the wallet when it\n * does. Show it as closing; no actions apply.\n * - `terminated`, `redeemed`, `failed`: final.\n */\nexport type CardStatus =\n | \"pending_payment\"\n | \"pending\"\n | \"active\"\n | \"frozen\"\n | \"terminating\"\n | \"terminated\"\n | \"redeemed\"\n | \"failed\";\n\n/**\n * Who made the card's last status change. `provider` on a `frozen` card\n * means the issuer froze it (a risk check, a lost-card report): the holder\n * cannot unfreeze it, so do not offer the button; say the freeze is lifted\n * through the issuer's support. `holder` and `operator` freezes are undone\n * with `unfreeze()` as usual.\n */\nexport type CardStatusSource = \"holder\" | \"operator\" | \"provider\";\n\n/** `virtual` cards show their numbers in the app; `physical` cards are plastic and have a PIN. */\nexport type CardForm = \"virtual\" | \"physical\";\n\n/**\n * Why `terminate()` is refused right now: `first_purchase_required` (the\n * card closes after its first purchase) or `card_locked` (only support can\n * change it).\n */\nexport type CloseBlockedReason = \"first_purchase_required\" | \"card_locked\";\n\n/**\n * A card design: the artwork a card is shown with. `image_url` is the front,\n * `image_url_back` the back; both are either absolute URLs or paths relative\n * to the API origin (the deployment's default design is\n * `/card-designs/default.svg`, its back `/card-designs/default.svg?side=back`)\n * — pass them through `client.assetUrl()` before rendering. `image_url_back`\n * is `null` or absent for a one-sided design: show the front on both sides.\n * The picture is in the proportions of a plastic card (1586×1000) and draws\n * no chip or card data; the client renders the number, name and expiry on\n * top. `id` is `null` for the deployment default, which is rendered from the\n * branding settings.\n */\nexport interface CardDesignRef {\n id: string | null;\n name?: string;\n image_url: string;\n image_url_back?: string | null;\n}\n\n/**\n * What issuing a card costs the caller. `amount` is the price after the\n * user's subscription discount; `base_amount` is the list price and\n * `discount_bps` the discount in basis points (1000 = 10 %). `label` is the\n * operator's wording for the fee line (\"Card issuance\").\n */\nexport interface CardProductPrice {\n /** What the user pays, decimal string, after their subscription discount. */\n amount: string;\n /**\n * ISO 4217 code: the currency the buyer pays in. A signed-in user sees\n * their wallet currency, converted the way issuance will charge it; the\n * public catalog shows the currency the operator priced the card in. It\n * is not necessarily the currency the card is held in (`CardProduct.currency`).\n */\n currency: string;\n /** Wording for the fee line, e.g. \"Card issuance\". */\n label: string;\n /** The list price before the discount, decimal string, in the same currency. */\n base_amount: string;\n /** Discount applied, in basis points (1000 = 10%). */\n discount_bps: number;\n}\n\n/**\n * A card the user can order, as listed by `GET /me/card-products`. The id is\n * opaque — it names a product, never a provider. The list comes in the\n * order the operator arranged the storefront; `is_default` marks the\n * product issued when none is chosen, wherever it sits. `designs` is the\n * set the user may pick from (may be empty when only the default applies);\n * `design` is what the card gets when no choice is made. `price` is `null`\n * for a free card. `features` is an operator-defined object (scheme, wallet\n * support, load limits, …) with no fixed keys.\n */\nexport interface CardProduct {\n id: string;\n name: string;\n /** One line under the name on the tile, or `null`. */\n tagline: string | null;\n description: string | null;\n /** Selling points to list on the product card, in order. May be empty. */\n benefits: string[];\n /**\n * Picture for the product tile, absolute URL, or `null`: show the card\n * design (`design.image_url`) then.\n */\n tile_image_url: string | null;\n card_type: CardType;\n currency: string | null;\n features: Record<string, unknown>;\n design: CardDesignRef;\n designs: CardDesignRef[];\n price: CardProductPrice | null;\n /**\n * The balance a new card comes with, already included in `price`; `null`\n * when the card starts empty and is funded with `topUp()` afterwards.\n */\n starting_balance: CardBalance | null;\n /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\n /**\n * Issuing this card sends the user's real personal details to the card\n * issuer. Show the consent screen before the order and send\n * `holder_data_transfer` in its `consents` (or give it once with\n * `client.consents.allowHolderData()`); without it the order fails with\n * 409 `holder_data_consent_required`. `false`: the issuer gets no real\n * details and no extra consent is asked.\n */\n holder_data_required: boolean;\n /**\n * What a card on this product costs to use, on top of the payments\n * themselves. A fee the card can't cover is owed and paid from the next\n * top-up (see `client.debt`). Every line is `\"0\"` when the product\n * charges nothing for it.\n */\n tariff: CardTariff;\n}\n\n/**\n * A card product's fees for using the card. Decimal strings: the fixed\n * amounts are in `currency` (the card's), the shares in percent of the\n * operation's amount.\n */\nexport interface CardTariff {\n /** `null` for a product held in several currencies: the card's own then. */\n currency: string | null;\n /** Per settled card payment, fixed. */\n operation_fixed: string;\n /** Per settled card payment, percent of its amount. */\n operation_percent: string;\n /**\n * Per payment declined through the user's own doing: not enough money,\n * wrong card details, a frozen card, a subscription not cancelled with the\n * merchant. A decline caused by the issuer or the platform costs nothing.\n */\n decline: string;\n /** Per cash withdrawal, fixed; charged instead of the payment fee. */\n cash_withdrawal_fixed: string;\n /** Per cash withdrawal, percent of its amount. */\n cash_withdrawal_percent: string;\n}\n\n/**\n * A card record as the Takeal API returns it. Mirrors the `cards` table. Note the\n * SDK never receives the full PAN or CVV here — only `last4` + expiry. The\n * gift-card `redemption_code` is returned exactly once (on create) and\n * scrubbed from subsequent list/get responses.\n */\nexport interface Card {\n id: string;\n user_id: string;\n card_type: CardType;\n status: CardStatus;\n /** Last four digits of the PAN — safe to display. */\n last4: string | null;\n expiry_month: number | null;\n expiry_year: number | null;\n /** Gift cards only, present once on create then scrubbed. */\n redemption_code?: string;\n /** The balance the card was issued with, decimal string; `null` or `\"0\"` for a card issued empty. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | null;\n /** Who changed the status last; `null` when it never changed. See {@link CardStatusSource}. */\n status_source: CardStatusSource | null;\n /** Virtual or plastic. A `physical` card takes a PIN with {@link CardsResource.setPin}. */\n card_form: CardForm;\n /** Why the card cannot be closed right now, or `null` when it can. */\n close_blocked: CloseBlockedReason | null;\n /**\n * Top-ups the issuer has accepted and not loaded yet, summed, decimal\n * string in `currency`; `null` when there are none. Show it next to the\n * balance as money on its way to the card.\n */\n topups_pending: string | null;\n /**\n * Top-ups the issuer has held for too long, summed, decimal string in\n * `currency`; `null` when there are none. The money is safe and waits for\n * support to settle it; say so instead of offering a retry.\n */\n topups_held: string | null;\n /**\n * The card this one replaced: support reissued it for free because that\n * card stopped working before its term. `null` otherwise.\n */\n reissued_from_card_id?: string | null;\n /** The card support issued to replace this one, or `null`. */\n reissued_to_card_id?: string | null;\n /**\n * What was left on the card this one replaced, on its way here. Show it as\n * money in transit next to the balance, not as part of it. `null` when\n * nothing is on its way.\n */\n in_transit?: CardInTransit | null;\n /** The name the user gave the card, or `null`. */\n name: string | null;\n /** The artwork the card is shown with. Always present. */\n design: CardDesignRef;\n /** The product the card was issued from; `null` for cards issued without one. */\n product: { id: string; name: string } | null;\n created_at: string;\n updated_at: string;\n /** Only on the result of `create`, when bonuses paid part of the price. */\n bonus?: IssuanceBonus;\n}\n\n/**\n * The balance of a closed card on its way to the card that replaced it. It\n * waits for the old card's issuer to return the money (`stage: \"issuer\"`),\n * then it is loaded onto this card (`stage: \"loading\"`); once it is there,\n * `in_transit` is `null` and the card's balance has it. The move is in the\n * history as a `closed_card_balance` entry.\n */\nexport interface CardInTransit {\n /** Decimal string in `currency`. What the issuer returned once it did; before that, what the old card held. */\n amount: string;\n currency: string;\n /** The closed card the money comes from. */\n from_card_id: string;\n stage: \"issuer\" | \"loading\" | (string & {});\n}\n\n/** How bonuses changed a new card's price (\"was / now\"). Decimal strings in `currency`. */\nexport interface IssuanceBonus {\n /** Bonuses used. */\n units: string;\n /** The price before bonuses (\"was\"). */\n price: string;\n /** What the bonuses covered. */\n covered: string;\n /** What the wallet paid (\"now\"). */\n paid: string;\n currency: string;\n}\n\nexport interface CreateCardInput {\n /**\n * A product id from {@link CardsResource.listProducts}. Sent as\n * `product_id`. When given, `type` and `issuer_slug` may be omitted; when\n * both are given they must agree with the product (400 `product_mismatch`).\n * Unknown, disabled or hidden product → 400 `unknown_product`.\n */\n productId?: string;\n /** A name for the card, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * One of the product's `designs`. Sent as `design_id`. `null` or omitted\n * picks the product's default design; a design outside the product's set →\n * 400 `design_not_allowed`.\n */\n designId?: string | null;\n /**\n * `prepaid` (the only fully-wired type today), `credit`, or `gift`.\n * Optional when `productId` is given, required otherwise.\n */\n type?: CardType;\n /**\n * @deprecated Ignored since 0.3.21. A card is issued for its product price;\n * the balance it starts with, if the product includes one, is part of that\n * price (see `CardProduct.starting_balance`). Money is added afterwards\n * with {@link CardsResource.topUp}. The field is no longer sent.\n */\n initial_amount?: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n /**\n * Optional. Slug of a specific issuer to mint with. Omit to let\n * the Takeal API pick the first active issuer. Unknown slug → 400; empty issuer\n * list → 503.\n */\n issuer_slug?: string;\n metadata?: Record<string, string>;\n /** Structured billing details — real issuers require these for 3DS / KYC. */\n customer?: CustomerInfo;\n /**\n * Pay part of the price with bonuses. Sent as `use_bonus`. On by default\n * whenever the user has bonuses; `false` pays it all from the wallet.\n */\n useBonus?: boolean;\n /** The most bonuses to use, decimal string. Sent as `bonus_amount`. */\n bonusAmount?: string;\n /**\n * A promo code for the card's price. Sent as `promo_code`. Its discount\n * comes off before bonuses; `client.codes.validate` shows it first. A code\n * that can't be used fails the request with 400 `promo_code_*` and the\n * reason. Without one, the code the user signed up with applies when it\n * covers cards. Ignored inside `deposits.initiate({ issue_card })`: send\n * `promo_code` on the top-up there.\n */\n promoCode?: string;\n /**\n * Consents the user gave with the order (`terms`, `personal_data`,\n * `marketing`, `holder_data_transfer`). Recorded with the card, or with the\n * top-up inside `deposits.initiate({ issue_card })`, at the version of\n * their documents in force now. A product with `holder_data_required`\n * needs `holder_data_transfer` here unless it was given before.\n */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original card; same key + different body returns 409.\n */\n idempotencyKey: string;\n}\n\n/**\n * The wire body of a card request: the camelCase fields renamed to what\n * the API reads. Shared by {@link CardsResource.create} and the\n * `issue_card` block of `deposits.initiate`.\n */\nexport function cardRequestBody(\n input: Omit<CreateCardInput, \"idempotencyKey\" | \"currency\"> & { currency?: string },\n): Record<string, unknown> {\n const {\n productId,\n name,\n designId,\n useBonus,\n bonusAmount,\n promoCode,\n consentChannel,\n initial_amount: _ignored,\n ...rest\n } = input;\n const body: Record<string, unknown> = { ...rest };\n if (productId !== undefined) body[\"product_id\"] = productId;\n if (name !== undefined) body[\"name\"] = name;\n if (designId !== undefined) body[\"design_id\"] = designId;\n if (useBonus !== undefined) body[\"use_bonus\"] = useBonus;\n if (bonusAmount !== undefined) body[\"bonus_amount\"] = bonusAmount;\n if (promoCode !== undefined) body[\"promo_code\"] = promoCode;\n if (consentChannel !== undefined) body[\"consent_channel\"] = consentChannel;\n return body;\n}\n\n/**\n * A card bought in one step with {@link CardsResource.order}: the product and\n * how the user pays. The platform works out the amount to pay in the\n * payment's currency, locks the rate and opens the top-up that issues the\n * card.\n */\nexport interface CardOrderInput {\n /** A product id from {@link CardsResource.listProducts}. Sent as `product_id`. */\n productId: string;\n /** One of the product's designs; omit for its default. Sent as `design_id`. */\n designId?: string;\n /** A name for the card, 1 to 40 characters; defaults to the product name. */\n name?: string;\n /** How the user pays, e.g. `\"sbp\"`. */\n method: DepositMethod;\n /** The funding connector to pay through; omit to let the API pick one that takes `method`. Sent as `funder_slug`. */\n funderSlug?: string;\n /** ISO 4217 code of the payment; defaults to the currency the method is priced in. */\n currency?: string;\n /** Money to put on the card on top of its price, decimal string in the card's currency. Sent as `extra_load`. */\n extraLoad?: string;\n /** A promo code for the payment. Sent as `promo_code`. */\n promoCode?: string;\n /** Pay part of the price with bonuses; on by default. Sent as `use_bonus`. */\n useBonus?: boolean;\n /**\n * Consents given with the order. A product with `holder_data_required`\n * needs `holder_data_transfer` here unless it was given before.\n */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /** Passed to the payment provider; `return_url` is where the payment page sends the user back. */\n metadata?: Record<string, string>;\n}\n\n/** What {@link CardsResource.order} returns: the top-up to pay and its price. */\nexport interface CardOrder {\n /** Send the user to `deposit.redirect_url` when `deposit.status` is `redirect_required`. The card is issued once the payment is confirmed. */\n deposit: Deposit;\n /** What the user pays, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the payment brings: the card's price, its starting balance and `debt_withheld`, in `card_currency`. */\n card_amount: string;\n card_currency: string;\n /**\n * What the user owes in card fees, in `card_currency`: included in\n * `card_amount` and paid from it first. `\"0\"` when nothing is owed. Show\n * it before the payment. Older platforms leave it out.\n */\n debt_withheld?: string;\n}\n\n/** Why a card ordered with the sign-up was not placed. The account exists all the same. */\nexport interface CardOrderError {\n code: string;\n message: string;\n}\n\n/** Build the API body of a card order. */\nexport function cardOrderBody(input: CardOrderInput): Record<string, unknown> {\n const body: Record<string, unknown> = {\n product_id: input.productId,\n method: input.method,\n };\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.funderSlug !== undefined) body[\"funder_slug\"] = input.funderSlug;\n if (input.currency !== undefined) body[\"currency\"] = input.currency;\n if (input.extraLoad !== undefined) body[\"extra_load\"] = input.extraLoad;\n if (input.promoCode !== undefined) body[\"promo_code\"] = input.promoCode;\n if (input.useBonus !== undefined) body[\"use_bonus\"] = input.useBonus;\n if (input.consents !== undefined) body[\"consents\"] = input.consents;\n if (input.consentChannel !== undefined) body[\"consent_channel\"] = input.consentChannel;\n if (input.metadata !== undefined) body[\"metadata\"] = input.metadata;\n return body;\n}\n\n/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\n}\n\n/** What a top-up of a card can be right now, from `GET /me/cards/{id}/topup`. */\nexport interface TopUpTerms {\n /** Whether the card can be topped up at this moment. */\n available: boolean;\n /** Why not, in plain words, when `available` is false. */\n reason: string | null;\n /** Currency top-ups are made in: the card's. */\n currency: string;\n /** What the wallet holds right now, in the wallet's currency. */\n wallet_available: CardBalance;\n /** Smallest single top-up the product allows, or `null` for no floor. */\n min: CardBalance | null;\n /** Largest single top-up the product allows, or `null` for no cap. */\n max: CardBalance | null;\n /**\n * What the user owes in card fees, in the card's currency, or `null` when\n * nothing is. A top-up from a wallet in the same currency pays it first\n * and the card gets the rest: show it before the top-up. Older platforms\n * leave it out.\n */\n debt?: CardBalance | null;\n}\n\nexport interface TopUpInput {\n /** Amount to add, decimal string, in the card's currency. */\n amount: string;\n /**\n * Required. Same key + same amount replays the first outcome; same key +\n * different amount is 409. Use a stable UUID per attempt so a retried\n * network call cannot move the money twice.\n */\n idempotencyKey: string;\n}\n\n/**\n * Where a top-up stands.\n *\n * - `pending`: the issuer accepted it and has not loaded the card yet. The\n * wallet is debited, the card balance is unchanged, the amount shows in\n * `Card.topups_pending`. Most issuers finish within minutes.\n * - `confirmed`: the money is on the card.\n * - `failed`: the issuer refused; the wallet is credited back.\n * - `stalled`: pending for longer than the deployment allows. The money is\n * safe and waits for support; it shows in `Card.topups_held`.\n * - `returned`: support sent the money back to the wallet.\n * - `written_off`: support closed it without the money coming back (the\n * issuer kept it); `failure_reason` says so.\n */\nexport type CardTopUpStatus =\n \"pending\" | \"confirmed\" | \"failed\" | \"stalled\" | \"returned\" | \"written_off\";\n\n/** One top-up attempt as the API records it. */\nexport interface CardTopUp {\n id: string;\n card_id: string;\n status: CardTopUpStatus;\n /** What landed on the card, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the wallet paid, decimal string, in `wallet_currency`. */\n wallet_amount: string;\n wallet_currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/**\n * The outcome of a top-up with the state to redraw: card, its balance, the\n * wallet. When `topup.status` is `pending`, the wallet has paid and\n * `card_balance` has not moved yet: show the amount as on its way\n * (`card.topups_pending`) and refresh the card later or on the\n * `card_topup` notification.\n */\nexport interface TopUpResult {\n topup: CardTopUp;\n card: Card;\n card_balance: CardBalance;\n wallet: CardBalance;\n}\n\n/** Fields a user can change on their own card. Omitted fields are left as they are. */\nexport interface UpdateCardInput {\n /** New name, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * New design (one of the product's `designs`), or `null` for the product's\n * default. Sent as `design_id`.\n */\n designId?: string | null;\n}\n\n/**\n * Kept for callers written against 0.3.x: the API no longer asks for a\n * password or a code on reveal, the session is enough. Both fields are\n * ignored and will be dropped in the next major.\n * @deprecated\n */\nexport interface RevealCardInput {\n password?: string;\n totpCode?: string;\n}\n\n/**\n * Full card data from a successful reveal. **Security**: never persist this,\n * keep it in volatile memory only, clear it within `expires_in_seconds`, and\n * never write it to localStorage / logs (the API marks the response no-store).\n *\n * Some issuers hand out a page that shows the numbers instead of the\n * numbers themselves. Then `reveal_url` is set, `pan` and `cvv` are empty,\n * and the client opens the page in a frame; see the README for the frame.\n */\nexport interface RevealedCard {\n /** The card number; empty when `reveal_url` is set. */\n pan: string;\n /** The security code; empty when `reveal_url` is set. */\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /**\n * A page at the card issuer that shows the details to the holder. Present\n * only for issuers that give a page instead of the numbers. Short-lived,\n * often single use: open it at once in an `<iframe>` and never store it.\n */\n reveal_url?: string;\n /**\n * The person the card is registered to at its issuer: what a checkout\n * asks for. Absent for cards issued before holders were kept.\n */\n cardholder?: Cardholder;\n /**\n * The address the card is registered at — what a merchant's checkout asks\n * for, and the postal code some of them decline a payment over. Absent\n * when the deployment has not set one.\n */\n billing_address?: BillingAddress;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\n}\n\n/** Postal address a card is registered at. Which parts exist depends on the country. */\nexport interface BillingAddress {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postal_code?: string;\n country?: string;\n}\n\n/**\n * The cardholder the issuer knows: the details to type into a checkout\n * that asks for the name, phone or address on the card. `source` says\n * whether the platform made them up (`generated`), the user supplied them\n * (`provided`) or both (`mixed`).\n */\nexport interface Cardholder {\n id: string;\n first_name: string;\n last_name: string;\n /** `YYYY-MM-DD`. */\n birth_date: string;\n /** E.164. */\n phone: string;\n /** A mailbox the platform owns; mail the issuer sends there reaches the user. */\n email: string;\n address: BillingAddress;\n source: \"generated\" | \"provided\" | \"mixed\";\n}\n\n/** The new PIN for a physical card. */\nexport interface SetPinInput {\n /**\n * Four to six digits, as the user typed them. Sent once to the issuer and\n * kept nowhere: not by the SDK, not by the API. Never log it.\n */\n pin: string;\n}\n\n/** What to move, and the key that makes a retry safe. */\nexport interface TransferInput {\n /** The card the money lands on. Must be the caller's, and of the same kind and currency. */\n toCardId: string;\n /** Amount to move, decimal string, in the cards' currency. */\n amount: string;\n /**\n * Required. The same key with the same body replays the first outcome; a\n * different body on the same key is 409.\n */\n idempotencyKey: string;\n}\n\n/** One transfer attempt as the API records it. */\nexport interface CardTransfer {\n id: string;\n from_card_id: string;\n to_card_id: string;\n /**\n * `confirmed` — the money is on the other card. `on_wallet` — it came off\n * the first card but the second did not take it, so it is on the wallet\n * and `failure_reason` says so in words. `pending` / `failed` otherwise.\n */\n status: \"pending\" | \"confirmed\" | \"on_wallet\" | \"failed\";\n amount: string;\n currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/** A finished transfer with the balances to redraw both cards and the wallet. */\nexport interface TransferResult {\n transfer: CardTransfer;\n from_balance: CardBalance;\n to_balance: CardBalance;\n /** Holds the money when `transfer.status` is `on_wallet`. */\n wallet: CardBalance;\n}\n\nexport class CardsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Issue a card backed by the user's wallet balance. Resolves to the new\n * `Card`. On a ledger failure after provider creation, the Takeal API rolls the row\n * to `failed` (never an orphaned active card); inspect `status` /\n * `failure_reason` on the result.\n * Errors: 409 `holder_data_consent_required` when the product has\n * `holder_data_required` and the user has not agreed to it.\n */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, ...card } = input;\n return this.http.post<Card>(\"/me/cards\", {\n body: cardRequestBody(card),\n idempotencyKey,\n });\n }\n\n /**\n * Buy a card in one step: the API prices the product in the payment's\n * currency, locks the rate and opens the top-up that issues the card.\n * Send the user to `order.deposit.redirect_url`; the card shows as\n * `pending_payment` until the payment is confirmed. The same\n * `idempotencyKey` returns the same order.\n * Errors: 400 `unknown_product` / `method_not_available` / a limit of the\n * way of paying, 409 `holder_data_consent_required` (the product has\n * `holder_data_required` and the user has not agreed to it), 503 no\n * funding connector or no exchange rate.\n */\n async order(input: CardOrderInput & { idempotencyKey: string }): Promise<CardOrder> {\n const { idempotencyKey, ...order } = input;\n return this.http.post<CardOrder>(\"/me/card-orders\", {\n body: cardOrderBody(order),\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the storefront shows them\n * (`is_default` marks the one issued when none is chosen). Each item\n * carries its product card (name, tagline, benefits, tile picture),\n * artwork, and the issuance price after the caller's subscription\n * discount, in the caller's wallet currency. Pass an item's `id` as\n * `productId` to {@link create}.\n */\n async listProducts(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/me/card-products\");\n }\n\n /** One product from the catalog. 404 when unknown, disabled or hidden. */\n async getProduct(id: string): Promise<CardProduct> {\n return this.http.get<CardProduct>(`/me/card-products/${encodeURIComponent(id)}`);\n }\n\n /**\n * The public catalog: the same products, order and default as\n * {@link listProducts}, but readable before sign-in, for a landing page or\n * the cabinet's first screen. Prices are list prices (`discount_bps` is\n * always 0); once the user is signed in, {@link listProducts} shows what\n * they pay. The API lets caches keep this response for a minute.\n */\n async catalog(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/card-products\");\n }\n\n /**\n * Rename the caller's own card or change its design. Resolves to the\n * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /\n * `design_not_allowed` on a bad value.\n */\n async update(id: string, input: UpdateCardInput): Promise<Card> {\n const body: Record<string, unknown> = {};\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n return this.http.patch<Card>(`/me/cards/${encodeURIComponent(id)}`, {\n body,\n });\n }\n\n /** Fetch one card by id. */\n async get(id: string): Promise<Card> {\n return this.http.get<Card>(`/me/cards/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's cards, most recent first. */\n async list(): Promise<Card[]> {\n return this.http.get<Card[]>(\"/me/cards\");\n }\n\n /**\n * Remaining balance of a prepaid card. `currency` is required by the Takeal API and\n * forwarded as a query param.\n */\n async balance(id: string, currency: string): Promise<CardBalance> {\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<CardBalance>(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);\n }\n\n /**\n * What a top-up of this card can be right now: whether it is possible, the\n * currency, the wallet balance, and the product's floor and cap for one\n * top-up. Read it before drawing the form. 404 if the card isn't the caller's.\n */\n async topUpTerms(id: string): Promise<TopUpTerms> {\n return this.http.get<TopUpTerms>(`/me/cards/${encodeURIComponent(id)}/topup`);\n }\n\n /**\n * Move money from the wallet onto the caller's own card. The wallet is\n * debited first, then the card's provider loads the card; if the provider\n * refuses, the money is back on the wallet and the error says so. Resolves\n * to the card, its new balance and the wallet balance, so no second call\n * is needed. Errors carry a sentence the user can read: 400 outside the\n * floor or cap · 402 not enough in the wallet · 404 not the caller's card ·\n * 409 card frozen, closed or still being issued · 501 provider can't top\n * up · 502/503 provider declined or unreachable (wallet untouched).\n */\n async topUp(id: string, input: TopUpInput): Promise<TopUpResult> {\n const { idempotencyKey, amount } = input;\n return this.http.post<TopUpResult>(`/me/cards/${encodeURIComponent(id)}/topup`, {\n body: { amount },\n idempotencyKey,\n });\n }\n\n /**\n * Move money from one of the caller's cards to another. Both must be\n * theirs, active, in the same currency and of the same kind. The money\n * travels through the wallet one leg at a time: when the second leg does\n * not go through, the call still resolves, `transfer.status` is\n * `on_wallet` and the money is on the wallet — never between two cards.\n * Errors carry a sentence the user can read: 400 the same card twice,\n * different currencies or different kinds · 402 the card holds less than\n * that · 404 one of the cards isn't theirs · 409 a card is frozen, closed\n * or still being issued, or the key was reused with a different body ·\n * 501/502/503 the provider cannot or will not move it.\n */\n async transfer(fromCardId: string, input: TransferInput): Promise<TransferResult> {\n const { toCardId, amount, idempotencyKey } = input;\n return this.http.post<TransferResult>(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {\n body: { to_card_id: toCardId, amount },\n idempotencyKey,\n });\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze} while\n * `status_source` is `holder` or `operator`. The optional `reason` is\n * recorded on the audit trail. Resolves to the updated card. 404 if the\n * card isn't the caller's; 409 `card_locked` when support holds it; 501 if\n * the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });\n }\n\n /**\n * Reveal the FULL PAN + CVV for the caller's own card. The signed-in\n * session is all the API asks for; the call is rate-limited and audited\n * server-side. The Takeal API never persists this data and marks the\n * response no-store; the SDK returns it verbatim and holds nothing.\n *\n * **Consumer security duties** (the SDK can't enforce these for you):\n * keep the result in volatile memory only, never write it to\n * localStorage / logs, and clear it within `expires_in_seconds`.\n *\n * The result is the numbers, or `reveal_url` with empty `pan` and `cvv`\n * when the issuer shows them on a page of its own: open that page in a\n * frame right away, it is short-lived.\n *\n * 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 `provider_unavailable`.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n return this.http.post<RevealedCard>(`/me/cards/${encodeURIComponent(id)}/reveal`);\n }\n\n /**\n * Unfreeze a previously-frozen card. Idempotent on an already-active card.\n * A card the issuer froze (`status_source: \"provider\"`) is not the\n * holder's to unfreeze: the API answers 409 `card_locked`, so hide the\n * button and say the freeze is lifted through the issuer's support.\n */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });\n }\n\n /**\n * Set the PIN of the caller's own physical card. The session is enough; the\n * call is rate-limited like {@link reveal} and the PIN is kept nowhere.\n * Resolves to the card; the user also gets a notification that the PIN\n * was set. 400 not four to six digits or the card is not active · 403 not\n * your card · 409 `card_locked`, or `provider_refused` when the issuer did\n * not take it · 429 too many attempts · 501 a virtual card has no PIN.\n */\n async setPin(id: string, input: SetPinInput): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/pin`, {\n body: { pin: input.pin },\n });\n }\n\n /**\n * Terminate the caller's own card. **One-way** — a terminated card cannot be\n * reactivated. The optional `reason` is audited. Idempotent on an\n * already-terminated card. A card that still holds money is refused (409\n * `move_balance_first` or `contact_support_to_close`): close it with\n * `client.closeRequests.request(id)` instead, and the money goes back the\n * way it was paid.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/terminate`, {\n body: { reason },\n });\n }\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './consents.cjs';
|
|
2
2
|
import '../http-DeANAoTs.cjs';
|
|
3
|
-
export { B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm,
|
|
3
|
+
export { B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, c as CardsResource, u as CloseBlockedReason, v as CreateCardInput, M as IssuanceBonus, P as RevealCardInput, Q as RevealedCard, S as SetPinInput, T as TopUpInput, U as TopUpResult, V as TopUpTerms, W as TransferInput, X as TransferResult, Y as UpdateCardInput, Z as cardOrderBody, _ as cardRequestBody } from '../cards-CEFKrVkl.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './consents.js';
|
|
2
2
|
import '../http-DeANAoTs.js';
|
|
3
|
-
export { B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm,
|
|
3
|
+
export { B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, c as CardsResource, u as CloseBlockedReason, v as CreateCardInput, M as IssuanceBonus, P as RevealCardInput, Q as RevealedCard, S as SetPinInput, T as TopUpInput, U as TopUpResult, V as TopUpTerms, W as TransferInput, X as TransferResult, Y as UpdateCardInput, Z as cardOrderBody, _ as cardRequestBody } from '../cards-ColpW52n.js';
|
package/dist/resources/cards.js
CHANGED
|
@@ -47,6 +47,8 @@ var CardsResource = class {
|
|
|
47
47
|
* `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
|
|
48
48
|
* to `failed` (never an orphaned active card); inspect `status` /
|
|
49
49
|
* `failure_reason` on the result.
|
|
50
|
+
* Errors: 409 `holder_data_consent_required` when the product has
|
|
51
|
+
* `holder_data_required` and the user has not agreed to it.
|
|
50
52
|
*/
|
|
51
53
|
async create(input) {
|
|
52
54
|
const { idempotencyKey, ...card } = input;
|
|
@@ -62,7 +64,9 @@ var CardsResource = class {
|
|
|
62
64
|
* `pending_payment` until the payment is confirmed. The same
|
|
63
65
|
* `idempotencyKey` returns the same order.
|
|
64
66
|
* Errors: 400 `unknown_product` / `method_not_available` / a limit of the
|
|
65
|
-
* way of paying,
|
|
67
|
+
* way of paying, 409 `holder_data_consent_required` (the product has
|
|
68
|
+
* `holder_data_required` and the user has not agreed to it), 503 no
|
|
69
|
+
* funding connector or no exchange rate.
|
|
66
70
|
*/
|
|
67
71
|
async order(input) {
|
|
68
72
|
const { idempotencyKey, ...order } = input;
|
|
@@ -224,7 +228,10 @@ var CardsResource = class {
|
|
|
224
228
|
/**
|
|
225
229
|
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
226
230
|
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
227
|
-
* already-terminated card.
|
|
231
|
+
* already-terminated card. A card that still holds money is refused (409
|
|
232
|
+
* `move_balance_first` or `contact_support_to_close`): close it with
|
|
233
|
+
* `client.closeRequests.request(id)` instead, and the money goes back the
|
|
234
|
+
* way it was paid.
|
|
228
235
|
*/
|
|
229
236
|
async terminate(id, reason) {
|
|
230
237
|
return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resources/cards.ts"],"names":[],"mappings":";AAiTO,SAAS,gBACd,KAAA,EACyB;AACzB,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,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C;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAW,aAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,UAAA,CAAA,EAAc;AAAA,MAC3E,IAAA,EAAM,EAAE,MAAA;AAAO,KAChB,CAAA;AAAA,EACH;AACF","file":"cards.js","sourcesContent":["import type { ConsentChannel, ConsentKind } from \"./consents.js\";\nimport type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\nimport type { Deposit, DepositMethod } from \"./deposits.js\";\n\n/**\n * Cards resource — `client.cards.*`.\n *\n * The end-user \"money OUT\" surface: a user issues themselves a card backed by\n * their wallet balance via an issuer connector. Mirrors the Takeal API's\n * `/me/cards` routes:\n *\n * GET /card-products → catalog (public, before sign-in)\n * GET /me/card-products → listProducts (the catalog, personal price)\n * GET /me/card-products/{id} → getProduct\n * GET /me/cards/{id}/topup → topUpTerms\n * POST /me/cards/{id}/topup → topUp\n * POST /me/cards → create\n * GET /me/cards → list (most recent first)\n * GET /me/cards/{id} → get\n * PATCH /me/cards/{id} → update (name, design)\n * GET /me/cards/{id}/balance → balance (prepaid remaining)\n * POST /me/cards/{id}/freeze → freeze\n * POST /me/cards/{id}/unfreeze → unfreeze\n * POST /me/cards/{id}/transfer → transfer (to another of their cards)\n * POST /me/cards/{id}/terminate → terminate (one-way)\n * POST /me/cards/{id}/reveal → reveal (the numbers, or a provider page)\n * POST /me/cards/{id}/pin → setPin (physical cards)\n *\n * The lifecycle actions are ownership-gated server-side: a caller can only\n * freeze / unfreeze / terminate a card that belongs to them (else 404).\n *\n * Today only PREPAID is wired end-to-end; CREDIT and GIFT return 400 from\n * the Takeal API until their issuer flows land.\n */\n\n/** Card product. Only `prepaid` is fully implemented today. */\nexport type CardType = \"credit\" | \"prepaid\" | \"gift\";\n\n/**\n * Card lifecycle state.\n *\n * - `pending_payment`: the row exists but the issuance fee has not been\n * paid yet; the provider has not been called and nothing is visible.\n * - `pending`: the issuer accepted the order and has not issued the card\n * yet. The price is charged. Show the card as \"being issued\" with no\n * numbers; it becomes `active` on its own, or `failed` with the price\n * back on the wallet. Some issuers take minutes, some a day.\n * - `active`, `frozen`: the usual states. Read `status_source` before\n * offering to unfreeze.\n * - `terminating`: the holder (or the issuer) closed the card and the\n * issuer has not finished: the balance comes back to the wallet when it\n * does. Show it as closing; no actions apply.\n * - `terminated`, `redeemed`, `failed`: final.\n */\nexport type CardStatus =\n | \"pending_payment\"\n | \"pending\"\n | \"active\"\n | \"frozen\"\n | \"terminating\"\n | \"terminated\"\n | \"redeemed\"\n | \"failed\";\n\n/**\n * Who made the card's last status change. `provider` on a `frozen` card\n * means the issuer froze it (a risk check, a lost-card report): the holder\n * cannot unfreeze it, so do not offer the button; say the freeze is lifted\n * through the issuer's support. `holder` and `operator` freezes are undone\n * with `unfreeze()` as usual.\n */\nexport type CardStatusSource = \"holder\" | \"operator\" | \"provider\";\n\n/** `virtual` cards show their numbers in the app; `physical` cards are plastic and have a PIN. */\nexport type CardForm = \"virtual\" | \"physical\";\n\n/**\n * Why `terminate()` is refused right now: `first_purchase_required` (the\n * card closes after its first purchase) or `card_locked` (only support can\n * change it).\n */\nexport type CloseBlockedReason = \"first_purchase_required\" | \"card_locked\";\n\n/**\n * A card design: the artwork a card is shown with. `image_url` is the front,\n * `image_url_back` the back; both are either absolute URLs or paths relative\n * to the API origin (the deployment's default design is\n * `/card-designs/default.svg`, its back `/card-designs/default.svg?side=back`)\n * — pass them through `client.assetUrl()` before rendering. `image_url_back`\n * is `null` or absent for a one-sided design: show the front on both sides.\n * The picture is in the proportions of a plastic card (1586×1000) and draws\n * no chip or card data; the client renders the number, name and expiry on\n * top. `id` is `null` for the deployment default, which is rendered from the\n * branding settings.\n */\nexport interface CardDesignRef {\n id: string | null;\n name?: string;\n image_url: string;\n image_url_back?: string | null;\n}\n\n/**\n * What issuing a card costs the caller. `amount` is the price after the\n * user's subscription discount; `base_amount` is the list price and\n * `discount_bps` the discount in basis points (1000 = 10 %). `label` is the\n * operator's wording for the fee line (\"Card issuance\").\n */\nexport interface CardProductPrice {\n /** What the user pays, decimal string, after their subscription discount. */\n amount: string;\n /**\n * ISO 4217 code: the currency the buyer pays in. A signed-in user sees\n * their wallet currency, converted the way issuance will charge it; the\n * public catalog shows the currency the operator priced the card in. It\n * is not necessarily the currency the card is held in (`CardProduct.currency`).\n */\n currency: string;\n /** Wording for the fee line, e.g. \"Card issuance\". */\n label: string;\n /** The list price before the discount, decimal string, in the same currency. */\n base_amount: string;\n /** Discount applied, in basis points (1000 = 10%). */\n discount_bps: number;\n}\n\n/**\n * A card the user can order, as listed by `GET /me/card-products`. The id is\n * opaque — it names a product, never a provider. The list comes in the\n * order the operator arranged the storefront; `is_default` marks the\n * product issued when none is chosen, wherever it sits. `designs` is the\n * set the user may pick from (may be empty when only the default applies);\n * `design` is what the card gets when no choice is made. `price` is `null`\n * for a free card. `features` is an operator-defined object (scheme, wallet\n * support, load limits, …) with no fixed keys.\n */\nexport interface CardProduct {\n id: string;\n name: string;\n /** One line under the name on the tile, or `null`. */\n tagline: string | null;\n description: string | null;\n /** Selling points to list on the product card, in order. May be empty. */\n benefits: string[];\n /**\n * Picture for the product tile, absolute URL, or `null`: show the card\n * design (`design.image_url`) then.\n */\n tile_image_url: string | null;\n card_type: CardType;\n currency: string | null;\n features: Record<string, unknown>;\n design: CardDesignRef;\n designs: CardDesignRef[];\n price: CardProductPrice | null;\n /**\n * The balance a new card comes with, already included in `price`; `null`\n * when the card starts empty and is funded with `topUp()` afterwards.\n */\n starting_balance: CardBalance | null;\n /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\n}\n\n/**\n * A card record as the Takeal API returns it. Mirrors the `cards` table. Note the\n * SDK never receives the full PAN or CVV here — only `last4` + expiry. The\n * gift-card `redemption_code` is returned exactly once (on create) and\n * scrubbed from subsequent list/get responses.\n */\nexport interface Card {\n id: string;\n user_id: string;\n card_type: CardType;\n status: CardStatus;\n /** Last four digits of the PAN — safe to display. */\n last4: string | null;\n expiry_month: number | null;\n expiry_year: number | null;\n /** Gift cards only, present once on create then scrubbed. */\n redemption_code?: string;\n /** The balance the card was issued with, decimal string; `null` or `\"0\"` for a card issued empty. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | null;\n /** Who changed the status last; `null` when it never changed. See {@link CardStatusSource}. */\n status_source: CardStatusSource | null;\n /** Virtual or plastic. A `physical` card takes a PIN with {@link CardsResource.setPin}. */\n card_form: CardForm;\n /** Why the card cannot be closed right now, or `null` when it can. */\n close_blocked: CloseBlockedReason | null;\n /**\n * Top-ups the issuer has accepted and not loaded yet, summed, decimal\n * string in `currency`; `null` when there are none. Show it next to the\n * balance as money on its way to the card.\n */\n topups_pending: string | null;\n /**\n * Top-ups the issuer has held for too long, summed, decimal string in\n * `currency`; `null` when there are none. The money is safe and waits for\n * support to settle it; say so instead of offering a retry.\n */\n topups_held: string | null;\n /** The name the user gave the card, or `null`. */\n name: string | null;\n /** The artwork the card is shown with. Always present. */\n design: CardDesignRef;\n /** The product the card was issued from; `null` for cards issued without one. */\n product: { id: string; name: string } | null;\n created_at: string;\n updated_at: string;\n /** Only on the result of `create`, when bonuses paid part of the price. */\n bonus?: IssuanceBonus;\n}\n\n/** How bonuses changed a new card's price (\"was / now\"). Decimal strings in `currency`. */\nexport interface IssuanceBonus {\n /** Bonuses used. */\n units: string;\n /** The price before bonuses (\"was\"). */\n price: string;\n /** What the bonuses covered. */\n covered: string;\n /** What the wallet paid (\"now\"). */\n paid: string;\n currency: string;\n}\n\nexport interface CreateCardInput {\n /**\n * A product id from {@link CardsResource.listProducts}. Sent as\n * `product_id`. When given, `type` and `issuer_slug` may be omitted; when\n * both are given they must agree with the product (400 `product_mismatch`).\n * Unknown, disabled or hidden product → 400 `unknown_product`.\n */\n productId?: string;\n /** A name for the card, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * One of the product's `designs`. Sent as `design_id`. `null` or omitted\n * picks the product's default design; a design outside the product's set →\n * 400 `design_not_allowed`.\n */\n designId?: string | null;\n /**\n * `prepaid` (the only fully-wired type today), `credit`, or `gift`.\n * Optional when `productId` is given, required otherwise.\n */\n type?: CardType;\n /**\n * @deprecated Ignored since 0.3.21. A card is issued for its product price;\n * the balance it starts with, if the product includes one, is part of that\n * price (see `CardProduct.starting_balance`). Money is added afterwards\n * with {@link CardsResource.topUp}. The field is no longer sent.\n */\n initial_amount?: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n /**\n * Optional. Slug of a specific issuer to mint with. Omit to let\n * the Takeal API pick the first active issuer. Unknown slug → 400; empty issuer\n * list → 503.\n */\n issuer_slug?: string;\n metadata?: Record<string, string>;\n /** Structured billing details — real issuers require these for 3DS / KYC. */\n customer?: CustomerInfo;\n /**\n * Pay part of the price with bonuses. Sent as `use_bonus`. On by default\n * whenever the user has bonuses; `false` pays it all from the wallet.\n */\n useBonus?: boolean;\n /** The most bonuses to use, decimal string. Sent as `bonus_amount`. */\n bonusAmount?: string;\n /**\n * A promo code for the card's price. Sent as `promo_code`. Its discount\n * comes off before bonuses; `client.codes.validate` shows it first. A code\n * that can't be used fails the request with 400 `promo_code_*` and the\n * reason. Without one, the code the user signed up with applies when it\n * covers cards. Ignored inside `deposits.initiate({ issue_card })`: send\n * `promo_code` on the top-up there.\n */\n promoCode?: string;\n /**\n * Consents the user gave with the order (`terms`, `personal_data`,\n * `marketing`). Recorded with the card, or with the top-up inside\n * `deposits.initiate({ issue_card })`, at the version of their documents\n * in force now.\n */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original card; same key + different body returns 409.\n */\n idempotencyKey: string;\n}\n\n/**\n * The wire body of a card request: the camelCase fields renamed to what\n * the API reads. Shared by {@link CardsResource.create} and the\n * `issue_card` block of `deposits.initiate`.\n */\nexport function cardRequestBody(\n input: Omit<CreateCardInput, \"idempotencyKey\" | \"currency\"> & { currency?: string },\n): Record<string, unknown> {\n const {\n productId,\n name,\n designId,\n useBonus,\n bonusAmount,\n promoCode,\n consentChannel,\n initial_amount: _ignored,\n ...rest\n } = input;\n const body: Record<string, unknown> = { ...rest };\n if (productId !== undefined) body[\"product_id\"] = productId;\n if (name !== undefined) body[\"name\"] = name;\n if (designId !== undefined) body[\"design_id\"] = designId;\n if (useBonus !== undefined) body[\"use_bonus\"] = useBonus;\n if (bonusAmount !== undefined) body[\"bonus_amount\"] = bonusAmount;\n if (promoCode !== undefined) body[\"promo_code\"] = promoCode;\n if (consentChannel !== undefined) body[\"consent_channel\"] = consentChannel;\n return body;\n}\n\n/**\n * A card bought in one step with {@link CardsResource.order}: the product and\n * how the user pays. The platform works out the amount to pay in the\n * payment's currency, locks the rate and opens the top-up that issues the\n * card.\n */\nexport interface CardOrderInput {\n /** A product id from {@link CardsResource.listProducts}. Sent as `product_id`. */\n productId: string;\n /** One of the product's designs; omit for its default. Sent as `design_id`. */\n designId?: string;\n /** A name for the card, 1 to 40 characters; defaults to the product name. */\n name?: string;\n /** How the user pays, e.g. `\"sbp\"`. */\n method: DepositMethod;\n /** The funding connector to pay through; omit to let the API pick one that takes `method`. Sent as `funder_slug`. */\n funderSlug?: string;\n /** ISO 4217 code of the payment; defaults to the currency the method is priced in. */\n currency?: string;\n /** Money to put on the card on top of its price, decimal string in the card's currency. Sent as `extra_load`. */\n extraLoad?: string;\n /** A promo code for the payment. Sent as `promo_code`. */\n promoCode?: string;\n /** Pay part of the price with bonuses; on by default. Sent as `use_bonus`. */\n useBonus?: boolean;\n /** Consents given with the order. */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /** Passed to the payment provider; `return_url` is where the payment page sends the user back. */\n metadata?: Record<string, string>;\n}\n\n/** What {@link CardsResource.order} returns: the top-up to pay and its price. */\nexport interface CardOrder {\n /** Send the user to `deposit.redirect_url` when `deposit.status` is `redirect_required`. The card is issued once the payment is confirmed. */\n deposit: Deposit;\n /** What the user pays, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What reaches the card: its price plus its starting balance, in `card_currency`. */\n card_amount: string;\n card_currency: string;\n}\n\n/** Why a card ordered with the sign-up was not placed. The account exists all the same. */\nexport interface CardOrderError {\n code: string;\n message: string;\n}\n\n/** Build the API body of a card order. */\nexport function cardOrderBody(input: CardOrderInput): Record<string, unknown> {\n const body: Record<string, unknown> = {\n product_id: input.productId,\n method: input.method,\n };\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.funderSlug !== undefined) body[\"funder_slug\"] = input.funderSlug;\n if (input.currency !== undefined) body[\"currency\"] = input.currency;\n if (input.extraLoad !== undefined) body[\"extra_load\"] = input.extraLoad;\n if (input.promoCode !== undefined) body[\"promo_code\"] = input.promoCode;\n if (input.useBonus !== undefined) body[\"use_bonus\"] = input.useBonus;\n if (input.consents !== undefined) body[\"consents\"] = input.consents;\n if (input.consentChannel !== undefined) body[\"consent_channel\"] = input.consentChannel;\n if (input.metadata !== undefined) body[\"metadata\"] = input.metadata;\n return body;\n}\n\n/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\n}\n\n/** What a top-up of a card can be right now, from `GET /me/cards/{id}/topup`. */\nexport interface TopUpTerms {\n /** Whether the card can be topped up at this moment. */\n available: boolean;\n /** Why not, in plain words, when `available` is false. */\n reason: string | null;\n /** Currency top-ups are made in: the card's. */\n currency: string;\n /** What the wallet holds right now, in the wallet's currency. */\n wallet_available: CardBalance;\n /** Smallest single top-up the product allows, or `null` for no floor. */\n min: CardBalance | null;\n /** Largest single top-up the product allows, or `null` for no cap. */\n max: CardBalance | null;\n}\n\nexport interface TopUpInput {\n /** Amount to add, decimal string, in the card's currency. */\n amount: string;\n /**\n * Required. Same key + same amount replays the first outcome; same key +\n * different amount is 409. Use a stable UUID per attempt so a retried\n * network call cannot move the money twice.\n */\n idempotencyKey: string;\n}\n\n/**\n * Where a top-up stands.\n *\n * - `pending`: the issuer accepted it and has not loaded the card yet. The\n * wallet is debited, the card balance is unchanged, the amount shows in\n * `Card.topups_pending`. Most issuers finish within minutes.\n * - `confirmed`: the money is on the card.\n * - `failed`: the issuer refused; the wallet is credited back.\n * - `stalled`: pending for longer than the deployment allows. The money is\n * safe and waits for support; it shows in `Card.topups_held`.\n * - `returned`: support sent the money back to the wallet.\n * - `written_off`: support closed it without the money coming back (the\n * issuer kept it); `failure_reason` says so.\n */\nexport type CardTopUpStatus =\n \"pending\" | \"confirmed\" | \"failed\" | \"stalled\" | \"returned\" | \"written_off\";\n\n/** One top-up attempt as the API records it. */\nexport interface CardTopUp {\n id: string;\n card_id: string;\n status: CardTopUpStatus;\n /** What landed on the card, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the wallet paid, decimal string, in `wallet_currency`. */\n wallet_amount: string;\n wallet_currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/**\n * The outcome of a top-up with the state to redraw: card, its balance, the\n * wallet. When `topup.status` is `pending`, the wallet has paid and\n * `card_balance` has not moved yet: show the amount as on its way\n * (`card.topups_pending`) and refresh the card later or on the\n * `card_topup` notification.\n */\nexport interface TopUpResult {\n topup: CardTopUp;\n card: Card;\n card_balance: CardBalance;\n wallet: CardBalance;\n}\n\n/** Fields a user can change on their own card. Omitted fields are left as they are. */\nexport interface UpdateCardInput {\n /** New name, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * New design (one of the product's `designs`), or `null` for the product's\n * default. Sent as `design_id`.\n */\n designId?: string | null;\n}\n\n/**\n * Kept for callers written against 0.3.x: the API no longer asks for a\n * password or a code on reveal, the session is enough. Both fields are\n * ignored and will be dropped in the next major.\n * @deprecated\n */\nexport interface RevealCardInput {\n password?: string;\n totpCode?: string;\n}\n\n/**\n * Full card data from a successful reveal. **Security**: never persist this,\n * keep it in volatile memory only, clear it within `expires_in_seconds`, and\n * never write it to localStorage / logs (the API marks the response no-store).\n *\n * Some issuers hand out a page that shows the numbers instead of the\n * numbers themselves. Then `reveal_url` is set, `pan` and `cvv` are empty,\n * and the client opens the page in a frame; see the README for the frame.\n */\nexport interface RevealedCard {\n /** The card number; empty when `reveal_url` is set. */\n pan: string;\n /** The security code; empty when `reveal_url` is set. */\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /**\n * A page at the card issuer that shows the details to the holder. Present\n * only for issuers that give a page instead of the numbers. Short-lived,\n * often single use: open it at once in an `<iframe>` and never store it.\n */\n reveal_url?: string;\n /**\n * The person the card is registered to at its issuer: what a checkout\n * asks for. Absent for cards issued before holders were kept.\n */\n cardholder?: Cardholder;\n /**\n * The address the card is registered at — what a merchant's checkout asks\n * for, and the postal code some of them decline a payment over. Absent\n * when the deployment has not set one.\n */\n billing_address?: BillingAddress;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\n}\n\n/** Postal address a card is registered at. Which parts exist depends on the country. */\nexport interface BillingAddress {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postal_code?: string;\n country?: string;\n}\n\n/**\n * The cardholder the issuer knows: the details to type into a checkout\n * that asks for the name, phone or address on the card. `source` says\n * whether the platform made them up (`generated`), the user supplied them\n * (`provided`) or both (`mixed`).\n */\nexport interface Cardholder {\n id: string;\n first_name: string;\n last_name: string;\n /** `YYYY-MM-DD`. */\n birth_date: string;\n /** E.164. */\n phone: string;\n /** A mailbox the platform owns; mail the issuer sends there reaches the user. */\n email: string;\n address: BillingAddress;\n source: \"generated\" | \"provided\" | \"mixed\";\n}\n\n/** The new PIN for a physical card. */\nexport interface SetPinInput {\n /**\n * Four to six digits, as the user typed them. Sent once to the issuer and\n * kept nowhere: not by the SDK, not by the API. Never log it.\n */\n pin: string;\n}\n\n/** What to move, and the key that makes a retry safe. */\nexport interface TransferInput {\n /** The card the money lands on. Must be the caller's, and of the same kind and currency. */\n toCardId: string;\n /** Amount to move, decimal string, in the cards' currency. */\n amount: string;\n /**\n * Required. The same key with the same body replays the first outcome; a\n * different body on the same key is 409.\n */\n idempotencyKey: string;\n}\n\n/** One transfer attempt as the API records it. */\nexport interface CardTransfer {\n id: string;\n from_card_id: string;\n to_card_id: string;\n /**\n * `confirmed` — the money is on the other card. `on_wallet` — it came off\n * the first card but the second did not take it, so it is on the wallet\n * and `failure_reason` says so in words. `pending` / `failed` otherwise.\n */\n status: \"pending\" | \"confirmed\" | \"on_wallet\" | \"failed\";\n amount: string;\n currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/** A finished transfer with the balances to redraw both cards and the wallet. */\nexport interface TransferResult {\n transfer: CardTransfer;\n from_balance: CardBalance;\n to_balance: CardBalance;\n /** Holds the money when `transfer.status` is `on_wallet`. */\n wallet: CardBalance;\n}\n\nexport class CardsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Issue a card backed by the user's wallet balance. Resolves to the new\n * `Card`. On a ledger failure after provider creation, the Takeal API rolls the row\n * to `failed` (never an orphaned active card); inspect `status` /\n * `failure_reason` on the result.\n */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, ...card } = input;\n return this.http.post<Card>(\"/me/cards\", {\n body: cardRequestBody(card),\n idempotencyKey,\n });\n }\n\n /**\n * Buy a card in one step: the API prices the product in the payment's\n * currency, locks the rate and opens the top-up that issues the card.\n * Send the user to `order.deposit.redirect_url`; the card shows as\n * `pending_payment` until the payment is confirmed. The same\n * `idempotencyKey` returns the same order.\n * Errors: 400 `unknown_product` / `method_not_available` / a limit of the\n * way of paying, 503 no funding connector or no exchange rate.\n */\n async order(input: CardOrderInput & { idempotencyKey: string }): Promise<CardOrder> {\n const { idempotencyKey, ...order } = input;\n return this.http.post<CardOrder>(\"/me/card-orders\", {\n body: cardOrderBody(order),\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the storefront shows them\n * (`is_default` marks the one issued when none is chosen). Each item\n * carries its product card (name, tagline, benefits, tile picture),\n * artwork, and the issuance price after the caller's subscription\n * discount, in the caller's wallet currency. Pass an item's `id` as\n * `productId` to {@link create}.\n */\n async listProducts(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/me/card-products\");\n }\n\n /** One product from the catalog. 404 when unknown, disabled or hidden. */\n async getProduct(id: string): Promise<CardProduct> {\n return this.http.get<CardProduct>(`/me/card-products/${encodeURIComponent(id)}`);\n }\n\n /**\n * The public catalog: the same products, order and default as\n * {@link listProducts}, but readable before sign-in, for a landing page or\n * the cabinet's first screen. Prices are list prices (`discount_bps` is\n * always 0); once the user is signed in, {@link listProducts} shows what\n * they pay. The API lets caches keep this response for a minute.\n */\n async catalog(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/card-products\");\n }\n\n /**\n * Rename the caller's own card or change its design. Resolves to the\n * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /\n * `design_not_allowed` on a bad value.\n */\n async update(id: string, input: UpdateCardInput): Promise<Card> {\n const body: Record<string, unknown> = {};\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n return this.http.patch<Card>(`/me/cards/${encodeURIComponent(id)}`, {\n body,\n });\n }\n\n /** Fetch one card by id. */\n async get(id: string): Promise<Card> {\n return this.http.get<Card>(`/me/cards/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's cards, most recent first. */\n async list(): Promise<Card[]> {\n return this.http.get<Card[]>(\"/me/cards\");\n }\n\n /**\n * Remaining balance of a prepaid card. `currency` is required by the Takeal API and\n * forwarded as a query param.\n */\n async balance(id: string, currency: string): Promise<CardBalance> {\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<CardBalance>(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);\n }\n\n /**\n * What a top-up of this card can be right now: whether it is possible, the\n * currency, the wallet balance, and the product's floor and cap for one\n * top-up. Read it before drawing the form. 404 if the card isn't the caller's.\n */\n async topUpTerms(id: string): Promise<TopUpTerms> {\n return this.http.get<TopUpTerms>(`/me/cards/${encodeURIComponent(id)}/topup`);\n }\n\n /**\n * Move money from the wallet onto the caller's own card. The wallet is\n * debited first, then the card's provider loads the card; if the provider\n * refuses, the money is back on the wallet and the error says so. Resolves\n * to the card, its new balance and the wallet balance, so no second call\n * is needed. Errors carry a sentence the user can read: 400 outside the\n * floor or cap · 402 not enough in the wallet · 404 not the caller's card ·\n * 409 card frozen, closed or still being issued · 501 provider can't top\n * up · 502/503 provider declined or unreachable (wallet untouched).\n */\n async topUp(id: string, input: TopUpInput): Promise<TopUpResult> {\n const { idempotencyKey, amount } = input;\n return this.http.post<TopUpResult>(`/me/cards/${encodeURIComponent(id)}/topup`, {\n body: { amount },\n idempotencyKey,\n });\n }\n\n /**\n * Move money from one of the caller's cards to another. Both must be\n * theirs, active, in the same currency and of the same kind. The money\n * travels through the wallet one leg at a time: when the second leg does\n * not go through, the call still resolves, `transfer.status` is\n * `on_wallet` and the money is on the wallet — never between two cards.\n * Errors carry a sentence the user can read: 400 the same card twice,\n * different currencies or different kinds · 402 the card holds less than\n * that · 404 one of the cards isn't theirs · 409 a card is frozen, closed\n * or still being issued, or the key was reused with a different body ·\n * 501/502/503 the provider cannot or will not move it.\n */\n async transfer(fromCardId: string, input: TransferInput): Promise<TransferResult> {\n const { toCardId, amount, idempotencyKey } = input;\n return this.http.post<TransferResult>(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {\n body: { to_card_id: toCardId, amount },\n idempotencyKey,\n });\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze} while\n * `status_source` is `holder` or `operator`. The optional `reason` is\n * recorded on the audit trail. Resolves to the updated card. 404 if the\n * card isn't the caller's; 409 `card_locked` when support holds it; 501 if\n * the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });\n }\n\n /**\n * Reveal the FULL PAN + CVV for the caller's own card. The signed-in\n * session is all the API asks for; the call is rate-limited and audited\n * server-side. The Takeal API never persists this data and marks the\n * response no-store; the SDK returns it verbatim and holds nothing.\n *\n * **Consumer security duties** (the SDK can't enforce these for you):\n * keep the result in volatile memory only, never write it to\n * localStorage / logs, and clear it within `expires_in_seconds`.\n *\n * The result is the numbers, or `reveal_url` with empty `pan` and `cvv`\n * when the issuer shows them on a page of its own: open that page in a\n * frame right away, it is short-lived.\n *\n * 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 `provider_unavailable`.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n return this.http.post<RevealedCard>(`/me/cards/${encodeURIComponent(id)}/reveal`);\n }\n\n /**\n * Unfreeze a previously-frozen card. Idempotent on an already-active card.\n * A card the issuer froze (`status_source: \"provider\"`) is not the\n * holder's to unfreeze: the API answers 409 `card_locked`, so hide the\n * button and say the freeze is lifted through the issuer's support.\n */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });\n }\n\n /**\n * Set the PIN of the caller's own physical card. The session is enough; the\n * call is rate-limited like {@link reveal} and the PIN is kept nowhere.\n * Resolves to the card; the user also gets a notification that the PIN\n * was set. 400 not four to six digits or the card is not active · 403 not\n * your card · 409 `card_locked`, or `provider_refused` when the issuer did\n * not take it · 429 too many attempts · 501 a virtual card has no PIN.\n */\n async setPin(id: string, input: SetPinInput): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/pin`, {\n body: { pin: input.pin },\n });\n }\n\n /**\n * Terminate the caller's own card. **One-way** — a terminated card cannot be\n * reactivated. The optional `reason` is audited. Idempotent on an\n * already-terminated card.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/terminate`, {\n body: { reason },\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/resources/cards.ts"],"names":[],"mappings":";AAuXO,SAAS,gBACd,KAAA,EACyB;AACzB,EAAA,MAAM;AAAA,IACJ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AAM,GAAA;AAAI,KACxB,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,SAAA,CAAU,EAAA,EAAY,MAAA,EAAgC;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAW,aAAa,kBAAA,CAAmB,EAAE,CAAC,CAAA,UAAA,CAAA,EAAc;AAAA,MAC3E,IAAA,EAAM,EAAE,MAAA;AAAO,KAChB,CAAA;AAAA,EACH;AACF","file":"cards.js","sourcesContent":["import type { ConsentChannel, ConsentKind } from \"./consents.js\";\nimport type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\nimport type { Deposit, DepositMethod } from \"./deposits.js\";\n\n/**\n * Cards resource — `client.cards.*`.\n *\n * The end-user \"money OUT\" surface: a user issues themselves a card backed by\n * their wallet balance via an issuer connector. Mirrors the Takeal API's\n * `/me/cards` routes:\n *\n * GET /card-products → catalog (public, before sign-in)\n * GET /me/card-products → listProducts (the catalog, personal price)\n * GET /me/card-products/{id} → getProduct\n * GET /me/cards/{id}/topup → topUpTerms\n * POST /me/cards/{id}/topup → topUp\n * POST /me/cards → create\n * GET /me/cards → list (most recent first)\n * GET /me/cards/{id} → get\n * PATCH /me/cards/{id} → update (name, design)\n * GET /me/cards/{id}/balance → balance (prepaid remaining)\n * POST /me/cards/{id}/freeze → freeze\n * POST /me/cards/{id}/unfreeze → unfreeze\n * POST /me/cards/{id}/transfer → transfer (to another of their cards)\n * POST /me/cards/{id}/terminate → terminate (one-way)\n * POST /me/cards/{id}/reveal → reveal (the numbers, or a provider page)\n * POST /me/cards/{id}/pin → setPin (physical cards)\n *\n * The lifecycle actions are ownership-gated server-side: a caller can only\n * freeze / unfreeze / terminate a card that belongs to them (else 404).\n *\n * Today only PREPAID is wired end-to-end; CREDIT and GIFT return 400 from\n * the Takeal API until their issuer flows land.\n */\n\n/** Card product. Only `prepaid` is fully implemented today. */\nexport type CardType = \"credit\" | \"prepaid\" | \"gift\";\n\n/**\n * Card lifecycle state.\n *\n * - `pending_payment`: the row exists but the issuance fee has not been\n * paid yet; the provider has not been called and nothing is visible.\n * - `pending`: the issuer accepted the order and has not issued the card\n * yet. The price is charged. Show the card as \"being issued\" with no\n * numbers; it becomes `active` on its own, or `failed` with the price\n * back on the wallet. Some issuers take minutes, some a day.\n * - `active`, `frozen`: the usual states. Read `status_source` before\n * offering to unfreeze.\n * - `terminating`: the holder (or the issuer) closed the card and the\n * issuer has not finished: the balance comes back to the wallet when it\n * does. Show it as closing; no actions apply.\n * - `terminated`, `redeemed`, `failed`: final.\n */\nexport type CardStatus =\n | \"pending_payment\"\n | \"pending\"\n | \"active\"\n | \"frozen\"\n | \"terminating\"\n | \"terminated\"\n | \"redeemed\"\n | \"failed\";\n\n/**\n * Who made the card's last status change. `provider` on a `frozen` card\n * means the issuer froze it (a risk check, a lost-card report): the holder\n * cannot unfreeze it, so do not offer the button; say the freeze is lifted\n * through the issuer's support. `holder` and `operator` freezes are undone\n * with `unfreeze()` as usual.\n */\nexport type CardStatusSource = \"holder\" | \"operator\" | \"provider\";\n\n/** `virtual` cards show their numbers in the app; `physical` cards are plastic and have a PIN. */\nexport type CardForm = \"virtual\" | \"physical\";\n\n/**\n * Why `terminate()` is refused right now: `first_purchase_required` (the\n * card closes after its first purchase) or `card_locked` (only support can\n * change it).\n */\nexport type CloseBlockedReason = \"first_purchase_required\" | \"card_locked\";\n\n/**\n * A card design: the artwork a card is shown with. `image_url` is the front,\n * `image_url_back` the back; both are either absolute URLs or paths relative\n * to the API origin (the deployment's default design is\n * `/card-designs/default.svg`, its back `/card-designs/default.svg?side=back`)\n * — pass them through `client.assetUrl()` before rendering. `image_url_back`\n * is `null` or absent for a one-sided design: show the front on both sides.\n * The picture is in the proportions of a plastic card (1586×1000) and draws\n * no chip or card data; the client renders the number, name and expiry on\n * top. `id` is `null` for the deployment default, which is rendered from the\n * branding settings.\n */\nexport interface CardDesignRef {\n id: string | null;\n name?: string;\n image_url: string;\n image_url_back?: string | null;\n}\n\n/**\n * What issuing a card costs the caller. `amount` is the price after the\n * user's subscription discount; `base_amount` is the list price and\n * `discount_bps` the discount in basis points (1000 = 10 %). `label` is the\n * operator's wording for the fee line (\"Card issuance\").\n */\nexport interface CardProductPrice {\n /** What the user pays, decimal string, after their subscription discount. */\n amount: string;\n /**\n * ISO 4217 code: the currency the buyer pays in. A signed-in user sees\n * their wallet currency, converted the way issuance will charge it; the\n * public catalog shows the currency the operator priced the card in. It\n * is not necessarily the currency the card is held in (`CardProduct.currency`).\n */\n currency: string;\n /** Wording for the fee line, e.g. \"Card issuance\". */\n label: string;\n /** The list price before the discount, decimal string, in the same currency. */\n base_amount: string;\n /** Discount applied, in basis points (1000 = 10%). */\n discount_bps: number;\n}\n\n/**\n * A card the user can order, as listed by `GET /me/card-products`. The id is\n * opaque — it names a product, never a provider. The list comes in the\n * order the operator arranged the storefront; `is_default` marks the\n * product issued when none is chosen, wherever it sits. `designs` is the\n * set the user may pick from (may be empty when only the default applies);\n * `design` is what the card gets when no choice is made. `price` is `null`\n * for a free card. `features` is an operator-defined object (scheme, wallet\n * support, load limits, …) with no fixed keys.\n */\nexport interface CardProduct {\n id: string;\n name: string;\n /** One line under the name on the tile, or `null`. */\n tagline: string | null;\n description: string | null;\n /** Selling points to list on the product card, in order. May be empty. */\n benefits: string[];\n /**\n * Picture for the product tile, absolute URL, or `null`: show the card\n * design (`design.image_url`) then.\n */\n tile_image_url: string | null;\n card_type: CardType;\n currency: string | null;\n features: Record<string, unknown>;\n design: CardDesignRef;\n designs: CardDesignRef[];\n price: CardProductPrice | null;\n /**\n * The balance a new card comes with, already included in `price`; `null`\n * when the card starts empty and is funded with `topUp()` afterwards.\n */\n starting_balance: CardBalance | null;\n /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\n /**\n * Issuing this card sends the user's real personal details to the card\n * issuer. Show the consent screen before the order and send\n * `holder_data_transfer` in its `consents` (or give it once with\n * `client.consents.allowHolderData()`); without it the order fails with\n * 409 `holder_data_consent_required`. `false`: the issuer gets no real\n * details and no extra consent is asked.\n */\n holder_data_required: boolean;\n /**\n * What a card on this product costs to use, on top of the payments\n * themselves. A fee the card can't cover is owed and paid from the next\n * top-up (see `client.debt`). Every line is `\"0\"` when the product\n * charges nothing for it.\n */\n tariff: CardTariff;\n}\n\n/**\n * A card product's fees for using the card. Decimal strings: the fixed\n * amounts are in `currency` (the card's), the shares in percent of the\n * operation's amount.\n */\nexport interface CardTariff {\n /** `null` for a product held in several currencies: the card's own then. */\n currency: string | null;\n /** Per settled card payment, fixed. */\n operation_fixed: string;\n /** Per settled card payment, percent of its amount. */\n operation_percent: string;\n /**\n * Per payment declined through the user's own doing: not enough money,\n * wrong card details, a frozen card, a subscription not cancelled with the\n * merchant. A decline caused by the issuer or the platform costs nothing.\n */\n decline: string;\n /** Per cash withdrawal, fixed; charged instead of the payment fee. */\n cash_withdrawal_fixed: string;\n /** Per cash withdrawal, percent of its amount. */\n cash_withdrawal_percent: string;\n}\n\n/**\n * A card record as the Takeal API returns it. Mirrors the `cards` table. Note the\n * SDK never receives the full PAN or CVV here — only `last4` + expiry. The\n * gift-card `redemption_code` is returned exactly once (on create) and\n * scrubbed from subsequent list/get responses.\n */\nexport interface Card {\n id: string;\n user_id: string;\n card_type: CardType;\n status: CardStatus;\n /** Last four digits of the PAN — safe to display. */\n last4: string | null;\n expiry_month: number | null;\n expiry_year: number | null;\n /** Gift cards only, present once on create then scrubbed. */\n redemption_code?: string;\n /** The balance the card was issued with, decimal string; `null` or `\"0\"` for a card issued empty. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | null;\n /** Who changed the status last; `null` when it never changed. See {@link CardStatusSource}. */\n status_source: CardStatusSource | null;\n /** Virtual or plastic. A `physical` card takes a PIN with {@link CardsResource.setPin}. */\n card_form: CardForm;\n /** Why the card cannot be closed right now, or `null` when it can. */\n close_blocked: CloseBlockedReason | null;\n /**\n * Top-ups the issuer has accepted and not loaded yet, summed, decimal\n * string in `currency`; `null` when there are none. Show it next to the\n * balance as money on its way to the card.\n */\n topups_pending: string | null;\n /**\n * Top-ups the issuer has held for too long, summed, decimal string in\n * `currency`; `null` when there are none. The money is safe and waits for\n * support to settle it; say so instead of offering a retry.\n */\n topups_held: string | null;\n /**\n * The card this one replaced: support reissued it for free because that\n * card stopped working before its term. `null` otherwise.\n */\n reissued_from_card_id?: string | null;\n /** The card support issued to replace this one, or `null`. */\n reissued_to_card_id?: string | null;\n /**\n * What was left on the card this one replaced, on its way here. Show it as\n * money in transit next to the balance, not as part of it. `null` when\n * nothing is on its way.\n */\n in_transit?: CardInTransit | null;\n /** The name the user gave the card, or `null`. */\n name: string | null;\n /** The artwork the card is shown with. Always present. */\n design: CardDesignRef;\n /** The product the card was issued from; `null` for cards issued without one. */\n product: { id: string; name: string } | null;\n created_at: string;\n updated_at: string;\n /** Only on the result of `create`, when bonuses paid part of the price. */\n bonus?: IssuanceBonus;\n}\n\n/**\n * The balance of a closed card on its way to the card that replaced it. It\n * waits for the old card's issuer to return the money (`stage: \"issuer\"`),\n * then it is loaded onto this card (`stage: \"loading\"`); once it is there,\n * `in_transit` is `null` and the card's balance has it. The move is in the\n * history as a `closed_card_balance` entry.\n */\nexport interface CardInTransit {\n /** Decimal string in `currency`. What the issuer returned once it did; before that, what the old card held. */\n amount: string;\n currency: string;\n /** The closed card the money comes from. */\n from_card_id: string;\n stage: \"issuer\" | \"loading\" | (string & {});\n}\n\n/** How bonuses changed a new card's price (\"was / now\"). Decimal strings in `currency`. */\nexport interface IssuanceBonus {\n /** Bonuses used. */\n units: string;\n /** The price before bonuses (\"was\"). */\n price: string;\n /** What the bonuses covered. */\n covered: string;\n /** What the wallet paid (\"now\"). */\n paid: string;\n currency: string;\n}\n\nexport interface CreateCardInput {\n /**\n * A product id from {@link CardsResource.listProducts}. Sent as\n * `product_id`. When given, `type` and `issuer_slug` may be omitted; when\n * both are given they must agree with the product (400 `product_mismatch`).\n * Unknown, disabled or hidden product → 400 `unknown_product`.\n */\n productId?: string;\n /** A name for the card, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * One of the product's `designs`. Sent as `design_id`. `null` or omitted\n * picks the product's default design; a design outside the product's set →\n * 400 `design_not_allowed`.\n */\n designId?: string | null;\n /**\n * `prepaid` (the only fully-wired type today), `credit`, or `gift`.\n * Optional when `productId` is given, required otherwise.\n */\n type?: CardType;\n /**\n * @deprecated Ignored since 0.3.21. A card is issued for its product price;\n * the balance it starts with, if the product includes one, is part of that\n * price (see `CardProduct.starting_balance`). Money is added afterwards\n * with {@link CardsResource.topUp}. The field is no longer sent.\n */\n initial_amount?: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n /**\n * Optional. Slug of a specific issuer to mint with. Omit to let\n * the Takeal API pick the first active issuer. Unknown slug → 400; empty issuer\n * list → 503.\n */\n issuer_slug?: string;\n metadata?: Record<string, string>;\n /** Structured billing details — real issuers require these for 3DS / KYC. */\n customer?: CustomerInfo;\n /**\n * Pay part of the price with bonuses. Sent as `use_bonus`. On by default\n * whenever the user has bonuses; `false` pays it all from the wallet.\n */\n useBonus?: boolean;\n /** The most bonuses to use, decimal string. Sent as `bonus_amount`. */\n bonusAmount?: string;\n /**\n * A promo code for the card's price. Sent as `promo_code`. Its discount\n * comes off before bonuses; `client.codes.validate` shows it first. A code\n * that can't be used fails the request with 400 `promo_code_*` and the\n * reason. Without one, the code the user signed up with applies when it\n * covers cards. Ignored inside `deposits.initiate({ issue_card })`: send\n * `promo_code` on the top-up there.\n */\n promoCode?: string;\n /**\n * Consents the user gave with the order (`terms`, `personal_data`,\n * `marketing`, `holder_data_transfer`). Recorded with the card, or with the\n * top-up inside `deposits.initiate({ issue_card })`, at the version of\n * their documents in force now. A product with `holder_data_required`\n * needs `holder_data_transfer` here unless it was given before.\n */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original card; same key + different body returns 409.\n */\n idempotencyKey: string;\n}\n\n/**\n * The wire body of a card request: the camelCase fields renamed to what\n * the API reads. Shared by {@link CardsResource.create} and the\n * `issue_card` block of `deposits.initiate`.\n */\nexport function cardRequestBody(\n input: Omit<CreateCardInput, \"idempotencyKey\" | \"currency\"> & { currency?: string },\n): Record<string, unknown> {\n const {\n productId,\n name,\n designId,\n useBonus,\n bonusAmount,\n promoCode,\n consentChannel,\n initial_amount: _ignored,\n ...rest\n } = input;\n const body: Record<string, unknown> = { ...rest };\n if (productId !== undefined) body[\"product_id\"] = productId;\n if (name !== undefined) body[\"name\"] = name;\n if (designId !== undefined) body[\"design_id\"] = designId;\n if (useBonus !== undefined) body[\"use_bonus\"] = useBonus;\n if (bonusAmount !== undefined) body[\"bonus_amount\"] = bonusAmount;\n if (promoCode !== undefined) body[\"promo_code\"] = promoCode;\n if (consentChannel !== undefined) body[\"consent_channel\"] = consentChannel;\n return body;\n}\n\n/**\n * A card bought in one step with {@link CardsResource.order}: the product and\n * how the user pays. The platform works out the amount to pay in the\n * payment's currency, locks the rate and opens the top-up that issues the\n * card.\n */\nexport interface CardOrderInput {\n /** A product id from {@link CardsResource.listProducts}. Sent as `product_id`. */\n productId: string;\n /** One of the product's designs; omit for its default. Sent as `design_id`. */\n designId?: string;\n /** A name for the card, 1 to 40 characters; defaults to the product name. */\n name?: string;\n /** How the user pays, e.g. `\"sbp\"`. */\n method: DepositMethod;\n /** The funding connector to pay through; omit to let the API pick one that takes `method`. Sent as `funder_slug`. */\n funderSlug?: string;\n /** ISO 4217 code of the payment; defaults to the currency the method is priced in. */\n currency?: string;\n /** Money to put on the card on top of its price, decimal string in the card's currency. Sent as `extra_load`. */\n extraLoad?: string;\n /** A promo code for the payment. Sent as `promo_code`. */\n promoCode?: string;\n /** Pay part of the price with bonuses; on by default. Sent as `use_bonus`. */\n useBonus?: boolean;\n /**\n * Consents given with the order. A product with `holder_data_required`\n * needs `holder_data_transfer` here unless it was given before.\n */\n consents?: ConsentKind[];\n /** Where they were given. Sent as `consent_channel`. */\n consentChannel?: ConsentChannel;\n /** Passed to the payment provider; `return_url` is where the payment page sends the user back. */\n metadata?: Record<string, string>;\n}\n\n/** What {@link CardsResource.order} returns: the top-up to pay and its price. */\nexport interface CardOrder {\n /** Send the user to `deposit.redirect_url` when `deposit.status` is `redirect_required`. The card is issued once the payment is confirmed. */\n deposit: Deposit;\n /** What the user pays, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the payment brings: the card's price, its starting balance and `debt_withheld`, in `card_currency`. */\n card_amount: string;\n card_currency: string;\n /**\n * What the user owes in card fees, in `card_currency`: included in\n * `card_amount` and paid from it first. `\"0\"` when nothing is owed. Show\n * it before the payment. Older platforms leave it out.\n */\n debt_withheld?: string;\n}\n\n/** Why a card ordered with the sign-up was not placed. The account exists all the same. */\nexport interface CardOrderError {\n code: string;\n message: string;\n}\n\n/** Build the API body of a card order. */\nexport function cardOrderBody(input: CardOrderInput): Record<string, unknown> {\n const body: Record<string, unknown> = {\n product_id: input.productId,\n method: input.method,\n };\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.funderSlug !== undefined) body[\"funder_slug\"] = input.funderSlug;\n if (input.currency !== undefined) body[\"currency\"] = input.currency;\n if (input.extraLoad !== undefined) body[\"extra_load\"] = input.extraLoad;\n if (input.promoCode !== undefined) body[\"promo_code\"] = input.promoCode;\n if (input.useBonus !== undefined) body[\"use_bonus\"] = input.useBonus;\n if (input.consents !== undefined) body[\"consents\"] = input.consents;\n if (input.consentChannel !== undefined) body[\"consent_channel\"] = input.consentChannel;\n if (input.metadata !== undefined) body[\"metadata\"] = input.metadata;\n return body;\n}\n\n/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\n}\n\n/** What a top-up of a card can be right now, from `GET /me/cards/{id}/topup`. */\nexport interface TopUpTerms {\n /** Whether the card can be topped up at this moment. */\n available: boolean;\n /** Why not, in plain words, when `available` is false. */\n reason: string | null;\n /** Currency top-ups are made in: the card's. */\n currency: string;\n /** What the wallet holds right now, in the wallet's currency. */\n wallet_available: CardBalance;\n /** Smallest single top-up the product allows, or `null` for no floor. */\n min: CardBalance | null;\n /** Largest single top-up the product allows, or `null` for no cap. */\n max: CardBalance | null;\n /**\n * What the user owes in card fees, in the card's currency, or `null` when\n * nothing is. A top-up from a wallet in the same currency pays it first\n * and the card gets the rest: show it before the top-up. Older platforms\n * leave it out.\n */\n debt?: CardBalance | null;\n}\n\nexport interface TopUpInput {\n /** Amount to add, decimal string, in the card's currency. */\n amount: string;\n /**\n * Required. Same key + same amount replays the first outcome; same key +\n * different amount is 409. Use a stable UUID per attempt so a retried\n * network call cannot move the money twice.\n */\n idempotencyKey: string;\n}\n\n/**\n * Where a top-up stands.\n *\n * - `pending`: the issuer accepted it and has not loaded the card yet. The\n * wallet is debited, the card balance is unchanged, the amount shows in\n * `Card.topups_pending`. Most issuers finish within minutes.\n * - `confirmed`: the money is on the card.\n * - `failed`: the issuer refused; the wallet is credited back.\n * - `stalled`: pending for longer than the deployment allows. The money is\n * safe and waits for support; it shows in `Card.topups_held`.\n * - `returned`: support sent the money back to the wallet.\n * - `written_off`: support closed it without the money coming back (the\n * issuer kept it); `failure_reason` says so.\n */\nexport type CardTopUpStatus =\n \"pending\" | \"confirmed\" | \"failed\" | \"stalled\" | \"returned\" | \"written_off\";\n\n/** One top-up attempt as the API records it. */\nexport interface CardTopUp {\n id: string;\n card_id: string;\n status: CardTopUpStatus;\n /** What landed on the card, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the wallet paid, decimal string, in `wallet_currency`. */\n wallet_amount: string;\n wallet_currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/**\n * The outcome of a top-up with the state to redraw: card, its balance, the\n * wallet. When `topup.status` is `pending`, the wallet has paid and\n * `card_balance` has not moved yet: show the amount as on its way\n * (`card.topups_pending`) and refresh the card later or on the\n * `card_topup` notification.\n */\nexport interface TopUpResult {\n topup: CardTopUp;\n card: Card;\n card_balance: CardBalance;\n wallet: CardBalance;\n}\n\n/** Fields a user can change on their own card. Omitted fields are left as they are. */\nexport interface UpdateCardInput {\n /** New name, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * New design (one of the product's `designs`), or `null` for the product's\n * default. Sent as `design_id`.\n */\n designId?: string | null;\n}\n\n/**\n * Kept for callers written against 0.3.x: the API no longer asks for a\n * password or a code on reveal, the session is enough. Both fields are\n * ignored and will be dropped in the next major.\n * @deprecated\n */\nexport interface RevealCardInput {\n password?: string;\n totpCode?: string;\n}\n\n/**\n * Full card data from a successful reveal. **Security**: never persist this,\n * keep it in volatile memory only, clear it within `expires_in_seconds`, and\n * never write it to localStorage / logs (the API marks the response no-store).\n *\n * Some issuers hand out a page that shows the numbers instead of the\n * numbers themselves. Then `reveal_url` is set, `pan` and `cvv` are empty,\n * and the client opens the page in a frame; see the README for the frame.\n */\nexport interface RevealedCard {\n /** The card number; empty when `reveal_url` is set. */\n pan: string;\n /** The security code; empty when `reveal_url` is set. */\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /**\n * A page at the card issuer that shows the details to the holder. Present\n * only for issuers that give a page instead of the numbers. Short-lived,\n * often single use: open it at once in an `<iframe>` and never store it.\n */\n reveal_url?: string;\n /**\n * The person the card is registered to at its issuer: what a checkout\n * asks for. Absent for cards issued before holders were kept.\n */\n cardholder?: Cardholder;\n /**\n * The address the card is registered at — what a merchant's checkout asks\n * for, and the postal code some of them decline a payment over. Absent\n * when the deployment has not set one.\n */\n billing_address?: BillingAddress;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\n}\n\n/** Postal address a card is registered at. Which parts exist depends on the country. */\nexport interface BillingAddress {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postal_code?: string;\n country?: string;\n}\n\n/**\n * The cardholder the issuer knows: the details to type into a checkout\n * that asks for the name, phone or address on the card. `source` says\n * whether the platform made them up (`generated`), the user supplied them\n * (`provided`) or both (`mixed`).\n */\nexport interface Cardholder {\n id: string;\n first_name: string;\n last_name: string;\n /** `YYYY-MM-DD`. */\n birth_date: string;\n /** E.164. */\n phone: string;\n /** A mailbox the platform owns; mail the issuer sends there reaches the user. */\n email: string;\n address: BillingAddress;\n source: \"generated\" | \"provided\" | \"mixed\";\n}\n\n/** The new PIN for a physical card. */\nexport interface SetPinInput {\n /**\n * Four to six digits, as the user typed them. Sent once to the issuer and\n * kept nowhere: not by the SDK, not by the API. Never log it.\n */\n pin: string;\n}\n\n/** What to move, and the key that makes a retry safe. */\nexport interface TransferInput {\n /** The card the money lands on. Must be the caller's, and of the same kind and currency. */\n toCardId: string;\n /** Amount to move, decimal string, in the cards' currency. */\n amount: string;\n /**\n * Required. The same key with the same body replays the first outcome; a\n * different body on the same key is 409.\n */\n idempotencyKey: string;\n}\n\n/** One transfer attempt as the API records it. */\nexport interface CardTransfer {\n id: string;\n from_card_id: string;\n to_card_id: string;\n /**\n * `confirmed` — the money is on the other card. `on_wallet` — it came off\n * the first card but the second did not take it, so it is on the wallet\n * and `failure_reason` says so in words. `pending` / `failed` otherwise.\n */\n status: \"pending\" | \"confirmed\" | \"on_wallet\" | \"failed\";\n amount: string;\n currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/** A finished transfer with the balances to redraw both cards and the wallet. */\nexport interface TransferResult {\n transfer: CardTransfer;\n from_balance: CardBalance;\n to_balance: CardBalance;\n /** Holds the money when `transfer.status` is `on_wallet`. */\n wallet: CardBalance;\n}\n\nexport class CardsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Issue a card backed by the user's wallet balance. Resolves to the new\n * `Card`. On a ledger failure after provider creation, the Takeal API rolls the row\n * to `failed` (never an orphaned active card); inspect `status` /\n * `failure_reason` on the result.\n * Errors: 409 `holder_data_consent_required` when the product has\n * `holder_data_required` and the user has not agreed to it.\n */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, ...card } = input;\n return this.http.post<Card>(\"/me/cards\", {\n body: cardRequestBody(card),\n idempotencyKey,\n });\n }\n\n /**\n * Buy a card in one step: the API prices the product in the payment's\n * currency, locks the rate and opens the top-up that issues the card.\n * Send the user to `order.deposit.redirect_url`; the card shows as\n * `pending_payment` until the payment is confirmed. The same\n * `idempotencyKey` returns the same order.\n * Errors: 400 `unknown_product` / `method_not_available` / a limit of the\n * way of paying, 409 `holder_data_consent_required` (the product has\n * `holder_data_required` and the user has not agreed to it), 503 no\n * funding connector or no exchange rate.\n */\n async order(input: CardOrderInput & { idempotencyKey: string }): Promise<CardOrder> {\n const { idempotencyKey, ...order } = input;\n return this.http.post<CardOrder>(\"/me/card-orders\", {\n body: cardOrderBody(order),\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the storefront shows them\n * (`is_default` marks the one issued when none is chosen). Each item\n * carries its product card (name, tagline, benefits, tile picture),\n * artwork, and the issuance price after the caller's subscription\n * discount, in the caller's wallet currency. Pass an item's `id` as\n * `productId` to {@link create}.\n */\n async listProducts(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/me/card-products\");\n }\n\n /** One product from the catalog. 404 when unknown, disabled or hidden. */\n async getProduct(id: string): Promise<CardProduct> {\n return this.http.get<CardProduct>(`/me/card-products/${encodeURIComponent(id)}`);\n }\n\n /**\n * The public catalog: the same products, order and default as\n * {@link listProducts}, but readable before sign-in, for a landing page or\n * the cabinet's first screen. Prices are list prices (`discount_bps` is\n * always 0); once the user is signed in, {@link listProducts} shows what\n * they pay. The API lets caches keep this response for a minute.\n */\n async catalog(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/card-products\");\n }\n\n /**\n * Rename the caller's own card or change its design. Resolves to the\n * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /\n * `design_not_allowed` on a bad value.\n */\n async update(id: string, input: UpdateCardInput): Promise<Card> {\n const body: Record<string, unknown> = {};\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n return this.http.patch<Card>(`/me/cards/${encodeURIComponent(id)}`, {\n body,\n });\n }\n\n /** Fetch one card by id. */\n async get(id: string): Promise<Card> {\n return this.http.get<Card>(`/me/cards/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's cards, most recent first. */\n async list(): Promise<Card[]> {\n return this.http.get<Card[]>(\"/me/cards\");\n }\n\n /**\n * Remaining balance of a prepaid card. `currency` is required by the Takeal API and\n * forwarded as a query param.\n */\n async balance(id: string, currency: string): Promise<CardBalance> {\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<CardBalance>(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);\n }\n\n /**\n * What a top-up of this card can be right now: whether it is possible, the\n * currency, the wallet balance, and the product's floor and cap for one\n * top-up. Read it before drawing the form. 404 if the card isn't the caller's.\n */\n async topUpTerms(id: string): Promise<TopUpTerms> {\n return this.http.get<TopUpTerms>(`/me/cards/${encodeURIComponent(id)}/topup`);\n }\n\n /**\n * Move money from the wallet onto the caller's own card. The wallet is\n * debited first, then the card's provider loads the card; if the provider\n * refuses, the money is back on the wallet and the error says so. Resolves\n * to the card, its new balance and the wallet balance, so no second call\n * is needed. Errors carry a sentence the user can read: 400 outside the\n * floor or cap · 402 not enough in the wallet · 404 not the caller's card ·\n * 409 card frozen, closed or still being issued · 501 provider can't top\n * up · 502/503 provider declined or unreachable (wallet untouched).\n */\n async topUp(id: string, input: TopUpInput): Promise<TopUpResult> {\n const { idempotencyKey, amount } = input;\n return this.http.post<TopUpResult>(`/me/cards/${encodeURIComponent(id)}/topup`, {\n body: { amount },\n idempotencyKey,\n });\n }\n\n /**\n * Move money from one of the caller's cards to another. Both must be\n * theirs, active, in the same currency and of the same kind. The money\n * travels through the wallet one leg at a time: when the second leg does\n * not go through, the call still resolves, `transfer.status` is\n * `on_wallet` and the money is on the wallet — never between two cards.\n * Errors carry a sentence the user can read: 400 the same card twice,\n * different currencies or different kinds · 402 the card holds less than\n * that · 404 one of the cards isn't theirs · 409 a card is frozen, closed\n * or still being issued, or the key was reused with a different body ·\n * 501/502/503 the provider cannot or will not move it.\n */\n async transfer(fromCardId: string, input: TransferInput): Promise<TransferResult> {\n const { toCardId, amount, idempotencyKey } = input;\n return this.http.post<TransferResult>(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {\n body: { to_card_id: toCardId, amount },\n idempotencyKey,\n });\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze} while\n * `status_source` is `holder` or `operator`. The optional `reason` is\n * recorded on the audit trail. Resolves to the updated card. 404 if the\n * card isn't the caller's; 409 `card_locked` when support holds it; 501 if\n * the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });\n }\n\n /**\n * Reveal the FULL PAN + CVV for the caller's own card. The signed-in\n * session is all the API asks for; the call is rate-limited and audited\n * server-side. The Takeal API never persists this data and marks the\n * response no-store; the SDK returns it verbatim and holds nothing.\n *\n * **Consumer security duties** (the SDK can't enforce these for you):\n * keep the result in volatile memory only, never write it to\n * localStorage / logs, and clear it within `expires_in_seconds`.\n *\n * The result is the numbers, or `reveal_url` with empty `pan` and `cvv`\n * when the issuer shows them on a page of its own: open that page in a\n * frame right away, it is short-lived.\n *\n * 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 `provider_unavailable`.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n return this.http.post<RevealedCard>(`/me/cards/${encodeURIComponent(id)}/reveal`);\n }\n\n /**\n * Unfreeze a previously-frozen card. Idempotent on an already-active card.\n * A card the issuer froze (`status_source: \"provider\"`) is not the\n * holder's to unfreeze: the API answers 409 `card_locked`, so hide the\n * button and say the freeze is lifted through the issuer's support.\n */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });\n }\n\n /**\n * Set the PIN of the caller's own physical card. The session is enough; the\n * call is rate-limited like {@link reveal} and the PIN is kept nowhere.\n * Resolves to the card; the user also gets a notification that the PIN\n * was set. 400 not four to six digits or the card is not active · 403 not\n * your card · 409 `card_locked`, or `provider_refused` when the issuer did\n * not take it · 429 too many attempts · 501 a virtual card has no PIN.\n */\n async setPin(id: string, input: SetPinInput): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/pin`, {\n body: { pin: input.pin },\n });\n }\n\n /**\n * Terminate the caller's own card. **One-way** — a terminated card cannot be\n * reactivated. The optional `reason` is audited. Idempotent on an\n * already-terminated card. A card that still holds money is refused (409\n * `move_balance_first` or `contact_support_to_close`): close it with\n * `client.closeRequests.request(id)` instead, and the money goes back the\n * way it was paid.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/terminate`, {\n body: { reason },\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/resources/close-requests.ts
|
|
4
|
+
var CloseRequestsResource = class {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Close a card that holds money, the rest going back the way it was paid.
|
|
10
|
+
* Asking again for the same card returns the same request. 404 no such
|
|
11
|
+
* card · 409 {@link CloseRequestError}: `no_balance` means the card holds
|
|
12
|
+
* nothing, close it with `cards.terminate()` · 503 the issuer can't be
|
|
13
|
+
* reached; the card stays as it was.
|
|
14
|
+
*/
|
|
15
|
+
async request(cardId, input = {}) {
|
|
16
|
+
return this.http.post(`/me/cards/${encodeURIComponent(cardId)}/close-request`, {
|
|
17
|
+
body: { reason: input.reason }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** Every card close request of the user, newest first. */
|
|
21
|
+
async list(opts = {}) {
|
|
22
|
+
const res = await this.http.get("/me/close-requests", {
|
|
23
|
+
signal: opts.signal
|
|
24
|
+
});
|
|
25
|
+
return res.items;
|
|
26
|
+
}
|
|
27
|
+
/** One close request. 404 when it isn't the user's. */
|
|
28
|
+
async get(id, opts = {}) {
|
|
29
|
+
return this.http.get(`/me/close-requests/${encodeURIComponent(id)}`, {
|
|
30
|
+
signal: opts.signal
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** The request for this card, if the user made one. */
|
|
34
|
+
async forCard(cardId, opts = {}) {
|
|
35
|
+
const all = await this.list(opts);
|
|
36
|
+
return all.find((r) => r.card_id === cardId) ?? null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Give a bank account or a card in the user's own name, when the request
|
|
40
|
+
* is `payout_details_required` (or `identity_check`, to correct them). 400
|
|
41
|
+
* `validation`: a name, number or bank code that doesn't look right · 409
|
|
42
|
+
* `details_not_needed`.
|
|
43
|
+
*/
|
|
44
|
+
async submitPayoutDetails(id, details) {
|
|
45
|
+
return this.http.post(
|
|
46
|
+
`/me/close-requests/${encodeURIComponent(id)}/payout-details`,
|
|
47
|
+
{ body: details }
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.CloseRequestsResource = CloseRequestsResource;
|
|
53
|
+
//# sourceMappingURL=close-requests.cjs.map
|
|
54
|
+
//# sourceMappingURL=close-requests.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/close-requests.ts"],"names":[],"mappings":";;;AAkJO,IAAM,wBAAN,MAA4B;AAAA,EACjC,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAShD,MAAM,OAAA,CAAQ,MAAA,EAAgB,KAAA,GAA6B,EAAC,EAA0B;AACpF,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,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: close a card that still holds\n * money and get what is left back the way it was paid.\n *\n * POST /me/cards/{id}/close-request → request\n * GET /me/close-requests → list\n * GET /me/close-requests/{id} → get\n * POST /me/close-requests/{id}/payout-details → submitPayoutDetails\n *\n * `cards.terminate()` refuses a card with money on it (409\n * `move_balance_first` or `contact_support_to_close`). Offer\n * `closeRequests.request(cardId)` instead: the card is closed at its issuer\n * right away, and once the issuer returns what was left on it the money goes\n * back to the payments the card was topped up with, in the currency they\n * were paid in, newest first. Unspent bonuses are not refunded, and a debt\n * the user was told about (`client.debt`) is withheld first.\n *\n * The request moves through `status`:\n *\n * - `accepted`: the card is being closed;\n * - `awaiting_issuer`: closed; the issuer has not returned the balance yet;\n * - `refunding`: the money is on its way back (`refunds`, `on_the_way`);\n * - `payout_details_required`: it can't go back the way it came. Ask the\n * user for a bank account or a card in their own name and send it with\n * {@link CloseRequestsResource.submitPayoutDetails};\n * - `identity_check`: the details are being checked (they can still be\n * corrected);\n * - `manual_payout`: checked; the transfer is being made;\n * - `refunded`: everything due went back.\n *\n * Amounts only, never rates: the user sees what the card held\n * (`balance`), what is kept back (`bonus_excluded`, `debt_withheld`), what\n * goes back in all once it is known (`refund_total`) and what went back so\n * far (`refunded`). `deadline_at` is when the refund is due by. The user is\n * notified when the close is accepted (`card_close_requested`), each time\n * money is sent back (`card_close_refund_sent`), when details are needed\n * (`card_close_payout_details_needed`) and when a transfer by hand was made\n * (`card_close_paid_manually`).\n */\n\n/** An amount with its currency, decimal string. */\nexport interface CloseAmount {\n amount: string;\n currency: string;\n}\n\n/** Where a close request stands. */\nexport type CloseRequestStatus =\n | \"accepted\"\n | \"awaiting_issuer\"\n | \"refunding\"\n | \"payout_details_required\"\n | \"identity_check\"\n | \"manual_payout\"\n | \"refunded\"\n | (string & {});\n\n/** One part of the refund. */\nexport interface CloseRefund {\n id: string;\n /** Decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** `pending` (sent, the bank has not confirmed it yet) or `succeeded`. */\n status: \"pending\" | \"succeeded\" | (string & {});\n /** `original_payment`: back to a payment's details; `manual`: transferred to the details the user gave. */\n method: \"original_payment\" | \"manual\" | (string & {});\n created_at: string;\n /** When it went through; `null` while pending. */\n completed_at: string | null;\n}\n\n/** The details given for a transfer by hand, as shown back: never the whole number. */\nexport interface PayoutDetailsShown {\n kind: \"account\" | \"card\" | (string & {});\n /** The last four digits, e.g. `•••• 4312`. */\n masked: string;\n given_at: string | null;\n}\n\n/** A request to close a card with money on it. */\nexport interface CloseRequest {\n id: string;\n card_id: string;\n card_last4: string | null;\n status: CloseRequestStatus;\n /** What the card held: what the issuer returned once it did, before that what the card showed. */\n balance: CloseAmount;\n /** Unspent bonuses, not refunded, in the card's currency; `null` until the issuer returned the balance. */\n bonus_excluded: string | null;\n /** The debt withheld, in the card's currency; `null` until the issuer returned the balance. */\n debt_withheld: string | null;\n /** Everything that goes back, in the currency the card was paid in; `null` until known. */\n refund_total: CloseAmount | null;\n /** What went back already. */\n refunded: CloseAmount;\n /** Sent and not confirmed yet. */\n on_the_way: CloseAmount;\n /** The parts of the refund, oldest first. */\n refunds: CloseRefund[];\n /** The details given for a transfer by hand, if any. */\n payout_details: PayoutDetailsShown | null;\n /** The refund is due by then. */\n deadline_at: string;\n created_at: string;\n /** When the issuer took the close. */\n closed_at: string | null;\n /** When the issuer returned the balance. */\n returned_at: string | null;\n refunded_at: string | null;\n}\n\n/**\n * Where to send the money when it can't go back the way it came. Either kind\n * must be in the user's own name. Spaces and dashes in numbers are fine.\n */\nexport type PayoutDetailsInput =\n | {\n kind: \"account\";\n /** The account holder's full name as the bank has it. */\n holder_name: string;\n account_number: string;\n /** The bank's code (BIC). */\n bank_code: string;\n bank_name?: string;\n }\n | {\n kind: \"card\";\n /** The cardholder's full name as on the card. */\n holder_name: string;\n card_number: string;\n };\n\n/** Why a close request can't be made right now (409 `code`). */\nexport type CloseRequestError =\n | \"card_locked\"\n | \"first_purchase_required\"\n | \"card_not_closable\"\n | \"topup_in_progress\"\n | \"card_closing\"\n | \"no_balance\"\n | \"provider_refused\"\n | (string & {});\n\nexport class CloseRequestsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Close a card that holds money, the rest going back the way it was paid.\n * Asking again for the same card returns the same request. 404 no such\n * card · 409 {@link CloseRequestError}: `no_balance` means the card holds\n * nothing, close it with `cards.terminate()` · 503 the issuer can't be\n * reached; the card stays as it was.\n */\n async request(cardId: string, input: { reason?: string } = {}): Promise<CloseRequest> {\n return this.http.post<CloseRequest>(`/me/cards/${encodeURIComponent(cardId)}/close-request`, {\n body: { reason: input.reason },\n });\n }\n\n /** Every card close request of the user, newest first. */\n async list(opts: { signal?: AbortSignal } = {}): Promise<CloseRequest[]> {\n const res = await this.http.get<{ items: CloseRequest[] }>(\"/me/close-requests\", {\n signal: opts.signal,\n });\n return res.items;\n }\n\n /** One close request. 404 when it isn't the user's. */\n async get(id: string, opts: { signal?: AbortSignal } = {}): Promise<CloseRequest> {\n return this.http.get<CloseRequest>(`/me/close-requests/${encodeURIComponent(id)}`, {\n signal: opts.signal,\n });\n }\n\n /** The request for this card, if the user made one. */\n async forCard(cardId: string, opts: { signal?: AbortSignal } = {}): Promise<CloseRequest | null> {\n const all = await this.list(opts);\n return all.find((r) => r.card_id === cardId) ?? null;\n }\n\n /**\n * Give a bank account or a card in the user's own name, when the request\n * is `payout_details_required` (or `identity_check`, to correct them). 400\n * `validation`: a name, number or bank code that doesn't look right · 409\n * `details_not_needed`.\n */\n async submitPayoutDetails(id: string, details: PayoutDetailsInput): Promise<CloseRequest> {\n return this.http.post<CloseRequest>(\n `/me/close-requests/${encodeURIComponent(id)}/payout-details`,\n { body: details },\n );\n }\n}\n"]}
|