@asteby/storefront-react 0.26.1 → 0.28.1
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/README.md +7 -2
- package/dist/account-server.cjs +533 -83
- package/dist/account-server.cjs.map +1 -1
- package/dist/account-server.d.cts +13 -2
- package/dist/account-server.d.ts +13 -2
- package/dist/account-server.js +23 -6
- package/dist/account-server.js.map +1 -1
- package/dist/account.cjs +572 -96
- package/dist/account.cjs.map +1 -1
- package/dist/account.d.cts +82 -45
- package/dist/account.d.ts +82 -45
- package/dist/account.js +53 -14
- package/dist/account.js.map +1 -1
- package/dist/checkout.cjs +114 -38
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +24 -1
- package/dist/checkout.d.ts +24 -1
- package/dist/checkout.js +114 -38
- package/dist/checkout.js.map +1 -1
- package/dist/{chunk-MNLROALF.js → chunk-4DZW3R33.js} +19 -2
- package/dist/chunk-4DZW3R33.js.map +1 -0
- package/dist/chunk-BXKV2KWZ.js +291 -0
- package/dist/chunk-BXKV2KWZ.js.map +1 -0
- package/dist/chunk-LIUEQENV.js +156 -0
- package/dist/chunk-LIUEQENV.js.map +1 -0
- package/dist/payments-server.cjs +17 -0
- package/dist/payments-server.cjs.map +1 -1
- package/dist/payments-server.js +2 -2
- package/dist/payments.cjs +17 -0
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.js +2 -2
- package/dist/voucher-document-FWH4DQ5N.js +72 -0
- package/dist/voucher-document-FWH4DQ5N.js.map +1 -0
- package/dist/voucher-pdf-LQC333AB.js +213 -0
- package/dist/voucher-pdf-LQC333AB.js.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-MNLROALF.js.map +0 -1
- package/dist/chunk-TXEYBDFG.js +0 -182
- package/dist/chunk-TXEYBDFG.js.map +0 -1
- package/dist/voucher-document-SFWJCLTN.js +0 -124
- package/dist/voucher-document-SFWJCLTN.js.map +0 -1
|
@@ -196,6 +196,23 @@ function checkoutToAttempt(result) {
|
|
|
196
196
|
const decline = payment.decline_code ?? "declined";
|
|
197
197
|
return { ...base, payment: { provider: payment.provider, status: "failed", outcome: "rejected", decline_code: decline, retryable: true } };
|
|
198
198
|
}
|
|
199
|
+
if (payment.outcome === "rejected") {
|
|
200
|
+
const decline = payment.decline_code ?? "declined";
|
|
201
|
+
return {
|
|
202
|
+
...base,
|
|
203
|
+
payment: {
|
|
204
|
+
provider: payment.provider,
|
|
205
|
+
status: "failed",
|
|
206
|
+
outcome: "rejected",
|
|
207
|
+
decline_code: decline,
|
|
208
|
+
retryable: payment.retryable !== false,
|
|
209
|
+
...payment.next_step ? { next_step: payment.next_step } : {},
|
|
210
|
+
...payment.message ? { message: payment.message } : {},
|
|
211
|
+
...payment.message_en ? { message_en: payment.message_en } : {}
|
|
212
|
+
},
|
|
213
|
+
...typeof payment.attempts_left === "number" ? { attempts_left: payment.attempts_left } : {}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
199
216
|
if (action?.type === "challenge") return { ...base, payment: { provider: payment.provider, status: "requires_action", outcome: "challenge", action } };
|
|
200
217
|
return { ...base, payment: { provider: payment.provider, status: "pending", outcome: "pending", action: action ?? { type: "none" } } };
|
|
201
218
|
}
|
|
@@ -244,5 +261,5 @@ function voucherRows(voucher, labels, locale) {
|
|
|
244
261
|
}
|
|
245
262
|
|
|
246
263
|
export { buildPayChoices, cashProviderData, checkoutToAttempt, choiceValue, parseChoice, payErrorResponse, paymentCsp, paymentCspHeaderName, paymentCspHeaders, paymentCspMode, paymentNonce, paymentNonceFromHeaders, paymentRecoveryMessages, safeHttpStatus, voucherRows };
|
|
247
|
-
//# sourceMappingURL=chunk-
|
|
248
|
-
//# sourceMappingURL=chunk-
|
|
264
|
+
//# sourceMappingURL=chunk-4DZW3R33.js.map
|
|
265
|
+
//# sourceMappingURL=chunk-4DZW3R33.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/payments/recovery-messages.ts","../src/payments/csp.ts","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AI,IAAA,CAAK,cAAA,CAAe,QAAQ,EAAE,SAAA,EAAW,QAAQ,SAAA,EAAW,OAAA,EAAS,UAAU,KAAA,EAAO,EAAE,MAAA,CAAO,CAAC,CAAA,GAAI,MAAM,CAAC,CAAA;AAAA,IAC5I;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT","file":"chunk-4DZW3R33.js","sourcesContent":["import type { PaymentErrorClassKind } from '@asteby/storefront'\n\n/** The notices `<PaymentRecovery>` can show. */\nexport type PaymentNoticeKind =\n /** Confirming the payment (automatic retry or status check). */\n | 'confirming'\n /** The secure card form did not load after the automatic retries. */\n | 'form_failed'\n /** The bank or provider rejected the charge (definitive): another card can be tried. */\n | 'rejected'\n /** The provider refused the charge at API level (definitive, nothing charged). */\n | 'provider_declined'\n /** Credentials or configuration of the merchant with the provider. */\n | 'merchant_config'\n /** The cart already became an order and the payment could not be reopened. */\n | 'stale_checkout'\n /** Another definitive error. */\n | 'other'\n\nexport type PaymentRecoveryMessageKey =\n | `error.${PaymentErrorClassKind}`\n | `notice.${PaymentNoticeKind}.title`\n | `notice.${PaymentNoticeKind}.body`\n | 'action.retry'\n | 'action.retry_form'\n | 'action.refresh'\n /** `{label}` is the name of the alternative payment choice. */\n | 'action.alternative'\n\nexport type PaymentRecoveryMessages = Record<PaymentRecoveryMessageKey, string>\n\nconst ES: PaymentRecoveryMessages = {\n 'error.transient': 'Estamos verificando tu pago. Si el cargo se hizo, lo veremos aquí; no te cobraremos dos veces.',\n 'error.in_progress': 'Ya hay un pago en proceso para este pedido. Estamos verificándolo; no vuelvas a pagar.',\n 'error.rate_limited': 'Hiciste varios intentos seguidos. Espera unos minutos e inténtalo de nuevo.',\n 'error.merchant_config': 'Por ahora no podemos procesar pagos con tarjeta. No es un problema con tu tarjeta: puedes pagar de otra forma.',\n 'error.provider_declined': 'No pudimos procesar tu pago con esa tarjeta. Revisa los datos o prueba con otro método; no se hizo ningún cobro.',\n 'error.stale_checkout': 'Este pedido ya quedó registrado y no se pudo reabrir el pago. Actualiza para ver cómo va tu pedido.',\n 'error.expired': 'Tu carrito venció. Vuelve a armarlo para pagar.',\n 'error.price_mismatch': 'El total cambió. Revisa el nuevo total y vuelve a pagar.',\n 'error.store_closed': 'Esta tienda aún no está abierta para compras. Vuelve pronto.',\n 'error.validation': 'Completa los campos marcados.',\n 'error.other': 'No pudimos procesar tu pago. Intenta de nuevo.',\n 'notice.confirming.title': 'Estamos confirmando tu pago…',\n 'notice.confirming.body': 'No cierres esta página ni vuelvas a pagar. Si el cargo ya se hizo, lo verás reflejado aquí.',\n 'notice.form_failed.title': 'No pudimos cargar el formulario de tarjeta',\n 'notice.form_failed.body': 'Suele resolverse al intentar de nuevo. También puedes pagar de otra forma.',\n 'notice.rejected.title': 'El cargo no se completó',\n 'notice.rejected.body': 'No se hizo ningún cobro. Puedes intentar con otra tarjeta o elegir otra forma de pago.',\n 'notice.provider_declined.title': 'No pudimos procesar tu pago con esa tarjeta',\n 'notice.provider_declined.body': 'No se hizo ningún cobro. Revisa los datos o prueba con otra tarjeta u otro método de pago.',\n 'notice.merchant_config.title': 'Por ahora no podemos cobrar con tarjeta',\n 'notice.merchant_config.body': 'No es un problema con tu tarjeta: es un tema de nuestro lado. Puedes pagar de otra forma.',\n 'notice.stale_checkout.title': 'Tu pedido ya quedó registrado',\n 'notice.stale_checkout.body': 'No pudimos reabrir el pago de este pedido. Actualiza para ver cómo va tu pedido; no se cobró de nuevo.',\n 'notice.other.title': 'No pudimos procesar tu pago',\n 'notice.other.body': 'Intenta de nuevo; si sigue igual, puedes pagar de otra forma.',\n 'action.retry': 'Reintentar pago',\n 'action.retry_form': 'Reintentar',\n 'action.refresh': 'Actualizar mi pedido',\n 'action.alternative': 'Pagar con {label}',\n}\n\nconst EN: PaymentRecoveryMessages = {\n 'error.transient': \"We're verifying your payment. If the charge went through we'll show it here; you won't be charged twice.\",\n 'error.in_progress': \"A payment is already in progress for this order. We're verifying it; don't pay again.\",\n 'error.rate_limited': 'Too many attempts in a row. Wait a few minutes and try again.',\n 'error.merchant_config': \"We can't take card payments right now. It isn't a problem with your card: you can pay another way.\",\n 'error.provider_declined': \"We couldn't process your payment with that card. Check the details or try another method; you were not charged.\",\n 'error.stale_checkout': \"This order is already registered and the payment couldn't be reopened. Refresh to see how it's going.\",\n 'error.expired': 'Your cart expired. Rebuild it to pay.',\n 'error.price_mismatch': 'The total changed. Check the new total and pay again.',\n 'error.store_closed': \"This store isn't open for purchases yet. Come back soon.\",\n 'error.validation': 'Complete the marked fields.',\n 'error.other': \"We couldn't process your payment. Try again.\",\n 'notice.confirming.title': \"We're confirming your payment…\",\n 'notice.confirming.body': \"Don't close this page or pay again. If the charge already went through you'll see it here.\",\n 'notice.form_failed.title': \"We couldn't load the card form\",\n 'notice.form_failed.body': 'Trying again usually fixes it. You can also pay another way.',\n 'notice.rejected.title': \"The charge didn't go through\",\n 'notice.rejected.body': 'You were not charged. Try another card or choose another way to pay.',\n 'notice.provider_declined.title': \"We couldn't process your payment with that card\",\n 'notice.provider_declined.body': 'You were not charged. Check the details or try another card or method.',\n 'notice.merchant_config.title': \"We can't charge cards right now\",\n 'notice.merchant_config.body': \"It isn't a problem with your card: it's on our side. You can pay another way.\",\n 'notice.stale_checkout.title': 'Your order is already registered',\n 'notice.stale_checkout.body': \"We couldn't reopen the payment for this order. Refresh to see how it's going; you were not charged again.\",\n 'notice.other.title': \"We couldn't process your payment\",\n 'notice.other.body': 'Try again; if it keeps failing you can pay another way.',\n 'action.retry': 'Retry payment',\n 'action.retry_form': 'Retry',\n 'action.refresh': 'Refresh my order',\n 'action.alternative': 'Pay with {label}',\n}\n\n/** Texts for a locale (`es*` default, `en*`), with optional overrides. Nothing here names a provider or a brand. */\nexport function paymentRecoveryMessages(locale?: string | null, overrides?: Partial<PaymentRecoveryMessages> | null): PaymentRecoveryMessages {\n const base = (locale ?? 'es-MX').toLowerCase().startsWith('en') ? EN : ES\n return overrides ? { ...base, ...overrides } : base\n}\n","import type { PaymentClient } from '@asteby/storefront'\n\nexport type PaymentCspOptions = {\n /** Per-request nonce; also set it on the inserted `<script>` and on `<Scripts nonce>`. */\n nonce?: string\n /** Extra origins by directive (e.g. your image CDN). */\n extra?: { script?: string[]; frame?: string[]; connect?: string[]; img?: string[]; form?: string[] }\n /** `report-uri` / `report-to` target for the report-only rollout. */\n reportUri?: string\n /** Inline scripts allowed by hash (`'sha256-…'`), e.g. a theme bootstrap that runs before paint. */\n scriptHashes?: string[]\n /** Allow any https image source (product photos from a CDN). */\n imgHttps?: boolean\n}\n\n/** One origin source: `https://host`, `https://*.host`, optional port. Anything else (`;`, spaces, `'unsafe-eval'`) is dropped. */\nconst ORIGIN = /^https:\\/\\/(\\*\\.)?[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*(:\\d{1,5})?$/i\n\nfunction origins(...lists: (readonly string[] | undefined)[]): string[] {\n const out = new Set<string>()\n for (const list of lists) for (const o of list ?? []) if (ORIGIN.test(o)) out.add(o)\n return [...out]\n}\n\n/**\n * Builds the Content-Security-Policy for the payment routes from what each provider declares\n * (`PaymentClient.csp`), so the shop never hard-codes provider hosts. Meant for `/pagar` only,\n * never for the whole site. Roll out as `Content-Security-Policy-Report-Only` first.\n *\n * No SRI on purpose: provider SDK URLs are unversioned and a hash would break payments on any update.\n */\nexport function paymentCsp(clients: readonly (PaymentClient | null | undefined)[], options: PaymentCspOptions = {}): string {\n const list = clients.filter((c): c is PaymentClient => !!c)\n const pick = (k: keyof NonNullable<PaymentClient['csp']>) => list.map((c) => c.csp?.[k])\n const nonce = options.nonce && /^[A-Za-z0-9+/=_-]+$/.test(options.nonce) ? options.nonce : undefined\n const sdkOrigins = list.flatMap((c) => {\n try {\n const u = new URL(c.sdk_url)\n return u.protocol === 'https:' ? [u.origin] : []\n } catch {\n return []\n }\n })\n const dir = (name: string, values: string[]) => `${name} ${values.join(' ')}`\n const parts = [\n \"default-src 'self'\",\n dir('script-src', [\"'self'\", ...(options.scriptHashes ?? []).filter((h) => /^'sha(256|384|512)-[A-Za-z0-9+/=]+'$/.test(h)), ...(nonce ? [`'nonce-${nonce}'`] : []), ...origins(sdkOrigins, ...pick('script'), options.extra?.script)]),\n dir('frame-src', origins(...pick('frame'), options.extra?.frame).length ? origins(...pick('frame'), options.extra?.frame) : [\"'none'\"]),\n dir('connect-src', [\"'self'\", ...origins(...pick('connect'), options.extra?.connect)]),\n dir('img-src', [\"'self'\", 'data:', ...(options.imgHttps ? ['https:'] : []), ...origins(...pick('img'), options.extra?.img)]),\n \"style-src 'self' 'unsafe-inline'\",\n dir('form-action', [\"'self'\", ...origins(...pick('form'), options.extra?.form)]),\n \"frame-ancestors 'none'\",\n \"base-uri 'self'\",\n \"object-src 'none'\",\n ]\n if (options.reportUri && /^(https:\\/\\/|\\/)[^\\s;,]+$/.test(options.reportUri)) parts.push(`report-uri ${options.reportUri}`)\n return parts.join('; ')\n}\n\n/** `Content-Security-Policy` or, during the rollout week, `Content-Security-Policy-Report-Only`. */\nexport function paymentCspHeaderName(reportOnly: boolean): string {\n return reportOnly ? 'Content-Security-Policy-Report-Only' : 'Content-Security-Policy'\n}\n\nexport type PaymentCspMode = 'off' | 'report-only' | 'enforce'\n\n/** `PAYMENT_CSP`-style value: `off`, `report-only` or `enforce`. Unset: report-only in production, off elsewhere (dev servers inject scripts). */\nexport function paymentCspMode(value: string | null | undefined, production: boolean): PaymentCspMode {\n const raw = (value ?? '').trim().toLowerCase()\n if (raw === 'off' || raw === 'report-only' || raw === 'enforce') return raw\n return production ? 'report-only' : 'off'\n}\n\n/** Fresh per-request nonce (128 bits, base64). Works in Node, edge and browsers. */\nexport function paymentNonce(): string {\n const bytes = new Uint8Array(16)\n crypto.getRandomValues(bytes)\n let bin = ''\n for (const b of bytes) bin += String.fromCharCode(b)\n return btoa(bin)\n}\n\n/** Header ready for the response (`{}` when `off`): policy from the providers' `client.csp`, never the whole site. */\nexport function paymentCspHeaders(\n clients: readonly (PaymentClient | null | undefined)[],\n options: PaymentCspOptions & { mode: PaymentCspMode },\n): Record<string, string> {\n if (options.mode === 'off') return {}\n return { [paymentCspHeaderName(options.mode === 'report-only')]: paymentCsp(clients, options) }\n}\n\n/** The nonce the route left in the CSP header, to hand to `ServerRouter` / `<Scripts>`. */\nexport function paymentNonceFromHeaders(headers: Headers): string | undefined {\n const csp = headers.get('Content-Security-Policy') ?? headers.get('Content-Security-Policy-Report-Only') ?? ''\n return /'nonce-([A-Za-z0-9+/=_-]+)'/.exec(csp)?.[1]\n}\n","/**\n * \"Payment method\" rows for a hybrid checkout: pure functions, no DOM and no server, so the loader, the action and the\n * browser share them.\n *\n * Rules (embedded-payment contract 1.2):\n * - Rows come ONLY from what the server publishes (`payment-methods[].options` and `.client`). No provider names and no\n * amounts live here.\n * - Card and cash are paid in the page; `wallet` and `credits` redirect to the provider.\n * - Without `client`, or with the card flagged `redirect: true`, the server does not offer `embedded`: the shop falls\n * back to the usual redirect flow.\n */\nimport { classifyPaymentError } from '@asteby/storefront'\nimport type {\n CheckoutResult,\n PaymentAttemptResult,\n PaymentClient,\n PaymentErrorClassKind,\n PaymentMethod,\n PaymentOption,\n PaymentOptionKey,\n PaymentPoint,\n} from '@asteby/storefront'\nimport { paymentRecoveryMessages, type PaymentRecoveryMessages } from './recovery-messages.js'\n\n/** One row of \"Payment method\". `value` is what travels in the form (`payment_choice`). */\nexport type PayChoice = {\n value: string\n /** Server method key (`payment_method` of the checkout). */\n methodKey: string\n /** Provider option; `null` for a method without options (the plain flow). */\n option: PaymentOptionKey | null\n /** `card` (form in the page), `cash` (voucher), `redirect` (leaves to the gateway) or `plain`. */\n mode: 'card' | 'cash' | 'redirect' | 'plain'\n /** The provider's own text (`option.label`); the shop supplies its own when missing. */\n label: string | null\n points: PaymentPoint[]\n maxInstallments: number | null\n}\n\nexport type PayChoices = {\n choices: PayChoice[]\n /** Public data to mount the card form; `null` when the server does not offer `embedded`. */\n cardClient: PaymentClient | null\n defaultValue: string | null\n}\n\nexport type BuildPayChoicesOptions = {\n /** Method keys this shop never offers even when the server publishes them (e.g. a manual transfer). */\n hide?: Iterable<string>\n}\n\nconst SEP = '|'\n\nexport function choiceValue(methodKey: string, option: PaymentOptionKey | null): string {\n return option ? `${methodKey}${SEP}${option}` : methodKey\n}\n\n/** `\"mercadopago|card\"` becomes method and option. A value without `|` is a method without options. */\nexport function parseChoice(value: string | null | undefined): { methodKey: string; option: PaymentOptionKey | null } | null {\n const raw = (value ?? '').trim()\n if (!raw) return null\n const i = raw.lastIndexOf(SEP)\n if (i === -1) return { methodKey: raw, option: null }\n const option = raw.slice(i + 1)\n if (option !== 'card' && option !== 'cash' && option !== 'wallet' && option !== 'credits') return null\n return { methodKey: raw.slice(0, i), option }\n}\n\nfunction modeOf(option: PaymentOption): PayChoice['mode'] {\n if (option.redirect || option.key === 'wallet' || option.key === 'credits') return 'redirect'\n return option.key === 'cash' ? 'cash' : 'card'\n}\n\n/**\n * Rows from `GET payment-methods`. A method with `options` unfolds into one row per option (server order); one without\n * is a single plain row. `cardClient` only exists when the card is paid in the page.\n */\nexport function buildPayChoices(methods: readonly PaymentMethod[], options: BuildPayChoicesOptions = {}): PayChoices {\n const hidden = new Set(options.hide ?? [])\n const choices: PayChoice[] = []\n let cardClient: PaymentClient | null = null\n let defaultValue: string | null = null\n for (const method of methods) {\n if (hidden.has(method.key)) continue\n const opts = method.options ?? []\n if (opts.length === 0) {\n const value = choiceValue(method.key, null)\n choices.push({ value, methodKey: method.key, option: null, mode: 'plain', label: null, points: [], maxInstallments: null })\n if (method.default && !defaultValue) defaultValue = value\n continue\n }\n opts.forEach((option, i) => {\n const mode = modeOf(option)\n const value = choiceValue(method.key, option.key)\n choices.push({\n value,\n methodKey: method.key,\n option: option.key,\n mode,\n label: option.label?.trim() || null,\n points: option.key === 'cash' ? (option.points ?? []) : [],\n maxInstallments: option.max_installments ?? null,\n })\n if (mode === 'card' && method.client && !cardClient) cardClient = method.client\n if (method.default && i === 0 && !defaultValue) defaultValue = value\n })\n }\n // A card meant for the page but without `client` cannot be mounted: it is paid by redirect.\n const usable = choices.map((c) => (c.mode === 'card' && !cardClient ? { ...c, mode: 'redirect' as const } : c))\n return { choices: usable, cardClient, defaultValue: defaultValue ?? usable[0]?.value ?? null }\n}\n\n/** Chosen cash point becomes the cash `provider_data`, built on the server from the provider's list. */\nexport function cashProviderData(points: readonly PaymentPoint[], pointId: string | null | undefined): Record<string, string> | null {\n const point = points.find((p) => p.id === pointId) ?? (pointId ? null : points[0])\n if (!point) return null\n return {\n payment_method_id: point.payment_method_id,\n ...(point.payment_point ? { payment_point: point.payment_point } : {}),\n }\n}\n\n/**\n * A checkout (`GET checkouts/:id`) as an attempt result, for polling a 3DS challenge or a payment under review.\n * It only translates server states: it never decides a payment.\n */\nexport function checkoutToAttempt(result: CheckoutResult): PaymentAttemptResult {\n const { checkout, payment, order } = result\n const action = payment.action ?? null\n const base = { checkout, ...(order ? { order } : {}) }\n const status = (checkout.status ?? '').toLowerCase()\n if (status === 'paid' || status === 'converted') return { ...base, payment: { provider: payment.provider, status: 'paid', outcome: 'approved' } }\n if (status === 'cancelled' || status === 'canceled') return { ...base, payment: { provider: payment.provider, status: 'cancelled' } }\n if (status === 'expired') return { ...base, payment: { provider: payment.provider, status: 'expired' } }\n if (status === 'failed') {\n const decline = (payment as { decline_code?: PaymentAttemptResult['payment']['decline_code'] }).decline_code ?? 'declined'\n return { ...base, payment: { provider: payment.provider, status: 'failed', outcome: 'rejected', decline_code: decline, retryable: true } }\n }\n // The latest attempt was rejected (e.g. the bank failed the 3DS challenge) but the checkout is still open for another\n // try: OPS reports `payment.outcome: 'rejected'` with the checkout `pending`. It is a rejection, never \"under review\".\n if (payment.outcome === 'rejected') {\n const decline = payment.decline_code ?? 'declined'\n return {\n ...base,\n payment: {\n provider: payment.provider,\n status: 'failed',\n outcome: 'rejected',\n decline_code: decline,\n retryable: payment.retryable !== false,\n ...(payment.next_step ? { next_step: payment.next_step } : {}),\n ...(payment.message ? { message: payment.message } : {}),\n ...(payment.message_en ? { message_en: payment.message_en } : {}),\n },\n ...(typeof payment.attempts_left === 'number' ? { attempts_left: payment.attempts_left } : {}),\n }\n }\n // Still pending: same as the last attempt left it (challenge or review), so the screen does not change.\n if (action?.type === 'challenge') return { ...base, payment: { provider: payment.provider, status: 'requires_action', outcome: 'challenge', action } }\n return { ...base, payment: { provider: payment.provider, status: 'pending', outcome: 'pending', action: action ?? { type: 'none' } } }\n}\n\n/**\n * Body `{ error: { code, message, retryable, kind, ... } }` that `createFetchTransport` and `createResilientTransport`\n * understand. `retryable` and `kind` come from `classifyPaymentError`: the browser never guesses them from the status.\n */\nexport type PayErrorBody = {\n error: { code: string; message: string; retryable: boolean; kind: PaymentErrorClassKind; field?: string; retry_after?: number; details?: unknown }\n}\n\ntype ErrorLike = {\n status?: number\n code?: string\n field?: string\n message?: string\n details?: unknown\n /** `StorefrontError.retryable`: what OPS declared. */\n retryable?: boolean | undefined\n checkoutId?: string | undefined\n retryAfter?: number | undefined\n}\n\nexport type PayErrorOptions = {\n locale?: string\n /** Replaces the default texts (`error.<kind>`). */\n messages?: Partial<PaymentRecoveryMessages>\n /** Forces the classification (for refusals the shop itself makes). */\n kind?: PaymentErrorClassKind\n /** `err.message` was written by the shop itself (a refusal it makes, such as `tooManyRequests`): always kept. */\n ownMessage?: boolean\n}\n\n/**\n * 502-504 never leave the shop's pay routes: the proxy (Traefik's `errors` middleware, a CDN) replaces them with an HTML\n * page, and the browser loses the JSON and the `Set-Cookie` of the payment session. They are answered as 500; the\n * body (`retryable`, `kind`) is what decides.\n */\nexport function safeHttpStatus(status: number): number {\n return status === 502 || status === 503 || status === 504 ? 500 : status\n}\n\n/**\n * Server error becomes a JSON response for the browser. Keeps the codes the SDK knows how to read (`price_mismatch`,\n * `payment_in_progress`, `expired`, `too_many_attempts`); the mock sends \"in progress\" in `field`, so that is checked too.\n * Always JSON, never 502-504 (see `safeHttpStatus`), always with `retryable` and `kind`.\n */\nexport function payErrorResponse(err: ErrorLike, options: PayErrorOptions = {}): { status: number; body: PayErrorBody } {\n const status = typeof err.status === 'number' && err.status >= 400 ? err.status : 503\n const { kind: classified, retryable } = classifyPaymentError({ ...err, status, checkoutId: err.checkoutId ?? null })\n const kind = options.kind ?? classified\n let code = err.code ?? (kind === 'transient' ? 'unavailable' : 'server_error')\n if (status === 409 && err.field === 'payment_in_progress') code = 'payment_in_progress'\n if (status === 429) code = 'too_many_attempts'\n if (status === 422 && err.field === 'expected_total') code = 'price_mismatch'\n // Texts the shop wrote itself (missing fields, expired cart, a row it does not offer) are kept; OPS' own message,\n // often technical or in English, is replaced by the catalog text for the kind.\n const own = (options.ownMessage || kind === 'validation' || kind === 'expired' || kind === 'price_mismatch' || (kind === 'other' && status < 500)) && err.message\n const message = own || paymentRecoveryMessages(options.locale, options.messages)[`error.${kind}`]\n return {\n status: safeHttpStatus(status),\n body: {\n error: {\n code,\n message,\n retryable: options.kind ? options.kind === 'transient' || options.kind === 'in_progress' || options.kind === 'rate_limited' : retryable,\n kind,\n ...(err.field ? { field: err.field } : {}),\n ...(err.retryAfter ? { retry_after: err.retryAfter } : {}),\n ...(err.details !== undefined ? { details: err.details } : {}),\n },\n },\n }\n}\n\nexport type VoucherRowLabels = { point: string; reference: string; clabe: string; barcode: string; expires: string }\n\n/** Cookie receipt rows for a payment under review or with a voucher (shown on the thank-you page). */\nexport function voucherRows(\n voucher: NonNullable<NonNullable<PaymentAttemptResult['payment']['action']>['voucher']> | null | undefined,\n labels: VoucherRowLabels,\n locale: string,\n): [label: string, value: string][] {\n if (!voucher) return []\n const rows: [string, string][] = []\n if (voucher.payment_point) rows.push([labels.point, String(voucher.payment_point).slice(0, 60)])\n if (voucher.reference) rows.push([labels.reference, String(voucher.reference).slice(0, 80)])\n if (voucher.clabe) rows.push([labels.clabe, String(voucher.clabe).slice(0, 40)])\n if (voucher.barcode) rows.push([labels.barcode, String(voucher.barcode).slice(0, 80)])\n if (voucher.expires_at) {\n const d = new Date(voucher.expires_at)\n if (!Number.isNaN(d.getTime())) {\n rows.push([labels.expires, new Intl.DateTimeFormat(locale, { dateStyle: 'long', timeStyle: 'short', timeZone: 'UTC' }).format(d) + ' UTC'])\n }\n }\n return rows\n}\n"]}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
// src/account/voucher.ts
|
|
2
|
+
var MAX = 256;
|
|
3
|
+
var CASH_METHODS = /* @__PURE__ */ new Set(["oxxo", "cash", "store", "convenience_store", "efectivo", "bank_deposit", "deposit", "paynet", "paycash", "bancomer", "7eleven", "seven_eleven", "farmacias_guadalajara", "circle_k"]);
|
|
4
|
+
var TRANSFER_METHODS = /* @__PURE__ */ new Set(["spei", "bank_transfer", "transfer", "wire", "clabe"]);
|
|
5
|
+
function formatOf(v) {
|
|
6
|
+
const f = typeof v === "string" ? v.toLowerCase().replace(/[^a-z0-9]/g, "") : "";
|
|
7
|
+
if (f === "code128" || f === "c128" || f === "code128b" || f === "code128c") return "code128";
|
|
8
|
+
if (f === "code39" || f === "c39") return "code39";
|
|
9
|
+
if (f === "itf" || f === "itf14" || f === "i25" || f === "interleaved2of5") return "itf";
|
|
10
|
+
if (f === "ean13") return "ean13";
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
function barcodeOf(ext, raw) {
|
|
14
|
+
if ("barcode_data" in ext) {
|
|
15
|
+
const d = ext.barcode_data;
|
|
16
|
+
if (d && typeof d === "object") {
|
|
17
|
+
const o = d;
|
|
18
|
+
const value2 = text(o.value);
|
|
19
|
+
const format = formatOf(o.format);
|
|
20
|
+
if (value2 && format && barcodeModules(value2, format)) return { draw: { value: value2, format }, text: null };
|
|
21
|
+
return { draw: null, text: value2 ?? text(raw) };
|
|
22
|
+
}
|
|
23
|
+
return { draw: null, text: text(raw) };
|
|
24
|
+
}
|
|
25
|
+
if (raw && typeof raw === "object") {
|
|
26
|
+
const o = raw;
|
|
27
|
+
const value2 = text(o.value);
|
|
28
|
+
const format = formatOf(o.format ?? "code128");
|
|
29
|
+
return { draw: value2 && format ? { value: value2, format } : null, text: null };
|
|
30
|
+
}
|
|
31
|
+
const value = text(raw);
|
|
32
|
+
return { draw: value ? { value, format: "code128" } : null, text: null };
|
|
33
|
+
}
|
|
34
|
+
function instructionsKeyOf(raw) {
|
|
35
|
+
const k = raw?.replace(/^payment\.voucher\.instructions\./, "").toLowerCase() ?? "";
|
|
36
|
+
return !k ? null : k === "other" ? "generic" : k;
|
|
37
|
+
}
|
|
38
|
+
function httpsUrl(v) {
|
|
39
|
+
const s = typeof v === "string" ? v.trim() : "";
|
|
40
|
+
return /^https:\/\//i.test(s) && s.length <= 2048 ? s : null;
|
|
41
|
+
}
|
|
42
|
+
function kindOf(kind, method, key) {
|
|
43
|
+
for (const c of [kind, method, key]) {
|
|
44
|
+
const k = c?.toLowerCase();
|
|
45
|
+
if (!k || k === "other" || k === "generic") continue;
|
|
46
|
+
if (k === "oxxo" || k === "cash" || CASH_METHODS.has(k)) return "cash";
|
|
47
|
+
if (k === "spei" || k === "transfer" || TRANSFER_METHODS.has(k)) return "transfer";
|
|
48
|
+
}
|
|
49
|
+
return "generic";
|
|
50
|
+
}
|
|
51
|
+
var digits = (s) => s ? s.replace(/\D/g, "") : "";
|
|
52
|
+
function text(v) {
|
|
53
|
+
if (typeof v === "number" && Number.isFinite(v)) return String(v);
|
|
54
|
+
if (typeof v !== "string") return null;
|
|
55
|
+
const s = v.trim().slice(0, MAX);
|
|
56
|
+
return s || null;
|
|
57
|
+
}
|
|
58
|
+
function moneyOf(v) {
|
|
59
|
+
if (!v || typeof v !== "object") return null;
|
|
60
|
+
const m = v;
|
|
61
|
+
const amount = text(m.amount);
|
|
62
|
+
const cur = text(m.currency_code);
|
|
63
|
+
return amount && cur && Number.isFinite(Number(amount)) ? { amount, currency_code: cur.toUpperCase() } : null;
|
|
64
|
+
}
|
|
65
|
+
function voucherOf(p) {
|
|
66
|
+
const pay = p?.payment;
|
|
67
|
+
if (!pay || typeof pay !== "object") return null;
|
|
68
|
+
const ext = pay;
|
|
69
|
+
const method = text(pay.method ?? pay.provider);
|
|
70
|
+
const key = instructionsKeyOf(text(ext.instructions_key));
|
|
71
|
+
const bc = barcodeOf(ext, pay.barcode);
|
|
72
|
+
const clabe = text(pay.clabe);
|
|
73
|
+
let reference = text(pay.reference);
|
|
74
|
+
if (clabe && reference && digits(reference) === digits(clabe)) reference = null;
|
|
75
|
+
const v = {
|
|
76
|
+
method,
|
|
77
|
+
reference,
|
|
78
|
+
barcode: bc.draw?.value ?? null,
|
|
79
|
+
barcode_format: bc.draw?.format ?? null,
|
|
80
|
+
barcode_text: bc.text && bc.text !== reference ? bc.text : null,
|
|
81
|
+
clabe,
|
|
82
|
+
beneficiary: text(ext.beneficiary),
|
|
83
|
+
bank: text(ext.bank),
|
|
84
|
+
kind: kindOf(text(ext.kind), method, key),
|
|
85
|
+
instructions_key: key,
|
|
86
|
+
ticket_url: httpsUrl(ext.ticket_url) ?? httpsUrl(ext.voucher_url),
|
|
87
|
+
expires_at: text(pay.expires_at) ?? text(p?.expires_at),
|
|
88
|
+
amount: moneyOf(pay.amount) ?? moneyOf(p?.total),
|
|
89
|
+
instructions: text(pay.instructions)
|
|
90
|
+
};
|
|
91
|
+
return v.reference || v.barcode || v.barcode_text || v.clabe ? v : null;
|
|
92
|
+
}
|
|
93
|
+
function barcodeValue(v) {
|
|
94
|
+
return v.barcode;
|
|
95
|
+
}
|
|
96
|
+
var BARS = [
|
|
97
|
+
"11011001100",
|
|
98
|
+
"11001101100",
|
|
99
|
+
"11001100110",
|
|
100
|
+
"10010011000",
|
|
101
|
+
"10010001100",
|
|
102
|
+
"10001001100",
|
|
103
|
+
"10011001000",
|
|
104
|
+
"10011000100",
|
|
105
|
+
"10001100100",
|
|
106
|
+
"11001001000",
|
|
107
|
+
"11001000100",
|
|
108
|
+
"11000100100",
|
|
109
|
+
"10110011100",
|
|
110
|
+
"10011011100",
|
|
111
|
+
"10011001110",
|
|
112
|
+
"10111001100",
|
|
113
|
+
"10011101100",
|
|
114
|
+
"10011100110",
|
|
115
|
+
"11001110010",
|
|
116
|
+
"11001011100",
|
|
117
|
+
"11001001110",
|
|
118
|
+
"11011100100",
|
|
119
|
+
"11001110100",
|
|
120
|
+
"11101101110",
|
|
121
|
+
"11101001100",
|
|
122
|
+
"11100101100",
|
|
123
|
+
"11100100110",
|
|
124
|
+
"11101100100",
|
|
125
|
+
"11100110100",
|
|
126
|
+
"11100110010",
|
|
127
|
+
"11011011000",
|
|
128
|
+
"11011000110",
|
|
129
|
+
"11000110110",
|
|
130
|
+
"10100011000",
|
|
131
|
+
"10001011000",
|
|
132
|
+
"10001000110",
|
|
133
|
+
"10110001000",
|
|
134
|
+
"10001101000",
|
|
135
|
+
"10001100010",
|
|
136
|
+
"11010001000",
|
|
137
|
+
"11000101000",
|
|
138
|
+
"11000100010",
|
|
139
|
+
"10110111000",
|
|
140
|
+
"10110001110",
|
|
141
|
+
"10001101110",
|
|
142
|
+
"10111011000",
|
|
143
|
+
"10111000110",
|
|
144
|
+
"10001110110",
|
|
145
|
+
"11101110110",
|
|
146
|
+
"11010001110",
|
|
147
|
+
"11000101110",
|
|
148
|
+
"11011101000",
|
|
149
|
+
"11011100010",
|
|
150
|
+
"11011101110",
|
|
151
|
+
"11101011000",
|
|
152
|
+
"11101000110",
|
|
153
|
+
"11100010110",
|
|
154
|
+
"11101101000",
|
|
155
|
+
"11101100010",
|
|
156
|
+
"11100011010",
|
|
157
|
+
"11101111010",
|
|
158
|
+
"11001000010",
|
|
159
|
+
"11110001010",
|
|
160
|
+
"10100110000",
|
|
161
|
+
"10100001100",
|
|
162
|
+
"10010110000",
|
|
163
|
+
"10010000110",
|
|
164
|
+
"10000101100",
|
|
165
|
+
"10000100110",
|
|
166
|
+
"10110010000",
|
|
167
|
+
"10110000100",
|
|
168
|
+
"10011010000",
|
|
169
|
+
"10011000010",
|
|
170
|
+
"10000110100",
|
|
171
|
+
"10000110010",
|
|
172
|
+
"11000010010",
|
|
173
|
+
"11001010000",
|
|
174
|
+
"11110111010",
|
|
175
|
+
"11000010100",
|
|
176
|
+
"10001111010",
|
|
177
|
+
"10100111100",
|
|
178
|
+
"10010111100",
|
|
179
|
+
"10010011110",
|
|
180
|
+
"10111100100",
|
|
181
|
+
"10011110100",
|
|
182
|
+
"10011110010",
|
|
183
|
+
"11110100100",
|
|
184
|
+
"11110010100",
|
|
185
|
+
"11110010010",
|
|
186
|
+
"11011011110",
|
|
187
|
+
"11011110110",
|
|
188
|
+
"11110110110",
|
|
189
|
+
"10101111000",
|
|
190
|
+
"10100011110",
|
|
191
|
+
"10001011110",
|
|
192
|
+
"10111101000",
|
|
193
|
+
"10111100010",
|
|
194
|
+
"11110101000",
|
|
195
|
+
"11110100010",
|
|
196
|
+
"10111011110",
|
|
197
|
+
"10111101110",
|
|
198
|
+
"11101011110",
|
|
199
|
+
"11110101110",
|
|
200
|
+
"11010000100",
|
|
201
|
+
"11010010000",
|
|
202
|
+
"11010011100"
|
|
203
|
+
];
|
|
204
|
+
var STOP = "1100011101011";
|
|
205
|
+
function code128Modules(value) {
|
|
206
|
+
if (!value || value.length > 80) return null;
|
|
207
|
+
let codes;
|
|
208
|
+
if (/^\d+$/.test(value) && value.length % 2 === 0) {
|
|
209
|
+
codes = [105];
|
|
210
|
+
for (let i = 0; i < value.length; i += 2) codes.push(Number(value.slice(i, i + 2)));
|
|
211
|
+
} else {
|
|
212
|
+
codes = [104];
|
|
213
|
+
for (const ch of value) {
|
|
214
|
+
const c = ch.charCodeAt(0);
|
|
215
|
+
if (c < 32 || c > 126) return null;
|
|
216
|
+
codes.push(c - 32);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
let sum = codes[0];
|
|
220
|
+
for (let i = 1; i < codes.length; i++) sum += codes[i] * i;
|
|
221
|
+
codes.push(sum % 103);
|
|
222
|
+
return codes.map((c) => BARS[c]).join("") + STOP;
|
|
223
|
+
}
|
|
224
|
+
var C39_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. */+%$";
|
|
225
|
+
var C39_WIDE = "346038238023348034234368036236058258025458045245568056256456078278027478047247678067267467018128012148014124168016126146137157357135";
|
|
226
|
+
var CODE39_PATTERNS = Object.fromEntries(
|
|
227
|
+
[...C39_CHARS].map((ch, i) => [ch, [...Array(9).keys()].map((e) => C39_WIDE.slice(i * 3, i * 3 + 3).includes(String(e)) ? "w" : "n").join("")])
|
|
228
|
+
);
|
|
229
|
+
function code39Modules(value) {
|
|
230
|
+
if (!value || value.length > 40) return null;
|
|
231
|
+
let out = "";
|
|
232
|
+
for (const ch of `*${value}*`) {
|
|
233
|
+
const p = Object.prototype.hasOwnProperty.call(CODE39_PATTERNS, ch) ? CODE39_PATTERNS[ch] : void 0;
|
|
234
|
+
if (!p || ch === "*" && value.includes("*")) return null;
|
|
235
|
+
for (let i = 0; i < 9; i++) out += (i % 2 === 0 ? "1" : "0").repeat(p[i] === "w" ? 3 : 1);
|
|
236
|
+
out += "0";
|
|
237
|
+
}
|
|
238
|
+
return out.slice(0, -1);
|
|
239
|
+
}
|
|
240
|
+
var ITF_DIGITS = ["nnwwn", "wnnnw", "nwnnw", "wwnnn", "nnwnw", "wnwnn", "nwwnn", "nnnww", "wnnwn", "nwnwn"];
|
|
241
|
+
function itfModules(value) {
|
|
242
|
+
if (!value || value.length > 80 || value.length % 2 !== 0 || !/^\d+$/.test(value)) return null;
|
|
243
|
+
let out = "1010";
|
|
244
|
+
for (let i = 0; i < value.length; i += 2) {
|
|
245
|
+
const bars = ITF_DIGITS[Number(value[i])];
|
|
246
|
+
const spaces = ITF_DIGITS[Number(value[i + 1])];
|
|
247
|
+
for (let e = 0; e < 5; e++) out += "1".repeat(bars[e] === "w" ? 3 : 1) + "0".repeat(spaces[e] === "w" ? 3 : 1);
|
|
248
|
+
}
|
|
249
|
+
return out + "11101";
|
|
250
|
+
}
|
|
251
|
+
var EAN_L = ["0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011"];
|
|
252
|
+
var EAN_R = EAN_L.map((c) => [...c].map((b) => b === "1" ? "0" : "1").join(""));
|
|
253
|
+
var EAN_G = EAN_R.map((c) => [...c].reverse().join(""));
|
|
254
|
+
var EAN_PARITY = ["LLLLLL", "LLGLGG", "LLGGLG", "LLGGGL", "LGLLGG", "LGGLLG", "LGGGLL", "LGLGLG", "LGLGGL", "LGGLGL"];
|
|
255
|
+
function ean13Modules(value) {
|
|
256
|
+
if (!/^\d{13}$/.test(value)) return null;
|
|
257
|
+
const d = [...value].map(Number);
|
|
258
|
+
const sum = d.slice(0, 12).reduce((a, n, i) => a + n * (i % 2 === 0 ? 1 : 3), 0);
|
|
259
|
+
if ((10 - sum % 10) % 10 !== d[12]) return null;
|
|
260
|
+
const parity = EAN_PARITY[d[0]];
|
|
261
|
+
let out = "101";
|
|
262
|
+
for (let i = 0; i < 6; i++) out += (parity[i] === "L" ? EAN_L : EAN_G)[d[i + 1]];
|
|
263
|
+
out += "01010";
|
|
264
|
+
for (let i = 7; i < 13; i++) out += EAN_R[d[i]];
|
|
265
|
+
return out + "101";
|
|
266
|
+
}
|
|
267
|
+
function barcodeModules(value, format = "code128") {
|
|
268
|
+
return format === "code39" ? code39Modules(value) : format === "itf" ? itfModules(value) : format === "ean13" ? ean13Modules(value) : code128Modules(value);
|
|
269
|
+
}
|
|
270
|
+
function barcodeGeometry(value, opts = {}) {
|
|
271
|
+
const bits = barcodeModules(value, opts.format);
|
|
272
|
+
if (!bits) return null;
|
|
273
|
+
const mod = opts.module ?? 2;
|
|
274
|
+
const quiet = 10;
|
|
275
|
+
const rects = [];
|
|
276
|
+
for (let i = 0; i < bits.length; ) {
|
|
277
|
+
if (bits[i] === "0") {
|
|
278
|
+
i++;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
let j = i;
|
|
282
|
+
while (j < bits.length && bits[j] === "1") j++;
|
|
283
|
+
rects.push({ x: (quiet + i) * mod, w: (j - i) * mod });
|
|
284
|
+
i = j;
|
|
285
|
+
}
|
|
286
|
+
return { width: (bits.length + quiet * 2) * mod, height: opts.height ?? 70, rects };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export { barcodeGeometry, barcodeModules, barcodeValue, code128Modules, code39Modules, voucherOf };
|
|
290
|
+
//# sourceMappingURL=chunk-BXKV2KWZ.js.map
|
|
291
|
+
//# sourceMappingURL=chunk-BXKV2KWZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/account/voucher.ts"],"names":["value"],"mappings":";AAmCA,IAAM,GAAA,GAAM,GAAA;AAKZ,IAAM,+BAAe,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,MAAA,EAAQ,SAAS,mBAAA,EAAqB,UAAA,EAAY,cAAA,EAAgB,SAAA,EAAW,UAAU,SAAA,EAAW,UAAA,EAAY,WAAW,cAAA,EAAgB,uBAAA,EAAyB,UAAU,CAAC,CAAA;AACnN,IAAM,gBAAA,uBAAuB,GAAA,CAAI,CAAC,QAAQ,eAAA,EAAiB,UAAA,EAAY,MAAA,EAAQ,OAAO,CAAC,CAAA;AAEvF,SAAS,SAAS,CAAA,EAAkC;AAClD,EAAA,MAAM,CAAA,GAAI,OAAO,CAAA,KAAM,QAAA,GAAW,CAAA,CAAE,aAAY,CAAE,OAAA,CAAQ,YAAA,EAAc,EAAE,CAAA,GAAI,EAAA;AAC9E,EAAA,IAAI,CAAA,KAAM,aAAa,CAAA,KAAM,MAAA,IAAU,MAAM,UAAA,IAAc,CAAA,KAAM,YAAY,OAAO,SAAA;AACpF,EAAA,IAAI,CAAA,KAAM,QAAA,IAAY,CAAA,KAAM,KAAA,EAAO,OAAO,QAAA;AAC1C,EAAA,IAAI,CAAA,KAAM,SAAS,CAAA,KAAM,OAAA,IAAW,MAAM,KAAA,IAAS,CAAA,KAAM,mBAAmB,OAAO,KAAA;AACnF,EAAA,IAAI,CAAA,KAAM,SAAS,OAAO,OAAA;AAC1B,EAAA,OAAO,IAAA;AACT;AAOA,SAAS,SAAA,CAAU,KAA8B,GAAA,EA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AA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,EAAA,MAAM,GAAA,GAAM,KAAK,MAAA,IAAU,CAAA;AAC3B,EAAA,MAAM,KAAA,GAAQ,EAAA;AACd,EAAA,MAAM,QAAoC,EAAC;AAC3C,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,IAAA,CAAK,MAAA,IAAU;AACjC,IAAA,IAAI,IAAA,CAAK,CAAC,CAAA,KAAM,GAAA,EAAK;AACnB,MAAA,CAAA,EAAA;AACA,MAAA;AAAA,IACF;AACA,IAAA,IAAI,CAAA,GAAI,CAAA;AACR,IAAA,OAAO,IAAI,IAAA,CAAK,MAAA,IAAU,IAAA,CAAK,CAAC,MAAM,GAAA,EAAK,CAAA,EAAA;AAC3C,IAAA,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA,EAAA,CAAI,KAAA,GAAQ,CAAA,IAAK,KAAK,CAAA,EAAA,CAAI,CAAA,GAAI,CAAA,IAAK,GAAA,EAAK,CAAA;AACrD,IAAA,CAAA,GAAI,CAAA;AAAA,EACN;AACA,EAAA,OAAO,EAAE,KAAA,EAAA,CAAQ,IAAA,CAAK,MAAA,GAAS,KAAA,GAAQ,CAAA,IAAK,GAAA,EAAK,MAAA,EAAQ,IAAA,CAAK,MAAA,IAAU,EAAA,EAAI,KAAA,EAAM;AACpF","file":"chunk-BXKV2KWZ.js","sourcesContent":["/**\n * Pure pieces of the cash voucher (OXXO, SPEI, deposit): the normalized `VoucherView` of a `PendingPayment` and the\n * Code 128 barcode (the one cashiers' readers scan). No React, no DOM: the same code draws the barcode in the page\n * (`<Barcode>`) and in the printable document (`voucher-document.ts`, loaded only when the buyer prints).\n */\nimport type { Money, PendingPayment } from '@asteby/storefront'\n\nexport type VoucherView = {\n /** `oxxo`, `spei`, ... as the gateway publishes it. */\n method: string | null\n reference: string | null\n /** Value the barcode encodes, exactly as the server sent it. `null` when the server sent none or it cannot be drawn. */\n barcode: string | null\n /** Symbology of `barcode`; `null` when there is no barcode or its format is not one we can draw. */\n barcode_format: BarcodeFormat | null\n /**\n * Code the server sent but that is NOT drawn (`barcode_data` is null or names a symbology we cannot draw): shown as\n * plain text. `null` when there is nothing to show (also when it is the same as `reference`).\n */\n barcode_text: string | null\n clabe: string | null\n /** SPEI / transfer: who receives the money and in which bank. */\n beneficiary: string | null\n bank: string | null\n /** What kind of document to print: cash at a store, bank transfer, or unknown (generic, no brand named). */\n kind: VoucherKind\n /** Server-chosen key of the instructions (`oxxo`, `spei`...); unknown keys fall back to the kind. */\n instructions_key: string | null\n /** `https` link to the provider's own receipt: `ticket_url`, else the older `voucher_url`. */\n ticket_url: string | null\n expires_at: string | null\n amount: Money | null\n instructions: string | null\n}\n\nconst MAX = 256\n\nexport type BarcodeFormat = 'code128' | 'code39' | 'itf' | 'ean13'\nexport type VoucherKind = 'cash' | 'transfer' | 'generic'\n\nconst CASH_METHODS = new Set(['oxxo', 'cash', 'store', 'convenience_store', 'efectivo', 'bank_deposit', 'deposit', 'paynet', 'paycash', 'bancomer', '7eleven', 'seven_eleven', 'farmacias_guadalajara', 'circle_k'])\nconst TRANSFER_METHODS = new Set(['spei', 'bank_transfer', 'transfer', 'wire', 'clabe'])\n\nfunction formatOf(v: unknown): BarcodeFormat | null {\n const f = typeof v === 'string' ? v.toLowerCase().replace(/[^a-z0-9]/g, '') : ''\n if (f === 'code128' || f === 'c128' || f === 'code128b' || f === 'code128c') return 'code128'\n if (f === 'code39' || f === 'c39') return 'code39'\n if (f === 'itf' || f === 'itf14' || f === 'i25' || f === 'interleaved2of5') return 'itf'\n if (f === 'ean13') return 'ean13'\n return null\n}\n\n/**\n * The barcode the server declared. `barcode_data` (contract 1.10) is authoritative when the key is present, object or\n * `null`: `value` is what to draw, `text` what to show when it cannot be drawn. Without the key (older servers) the\n * plain `barcode` string is Code 128.\n */\nfunction barcodeOf(ext: Record<string, unknown>, raw: unknown): { draw: { value: string; format: BarcodeFormat } | null; text: string | null } {\n if ('barcode_data' in ext) {\n const d = ext.barcode_data\n if (d && typeof d === 'object') {\n const o = d as Record<string, unknown>\n const value = text(o.value)\n const format = formatOf(o.format)\n if (value && format && barcodeModules(value, format)) return { draw: { value, format }, text: null }\n return { draw: null, text: value ?? text(raw) }\n }\n return { draw: null, text: text(raw) }\n }\n if (raw && typeof raw === 'object') {\n const o = raw as Record<string, unknown>\n const value = text(o.value)\n const format = formatOf(o.format ?? 'code128')\n return { draw: value && format ? { value, format } : null, text: null }\n }\n const value = text(raw)\n return { draw: value ? { value, format: 'code128' } : null, text: null }\n}\n\n/** `payment.voucher.instructions.oxxo` -> `oxxo`; `other` -> `generic`. */\nfunction instructionsKeyOf(raw: string | null): string | null {\n const k = raw?.replace(/^payment\\.voucher\\.instructions\\./, '').toLowerCase() ?? ''\n return !k ? null : k === 'other' ? 'generic' : k\n}\n\nfunction httpsUrl(v: unknown): string | null {\n const s = typeof v === 'string' ? v.trim() : ''\n return /^https:\\/\\//i.test(s) && s.length <= 2048 ? s : null\n}\n\nfunction kindOf(kind: string | null, method: string | null, key: string | null): VoucherKind {\n for (const c of [kind, method, key]) {\n const k = c?.toLowerCase()\n if (!k || k === 'other' || k === 'generic') continue\n if (k === 'oxxo' || k === 'cash' || CASH_METHODS.has(k)) return 'cash'\n if (k === 'spei' || k === 'transfer' || TRANSFER_METHODS.has(k)) return 'transfer'\n }\n return 'generic'\n}\n\nconst digits = (s: string | null) => (s ? s.replace(/\\D/g, '') : '')\n\nfunction text(v: unknown): string | null {\n if (typeof v === 'number' && Number.isFinite(v)) return String(v)\n if (typeof v !== 'string') return null\n const s = v.trim().slice(0, MAX)\n return s || null\n}\n\nfunction moneyOf(v: unknown): Money | null {\n if (!v || typeof v !== 'object') return null\n const m = v as Record<string, unknown>\n const amount = text(m.amount)\n const cur = text(m.currency_code)\n return amount && cur && Number.isFinite(Number(amount)) ? { amount, currency_code: cur.toUpperCase() } : null\n}\n\n/** The voucher of a pending payment; `null` when it has neither reference, barcode nor CLABE (nothing to pay with). */\nexport function voucherOf(p: Pick<PendingPayment, 'payment' | 'total' | 'expires_at'> | null | undefined): VoucherView | null {\n const pay = p?.payment\n if (!pay || typeof pay !== 'object') return null\n // Fields the contract adds later are read defensively: an older SDK type does not declare them yet.\n const ext = pay as Record<string, unknown>\n const method = text(pay.method ?? pay.provider)\n const key = instructionsKeyOf(text(ext.instructions_key))\n const bc = barcodeOf(ext, pay.barcode)\n const clabe = text(pay.clabe)\n let reference = text(pay.reference)\n // Some gateways publish the CLABE as the \"reference\" too: printing both reads as two different numbers.\n if (clabe && reference && digits(reference) === digits(clabe)) reference = null\n const v: VoucherView = {\n method,\n reference,\n barcode: bc.draw?.value ?? null,\n barcode_format: bc.draw?.format ?? null,\n barcode_text: bc.text && bc.text !== reference ? bc.text : null,\n clabe,\n beneficiary: text(ext.beneficiary),\n bank: text(ext.bank),\n kind: kindOf(text(ext.kind), method, key),\n instructions_key: key,\n ticket_url: httpsUrl(ext.ticket_url) ?? httpsUrl(ext.voucher_url),\n expires_at: text(pay.expires_at) ?? text(p?.expires_at),\n amount: moneyOf(pay.amount) ?? moneyOf(p?.total),\n instructions: text(pay.instructions),\n }\n return v.reference || v.barcode || v.barcode_text || v.clabe ? v : null\n}\n\n/**\n * The value the barcode encodes: only what the server sent. A reference is NOT a barcode (an OXXO reference and its\n * scannable code differ), so without `barcode` nothing is drawn and the reference is shown as text.\n */\nexport function barcodeValue(v: Pick<VoucherView, 'barcode'>): string | null {\n return v.barcode\n}\n\n// 11-module patterns of symbols 0..105 and the 13-module stop (ISO/IEC 15417).\nconst BARS = [\n '11011001100', '11001101100', '11001100110', '10010011000', '10010001100', '10001001100', '10011001000', '10011000100', '10001100100', '11001001000',\n '11001000100', '11000100100', '10110011100', '10011011100', '10011001110', '10111001100', '10011101100', '10011100110', '11001110010', '11001011100',\n '11001001110', '11011100100', '11001110100', '11101101110', '11101001100', '11100101100', '11100100110', '11101100100', '11100110100', '11100110010',\n '11011011000', '11011000110', '11000110110', '10100011000', '10001011000', '10001000110', '10110001000', '10001101000', '10001100010', '11010001000',\n '11000101000', '11000100010', '10110111000', '10110001110', '10001101110', '10111011000', '10111000110', '10001110110', '11101110110', '11010001110',\n '11000101110', '11011101000', '11011100010', '11011101110', '11101011000', '11101000110', '11100010110', '11101101000', '11101100010', '11100011010',\n '11101111010', '11001000010', '11110001010', '10100110000', '10100001100', '10010110000', '10010000110', '10000101100', '10000100110', '10110010000',\n '10110000100', '10011010000', '10011000010', '10000110100', '10000110010', '11000010010', '11001010000', '11110111010', '11000010100', '10001111010',\n '10100111100', '10010111100', '10010011110', '10111100100', '10011110100', '10011110010', '11110100100', '11110010100', '11110010010', '11011011110',\n '11011110110', '11110110110', '10101111000', '10100011110', '10001011110', '10111101000', '10111100010', '11110101000', '11110100010', '10111011110',\n '10111101110', '11101011110', '11110101110', '11010000100', '11010010000', '11010011100',\n]\nconst STOP = '1100011101011'\n\n/**\n * Modules (`1` bar, `0` space) of the Code 128 of `value`: set C (digit pairs) when it is all digits of even length,\n * set B (printable ASCII) otherwise. `null` when it cannot be encoded.\n */\nexport function code128Modules(value: string): string | null {\n if (!value || value.length > 80) return null\n let codes: number[]\n if (/^\\d+$/.test(value) && value.length % 2 === 0) {\n codes = [105]\n for (let i = 0; i < value.length; i += 2) codes.push(Number(value.slice(i, i + 2)))\n } else {\n codes = [104]\n for (const ch of value) {\n const c = ch.charCodeAt(0)\n if (c < 32 || c > 126) return null\n codes.push(c - 32)\n }\n }\n let sum = codes[0]!\n for (let i = 1; i < codes.length; i++) sum += codes[i]! * i\n codes.push(sum % 103)\n return codes.map((c) => BARS[c]).join('') + STOP\n}\n\n// Code 39: 9 elements per character (bar, space, bar...), 3 of them wide (3 modules, the rest 1). Per character, in\n// order of `C39_CHARS`, the indices (0..8) of its wide elements. One narrow gap separates characters.\nconst C39_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. */+%$'\nconst C39_WIDE = '346038238023348034234368036236058258025458045245568056256456078278027478047247678067267467018128012148014124168016126146137157357135'\n/** Code 39 patterns as `n`/`w` strings per character (exported for the tests). */\nexport const CODE39_PATTERNS: Record<string, string> = Object.fromEntries(\n [...C39_CHARS].map((ch, i) => [ch, [...Array(9).keys()].map((e) => (C39_WIDE.slice(i * 3, i * 3 + 3).includes(String(e)) ? 'w' : 'n')).join('')]),\n)\n\n/** Modules of the Code 39 of `value` (`*` start/stop added). `null` for lower case, `*` or anything outside its set. */\nexport function code39Modules(value: string): string | null {\n if (!value || value.length > 40) return null\n let out = ''\n for (const ch of `*${value}*`) {\n const p = Object.prototype.hasOwnProperty.call(CODE39_PATTERNS, ch) ? CODE39_PATTERNS[ch] : undefined\n if (!p || (ch === '*' && value.includes('*'))) return null\n for (let i = 0; i < 9; i++) out += (i % 2 === 0 ? '1' : '0').repeat(p[i] === 'w' ? 3 : 1)\n out += '0'\n }\n return out.slice(0, -1)\n}\n\n// Interleaved 2 of 5: digits in pairs, the first of each pair in the bars, the second in the spaces. Per digit the\n// 5 elements as `n`/`w` (wide = 3 modules). Start: bar-space-bar-space narrow; stop: wide bar, narrow space, narrow bar.\nconst ITF_DIGITS = ['nnwwn', 'wnnnw', 'nwnnw', 'wwnnn', 'nnwnw', 'wnwnn', 'nwwnn', 'nnnww', 'wnnwn', 'nwnwn']\n\n/** Modules of the ITF (Interleaved 2 of 5) of `value`: digits only, even count. `null` otherwise. */\nexport function itfModules(value: string): string | null {\n if (!value || value.length > 80 || value.length % 2 !== 0 || !/^\\d+$/.test(value)) return null\n let out = '1010'\n for (let i = 0; i < value.length; i += 2) {\n const bars = ITF_DIGITS[Number(value[i])]!\n const spaces = ITF_DIGITS[Number(value[i + 1])]!\n for (let e = 0; e < 5; e++) out += '1'.repeat(bars[e] === 'w' ? 3 : 1) + '0'.repeat(spaces[e] === 'w' ? 3 : 1)\n }\n return out + '11101'\n}\n\nconst EAN_L = ['0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011']\nconst EAN_R = EAN_L.map((c) => [...c].map((b) => (b === '1' ? '0' : '1')).join(''))\nconst EAN_G = EAN_R.map((c) => [...c].reverse().join(''))\nconst EAN_PARITY = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL']\n\n/** Modules (95) of the EAN-13 of `value`: exactly 13 digits whose last one is the correct check digit. `null` otherwise. */\nexport function ean13Modules(value: string): string | null {\n if (!/^\\d{13}$/.test(value)) return null\n const d = [...value].map(Number)\n const sum = d.slice(0, 12).reduce((a, n, i) => a + n * (i % 2 === 0 ? 1 : 3), 0)\n if ((10 - (sum % 10)) % 10 !== d[12]) return null\n const parity = EAN_PARITY[d[0]!]!\n let out = '101'\n for (let i = 0; i < 6; i++) out += (parity[i] === 'L' ? EAN_L : EAN_G)[d[i + 1]!]\n out += '01010'\n for (let i = 7; i < 13; i++) out += EAN_R[d[i]!]\n return out + '101'\n}\n\n/** Modules of `value` in the given symbology. */\nexport function barcodeModules(value: string, format: BarcodeFormat = 'code128'): string | null {\n return format === 'code39' ? code39Modules(value) : format === 'itf' ? itfModules(value) : format === 'ean13' ? ean13Modules(value) : code128Modules(value)\n}\n\nexport type BarcodeGeometry = { width: number; height: number; rects: { x: number; w: number }[] }\n\n/** Bars of the barcode as rectangles (quiet zone of 10 modules each side included in `width`). `null` if not encodable. */\nexport function barcodeGeometry(value: string, opts: { module?: number; height?: number; format?: BarcodeFormat } = {}): BarcodeGeometry | null {\n const bits = barcodeModules(value, opts.format)\n if (!bits) return null\n const mod = opts.module ?? 2\n const quiet = 10\n const rects: { x: number; w: number }[] = []\n for (let i = 0; i < bits.length; ) {\n if (bits[i] === '0') {\n i++\n continue\n }\n let j = i\n while (j < bits.length && bits[j] === '1') j++\n rects.push({ x: (quiet + i) * mod, w: (j - i) * mod })\n i = j\n }\n return { width: (bits.length + quiet * 2) * mod, height: opts.height ?? 70, rects }\n}\n"]}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// src/account/voucher-text.ts
|
|
2
|
+
var KEEP_ES = "Conserva tu comprobante: confirmaremos tu pago autom\xE1ticamente.";
|
|
3
|
+
var KEEP_EN = "Keep your receipt: we will confirm your payment automatically.";
|
|
4
|
+
var ES = {
|
|
5
|
+
title: "Ficha de pago",
|
|
6
|
+
total: "Total a pagar",
|
|
7
|
+
reference: "Referencia",
|
|
8
|
+
clabe: "CLABE",
|
|
9
|
+
beneficiary: "Beneficiario",
|
|
10
|
+
bank: "Banco",
|
|
11
|
+
expires: "Vence",
|
|
12
|
+
expiresNote: "Pasada esa fecha la ficha deja de ser v\xE1lida.",
|
|
13
|
+
order: "Pedido",
|
|
14
|
+
barcode: "C\xF3digo de barras",
|
|
15
|
+
code: "C\xF3digo",
|
|
16
|
+
print: "Imprimir",
|
|
17
|
+
downloadPdf: "Descargar PDF",
|
|
18
|
+
noScript: "Para imprimir usa la opci\xF3n Imprimir de tu navegador (Ctrl+P) o descarga el PDF.",
|
|
19
|
+
stepsTitle: "C\xF3mo pagar",
|
|
20
|
+
footer: "Tu pedido se genera cuando se confirma el pago. Esta ficha es de un solo uso; no la compartas.",
|
|
21
|
+
methods: { oxxo: "OXXO", spei: "Transferencia SPEI", bank_transfer: "Transferencia bancaria", bank_deposit: "Dep\xF3sito bancario", cash: "Pago en efectivo" },
|
|
22
|
+
cash: "Pago en efectivo",
|
|
23
|
+
steps: {
|
|
24
|
+
oxxo: (v) => [
|
|
25
|
+
"Acude a cualquier tienda OXXO y di que vas a hacer un pago de servicio en efectivo.",
|
|
26
|
+
v.barcode ? "Muestra el c\xF3digo de barras en caja o dicta la referencia, y paga el monto exacto." : "Dicta la referencia en caja y paga el monto exacto.",
|
|
27
|
+
KEEP_ES
|
|
28
|
+
],
|
|
29
|
+
cash: (v) => [
|
|
30
|
+
"Acude a la tienda o comercio indicado y di que vas a hacer un pago en efectivo.",
|
|
31
|
+
v.barcode ? "Muestra el c\xF3digo de barras o dicta la referencia, y paga el monto exacto." : "Dicta la referencia y paga el monto exacto.",
|
|
32
|
+
KEEP_ES
|
|
33
|
+
],
|
|
34
|
+
spei: (v) => [
|
|
35
|
+
"Entra a la banca en l\xEDnea o a la app de tu banco.",
|
|
36
|
+
"Haz una transferencia SPEI a la CLABE indicada, por el monto exacto.",
|
|
37
|
+
...v.reference ? ["Escribe la referencia de esta ficha en el concepto o referencia de la transferencia."] : [],
|
|
38
|
+
KEEP_ES
|
|
39
|
+
],
|
|
40
|
+
bank_transfer: (v) => [
|
|
41
|
+
"Entra a la banca en l\xEDnea o a la app de tu banco.",
|
|
42
|
+
"Haz una transferencia a la cuenta o CLABE indicada, por el monto exacto.",
|
|
43
|
+
...v.reference ? ["Escribe la referencia de esta ficha en el concepto de la transferencia."] : [],
|
|
44
|
+
KEEP_ES
|
|
45
|
+
],
|
|
46
|
+
bank_deposit: (v) => [
|
|
47
|
+
"Acude a una sucursal del banco indicado o a su cajero con dep\xF3sitos.",
|
|
48
|
+
`Deposita el monto exacto a la cuenta${v.reference ? " con la referencia de esta ficha" : " indicada"}.`,
|
|
49
|
+
KEEP_ES
|
|
50
|
+
],
|
|
51
|
+
transfer: (v) => [
|
|
52
|
+
"Entra a la banca en l\xEDnea o a la app de tu banco.",
|
|
53
|
+
"Haz una transferencia a la CLABE indicada, por el monto exacto.",
|
|
54
|
+
...v.reference ? ["Escribe la referencia de esta ficha en el concepto de la transferencia."] : [],
|
|
55
|
+
KEEP_ES
|
|
56
|
+
],
|
|
57
|
+
generic: () => ["Realiza el pago con los datos de esta ficha, por el monto exacto y antes de que venza.", KEEP_ES]
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var EN = {
|
|
61
|
+
title: "Payment voucher",
|
|
62
|
+
total: "Amount to pay",
|
|
63
|
+
reference: "Reference",
|
|
64
|
+
clabe: "CLABE",
|
|
65
|
+
beneficiary: "Beneficiary",
|
|
66
|
+
bank: "Bank",
|
|
67
|
+
expires: "Expires",
|
|
68
|
+
expiresNote: "After that date the voucher is no longer valid.",
|
|
69
|
+
order: "Order",
|
|
70
|
+
barcode: "Barcode",
|
|
71
|
+
code: "Code",
|
|
72
|
+
print: "Print",
|
|
73
|
+
downloadPdf: "Download PDF",
|
|
74
|
+
noScript: "To print, use your browser's Print option (Ctrl+P) or download the PDF.",
|
|
75
|
+
stepsTitle: "How to pay",
|
|
76
|
+
footer: "Your order is created when the payment is confirmed. This voucher is single-use; do not share it.",
|
|
77
|
+
methods: { oxxo: "OXXO", spei: "SPEI transfer", bank_transfer: "Bank transfer", bank_deposit: "Bank deposit", cash: "Cash payment" },
|
|
78
|
+
cash: "Cash payment",
|
|
79
|
+
steps: {
|
|
80
|
+
oxxo: (v) => [
|
|
81
|
+
"Go to any OXXO store and say you want to make a cash service payment.",
|
|
82
|
+
v.barcode ? "Show the barcode at the register or read out the reference, and pay the exact amount." : "Read out the reference at the register and pay the exact amount.",
|
|
83
|
+
KEEP_EN
|
|
84
|
+
],
|
|
85
|
+
cash: (v) => [
|
|
86
|
+
"Go to the store indicated and say you want to make a cash payment.",
|
|
87
|
+
v.barcode ? "Show the barcode or read out the reference, and pay the exact amount." : "Read out the reference and pay the exact amount.",
|
|
88
|
+
KEEP_EN
|
|
89
|
+
],
|
|
90
|
+
spei: (v) => [
|
|
91
|
+
"Open your online banking or your bank app.",
|
|
92
|
+
"Make a SPEI transfer to the CLABE below for the exact amount.",
|
|
93
|
+
...v.reference ? ["Enter the reference of this voucher as the transfer concept or reference."] : [],
|
|
94
|
+
KEEP_EN
|
|
95
|
+
],
|
|
96
|
+
bank_transfer: (v) => [
|
|
97
|
+
"Open your online banking or your bank app.",
|
|
98
|
+
"Make a transfer to the account or CLABE below for the exact amount.",
|
|
99
|
+
...v.reference ? ["Enter the reference of this voucher as the transfer concept."] : [],
|
|
100
|
+
KEEP_EN
|
|
101
|
+
],
|
|
102
|
+
bank_deposit: (v) => [
|
|
103
|
+
"Go to a branch of the bank indicated or to one of its deposit ATMs.",
|
|
104
|
+
`Deposit the exact amount to the account${v.reference ? " with the reference of this voucher" : " indicated"}.`,
|
|
105
|
+
KEEP_EN
|
|
106
|
+
],
|
|
107
|
+
transfer: (v) => [
|
|
108
|
+
"Open your online banking or your bank app.",
|
|
109
|
+
"Make a transfer to the CLABE below for the exact amount.",
|
|
110
|
+
...v.reference ? ["Enter the reference of this voucher as the transfer concept."] : [],
|
|
111
|
+
KEEP_EN
|
|
112
|
+
],
|
|
113
|
+
generic: () => ["Make the payment with the details of this voucher, for the exact amount and before it expires.", KEEP_EN]
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
var isEnglish = (locale) => locale.toLowerCase().startsWith("en");
|
|
117
|
+
function docText(locale) {
|
|
118
|
+
return isEnglish(locale) ? EN : ES;
|
|
119
|
+
}
|
|
120
|
+
var own = (o, k) => {
|
|
121
|
+
const key = k?.toLowerCase();
|
|
122
|
+
return key && Object.prototype.hasOwnProperty.call(o, key) ? o[key] : void 0;
|
|
123
|
+
};
|
|
124
|
+
function methodName(v, t) {
|
|
125
|
+
return v.method ? own(t.methods, v.method) ?? v.method : t.cash;
|
|
126
|
+
}
|
|
127
|
+
function voucherSteps(v, t) {
|
|
128
|
+
const fn = own(t.steps, v.instructions_key) ?? own(t.steps, v.method) ?? (v.kind === "cash" ? t.steps.cash : v.kind === "transfer" ? t.steps.transfer : t.steps.generic);
|
|
129
|
+
return fn(v);
|
|
130
|
+
}
|
|
131
|
+
function voucherFields(v, t) {
|
|
132
|
+
const f = (key, label, value) => value ? [{ key, label, value }] : [];
|
|
133
|
+
return v.kind === "transfer" ? [...f("beneficiary", t.beneficiary, v.beneficiary), ...f("bank", t.bank, v.bank), ...f("clabe", t.clabe, v.clabe), ...f("reference", t.reference, v.reference), ...f("code", t.code, v.barcode_text)] : [...f("reference", t.reference, v.reference), ...f("clabe", t.clabe, v.clabe), ...f("beneficiary", t.beneficiary, v.beneficiary), ...f("bank", t.bank, v.bank), ...f("code", t.code, v.barcode_text)];
|
|
134
|
+
}
|
|
135
|
+
function formatMoney(m, locale) {
|
|
136
|
+
if (!m) return "";
|
|
137
|
+
try {
|
|
138
|
+
return new Intl.NumberFormat(locale, { style: "currency", currency: m.currency_code }).format(Number(m.amount));
|
|
139
|
+
} catch {
|
|
140
|
+
return `${m.amount} ${m.currency_code}`;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function formatDate(iso, locale, timeZone) {
|
|
144
|
+
if (!iso) return "";
|
|
145
|
+
const d = new Date(iso);
|
|
146
|
+
if (Number.isNaN(d.getTime())) return "";
|
|
147
|
+
try {
|
|
148
|
+
return d.toLocaleString(locale, { dateStyle: "long", timeStyle: "short", ...timeZone ? { timeZone } : {} });
|
|
149
|
+
} catch {
|
|
150
|
+
return d.toISOString();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export { docText, formatDate, formatMoney, methodName, voucherFields, voucherSteps };
|
|
155
|
+
//# sourceMappingURL=chunk-LIUEQENV.js.map
|
|
156
|
+
//# sourceMappingURL=chunk-LIUEQENV.js.map
|