@aglyn/plugins-commerce 1.15.2 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +13 -13
- package/src/lib/components/cart.js +2 -1
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/console/payments-settings-card.component.js +6 -1
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-api.d.ts +5 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +2 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js +13 -6
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-tender-panel.component.js +7 -4
- package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -1
- package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
- package/src/lib/components/console/product-add-ons-fields.component.js +96 -3
- package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
- package/src/lib/components/console/product-builder-fields.component.d.ts +39 -0
- package/src/lib/components/console/product-builder-fields.component.js +195 -0
- package/src/lib/components/console/product-builder-fields.component.js.map +1 -0
- package/src/lib/components/console/product-editor-dialog.component.js +35 -2
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-editor-dialog.component.js +43 -6
- package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-messages.component.d.ts +21 -0
- package/src/lib/components/console/quote-messages.component.js +185 -0
- package/src/lib/components/console/quote-messages.component.js.map +1 -0
- package/src/lib/components/console/quote-pay-link.component.js +1 -1
- package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
- package/src/lib/components/console/quote-proofs.component.js +30 -3
- package/src/lib/components/console/quote-proofs.component.js.map +1 -1
- package/src/lib/components/console/quote-settings-card.component.d.ts +7 -3
- package/src/lib/components/console/quote-settings-card.component.js +154 -24
- package/src/lib/components/console/quote-settings-card.component.js.map +1 -1
- package/src/lib/components/product-builder-context.d.ts +22 -0
- package/src/lib/components/product-builder-context.js +21 -0
- package/src/lib/components/product-builder-context.js.map +1 -0
- package/src/lib/components/product-builder-mockup.d.ts +42 -0
- package/src/lib/components/product-builder-mockup.js +120 -0
- package/src/lib/components/product-builder-mockup.js.map +1 -0
- package/src/lib/components/product-builder-sample.d.ts +63 -0
- package/src/lib/components/product-builder-sample.js +96 -0
- package/src/lib/components/product-builder-sample.js.map +1 -0
- package/src/lib/components/product-choice-cards.d.ts +51 -0
- package/src/lib/components/product-choice-cards.js +311 -0
- package/src/lib/components/product-choice-cards.js.map +1 -0
- package/src/lib/components/product-detail-panels.d.ts +42 -0
- package/src/lib/components/product-detail-panels.js +185 -0
- package/src/lib/components/product-detail-panels.js.map +1 -0
- package/src/lib/components/product-detail.d.ts +20 -12
- package/src/lib/components/product-detail.js +136 -221
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.d.ts +7 -0
- package/src/lib/components/product-grid.js +11 -8
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/product-options-field-body.d.ts +9 -8
- package/src/lib/components/product-options-field-body.js +152 -3
- package/src/lib/components/product-options-field-body.js.map +1 -1
- package/src/lib/components/product-options-field.js +1 -1
- package/src/lib/components/product-options-field.js.map +1 -1
- package/src/lib/components/product-photo-fit.d.ts +49 -0
- package/src/lib/components/product-photo-fit.js +58 -0
- package/src/lib/components/product-photo-fit.js.map +1 -0
- package/src/lib/components/product-restock-notify.d.ts +12 -0
- package/src/lib/components/product-restock-notify.js +86 -0
- package/src/lib/components/product-restock-notify.js.map +1 -0
- package/src/lib/components/quote-messages-panel.d.ts +21 -0
- package/src/lib/components/quote-messages-panel.js +191 -0
- package/src/lib/components/quote-messages-panel.js.map +1 -0
- package/src/lib/components/quote-page-body.js +15 -1
- package/src/lib/components/quote-page-body.js.map +1 -1
- package/src/lib/components/quote-proof-panel.d.ts +6 -3
- package/src/lib/components/quote-proof-panel.js +139 -14
- package/src/lib/components/quote-proof-panel.js.map +1 -1
- package/src/lib/components/related-products.d.ts +7 -0
- package/src/lib/components/related-products.js +8 -6
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/constants/quote-page.d.ts +8 -0
- package/src/lib/constants/quote-page.js +11 -0
- package/src/lib/constants/quote-page.js.map +1 -1
- package/src/lib/model/commerce-cart.d.ts +6 -1
- package/src/lib/model/commerce-cart.js +5 -1
- package/src/lib/model/commerce-cart.js.map +1 -1
- package/src/lib/model/commerce-invoices.js +5 -1
- package/src/lib/model/commerce-invoices.js.map +1 -1
- package/src/lib/model/commerce-pos-ops.d.ts +3 -0
- package/src/lib/model/commerce-pos-ops.js +3 -0
- package/src/lib/model/commerce-pos-ops.js.map +1 -1
- package/src/lib/model/commerce-pos.d.ts +8 -0
- package/src/lib/model/commerce-pos.js.map +1 -1
- package/src/lib/model/commerce-quote-messages.d.ts +106 -0
- package/src/lib/model/commerce-quote-messages.js +146 -0
- package/src/lib/model/commerce-quote-messages.js.map +1 -0
- package/src/lib/model/commerce-quote-pay.d.ts +31 -2
- package/src/lib/model/commerce-quote-pay.js +31 -7
- package/src/lib/model/commerce-quote-pay.js.map +1 -1
- package/src/lib/model/commerce-quote-proofs.d.ts +47 -8
- package/src/lib/model/commerce-quote-proofs.js +73 -18
- package/src/lib/model/commerce-quote-proofs.js.map +1 -1
- package/src/lib/model/commerce-quote-request.d.ts +14 -4
- package/src/lib/model/commerce-quote-request.js +25 -2
- package/src/lib/model/commerce-quote-request.js.map +1 -1
- package/src/lib/model/commerce-quotes.d.ts +56 -3
- package/src/lib/model/commerce-quotes.js +47 -2
- package/src/lib/model/commerce-quotes.js.map +1 -1
- package/src/lib/model/commerce.d.ts +12 -1
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/pos-cellular.d.ts +5 -0
- package/src/lib/model/pos-cellular.js.map +1 -1
- package/src/lib/model/product-card-rules.d.ts +41 -0
- package/src/lib/model/product-card-rules.js +90 -0
- package/src/lib/model/product-card-rules.js.map +1 -0
- package/src/lib/model/product-modifiers.d.ts +11 -0
- package/src/lib/model/product-modifiers.js +10 -0
- package/src/lib/model/product-modifiers.js.map +1 -1
- package/src/lib/model/product-write.d.ts +3 -0
- package/src/lib/server/billing-webhook.js +6 -2
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +15 -0
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/channel-order-updates.js +15 -1
- package/src/lib/server/channel-order-updates.js.map +1 -1
- package/src/lib/server/channel-orders.js +20 -0
- package/src/lib/server/channel-orders.js.map +1 -1
- package/src/lib/server/checkout.js +1 -1
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/local-fulfillment.js +1 -1
- package/src/lib/server/local-fulfillment.js.map +1 -1
- package/src/lib/server/pos-cellular-billing.d.ts +1 -1
- package/src/lib/server/pos-cellular-billing.js +2 -1
- package/src/lib/server/pos-cellular-billing.js.map +1 -1
- package/src/lib/server/pos-cellular.d.ts +3 -1
- package/src/lib/server/pos-cellular.js +15 -8
- package/src/lib/server/pos-cellular.js.map +1 -1
- package/src/lib/server/pos-offline-sync.d.ts +3 -3
- package/src/lib/server/pos-offline-sync.js +17 -4
- package/src/lib/server/pos-offline-sync.js.map +1 -1
- package/src/lib/server/pos-order.js +17 -6
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.js +27 -11
- package/src/lib/server/pos-payment.js.map +1 -1
- package/src/lib/server/pos-reader-splash.js +10 -5
- package/src/lib/server/pos-reader-splash.js.map +1 -1
- package/src/lib/server/pos-readers.js +34 -10
- package/src/lib/server/pos-readers.js.map +1 -1
- package/src/lib/server/pos-return.js +19 -3
- package/src/lib/server/pos-return.js.map +1 -1
- package/src/lib/server/pos-stripe.d.ts +14 -0
- package/src/lib/server/pos-stripe.js +6 -2
- package/src/lib/server/pos-stripe.js.map +1 -1
- package/src/lib/server/pos-terminal-connection-token.js +23 -9
- package/src/lib/server/pos-terminal-connection-token.js.map +1 -1
- package/src/lib/server/pos-terminal.d.ts +80 -14
- package/src/lib/server/pos-terminal.js +393 -123
- package/src/lib/server/pos-terminal.js.map +1 -1
- package/src/lib/server/product-drafts.d.ts +1 -1
- package/src/lib/server/product-drafts.js +4 -3
- package/src/lib/server/product-drafts.js.map +1 -1
- package/src/lib/server/product-writer.js +5 -4
- package/src/lib/server/product-writer.js.map +1 -1
- package/src/lib/server/product.d.ts +11 -0
- package/src/lib/server/product.js +18 -3
- package/src/lib/server/product.js.map +1 -1
- package/src/lib/server/products-write.js +4 -3
- package/src/lib/server/products-write.js.map +1 -1
- package/src/lib/server/quote-email.d.ts +26 -0
- package/src/lib/server/quote-email.js +73 -7
- package/src/lib/server/quote-email.js.map +1 -1
- package/src/lib/server/quote-messages.d.ts +72 -0
- package/src/lib/server/quote-messages.js +356 -0
- package/src/lib/server/quote-messages.js.map +1 -0
- package/src/lib/server/quote-pay.d.ts +42 -0
- package/src/lib/server/quote-pay.js +81 -4
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/quote-proofs.d.ts +1 -1
- package/src/lib/server/quote-proofs.js +63 -19
- package/src/lib/server/quote-proofs.js.map +1 -1
- package/src/lib/server/quote.d.ts +12 -0
- package/src/lib/server/quote.js +44 -14
- package/src/lib/server/quote.js.map +1 -1
- package/src/lib/server/refund.js +3 -1
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/reserve-stock.js +9 -0
- package/src/lib/server/reserve-stock.js.map +1 -1
- package/src/lib/server/returns.js +15 -1
- package/src/lib/server/returns.js.map +1 -1
- package/src/lib/server/reviews.js +15 -0
- package/src/lib/server/reviews.js.map +1 -1
- package/src/lib/server/sold-out-drop.d.ts +58 -0
- package/src/lib/server/sold-out-drop.js +81 -0
- package/src/lib/server/sold-out-drop.js.map +1 -0
- package/src/lib/server/stock-levels.js +9 -0
- package/src/lib/server/stock-levels.js.map +1 -1
- package/src/lib/server/stripe-refund.d.ts +7 -0
- package/src/lib/server/stripe-refund.js +26 -7
- package/src/lib/server/stripe-refund.js.map +1 -1
- package/src/lib/server.js +2 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/tenant-emails.js +85 -2
- package/src/lib/tenant-emails.js.map +1 -1
- package/src/lib/testing/fake-seller-payment-account.d.ts +29 -0
- package/src/lib/testing/fake-seller-payment-account.js +40 -0
- package/src/lib/testing/fake-seller-payment-account.js.map +1 -0
- package/src/lib/transfer/product-transfer.js +6 -5
- package/src/lib/transfer/product-transfer.js.map +1 -1
- package/src/lib/transfer/products.server.js +4 -3
- package/src/lib/transfer/products.server.js.map +1 -1
- package/src/lib/utils/quote-email-content.d.ts +6 -0
- package/src/lib/utils/quote-email-content.js +6 -3
- package/src/lib/utils/quote-email-content.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-api.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport type * as CommerceModel from '../../../model'\nimport type { PosRegisterSettings } from '../../../plugin-config'\n\n/**\n * The register's client half (AGL-3607): one place that knows the routes, so\n * the components ask \"take cash\" rather than building requests. Every call\n * that starts a payment carries the attempt key it is given; the server\n * derives the payment from it, so a retried press finds the same payment.\n */\n\n/** The open sale as the server reports it after every change. */\nexport interface PosSaleSummary {\n orderId: string\n status: string\n totalCents: number\n paidCents: number\n dueCents: number\n tenderableCents: number\n tipCents: number\n payments: Array<{\n id: string\n method: CommerceModel.OrderPaymentMethod\n amountCents: number\n tipCents?: number\n status: CommerceModel.OrderPaymentStatus\n cardBrand?: string\n last4?: string\n changeCents?: number\n checkoutUrl?: string\n readerId?: string\n /** What a store-credit payment's provider calls it (AGL-3640). */\n creditLabel?: string\n failureMessage?: string\n livemode?: boolean\n }>\n}\n\nexport interface PosTenderResult {\n sale: PosSaleSummary\n paymentId?: string\n completed: boolean\n clientSecret?: string\n paymentIntentId?: string\n}\n\nexport interface PosRegisterContext {\n settings: PosRegisterSettings\n terminal: { available: boolean; testMode: boolean }\n readers: Array<{\n id: string\n label: string\n registerId: string | null\n status: string\n livemode: boolean\n }>\n publishableKey: string\n smsReceipts: boolean\n /** Store credit other plugins keep, taken as a tender (AGL-3640). */\n credits?: Array<{ providerId: string; label: string; lookup: boolean }>\n}\n\n/** A store-credit account a staff lookup found (AGL-3640). */\nexport interface PosCreditAccount {\n reference: string\n label: string\n last4: string\n availableCents: number\n detail?: string\n}\n\ntype User = Parameters<typeof authorizedFetch>[0]\n\nexport class PosRequestError extends Error {\n constructor(\n message: string,\n readonly status: number,\n ) {\n super(message)\n }\n}\n\nasync function call<T>(\n user: User,\n route: string,\n body: Record<string, unknown>,\n options: { attemptKey?: string; method?: 'GET' | 'POST' } = {},\n): Promise<T> {\n const method = options.method ?? 'POST'\n const url =\n method === 'GET'\n ? `${route}?${new URLSearchParams(\n Object.entries(body).map(([key, value]) => [key, String(value)]),\n ).toString()}`\n : route\n const response = await authorizedFetch(user, url, {\n method,\n headers: {\n ...(method === 'POST' ? { 'Content-Type': 'application/json' } : {}),\n ...(options.attemptKey ? { 'Idempotency-Key': options.attemptKey } : {}),\n },\n ...(method === 'POST' ? { body: JSON.stringify(body) } : {}),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n throw new PosRequestError(String(payload?.error ?? 'Something went wrong'), response.status)\n }\n return payload as T\n}\n\n/** A fresh attempt key, for one press of one tender. */\nexport function newAttemptKey(): string {\n return (\n globalThis.crypto?.randomUUID?.() ??\n `${Date.now()}-${Math.random().toString(36).slice(2)}`\n )\n}\n\nexport function posRegisterContext(user: User, hostId: string) {\n return call<PosRegisterContext>(user, '/api/commerce/pos-payment', { action: 'context', hostId }, { method: 'GET' })\n}\n\n/** Prices the basket on the server and opens a sale with an empty ledger. */\nexport function openPosSale(\n user: User,\n attemptKey: string,\n body: {\n hostId: string\n registerId: string\n lines: unknown[]\n discountPct: number\n customerEmail?: string\n /** The person the register's customer lookup attached (AGL-3609). */\n customer?: unknown\n /** A PIN-switched cashier's signed assertion (AGL-3609). */\n cashierAssertion?: string\n locationId?: string\n },\n) {\n return call<{ orderId: string; totals: CommerceModel.OrderTotals; dueCents: number; stockWarnings?: unknown[] }>(\n user,\n '/api/commerce/pos-order',\n { ...body, payment: 'open' },\n { attemptKey },\n )\n}\n\nexport type PosTenderAction =\n | 'cash'\n | 'gift-card'\n | 'credit'\n | 'folio'\n | 'card-present'\n | 'card-present-sdk'\n | 'card-keyed'\n | 'card-link'\n | 'status'\n | 'cancel'\n | 'retry'\n | 'simulate'\n | 'void'\n | 'receipt'\n\nexport function posTender(\n user: User,\n hostId: string,\n orderId: string,\n action: PosTenderAction,\n body: Record<string, unknown> = {},\n attemptKey?: string,\n) {\n return call<PosTenderResult>(\n user,\n '/api/commerce/pos-payment',\n { ...body, action, hostId, orderId },\n attemptKey ? { attemptKey } : {},\n )\n}\n\nexport function posGiftCardBalance(user: User, hostId: string, code: string) {\n return call<{ availableCents: number; frozen: boolean; voided: boolean; last4: string }>(\n user,\n '/api/commerce/pos-payment',\n { action: 'gift-card-balance', hostId, code },\n )\n}\n\n/** Finds store-credit accounts by a customer's email or code (AGL-3640). */\nexport function posCreditLookup(user: User, hostId: string, providerId: string, query: string) {\n return call<{ providerId: string; accounts: PosCreditAccount[] }>(user, '/api/commerce/pos-payment', {\n action: 'credit-lookup',\n hostId,\n providerId,\n query,\n })\n}\n\nexport function posDisplayCall<T = any>(\n user: User,\n body: Record<string, unknown>,\n method: 'GET' | 'POST' = 'POST',\n) {\n return call<T>(user, '/api/commerce/pos-display', body, { method })\n}\n\n/** The register's side of the self-service kiosk (AGL-3623): its queue of \"pay at counter\" orders. */\nexport function posKioskCall<T = any>(\n user: User,\n body: Record<string, unknown>,\n method: 'GET' | 'POST' = 'POST',\n) {\n return call<T>(user, '/api/commerce/pos-kiosk', body, { method })\n}\n\nexport function posReadersCall<T = any>(user: User, body: Record<string, unknown>) {\n return call<T>(user, '/api/commerce/pos-readers', body)\n}\n\n/** Cents as the register shows them. */\nexport const usd = (cents: number) => `$${(Math.max(0, cents) / 100).toFixed(2)}`\n\n/** A dollar string the cashier typed, as whole cents (NaN-safe, never negative). */\nexport function centsFromInput(value: string): number {\n const number = Math.round(Number(String(value).replace(/[^0-9.]/g, '')) * 100)\n return Number.isFinite(number) && number > 0 ? number : 0\n}\n\n/*==========================================\n * THE NATIVE BRIDGE (AGL-3618).\n *\n * The POS companion app loads this register in a WebView and injects\n * `window.AglynPosBridge`. When it is there, the register offers a third\n * card option — Tap to Pay or a Bluetooth reader — and hands the app a\n * PaymentIntent the SERVER created (`card-present-sdk`); the app collects\n * the card with the Stripe Terminal SDK and the register settles it exactly\n * like a smart-reader payment, by asking the server.\n *=========================================*/\n\nexport interface AglynPosBridge {\n collectCardPayment(input: {\n paymentIntentId: string\n clientSecret: string\n amountCents: number\n }): Promise<{ status: 'collected' | 'canceled' | 'failed'; message?: string }>\n}\n\nexport function posNativeBridge(): AglynPosBridge | null {\n const bridge = (globalThis as { AglynPosBridge?: AglynPosBridge }).AglynPosBridge\n return bridge && typeof bridge.collectCardPayment === 'function' ? bridge : null\n}\n"],"names":["authorizedFetch","PosRequestError","Error","message","status","call","user","route","body","options","method","url","URLSearchParams","Object","entries","map","key","value","String","toString","response","headers","attemptKey","JSON","stringify","payload","json","catch","ok","error","newAttemptKey","globalThis","crypto","randomUUID","Date","now","Math","random","slice","posRegisterContext","hostId","action","openPosSale","payment","posTender","orderId","posGiftCardBalance","code","posCreditLookup","providerId","query","posDisplayCall","posKioskCall","posReadersCall","usd","cents","max","toFixed","centsFromInput","number","round","Number","replace","isFinite","posNativeBridge","bridge","AglynPosBridge","collectCardPayment"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,eAAe,QAAQ,2CAA0C;AAyE1E,OAAO,MAAMC,wBAAwBC;IACnC,YACEC,OAAe,EACf,AAASC,MAAc,CACvB;QACA,KAAK,CAACD,eAFGC,SAAAA;IAGX;AACF;AAEA,eAAeC,KACbC,IAAU,EACVC,KAAa,EACbC,IAA6B,EAC7BC,UAA4D,CAAC,CAAC;QAE/CA;IAAf,MAAMC,UAASD,kBAAAA,QAAQC,MAAM,YAAdD,kBAAkB;IACjC,MAAME,MACJD,WAAW,QACP,GAAGH,MAAM,CAAC,EAAE,IAAIK,gBACdC,OAAOC,OAAO,CAACN,MAAMO,GAAG,CAAC,CAAC,CAACC,KAAKC,MAAM,GAAK;YAACD;YAAKE,OAAOD;SAAO,GAC/DE,QAAQ,IAAI,GACdZ;IACN,MAAMa,WAAW,MAAMpB,gBAAgBM,MAAMK,KAAK;QAChDD;QACAW,SAAS,aACHX,WAAW,SAAS;YAAE,gBAAgB;QAAmB,IAAI,CAAC,GAC9DD,QAAQa,UAAU,GAAG;YAAE,mBAAmBb,QAAQa,UAAU;QAAC,IAAI,CAAC;OAEpEZ,WAAW,SAAS;QAAEF,MAAMe,KAAKC,SAAS,CAAChB;IAAM,IAAI,CAAC;IAE5D,MAAMiB,UAAU,MAAML,SAASM,IAAI,GAAGC,KAAK,CAAC,IAAO,CAAA,CAAC,CAAA;IACpD,IAAI,CAACP,SAASQ,EAAE,EAAE;;QAChB,MAAM,IAAI3B,gBAAgBiB,eAAOO,2BAAAA,QAASI,KAAK,mBAAI,yBAAyBT,SAAShB,MAAM;IAC7F;I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nE;AAEA,oGAAoG,GACpG,OAAO,SAAS0C,aACd9C,IAAU,EACVE,IAA6B,EAC7BE,SAAyB,MAAM;IAE/B,OAAOL,KAAQC,MAAM,2BAA2BE,MAAM;QAAEE;IAAO;AACjE;AAEA,OAAO,SAAS2C,eAAwB/C,IAAU,EAAEE,IAA6B;IAC/E,OAAOH,KAAQC,MAAM,6BAA6BE;AACpD;AAEA,sCAAsC,GACtC,OAAO,MAAM8C,MAAM,CAACC,QAAkB,CAAC,CAAC,EAAE,AAACnB,CAAAA,KAAKoB,GAAG,CAAC,GAAGD,SAAS,GAAE,EAAGE,OAAO,CAAC,IAAI,CAAA;AAEjF,kFAAkF,GAClF,OAAO,SAASC,eAAezC,KAAa;IAC1C,MAAM0C,SAASvB,KAAKwB,KAAK,CAACC,OAAO3C,OAAOD,OAAO6C,OAAO,CAAC,YAAY,OAAO;IAC1E,OAAOD,OAAOE,QAAQ,CAACJ,WAAWA,SAAS,IAAIA,SAAS;AAC1D;AAqBA,OAAO,SAASK;IACd,MAAMC,SAAS,AAAClC,WAAmDmC,cAAc;IACjF,OAAOD,UAAU,OAAOA,OAAOE,kBAAkB,KAAK,aAAaF,SAAS;AAC9E"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-api.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport type * as CommerceModel from '../../../model'\nimport type { PosRegisterSettings } from '../../../plugin-config'\n\n/**\n * The register's client half (AGL-3607): one place that knows the routes, so\n * the components ask \"take cash\" rather than building requests. Every call\n * that starts a payment carries the attempt key it is given; the server\n * derives the payment from it, so a retried press finds the same payment.\n */\n\n/** The open sale as the server reports it after every change. */\nexport interface PosSaleSummary {\n orderId: string\n status: string\n totalCents: number\n paidCents: number\n dueCents: number\n tenderableCents: number\n tipCents: number\n payments: Array<{\n id: string\n method: CommerceModel.OrderPaymentMethod\n amountCents: number\n tipCents?: number\n status: CommerceModel.OrderPaymentStatus\n cardBrand?: string\n last4?: string\n changeCents?: number\n checkoutUrl?: string\n readerId?: string\n /** What a store-credit payment's provider calls it (AGL-3640). */\n creditLabel?: string\n failureMessage?: string\n livemode?: boolean\n }>\n}\n\nexport interface PosTenderResult {\n sale: PosSaleSummary\n paymentId?: string\n completed: boolean\n clientSecret?: string\n paymentIntentId?: string\n /**\n * For a typed card on a store that sells on its own Stripe account: the\n * account the intent lives on, which the Payment Element loads Stripe for.\n */\n stripeAccount?: string\n}\n\nexport interface PosRegisterContext {\n settings: PosRegisterSettings\n terminal: { available: boolean; testMode: boolean }\n readers: Array<{\n id: string\n label: string\n registerId: string | null\n status: string\n livemode: boolean\n }>\n publishableKey: string\n smsReceipts: boolean\n /** Store credit other plugins keep, taken as a tender (AGL-3640). */\n credits?: Array<{ providerId: string; label: string; lookup: boolean }>\n}\n\n/** A store-credit account a staff lookup found (AGL-3640). */\nexport interface PosCreditAccount {\n reference: string\n label: string\n last4: string\n availableCents: number\n detail?: string\n}\n\ntype User = Parameters<typeof authorizedFetch>[0]\n\nexport class PosRequestError extends Error {\n constructor(\n message: string,\n readonly status: number,\n ) {\n super(message)\n }\n}\n\nasync function call<T>(\n user: User,\n route: string,\n body: Record<string, unknown>,\n options: { attemptKey?: string; method?: 'GET' | 'POST' } = {},\n): Promise<T> {\n const method = options.method ?? 'POST'\n const url =\n method === 'GET'\n ? `${route}?${new URLSearchParams(\n Object.entries(body).map(([key, value]) => [key, String(value)]),\n ).toString()}`\n : route\n const response = await authorizedFetch(user, url, {\n method,\n headers: {\n ...(method === 'POST' ? { 'Content-Type': 'application/json' } : {}),\n ...(options.attemptKey ? { 'Idempotency-Key': options.attemptKey } : {}),\n },\n ...(method === 'POST' ? { body: JSON.stringify(body) } : {}),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n throw new PosRequestError(String(payload?.error ?? 'Something went wrong'), response.status)\n }\n return payload as T\n}\n\n/** A fresh attempt key, for one press of one tender. */\nexport function newAttemptKey(): string {\n return (\n globalThis.crypto?.randomUUID?.() ??\n `${Date.now()}-${Math.random().toString(36).slice(2)}`\n )\n}\n\nexport function posRegisterContext(user: User, hostId: string) {\n return call<PosRegisterContext>(user, '/api/commerce/pos-payment', { action: 'context', hostId }, { method: 'GET' })\n}\n\n/** Prices the basket on the server and opens a sale with an empty ledger. */\nexport function openPosSale(\n user: User,\n attemptKey: string,\n body: {\n hostId: string\n registerId: string\n lines: unknown[]\n discountPct: number\n customerEmail?: string\n /** The person the register's customer lookup attached (AGL-3609). */\n customer?: unknown\n /** A PIN-switched cashier's signed assertion (AGL-3609). */\n cashierAssertion?: string\n locationId?: string\n },\n) {\n return call<{ orderId: string; totals: CommerceModel.OrderTotals; dueCents: number; stockWarnings?: unknown[] }>(\n user,\n '/api/commerce/pos-order',\n { ...body, payment: 'open' },\n { attemptKey },\n )\n}\n\nexport type PosTenderAction =\n | 'cash'\n | 'gift-card'\n | 'credit'\n | 'folio'\n | 'card-present'\n | 'card-present-sdk'\n | 'card-keyed'\n | 'card-link'\n | 'status'\n | 'cancel'\n | 'retry'\n | 'simulate'\n | 'void'\n | 'receipt'\n\nexport function posTender(\n user: User,\n hostId: string,\n orderId: string,\n action: PosTenderAction,\n body: Record<string, unknown> = {},\n attemptKey?: string,\n) {\n return call<PosTenderResult>(\n user,\n '/api/commerce/pos-payment',\n { ...body, action, hostId, orderId },\n attemptKey ? { attemptKey } : {},\n )\n}\n\nexport function posGiftCardBalance(user: User, hostId: string, code: string) {\n return call<{ availableCents: number; frozen: boolean; voided: boolean; last4: string }>(\n user,\n '/api/commerce/pos-payment',\n { action: 'gift-card-balance', hostId, code },\n )\n}\n\n/** Finds store-credit accounts by a customer's email or code (AGL-3640). */\nexport function posCreditLookup(user: User, hostId: string, providerId: string, query: string) {\n return call<{ providerId: string; accounts: PosCreditAccount[] }>(user, '/api/commerce/pos-payment', {\n action: 'credit-lookup',\n hostId,\n providerId,\n query,\n })\n}\n\nexport function posDisplayCall<T = any>(\n user: User,\n body: Record<string, unknown>,\n method: 'GET' | 'POST' = 'POST',\n) {\n return call<T>(user, '/api/commerce/pos-display', body, { method })\n}\n\n/** The register's side of the self-service kiosk (AGL-3623): its queue of \"pay at counter\" orders. */\nexport function posKioskCall<T = any>(\n user: User,\n body: Record<string, unknown>,\n method: 'GET' | 'POST' = 'POST',\n) {\n return call<T>(user, '/api/commerce/pos-kiosk', body, { method })\n}\n\nexport function posReadersCall<T = any>(user: User, body: Record<string, unknown>) {\n return call<T>(user, '/api/commerce/pos-readers', body)\n}\n\n/** Cents as the register shows them. */\nexport const usd = (cents: number) => `$${(Math.max(0, cents) / 100).toFixed(2)}`\n\n/** A dollar string the cashier typed, as whole cents (NaN-safe, never negative). */\nexport function centsFromInput(value: string): number {\n const number = Math.round(Number(String(value).replace(/[^0-9.]/g, '')) * 100)\n return Number.isFinite(number) && number > 0 ? number : 0\n}\n\n/*==========================================\n * THE NATIVE BRIDGE (AGL-3618).\n *\n * The POS companion app loads this register in a WebView and injects\n * `window.AglynPosBridge`. When it is there, the register offers a third\n * card option — Tap to Pay or a Bluetooth reader — and hands the app a\n * PaymentIntent the SERVER created (`card-present-sdk`); the app collects\n * the card with the Stripe Terminal SDK and the register settles it exactly\n * like a smart-reader payment, by asking the server.\n *=========================================*/\n\nexport interface AglynPosBridge {\n collectCardPayment(input: {\n paymentIntentId: string\n clientSecret: string\n amountCents: number\n }): Promise<{ status: 'collected' | 'canceled' | 'failed'; message?: string }>\n}\n\nexport function posNativeBridge(): AglynPosBridge | null {\n const bridge = (globalThis as { AglynPosBridge?: AglynPosBridge }).AglynPosBridge\n return bridge && typeof bridge.collectCardPayment === 'function' ? bridge : null\n}\n"],"names":["authorizedFetch","PosRequestError","Error","message","status","call","user","route","body","options","method","url","URLSearchParams","Object","entries","map","key","value","String","toString","response","headers","attemptKey","JSON","stringify","payload","json","catch","ok","error","newAttemptKey","globalThis","crypto","randomUUID","Date","now","Math","random","slice","posRegisterContext","hostId","action","openPosSale","payment","posTender","orderId","posGiftCardBalance","code","posCreditLookup","providerId","query","posDisplayCall","posKioskCall","posReadersCall","usd","cents","max","toFixed","centsFromInput","number","round","Number","replace","isFinite","posNativeBridge","bridge","AglynPosBridge","collectCardPayment"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,eAAe,QAAQ,2CAA0C;AA8E1E,OAAO,MAAMC,wBAAwBC;IACnC,YACEC,OAAe,EACf,AAASC,MAAc,CACvB;QACA,KAAK,CAACD,eAFGC,SAAAA;IAGX;AACF;AAEA,eAAeC,KACbC,IAAU,EACVC,KAAa,EACbC,IAA6B,EAC7BC,UAA4D,CAAC,CAAC;QAE/CA;IAAf,MAAMC,UAASD,kBAAAA,QAAQC,MAAM,YAAdD,kBAAkB;IACjC,MAAME,MACJD,WAAW,QACP,GAAGH,MAAM,CAAC,EAAE,IAAIK,gBACdC,OAAOC,OAAO,CAACN,MAAMO,GAAG,CAAC,CAAC,CAACC,KAAKC,MAAM,GAAK;YAACD;YAAKE,OAAOD;SAAO,GAC/DE,QAAQ,IAAI,GACdZ;IACN,MAAMa,WAAW,MAAMpB,gBAAgBM,MAAMK,KAAK;QAChDD;QACAW,SAAS,aACHX,WAAW,SAAS;YAAE,gBAAgB;QAAmB,IAAI,CAAC,GAC9DD,QAAQa,UAAU,GAAG;YAAE,mBAAmBb,QAAQa,UAAU;QAAC,IAAI,CAAC;OAEpEZ,WAAW,SAAS;QAAEF,MAAMe,KAAKC,SAAS,CAAChB;IAAM,IAAI,CAAC;IAE5D,M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Aa;IAC3F,OAAO7C,KAA2DC,MAAM,6BAA6B;QACnGmC,QAAQ;QACRD;QACAS;QACAC;IACF;AACF;AAEA,OAAO,SAASC,eACd7C,IAAU,EACVE,IAA6B,EAC7BE,SAAyB,MAAM;IAE/B,OAAOL,KAAQC,MAAM,6BAA6BE,MAAM;QAAEE;IAAO;AACnE;AAEA,oGAAoG,GACpG,OAAO,SAAS0C,aACd9C,IAAU,EACVE,IAA6B,EAC7BE,SAAyB,MAAM;IAE/B,OAAOL,KAAQC,MAAM,2BAA2BE,MAAM;QAAEE;IAAO;AACjE;AAEA,OAAO,SAAS2C,eAAwB/C,IAAU,EAAEE,IAA6B;IAC/E,OAAOH,KAAQC,MAAM,6BAA6BE;AACpD;AAEA,sCAAsC,GACtC,OAAO,MAAM8C,MAAM,CAACC,QAAkB,CAAC,CAAC,EAAE,AAACnB,CAAAA,KAAKoB,GAAG,CAAC,GAAGD,SAAS,GAAE,EAAGE,OAAO,CAAC,IAAI,CAAA;AAEjF,kFAAkF,GAClF,OAAO,SAASC,eAAezC,KAAa;IAC1C,MAAM0C,SAASvB,KAAKwB,KAAK,CAACC,OAAO3C,OAAOD,OAAO6C,OAAO,CAAC,YAAY,OAAO;IAC1E,OAAOD,OAAOE,QAAQ,CAACJ,WAAWA,SAAS,IAAIA,SAAS;AAC1D;AAqBA,OAAO,SAASK;IACd,MAAMC,SAAS,AAAClC,WAAmDmC,cAAc;IACjF,OAAOD,UAAU,OAAOA,OAAOE,kBAAkB,KAAK,aAAaF,SAAS;AAC9E"}
|
|
@@ -48,6 +48,8 @@ export declare function PosQrDialog(props: {
|
|
|
48
48
|
export declare function PosKeyedCardDialog(props: {
|
|
49
49
|
clientSecret: string;
|
|
50
50
|
publishableKey: string;
|
|
51
|
+
/** A direct-charge store's own account, where its intent lives; empty for the platform. */
|
|
52
|
+
stripeAccount?: string;
|
|
51
53
|
amountCents: number;
|
|
52
54
|
onClose: () => void;
|
|
53
55
|
onConfirmed: () => void;
|
|
@@ -331,11 +331,14 @@ import { POS_TOUCH_PX } from "./pos-product-grid.component.js";
|
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
const stripePromises = new Map();
|
|
334
|
-
function stripeFor(publishableKey) {
|
|
335
|
-
|
|
334
|
+
/** Stripe for the key, on the store's own account when it sells on one. */ function stripeFor(publishableKey, stripeAccount) {
|
|
335
|
+
const key = `${publishableKey}|${stripeAccount}`;
|
|
336
|
+
let promise = stripePromises.get(key);
|
|
336
337
|
if (!promise) {
|
|
337
|
-
promise = loadStripe(publishableKey
|
|
338
|
-
|
|
338
|
+
promise = stripeAccount ? loadStripe(publishableKey, {
|
|
339
|
+
stripeAccount
|
|
340
|
+
}) : loadStripe(publishableKey);
|
|
341
|
+
stripePromises.set(key, promise);
|
|
339
342
|
}
|
|
340
343
|
return promise;
|
|
341
344
|
}
|
|
@@ -345,8 +348,12 @@ function stripeFor(publishableKey) {
|
|
|
345
348
|
* PaymentIntent and records the payment from Stripe, never from this form's
|
|
346
349
|
* say-so.
|
|
347
350
|
*/ export function PosKeyedCardDialog(props) {
|
|
348
|
-
const stripe = useMemo(()=>
|
|
349
|
-
|
|
351
|
+
const stripe = useMemo(()=>{
|
|
352
|
+
var _props_stripeAccount;
|
|
353
|
+
return props.publishableKey ? stripeFor(props.publishableKey, (_props_stripeAccount = props.stripeAccount) != null ? _props_stripeAccount : '') : null;
|
|
354
|
+
}, [
|
|
355
|
+
props.publishableKey,
|
|
356
|
+
props.stripeAccount
|
|
350
357
|
]);
|
|
351
358
|
return /*#__PURE__*/ _jsxs(Dialog, {
|
|
352
359
|
open: Boolean(props.clientSecret),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-tender-dialogs.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n Alert,\n Box,\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n List,\n ListItemButton,\n ListItemText,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { Elements, PaymentElement, useElements, useStripe } from '@stripe/react-stripe-js'\n// `/pure`: the Stripe script loads when a typed card is actually taken, not\n// whenever the register mounts (the AGL-2486 reasoning).\nimport { loadStripe } from '@stripe/stripe-js/pure'\nimport type { Stripe } from '@stripe/stripe-js'\nimport { QRCodeSVG } from 'qrcode.react'\nimport { useMemo, useState } from 'react'\nimport { centsFromInput, usd, type PosCreditAccount } from './pos-api'\nimport { POS_TOUCH_PX } from './pos-product-grid.component'\n\n/*==========================================\n * The register's tender dialogs (AGL-3607). Each collects what its tender\n * needs and hands it to the tender panel, which owns the request.\n *=========================================*/\n\n/** Cash: what the customer handed over, with one-tap round-ups. */\nexport function PosCashDialog(props: {\n open: boolean\n dueCents: number\n tipCents: number\n busy: boolean\n onClose: () => void\n onTake: (tenderedCents: number) => void\n}) {\n const [received, setReceived] = useState('')\n const owed = props.dueCents + props.tipCents\n const tendered = centsFromInput(received)\n const quick = [...new Set([owed, Math.ceil(owed / 500) * 500, Math.ceil(owed / 1000) * 1000, Math.ceil(owed / 2000) * 2000])]\n .filter((value) => value >= owed)\n .slice(0, 4)\n const close = () => {\n setReceived('')\n props.onClose()\n }\n return (\n <Dialog open={props.open} onClose={close} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Cash — ${usd(owed)}`}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label=\"Cash received ($)\"\n value={received}\n onChange={(event) => setReceived(event.target.value.replace(/[^0-9.]/g, ''))}\n autoFocus\n sx={{ mt: 1 }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n <Stack direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap' }}>\n {quick.map((cents) => (\n <Button\n key={cents}\n variant=\"outlined\"\n onClick={() => setReceived((cents / 100).toFixed(2))}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {cents === owed ? 'Exact' : usd(cents)}\n </Button>\n ))}\n </Stack>\n {tendered > 0 && tendered >= owed ? (\n <Alert severity=\"success\">{`Change: ${usd(tendered - owed)}`}</Alert>\n ) : tendered > 0 && tendered < owed ? (\n <Alert severity=\"info\">\n {`Takes ${usd(Math.max(0, tendered - props.tipCents))} toward the sale; ${usd(owed - tendered)} left to pay.`}\n </Alert>\n ) : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={close} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n disabled={props.busy || tendered <= props.tipCents}\n onClick={() => {\n props.onTake(tendered)\n setReceived('')\n }}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {'Take cash'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\n/** A gift card: type or scan the code, see the balance, apply it. */\nexport function PosGiftCardDialog(props: {\n open: boolean\n busy: boolean\n onClose: () => void\n onCheck: (code: string) => Promise<{ availableCents: number; frozen: boolean; voided: boolean } | null>\n onApply: (code: string) => void\n}) {\n const [code, setCode] = useState('')\n const [balance, setBalance] = useState<string | null>(null)\n const close = () => {\n setCode('')\n setBalance(null)\n props.onClose()\n }\n return (\n <Dialog open={props.open} onClose={close} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{'Gift card'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label=\"Gift card code\"\n value={code}\n onChange={(event) => {\n setCode(event.target.value.toUpperCase())\n setBalance(null)\n }}\n onKeyDown={async (event) => {\n if (event.key !== 'Enter' || !code.trim()) return\n const answer = await props.onCheck(code)\n setBalance(\n answer\n ? answer.frozen\n ? 'This card is on hold.'\n : answer.voided\n ? 'This card was voided.'\n : `Available: ${usd(answer.availableCents)}`\n : null,\n )\n }}\n autoFocus\n sx={{ mt: 1 }}\n slotProps={{ htmlInput: { autoComplete: 'off', autoCapitalize: 'characters' } }}\n />\n {balance ? <Alert severity=\"info\">{balance}</Alert> : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={close} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Cancel'}\n </Button>\n <Button\n disabled={!code.trim()}\n onClick={async () => {\n const answer = await props.onCheck(code)\n setBalance(\n answer\n ? answer.frozen\n ? 'This card is on hold.'\n : `Available: ${usd(answer.availableCents)}`\n : null,\n )\n }}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {'Check balance'}\n </Button>\n <Button\n variant=\"contained\"\n disabled={props.busy || !code.trim()}\n onClick={() => {\n props.onApply(code)\n setCode('')\n setBalance(null)\n }}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {'Apply card'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\n/** Charge to a checked-in stay's folio. */\nexport function PosFolioDialog(props: {\n open: boolean\n amountCents: number\n stays: any[]\n busy: boolean\n onClose: () => void\n onCharge: (reservationId: string) => void\n}) {\n const [stay, setStay] = useState('')\n return (\n <Dialog open={props.open} onClose={props.onClose} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Charge to room — ${usd(props.amountCents)}`}</DialogTitle>\n <DialogContent>\n <TextField\n label=\"Checked-in stay\"\n value={stay}\n onChange={(event) => setStay(event.target.value)}\n select\n fullWidth\n sx={{ mt: 1 }}\n >\n {props.stays.map((entry: any) => (\n <MenuItem key={entry.$id} value={entry.$id}>\n {entry.guestName ?? entry.guestEmail ?? entry.$id}\n </MenuItem>\n ))}\n </TextField>\n </DialogContent>\n <DialogActions>\n <Button onClick={props.onClose} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n disabled={props.busy || !stay}\n onClick={() => props.onCharge(stay)}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {'Charge folio'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\n/**\n * The QR payment page. Encoded in this browser, never fetched (AGL-1671): a\n * live payment URL in a third party's query string is a link that pays the\n * sale for whoever opens it.\n */\nexport function PosQrDialog(props: { url: string; amountCents: number; onClose: () => void }) {\n return (\n <Dialog open={Boolean(props.url)} onClose={props.onClose} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Scan to pay ${usd(props.amountCents)}`}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ mt: 1 }}>\n {'The customer scans this and pays on their phone. The payment shows ' +\n 'here as soon as it goes through.'}\n </Typography>\n <Box sx={{ display: 'flex', justifyContent: 'center' }}>\n <QRCodeSVG value={props.url} size={256} level=\"L\" marginSize={4} title=\"Payment QR\" role=\"img\" />\n </Box>\n <Button href={props.url} target=\"_blank\" rel=\"noopener noreferrer\">\n {'Open payment page'}\n </Button>\n </DialogContent>\n <DialogActions>\n <Button onClick={props.onClose} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Close'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\nconst stripePromises = new Map<string, Promise<Stripe | null>>()\n\nfunction stripeFor(publishableKey: string): Promise<Stripe | null> {\n let promise = stripePromises.get(publishableKey)\n if (!promise) {\n promise = loadStripe(publishableKey)\n stripePromises.set(publishableKey, promise)\n }\n return promise\n}\n\n/**\n * A card typed in by staff (card not present). The card goes into Stripe's\n * own Payment Element and never touches the register; the server created the\n * PaymentIntent and records the payment from Stripe, never from this form's\n * say-so.\n */\nexport function PosKeyedCardDialog(props: {\n clientSecret: string\n publishableKey: string\n amountCents: number\n onClose: () => void\n onConfirmed: () => void\n}) {\n const stripe = useMemo(\n () => (props.publishableKey ? stripeFor(props.publishableKey) : null),\n [props.publishableKey],\n )\n return (\n <Dialog open={Boolean(props.clientSecret)} onClose={props.onClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{`Type a card — ${usd(props.amountCents)}`}</DialogTitle>\n {props.clientSecret && stripe ? (\n <Elements stripe={stripe} options={{ clientSecret: props.clientSecret }}>\n <KeyedCardForm onClose={props.onClose} onConfirmed={props.onConfirmed} />\n </Elements>\n ) : null}\n </Dialog>\n )\n}\n\nfunction KeyedCardForm(props: { onClose: () => void; onConfirmed: () => void }) {\n const stripe = useStripe()\n const elements = useElements()\n const [error, setError] = useState('')\n const [busy, setBusy] = useState(false)\n return (\n <>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <PaymentElement options={{ layout: 'tabs', wallets: { applePay: 'never', googlePay: 'never' } }} />\n {error ? <Alert severity=\"error\">{error}</Alert> : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={props.onClose} disabled={busy} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n disabled={busy || !stripe || !elements}\n onClick={async () => {\n if (!stripe || !elements) return\n setBusy(true)\n setError('')\n const result = await stripe.confirmPayment({\n elements,\n redirect: 'if_required',\n confirmParams: { return_url: window.location.href },\n })\n setBusy(false)\n if (result.error) {\n setError(result.error.message ?? 'The card was not accepted.')\n return\n }\n props.onConfirmed()\n }}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {busy ? 'Charging…' : 'Charge card'}\n </Button>\n </DialogActions>\n </>\n )\n}\n\n/**\n * Store credit another plugin keeps (AGL-3640) — a rewards balance, a friend's\n * referral credit. The cashier finds the customer by email or code and takes\n * from the account found, or applies a code the customer reads out. Which\n * plugin answers is the provider's business; the register only shows its name\n * and what the account can give.\n */\nexport function PosCreditDialog(props: {\n open: boolean\n label: string\n canLookup: boolean\n busy: boolean\n onClose: () => void\n onLookup: (query: string) => Promise<PosCreditAccount[] | null>\n onApplyCode: (code: string) => void\n onApplyAccount: (account: PosCreditAccount) => void\n}) {\n const [query, setQuery] = useState('')\n const [found, setFound] = useState<PosCreditAccount[] | null>(null)\n const close = () => {\n setQuery('')\n setFound(null)\n props.onClose()\n }\n const find = async () => {\n if (!query.trim()) return\n setFound(await props.onLookup(query.trim()))\n }\n return (\n <Dialog open={props.open} onClose={close} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{props.label}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label={props.canLookup ? 'Code or customer email' : 'Code'}\n value={query}\n onChange={(event) => {\n setQuery(event.target.value)\n setFound(null)\n }}\n onKeyDown={(event) => {\n if (event.key === 'Enter' && props.canLookup) void find()\n }}\n autoFocus\n sx={{ mt: 1 }}\n slotProps={{ htmlInput: { autoComplete: 'off', 'data-testid': 'pos-credit-query' } }}\n />\n {found && !found.length ? <Alert severity=\"info\">{'No account matches.'}</Alert> : null}\n {found?.length ? (\n <List disablePadding>\n {found.map((account) => (\n <ListItemButton\n key={account.reference}\n disabled={props.busy || account.availableCents <= 0}\n onClick={() => {\n props.onApplyAccount(account)\n setQuery('')\n setFound(null)\n }}\n divider\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n <ListItemText\n primary={`${account.label}${account.last4 ? ` •• ${account.last4}` : ''} · ${usd(account.availableCents)} available`}\n secondary={account.detail}\n />\n </ListItemButton>\n ))}\n </List>\n ) : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={close} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Cancel'}\n </Button>\n {props.canLookup ? (\n <Button disabled={props.busy || !query.trim()} onClick={() => void find()} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Find'}\n </Button>\n ) : null}\n <Button\n variant=\"contained\"\n disabled={props.busy || !query.trim() || query.includes('@')}\n onClick={() => {\n props.onApplyCode(query.trim())\n setQuery('')\n setFound(null)\n }}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {'Apply code'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n"],"names":["Alert","Box","Button","Dialog","DialogActions","DialogContent","DialogTitle","List","ListItemButton","ListItemText","MenuItem","Stack","TextField","Typography","Elements","PaymentElement","useElements","useStripe","loadStripe","QRCodeSVG","useMemo","useState","centsFromInput","usd","POS_TOUCH_PX","PosCashDialog","props","received","setReceived","owed","dueCents","tipCents","tendered","quick","Set","Math","ceil","filter","value","slice","close","onClose","open","maxWidth","fullWidth","sx","display","flexDirection","gap","label","onChange","event","target","replace","autoFocus","mt","slotProps","htmlInput","inputMode","direction","spacing","flexWrap","map","cents","variant","onClick","toFixed","minHeight","severity","max","disabled","busy","onTake","PosGiftCardDialog","code","setCode","balance","setBalance","toUpperCase","onKeyDown","key","trim","answer","onCheck","frozen","voided","availableCents","autoComplete","autoCapitalize","onApply","PosFolioDialog","stay","setStay","amountCents","select","stays","entry","$id","guestName","guestEmail","onCharge","PosQrDialog","Boolean","url","color","justifyContent","size","level","marginSize","title","role","href","rel","stripePromises","Map","stripeFor","publishableKey","promise","get","set","PosKeyedCardDialog","stripe","clientSecret","options","KeyedCardForm","onConfirmed","elements","error","setError","setBusy","layout","wallets","applePay","googlePay","result","confirmPayment","redirect","confirmParams","return_url","window","location","message","PosCreditDialog","query","setQuery","found","setFound","find","onLookup","canLookup","length","disablePadding","account","onApplyAccount","divider","primary","last4","secondary","detail","reference","includes","onApplyCode"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,cAAc,EACdC,YAAY,EACZC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,QAAQ,EAAEC,cAAc,EAAEC,WAAW,EAAEC,SAAS,QAAQ,0BAAyB;AAC1F,4EAA4E;AAC5E,yDAAyD;AACzD,SAAS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CAACD;oCACrBR,SAAS;oCACTE,SAAS;gCACX;gCACAQ,OAAO;gCACP7G,IAAI;oCAAEsB,WAAW3C;gCAAa;0CAE9B,cAAA,KAACf;oCACCkJ,SAAS,GAAGH,QAAQvG,KAAK,GAAGuG,QAAQI,KAAK,GAAG,CAAC,IAAI,EAAEJ,QAAQI,KAAK,EAAE,GAAG,GAAG,GAAG,EAAErI,IAAIiI,QAAQlE,cAAc,EAAE,UAAU,CAAC;oCACpHuE,WAAWL,QAAQM,MAAM;;+BAZtBN,QAAQO,SAAS;yBAiB1B;;;0BAEN,MAAC3J;;kCACC,KAACF;wBAAO+D,SAASzB;wBAAOK,IAAI;4BAAEsB,WAAW3C;wBAAa;kCACnD;;oBAEFE,MAAM2H,SAAS,iBACd,KAACnJ;wBAAOoE,UAAU5C,MAAM6C,IAAI,IAAI,CAACwE,MAAM9D,IAAI;wBAAIhB,SAAS,IAAM,KAAKkF;wBAAQtG,IAAI;4BAAEsB,WAAW3C;wBAAa;kCACtG;yBAED;kCACJ,KAACtB;wBACC8D,SAAQ;wBACRM,UAAU5C,MAAM6C,IAAI,IAAI,CAACwE,MAAM9D,IAAI,MAAM8D,MAAMiB,QAAQ,CAAC;wBACxD/F,SAAS;4BACPvC,MAAMuI,WAAW,CAAClB,MAAM9D,IAAI;4BAC5B+D,SAAS;4BACTE,SAAS;wBACX;wBACArG,IAAI;4BAAEsB,WAAW3C;wBAAa;kCAE7B;;;;;;AAKX"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-tender-dialogs.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n Alert,\n Box,\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n List,\n ListItemButton,\n ListItemText,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { Elements, PaymentElement, useElements, useStripe } from '@stripe/react-stripe-js'\n// `/pure`: the Stripe script loads when a typed card is actually taken, not\n// whenever the register mounts (the AGL-2486 reasoning).\nimport { loadStripe } from '@stripe/stripe-js/pure'\nimport type { Stripe } from '@stripe/stripe-js'\nimport { QRCodeSVG } from 'qrcode.react'\nimport { useMemo, useState } from 'react'\nimport { centsFromInput, usd, type PosCreditAccount } from './pos-api'\nimport { POS_TOUCH_PX } from './pos-product-grid.component'\n\n/*==========================================\n * The register's tender dialogs (AGL-3607). Each collects what its tender\n * needs and hands it to the tender panel, which owns the request.\n *=========================================*/\n\n/** Cash: what the customer handed over, with one-tap round-ups. */\nexport function PosCashDialog(props: {\n open: boolean\n dueCents: number\n tipCents: number\n busy: boolean\n onClose: () => void\n onTake: (tenderedCents: number) => void\n}) {\n const [received, setReceived] = useState('')\n const owed = props.dueCents + props.tipCents\n const tendered = centsFromInput(received)\n const quick = [...new Set([owed, Math.ceil(owed / 500) * 500, Math.ceil(owed / 1000) * 1000, Math.ceil(owed / 2000) * 2000])]\n .filter((value) => value >= owed)\n .slice(0, 4)\n const close = () => {\n setReceived('')\n props.onClose()\n }\n return (\n <Dialog open={props.open} onClose={close} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Cash — ${usd(owed)}`}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label=\"Cash received ($)\"\n value={received}\n onChange={(event) => setReceived(event.target.value.replace(/[^0-9.]/g, ''))}\n autoFocus\n sx={{ mt: 1 }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n <Stack direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap' }}>\n {quick.map((cents) => (\n <Button\n key={cents}\n variant=\"outlined\"\n onClick={() => setReceived((cents / 100).toFixed(2))}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {cents === owed ? 'Exact' : usd(cents)}\n </Button>\n ))}\n </Stack>\n {tendered > 0 && tendered >= owed ? (\n <Alert severity=\"success\">{`Change: ${usd(tendered - owed)}`}</Alert>\n ) : tendered > 0 && tendered < owed ? (\n <Alert severity=\"info\">\n {`Takes ${usd(Math.max(0, tendered - props.tipCents))} toward the sale; ${usd(owed - tendered)} left to pay.`}\n </Alert>\n ) : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={close} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n disabled={props.busy || tendered <= props.tipCents}\n onClick={() => {\n props.onTake(tendered)\n setReceived('')\n }}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {'Take cash'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\n/** A gift card: type or scan the code, see the balance, apply it. */\nexport function PosGiftCardDialog(props: {\n open: boolean\n busy: boolean\n onClose: () => void\n onCheck: (code: string) => Promise<{ availableCents: number; frozen: boolean; voided: boolean } | null>\n onApply: (code: string) => void\n}) {\n const [code, setCode] = useState('')\n const [balance, setBalance] = useState<string | null>(null)\n const close = () => {\n setCode('')\n setBalance(null)\n props.onClose()\n }\n return (\n <Dialog open={props.open} onClose={close} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{'Gift card'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label=\"Gift card code\"\n value={code}\n onChange={(event) => {\n setCode(event.target.value.toUpperCase())\n setBalance(null)\n }}\n onKeyDown={async (event) => {\n if (event.key !== 'Enter' || !code.trim()) return\n const answer = await props.onCheck(code)\n setBalance(\n answer\n ? answer.frozen\n ? 'This card is on hold.'\n : answer.voided\n ? 'This card was voided.'\n : `Available: ${usd(answer.availableCents)}`\n : null,\n )\n }}\n autoFocus\n sx={{ mt: 1 }}\n slotProps={{ htmlInput: { autoComplete: 'off', autoCapitalize: 'characters' } }}\n />\n {balance ? <Alert severity=\"info\">{balance}</Alert> : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={close} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Cancel'}\n </Button>\n <Button\n disabled={!code.trim()}\n onClick={async () => {\n const answer = await props.onCheck(code)\n setBalance(\n answer\n ? answer.frozen\n ? 'This card is on hold.'\n : `Available: ${usd(answer.availableCents)}`\n : null,\n )\n }}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {'Check balance'}\n </Button>\n <Button\n variant=\"contained\"\n disabled={props.busy || !code.trim()}\n onClick={() => {\n props.onApply(code)\n setCode('')\n setBalance(null)\n }}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {'Apply card'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\n/** Charge to a checked-in stay's folio. */\nexport function PosFolioDialog(props: {\n open: boolean\n amountCents: number\n stays: any[]\n busy: boolean\n onClose: () => void\n onCharge: (reservationId: string) => void\n}) {\n const [stay, setStay] = useState('')\n return (\n <Dialog open={props.open} onClose={props.onClose} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Charge to room — ${usd(props.amountCents)}`}</DialogTitle>\n <DialogContent>\n <TextField\n label=\"Checked-in stay\"\n value={stay}\n onChange={(event) => setStay(event.target.value)}\n select\n fullWidth\n sx={{ mt: 1 }}\n >\n {props.stays.map((entry: any) => (\n <MenuItem key={entry.$id} value={entry.$id}>\n {entry.guestName ?? entry.guestEmail ?? entry.$id}\n </MenuItem>\n ))}\n </TextField>\n </DialogContent>\n <DialogActions>\n <Button onClick={props.onClose} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n disabled={props.busy || !stay}\n onClick={() => props.onCharge(stay)}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {'Charge folio'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\n/**\n * The QR payment page. Encoded in this browser, never fetched (AGL-1671): a\n * live payment URL in a third party's query string is a link that pays the\n * sale for whoever opens it.\n */\nexport function PosQrDialog(props: { url: string; amountCents: number; onClose: () => void }) {\n return (\n <Dialog open={Boolean(props.url)} onClose={props.onClose} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Scan to pay ${usd(props.amountCents)}`}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ mt: 1 }}>\n {'The customer scans this and pays on their phone. The payment shows ' +\n 'here as soon as it goes through.'}\n </Typography>\n <Box sx={{ display: 'flex', justifyContent: 'center' }}>\n <QRCodeSVG value={props.url} size={256} level=\"L\" marginSize={4} title=\"Payment QR\" role=\"img\" />\n </Box>\n <Button href={props.url} target=\"_blank\" rel=\"noopener noreferrer\">\n {'Open payment page'}\n </Button>\n </DialogContent>\n <DialogActions>\n <Button onClick={props.onClose} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Close'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\nconst stripePromises = new Map<string, Promise<Stripe | null>>()\n\n/** Stripe for the key, on the store's own account when it sells on one. */\nfunction stripeFor(publishableKey: string, stripeAccount: string): Promise<Stripe | null> {\n const key = `${publishableKey}|${stripeAccount}`\n let promise = stripePromises.get(key)\n if (!promise) {\n promise = stripeAccount ? loadStripe(publishableKey, { stripeAccount }) : loadStripe(publishableKey)\n stripePromises.set(key, promise)\n }\n return promise\n}\n\n/**\n * A card typed in by staff (card not present). The card goes into Stripe's\n * own Payment Element and never touches the register; the server created the\n * PaymentIntent and records the payment from Stripe, never from this form's\n * say-so.\n */\nexport function PosKeyedCardDialog(props: {\n clientSecret: string\n publishableKey: string\n /** A direct-charge store's own account, where its intent lives; empty for the platform. */\n stripeAccount?: string\n amountCents: number\n onClose: () => void\n onConfirmed: () => void\n}) {\n const stripe = useMemo(\n () => (props.publishableKey ? stripeFor(props.publishableKey, props.stripeAccount ?? '') : null),\n [props.publishableKey, props.stripeAccount],\n )\n return (\n <Dialog open={Boolean(props.clientSecret)} onClose={props.onClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{`Type a card — ${usd(props.amountCents)}`}</DialogTitle>\n {props.clientSecret && stripe ? (\n <Elements stripe={stripe} options={{ clientSecret: props.clientSecret }}>\n <KeyedCardForm onClose={props.onClose} onConfirmed={props.onConfirmed} />\n </Elements>\n ) : null}\n </Dialog>\n )\n}\n\nfunction KeyedCardForm(props: { onClose: () => void; onConfirmed: () => void }) {\n const stripe = useStripe()\n const elements = useElements()\n const [error, setError] = useState('')\n const [busy, setBusy] = useState(false)\n return (\n <>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <PaymentElement options={{ layout: 'tabs', wallets: { applePay: 'never', googlePay: 'never' } }} />\n {error ? <Alert severity=\"error\">{error}</Alert> : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={props.onClose} disabled={busy} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n disabled={busy || !stripe || !elements}\n onClick={async () => {\n if (!stripe || !elements) return\n setBusy(true)\n setError('')\n const result = await stripe.confirmPayment({\n elements,\n redirect: 'if_required',\n confirmParams: { return_url: window.location.href },\n })\n setBusy(false)\n if (result.error) {\n setError(result.error.message ?? 'The card was not accepted.')\n return\n }\n props.onConfirmed()\n }}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {busy ? 'Charging…' : 'Charge card'}\n </Button>\n </DialogActions>\n </>\n )\n}\n\n/**\n * Store credit another plugin keeps (AGL-3640) — a rewards balance, a friend's\n * referral credit. The cashier finds the customer by email or code and takes\n * from the account found, or applies a code the customer reads out. Which\n * plugin answers is the provider's business; the register only shows its name\n * and what the account can give.\n */\nexport function PosCreditDialog(props: {\n open: boolean\n label: string\n canLookup: boolean\n busy: boolean\n onClose: () => void\n onLookup: (query: string) => Promise<PosCreditAccount[] | null>\n onApplyCode: (code: string) => void\n onApplyAccount: (account: PosCreditAccount) => void\n}) {\n const [query, setQuery] = useState('')\n const [found, setFound] = useState<PosCreditAccount[] | null>(null)\n const close = () => {\n setQuery('')\n setFound(null)\n props.onClose()\n }\n const find = async () => {\n if (!query.trim()) return\n setFound(await props.onLookup(query.trim()))\n }\n return (\n <Dialog open={props.open} onClose={close} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{props.label}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label={props.canLookup ? 'Code or customer email' : 'Code'}\n value={query}\n onChange={(event) => {\n setQuery(event.target.value)\n setFound(null)\n }}\n onKeyDown={(event) => {\n if (event.key === 'Enter' && props.canLookup) void find()\n }}\n autoFocus\n sx={{ mt: 1 }}\n slotProps={{ htmlInput: { autoComplete: 'off', 'data-testid': 'pos-credit-query' } }}\n />\n {found && !found.length ? <Alert severity=\"info\">{'No account matches.'}</Alert> : null}\n {found?.length ? (\n <List disablePadding>\n {found.map((account) => (\n <ListItemButton\n key={account.reference}\n disabled={props.busy || account.availableCents <= 0}\n onClick={() => {\n props.onApplyAccount(account)\n setQuery('')\n setFound(null)\n }}\n divider\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n <ListItemText\n primary={`${account.label}${account.last4 ? ` •• ${account.last4}` : ''} · ${usd(account.availableCents)} available`}\n secondary={account.detail}\n />\n </ListItemButton>\n ))}\n </List>\n ) : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={close} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Cancel'}\n </Button>\n {props.canLookup ? (\n <Button disabled={props.busy || !query.trim()} onClick={() => void find()} sx={{ minHeight: POS_TOUCH_PX }}>\n {'Find'}\n </Button>\n ) : null}\n <Button\n variant=\"contained\"\n disabled={props.busy || !query.trim() || query.includes('@')}\n onClick={() => {\n props.onApplyCode(query.trim())\n setQuery('')\n setFound(null)\n }}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {'Apply code'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n"],"names":["Alert","Box","Button","Dialog","DialogActions","DialogContent","DialogTitle","List","ListItemButton","ListItemText","MenuItem","Stack","TextField","Typography","Elements","PaymentElement","useElements","useStripe","loadStripe","QRCodeSVG","useMemo","useState","centsFromInput","usd","POS_TOUCH_PX","PosCashDialog","props","received","setReceived","owed","dueCents","tipCents","tendered","quick","Set","Math","ceil","filter","value","slice","close","onClose","open","maxWidth","fullWidth","sx","display","flexDirection","gap","label","onChange","event","target","replace","autoFocus","mt","slotProps","htmlInput","inputMode","direction","spacing","flexWrap","map","cents","variant","onClick","toFixed","minHeight","severity","max","disabled","busy","onTake","PosGiftCardDialog","code","setCode","balance","setBalance","toUpperCase","onKeyDown","key","trim","answer","onCheck","frozen","voided","availableCents","autoComplete","autoCapitalize","onApply","PosFolioDialog","stay","setStay","amountCents","select","stays","entry","$id","guestName","guestEmail","onCharge","PosQrDialog","Boolean","url","color","justifyContent","size","level","marginSize","title","role","href","rel","stripePromises","Map","stripeFor","publishableKey","stripeAccount","promise","get","set","PosKeyedCardDialog","stripe","clientSecret","options","KeyedCardForm","onConfirmed","elements","error","setError","setBusy","layout","wallets","applePay","googlePay","result","confirmPayment","redirect","confirmParams","return_url","window","location","message","PosCreditDialog","query","setQuery","found","setFound","find","onLookup","canLookup","length","disablePadding","account","onApplyAccount","divider","primary","last4","secondary","detail","reference","includes","onApplyCode"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,cAAc,EACdC,YAAY,EACZC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,QAAQ,EAAEC,cAAc,EAAEC,WAAW,EAAEC,SAA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
* payments as it needs; it is paid when the balance reaches zero, and only
|
|
47
47
|
* then does the server take the stock and complete it.
|
|
48
48
|
*/ export function PosTenderPanel(props) {
|
|
49
|
-
var _payments_reason, _ref, _payments_href, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8;
|
|
49
|
+
var _payments_reason, _ref, _payments_href, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
|
|
50
50
|
var _context_terminal, _context_terminal1;
|
|
51
51
|
const { user, hostId, sale, context, display, onSale, notify } = props;
|
|
52
52
|
const settings = context == null ? void 0 : context.settings;
|
|
@@ -245,11 +245,13 @@ const STATUS_COLOR = {
|
|
|
245
245
|
tipCents
|
|
246
246
|
}, true);
|
|
247
247
|
if ((result == null ? void 0 : result.clientSecret) && result.paymentId) {
|
|
248
|
-
setKeyed({
|
|
248
|
+
setKeyed(_extends({
|
|
249
249
|
clientSecret: result.clientSecret,
|
|
250
250
|
amountCents: amountCents + tipCents,
|
|
251
251
|
paymentId: result.paymentId
|
|
252
|
-
}
|
|
252
|
+
}, result.stripeAccount ? {
|
|
253
|
+
stripeAccount: result.stripeAccount
|
|
254
|
+
} : {}));
|
|
253
255
|
}
|
|
254
256
|
}, [
|
|
255
257
|
run,
|
|
@@ -708,7 +710,8 @@ const STATUS_COLOR = {
|
|
|
708
710
|
/*#__PURE__*/ _jsx(PosKeyedCardDialog, {
|
|
709
711
|
clientSecret: (_ref6 = keyed == null ? void 0 : keyed.clientSecret) != null ? _ref6 : '',
|
|
710
712
|
publishableKey: (_ref7 = context == null ? void 0 : context.publishableKey) != null ? _ref7 : '',
|
|
711
|
-
|
|
713
|
+
stripeAccount: (_ref8 = keyed == null ? void 0 : keyed.stripeAccount) != null ? _ref8 : '',
|
|
714
|
+
amountCents: (_ref9 = keyed == null ? void 0 : keyed.amountCents) != null ? _ref9 : 0,
|
|
712
715
|
onClose: async ()=>{
|
|
713
716
|
const open = keyed;
|
|
714
717
|
setKeyed(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-tender-panel.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Divider,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { useMerchantPayments } from '@aglyn/tenant-feature-instance'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport * as CommerceModel from '../../../model'\nimport {\n centsFromInput,\n newAttemptKey,\n posCreditLookup,\n posGiftCardBalance,\n posNativeBridge,\n posTender,\n PosRequestError,\n usd,\n type PosRegisterContext,\n type PosSaleSummary,\n type PosTenderAction,\n type PosTenderResult,\n} from './pos-api'\nimport { POS_TOUCH_PX } from './pos-product-grid.component'\nimport {\n PosCashDialog,\n PosCreditDialog,\n PosFolioDialog,\n PosGiftCardDialog,\n PosKeyedCardDialog,\n PosQrDialog,\n} from './pos-tender-dialogs.component'\nimport type { PosDisplayControl } from './use-pos-display'\n\ntype User = Parameters<typeof posTender>[0]\n\nconst STATUS_LABEL: Record<CommerceModel.OrderPaymentStatus, string> = {\n pending: 'Waiting',\n succeeded: 'Approved',\n failed: 'Declined',\n canceled: 'Canceled',\n reversed: 'Returned',\n}\n\nconst STATUS_COLOR: Record<\n CommerceModel.OrderPaymentStatus,\n 'default' | 'success' | 'error' | 'warning' | 'info'\n> = {\n pending: 'info',\n succeeded: 'success',\n failed: 'error',\n canceled: 'default',\n reversed: 'warning',\n}\n\nexport interface PosTenderPanelProps {\n user: User\n hostId: string\n registerId: string\n sale: PosSaleSummary\n context: PosRegisterContext | null\n stays: any[]\n display: PosDisplayControl\n onSale: (sale: PosSaleSummary) => void\n /** The sale is voided: the basket is the cashier's again. */\n onVoided: () => void\n /** The tip chosen for the next payment, before it is taken. */\n onTipChange?: (tipCents: number) => void\n /** A PIN-switched cashier (AGL-3609) takes each payment they start. */\n cashierAssertion?: string\n notify: (message: string, variant: 'success' | 'error' | 'warning' | 'info') => void\n /**\n * The register is offline (AGL-3625). Every tender here is the server's —\n * the card reader, the typed card, the QR link, the gift card, the room\n * charge and this sale's own cash — so each is off until it returns.\n */\n offline?: boolean\n /** Rings this basket as an offline cash sale instead; offered while nothing is paid. */\n onSellOffline?: () => void\n}\n\n/**\n * Taking payment on an open sale (AGL-3607): the balance due, every payment\n * taken so far with its live status, and the tenders. A sale can take as many\n * payments as it needs; it is paid when the balance reaches zero, and only\n * then does the server take the stock and complete it.\n */\nexport function PosTenderPanel(props: PosTenderPanelProps) {\n const { user, hostId, sale, context, display, onSale, notify } = props\n const settings = context?.settings\n // Card tenders all charge through the workspace's Stripe account. They stay\n // on screen without one, disabled with the reason, so the register says\n // what to set up instead of losing the buttons or refusing after a tap.\n const payments = useMerchantPayments(hostId)\n const cardsBlocked = payments.blocked\n const cardsReason = payments.reason ?? ''\n const [amount, setAmount] = useState('')\n const [tipCents, setTipCents] = useState(0)\n const [busy, setBusy] = useState(false)\n const [dialog, setDialog] = useState<'cash' | 'gift' | 'folio' | 'credit' | null>(null)\n // The store-credit provider whose dialog is open (AGL-3640).\n const [creditProvider, setCreditProvider] = useState<{ providerId: string; label: string; lookup: boolean } | null>(\n null,\n )\n const [qr, setQr] = useState<{ url: string; amountCents: number } | null>(null)\n const [keyed, setKeyed] = useState<{ clientSecret: string; amountCents: number; paymentId: string } | null>(\n null,\n )\n const [readerId, setReaderId] = useState('')\n const inFlight = useRef(false)\n const { confirm } = useConfirmationContext()\n const { onTipChange } = props\n useEffect(() => {\n onTipChange?.(tipCents)\n }, [onTipChange, tipCents])\n\n const readers = (context?.readers ?? []).filter(\n (reader) => !reader.registerId || reader.registerId === props.registerId,\n )\n useEffect(() => {\n if (!readerId && readers.length) {\n setReaderId(readers.find((reader) => reader.registerId === props.registerId)?.id ?? readers[0].id)\n }\n }, [readerId, readers, props.registerId])\n\n // The amount defaults to whatever is still open; a split is the cashier\n // typing less than that.\n const typedCents = centsFromInput(amount)\n const chargeCents = typedCents > 0 ? Math.min(typedCents, sale.tenderableCents) : sale.tenderableCents\n const paid = sale.status === 'paid'\n const offline = props.offline === true\n\n const run = useCallback(\n async (\n action: PosTenderAction,\n body: Record<string, unknown> = {},\n starts = false,\n ): Promise<PosTenderResult | null> => {\n if (inFlight.current) return null\n inFlight.current = true\n setBusy(true)\n try {\n const result = await posTender(\n user,\n hostId,\n sale.orderId,\n action,\n starts && props.cashierAssertion ? { ...body, cashierAssertion: props.cashierAssertion } : body,\n starts ? newAttemptKey() : undefined,\n )\n onSale(result.sale)\n if (starts) {\n setAmount('')\n setTipCents(0)\n }\n return result\n } catch (error) {\n notify(error instanceof PosRequestError ? error.message : 'Something went wrong', 'error')\n return null\n } finally {\n inFlight.current = false\n setBusy(false)\n }\n },\n [user, hostId, sale.orderId, onSale, notify, props.cashierAssertion],\n )\n\n // Card payments still waiting are checked every two seconds: the reader,\n // the QR page and the typed card all settle on the server, and this is the\n // register's view of it (the webhook does the same thing when it lands).\n const pending = sale.payments.filter(\n (payment) => payment.status === 'pending' && CommerceModel.isCardPaymentMethod(payment.method),\n )\n const pendingKey = pending.map((payment) => payment.id).join(',')\n const latest = useRef({ user, onSale })\n latest.current = { user, onSale }\n useEffect(() => {\n if (!pendingKey) return undefined\n const timer = setInterval(async () => {\n for (const id of pendingKey.split(',')) {\n try {\n const result = await posTender(latest.current.user, hostId, sale.orderId, 'status', {\n paymentId: id,\n })\n latest.current.onSale(result.sale)\n } catch {\n // The next tick asks again.\n }\n }\n }, 2000)\n return () => clearInterval(timer)\n }, [pendingKey, hostId, sale.orderId])\n\n // The display shows \"tap your card\" while a reader payment waits, and the\n // running balance otherwise.\n const readerWaiting = pending.some((payment) => payment.method === 'card_present')\n useEffect(() => {\n if (!display.connected || display.asking) return\n if (readerWaiting) {\n void display.show({ mode: 'processing', processing: { message: 'Tap, insert or swipe your card on the reader.' } })\n }\n }, [readerWaiting, display])\n\n const askTip = useCallback(async () => {\n const base = chargeCents\n if (!(base > 0) || !settings) return\n const answer = await display.ask({\n mode: 'tip',\n tip: { baseCents: base, percentages: settings.tipPercentages, allowCustom: true },\n })\n if (answer) {\n setTipCents(answer.tipCents ?? 0)\n notify(answer.tipCents ? `Tip: ${usd(answer.tipCents)}` : 'No tip', 'info')\n }\n }, [chargeCents, settings, display, notify])\n\n const startCardPresent = useCallback(async () => {\n if (!readerId) return\n await run('card-present', { amountCents: chargeCents, tipCents, readerId }, true)\n }, [run, chargeCents, tipCents, readerId])\n\n const startBridge = useCallback(async () => {\n const bridge = posNativeBridge()\n if (!bridge) return\n const amountCents = chargeCents\n const result = await run('card-present-sdk', { amountCents, tipCents }, true)\n if (!result?.paymentIntentId || !result.clientSecret || !result.paymentId) return\n try {\n const collected = await bridge.collectCardPayment({\n paymentIntentId: result.paymentIntentId,\n clientSecret: result.clientSecret,\n amountCents: amountCents + tipCents,\n })\n if (collected.status !== 'collected') {\n notify(collected.message ?? 'The card was not taken.', 'warning')\n }\n } finally {\n // Settled by the server either way: the status poll captures an\n // authorized tap and records a decline or a cancel.\n await run('status', { paymentId: result.paymentId })\n }\n }, [run, chargeCents, tipCents, notify])\n\n const startKeyed = useCallback(async () => {\n const amountCents = chargeCents\n const result = await run('card-keyed', { amountCents, tipCents }, true)\n if (result?.clientSecret && result.paymentId) {\n setKeyed({ clientSecret: result.clientSecret, amountCents: amountCents + tipCents, paymentId: result.paymentId })\n }\n }, [run, chargeCents, tipCents])\n\n const startLink = useCallback(async () => {\n const amountCents = chargeCents\n const result = await run('card-link', { amountCents, tipCents }, true)\n const url = result?.sale.payments.find((payment) => payment.id === result.paymentId)?.checkoutUrl\n if (url) setQr({ url, amountCents: amountCents + tipCents })\n }, [run, chargeCents, tipCents])\n\n const tipOn = Boolean(settings?.tippingEnabled) && !paid\n\n return (\n <Stack spacing={1.5} sx={{ minHeight: 0 }}>\n <Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline' }}>\n <Typography variant=\"h6\">{paid ? 'Paid' : 'Balance due'}</Typography>\n <Typography variant=\"h4\" component=\"p\">\n {usd(paid ? sale.totalCents : sale.dueCents)}\n </Typography>\n </Box>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Total ${usd(sale.totalCents)} · paid ${usd(sale.paidCents)}` +\n (sale.tipCents ? ` · tips ${usd(sale.tipCents)}` : '')}\n </Typography>\n\n {sale.payments.length ? (\n <Stack spacing={1} aria-label=\"Payments\">\n {sale.payments.map((payment) => (\n <Box key={payment.id} sx={{ display: 'flex', alignItems: 'center', gap: 1, flexWrap: 'wrap' }}>\n <Typography variant=\"body2\" sx={{ flex: 1, minWidth: 140 }}>\n {CommerceModel.describeOrderPayment({ ...payment, atMs: 0 })}\n {payment.changeCents ? ` · change ${usd(payment.changeCents)}` : ''}\n </Typography>\n <Chip size=\"small\" label={STATUS_LABEL[payment.status]} color={STATUS_COLOR[payment.status]} />\n {payment.status === 'pending' && CommerceModel.isCardPaymentMethod(payment.method) ? (\n <>\n {payment.method === 'card_link' && payment.checkoutUrl ? (\n <Button\n size=\"small\"\n onClick={() => setQr({ url: payment.checkoutUrl as string, amountCents: payment.amountCents })}\n >\n {'Show QR'}\n </Button>\n ) : null}\n {payment.method === 'card_present' && payment.livemode === false && context?.terminal?.testMode ? (\n <Button size=\"small\" onClick={() => void run('simulate', { paymentId: payment.id })}>\n {'Simulate tap'}\n </Button>\n ) : null}\n <Button size=\"small\" color=\"error\" onClick={() => void run('cancel', { paymentId: payment.id })}>\n {'Cancel'}\n </Button>\n </>\n ) : null}\n {payment.status === 'failed' && payment.method === 'card_present' && !paid ? (\n <Button size=\"small\" onClick={() => void run('retry', { paymentId: payment.id })}>\n {'Retry'}\n </Button>\n ) : null}\n {payment.failureMessage && payment.status === 'failed' ? (\n <Typography variant=\"caption\" color=\"error\" sx={{ width: 1 }}>\n {payment.failureMessage}\n </Typography>\n ) : null}\n </Box>\n ))}\n </Stack>\n ) : null}\n\n {offline && !paid ? (\n <Alert\n severity=\"warning\"\n action={\n props.onSellOffline && sale.payments.length === 0 ? (\n <Button color=\"inherit\" size=\"small\" onClick={props.onSellOffline}>\n {'Sell for cash offline'}\n </Button>\n ) : null\n }\n >\n {sale.payments.length === 0\n ? 'Offline: card readers, typed cards, the QR link, gift cards, store credit and room charges are off. ' +\n 'Take this basket as an offline cash sale, or wait for the connection.'\n : 'Offline: this sale has a payment on it and finishes when the connection returns. ' +\n 'Card readers, typed cards, the QR link, gift cards, store credit and room charges are off.'}\n </Alert>\n ) : null}\n {!paid && !offline && cardsBlocked ? (\n <PrerequisiteNotice href={payments.href ?? undefined} actionLabel=\"Open Payments\">\n {`${cardsReason} Cash, gift cards and store credit work without it.`}\n </PrerequisiteNotice>\n ) : null}\n {!paid ? (\n <>\n <Divider />\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <TextField\n label=\"Amount to charge ($)\"\n placeholder={(sale.tenderableCents / 100).toFixed(2)}\n value={amount}\n onChange={(event) => setAmount(event.target.value.replace(/[^0-9.]/g, ''))}\n sx={{ flex: 1 }}\n helperText={\n typedCents > 0 && typedCents < sale.tenderableCents\n ? `Split: ${usd(sale.tenderableCents - typedCents)} stays open`\n : ' '\n }\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n </Stack>\n {tipOn ? (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}>\n <Typography variant=\"body2\" sx={{ mr: 1 }}>\n {`Tip ${usd(tipCents)}`}\n </Typography>\n {display.connected ? (\n <Button\n variant=\"outlined\"\n onClick={() => void askTip()}\n disabled={offline || busy || Boolean(display.asking)}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {display.asking === 'tip' ? 'Waiting for customer…' : 'Ask on display'}\n </Button>\n ) : null}\n {(settings?.tipPercentages ?? []).map((pct) => (\n <Button\n key={pct}\n variant={tipCents === CommerceModel.posTipFromPercent(chargeCents, pct) && tipCents > 0 ? 'contained' : 'outlined'}\n onClick={() => setTipCents(CommerceModel.posTipFromPercent(chargeCents, pct))}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {`${pct}%`}\n </Button>\n ))}\n <Button onClick={() => setTipCents(0)} sx={{ minHeight: POS_TOUCH_PX }}>\n {'No tip'}\n </Button>\n </Stack>\n ) : null}\n <Box\n sx={{\n display: 'grid',\n gap: 1,\n gridTemplateColumns: 'repeat(auto-fill, minmax(140px, 1fr))',\n }}\n >\n <Button\n variant=\"contained\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => setDialog('cash')}\n sx={{ minHeight: 56 }}\n >\n {'Cash'}\n </Button>\n {context?.terminal?.available && readers.length ? (\n <BlockedControl blocked={cardsBlocked} reason={cardsReason} fullWidth>\n <Button\n variant=\"contained\"\n disabled={offline || busy || chargeCents <= 0 || !readerId}\n onClick={() => void startCardPresent()}\n sx={{ minHeight: 56 }}\n >\n {'Card reader'}\n </Button>\n </BlockedControl>\n ) : null}\n {posNativeBridge() ? (\n <BlockedControl blocked={cardsBlocked} reason={cardsReason} fullWidth>\n <Button\n variant=\"contained\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => void startBridge()}\n sx={{ minHeight: 56 }}\n >\n {'Tap to Pay / Bluetooth reader'}\n </Button>\n </BlockedControl>\n ) : null}\n {context?.publishableKey ? (\n <BlockedControl blocked={cardsBlocked} reason={cardsReason} fullWidth>\n <Button\n variant=\"outlined\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => void startKeyed()}\n sx={{ minHeight: 56 }}\n >\n {'Type card'}\n </Button>\n </BlockedControl>\n ) : null}\n <BlockedControl blocked={cardsBlocked} reason={cardsReason} fullWidth>\n <Button\n variant=\"outlined\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => void startLink()}\n sx={{ minHeight: 56 }}\n >\n {'Card (QR)'}\n </Button>\n </BlockedControl>\n <Button\n variant=\"outlined\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => setDialog('gift')}\n sx={{ minHeight: 56 }}\n >\n {'Gift card'}\n </Button>\n {(context?.credits ?? []).map((credit) => (\n <Button\n key={credit.providerId}\n variant=\"outlined\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => {\n setCreditProvider(credit)\n setDialog('credit')\n }}\n sx={{ minHeight: 56 }}\n >\n {credit.label}\n </Button>\n ))}\n {props.stays.length ? (\n <Button\n variant=\"outlined\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => setDialog('folio')}\n sx={{ minHeight: 56 }}\n >\n {'Room'}\n </Button>\n ) : null}\n </Box>\n {context?.terminal?.available && readers.length > 1 ? (\n <TextField\n select\n size=\"small\"\n label=\"Card reader\"\n value={readerId}\n onChange={(event) => setReaderId(event.target.value)}\n >\n {readers.map((reader) => (\n <MenuItem key={reader.id} value={reader.id}>\n {`${reader.label}${reader.status === 'online' ? '' : ' (offline)'}`}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n {readers.some((reader) => reader.id === readerId && reader.status !== 'online') ? (\n <Alert severity=\"warning\">{'The selected card reader looks offline.'}</Alert>\n ) : null}\n <Button\n color=\"error\"\n disabled={offline || busy}\n onClick={async () => {\n const confirmed = await confirm({\n title: 'Void this sale?',\n description:\n 'Every payment taken on it is handed back: cards are refunded, gift ' +\n 'cards and store credit re-credited and room charges removed. Hand back any cash.',\n confirmationText: 'Void sale',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n const result = await run('void')\n if (result) {\n notify('Sale voided', 'info')\n props.onVoided()\n }\n }}\n sx={{ minHeight: POS_TOUCH_PX, alignSelf: 'flex-start' }}\n >\n {'Void sale'}\n </Button>\n </>\n ) : null}\n\n <PosCashDialog\n open={dialog === 'cash'}\n dueCents={chargeCents}\n tipCents={tipCents}\n busy={busy}\n onClose={() => setDialog(null)}\n onTake={async (tenderedCents) => {\n const result = await run(\n 'cash',\n {\n tenderedCents,\n ...(typedCents > 0 ? { amountCents: chargeCents } : {}),\n tipCents,\n },\n true,\n )\n if (result) {\n setDialog(null)\n const change = result.sale.payments.find((payment) => payment.id === result.paymentId)?.changeCents\n if (change) notify(`Change due: ${usd(change)}`, 'success')\n }\n }}\n />\n <PosGiftCardDialog\n open={dialog === 'gift'}\n busy={busy}\n onClose={() => setDialog(null)}\n onCheck={async (code) => {\n try {\n return await posGiftCardBalance(user, hostId, code)\n } catch (error) {\n notify(error instanceof PosRequestError ? error.message : 'Could not read that card', 'warning')\n return null\n }\n }}\n onApply={async (code) => {\n const result = await run('gift-card', { code, ...(typedCents > 0 ? { amountCents: chargeCents } : {}) }, true)\n if (result) setDialog(null)\n }}\n />\n <PosCreditDialog\n open={dialog === 'credit' && Boolean(creditProvider)}\n label={creditProvider?.label ?? 'Store credit'}\n canLookup={Boolean(creditProvider?.lookup)}\n busy={busy}\n onClose={() => setDialog(null)}\n onLookup={async (query) => {\n if (!creditProvider) return null\n try {\n return (await posCreditLookup(user, hostId, creditProvider.providerId, query)).accounts\n } catch (error) {\n notify(error instanceof PosRequestError ? error.message : 'Could not look that up', 'warning')\n return null\n }\n }}\n onApplyCode={async (code) => {\n const result = await run('credit', { code, ...(typedCents > 0 ? { amountCents: chargeCents } : {}) }, true)\n if (result) setDialog(null)\n }}\n onApplyAccount={async (account) => {\n if (!creditProvider) return\n const result = await run(\n 'credit',\n {\n providerId: creditProvider.providerId,\n reference: account.reference,\n ...(typedCents > 0 ? { amountCents: chargeCents } : {}),\n },\n true,\n )\n if (result) setDialog(null)\n }}\n />\n <PosFolioDialog\n open={dialog === 'folio'}\n amountCents={chargeCents}\n stays={props.stays}\n busy={busy}\n onClose={() => setDialog(null)}\n onCharge={async (reservationId) => {\n const result = await run(\n 'folio',\n { reservationId, ...(typedCents > 0 ? { amountCents: chargeCents } : {}) },\n true,\n )\n if (result) setDialog(null)\n }}\n />\n <PosQrDialog url={qr?.url ?? ''} amountCents={qr?.amountCents ?? 0} onClose={() => setQr(null)} />\n <PosKeyedCardDialog\n clientSecret={keyed?.clientSecret ?? ''}\n publishableKey={context?.publishableKey ?? ''}\n amountCents={keyed?.amountCents ?? 0}\n onClose={async () => {\n const open = keyed\n setKeyed(null)\n // Closing without paying releases the amount for another tender.\n if (open) await run('cancel', { paymentId: open.paymentId })\n }}\n onConfirmed={async () => {\n const open = keyed\n setKeyed(null)\n if (open) await run('status', { paymentId: open.paymentId })\n }}\n />\n </Stack>\n )\n}\nPosTenderPanel.displayName = 'PosTenderPanel'\n"],"names":["Alert","Box","Button","Chip","Divider","MenuItem","Stack","TextField","Typography","useConfirmationContext","BlockedControl","PrerequisiteNotice","useMerchantPayments","useCallback","useEffect","useRef","useState","CommerceModel","centsFromInput","newAttemptKey","posCreditLookup","posGiftCardBalance","posNativeBridge","posTender","PosRequestError","usd","POS_TOUCH_PX","PosCashDialog","PosCreditDialog","PosFolioDialog","PosGiftCardDialog","PosKeyedCardDialog","PosQrDialog","STATUS_LABEL","pending","succeeded","failed","canceled","reversed","STATUS_COLOR","PosTenderPanel","props","payments","context","user","hostId","sale","display","onSale","notify","settings","cardsBlocked","blocked","cardsReason","reason","amount","setAmount","tipCents","setTipCents","busy","setBusy","dialog","setDialog","creditProvider","setCreditProvider","qr","setQr","keyed","setKeyed","readerId","setReaderId","inFlight","confirm","onTipChange","readers","filter","reader","registerId","length","find","id","typedCents","chargeCents","Math","min","tenderableCents","paid","status","offline","run","action","body","starts","current","result","orderId","cashierAssertion","undefined","error","message","payment","isCardPaymentMethod","method","pendingKey","map","join","latest","timer","setInterval","split","paymentId","clearInterval","readerWaiting","some","connected","asking","show","mode","processing","askTip","base","answer","ask","tip","baseCents","percentages","tipPercentages","allowCustom","startCardPresent","amountCents","startBridge","bridge","paymentIntentId","clientSecret","collected","collectCardPayment","startKeyed","startLink","url","checkoutUrl","tipOn","Boolean","tippingEnabled","spacing","sx","minHeight","justifyContent","alignItems","variant","component","totalCents","dueCents","color","paidCents","aria-label","gap","flexWrap","flex","minWidth","describeOrderPayment","atMs","changeCents","size","label","onClick","livemode","terminal","testMode","failureMessage","width","severity","onSellOffline","href","actionLabel","direction","placeholder","toFixed","value","onChange","event","target","replace","helperText","slotProps","htmlInput","inputMode","rowGap","mr","disabled","pct","posTipFromPercent","gridTemplateColumns","available","fullWidth","publishableKey","credits","credit","providerId","stays","select","confirmed","title","description","confirmationText","confirmationButtonProps","then","catch","onVoided","alignSelf","open","onClose","onTake","tenderedCents","change","onCheck","code","onApply","canLookup","lookup","onLookup","query","accounts","onApplyCode","onApplyAccount","account","reference","onCharge","reservationId","onConfirmed","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,OAAO,EACPC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SAASC,mBAAmB,QAAQ,iCAAgC;AACpE,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,YAAYC,mBAAmB,0BAAgB;AAC/C,SACEC,cAAc,EACdC,aAAa,EACbC,eAAe,EACfC,kBAAkB,EAClBC,eAAe,EACfC,SAAS,EACTC,eAAe,EACfC,GA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B,OAAO9I;oBACbC,SAAS;oBACT,IAAI6I,MAAM,MAAMxH,IAAI,UAAU;wBAAEqB,WAAWmG,KAAKnG,SAAS;oBAAC;gBAC5D;;;;AAIR;AACAtE,eAAe6L,WAAW,GAAG"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos/pos-tender-panel.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Divider,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { useMerchantPayments } from '@aglyn/tenant-feature-instance'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport * as CommerceModel from '../../../model'\nimport {\n centsFromInput,\n newAttemptKey,\n posCreditLookup,\n posGiftCardBalance,\n posNativeBridge,\n posTender,\n PosRequestError,\n usd,\n type PosRegisterContext,\n type PosSaleSummary,\n type PosTenderAction,\n type PosTenderResult,\n} from './pos-api'\nimport { POS_TOUCH_PX } from './pos-product-grid.component'\nimport {\n PosCashDialog,\n PosCreditDialog,\n PosFolioDialog,\n PosGiftCardDialog,\n PosKeyedCardDialog,\n PosQrDialog,\n} from './pos-tender-dialogs.component'\nimport type { PosDisplayControl } from './use-pos-display'\n\ntype User = Parameters<typeof posTender>[0]\n\nconst STATUS_LABEL: Record<CommerceModel.OrderPaymentStatus, string> = {\n pending: 'Waiting',\n succeeded: 'Approved',\n failed: 'Declined',\n canceled: 'Canceled',\n reversed: 'Returned',\n}\n\nconst STATUS_COLOR: Record<\n CommerceModel.OrderPaymentStatus,\n 'default' | 'success' | 'error' | 'warning' | 'info'\n> = {\n pending: 'info',\n succeeded: 'success',\n failed: 'error',\n canceled: 'default',\n reversed: 'warning',\n}\n\nexport interface PosTenderPanelProps {\n user: User\n hostId: string\n registerId: string\n sale: PosSaleSummary\n context: PosRegisterContext | null\n stays: any[]\n display: PosDisplayControl\n onSale: (sale: PosSaleSummary) => void\n /** The sale is voided: the basket is the cashier's again. */\n onVoided: () => void\n /** The tip chosen for the next payment, before it is taken. */\n onTipChange?: (tipCents: number) => void\n /** A PIN-switched cashier (AGL-3609) takes each payment they start. */\n cashierAssertion?: string\n notify: (message: string, variant: 'success' | 'error' | 'warning' | 'info') => void\n /**\n * The register is offline (AGL-3625). Every tender here is the server's —\n * the card reader, the typed card, the QR link, the gift card, the room\n * charge and this sale's own cash — so each is off until it returns.\n */\n offline?: boolean\n /** Rings this basket as an offline cash sale instead; offered while nothing is paid. */\n onSellOffline?: () => void\n}\n\n/**\n * Taking payment on an open sale (AGL-3607): the balance due, every payment\n * taken so far with its live status, and the tenders. A sale can take as many\n * payments as it needs; it is paid when the balance reaches zero, and only\n * then does the server take the stock and complete it.\n */\nexport function PosTenderPanel(props: PosTenderPanelProps) {\n const { user, hostId, sale, context, display, onSale, notify } = props\n const settings = context?.settings\n // Card tenders all charge through the workspace's Stripe account. They stay\n // on screen without one, disabled with the reason, so the register says\n // what to set up instead of losing the buttons or refusing after a tap.\n const payments = useMerchantPayments(hostId)\n const cardsBlocked = payments.blocked\n const cardsReason = payments.reason ?? ''\n const [amount, setAmount] = useState('')\n const [tipCents, setTipCents] = useState(0)\n const [busy, setBusy] = useState(false)\n const [dialog, setDialog] = useState<'cash' | 'gift' | 'folio' | 'credit' | null>(null)\n // The store-credit provider whose dialog is open (AGL-3640).\n const [creditProvider, setCreditProvider] = useState<{ providerId: string; label: string; lookup: boolean } | null>(\n null,\n )\n const [qr, setQr] = useState<{ url: string; amountCents: number } | null>(null)\n const [keyed, setKeyed] = useState<{\n clientSecret: string\n amountCents: number\n paymentId: string\n stripeAccount?: string\n } | null>(null)\n const [readerId, setReaderId] = useState('')\n const inFlight = useRef(false)\n const { confirm } = useConfirmationContext()\n const { onTipChange } = props\n useEffect(() => {\n onTipChange?.(tipCents)\n }, [onTipChange, tipCents])\n\n const readers = (context?.readers ?? []).filter(\n (reader) => !reader.registerId || reader.registerId === props.registerId,\n )\n useEffect(() => {\n if (!readerId && readers.length) {\n setReaderId(readers.find((reader) => reader.registerId === props.registerId)?.id ?? readers[0].id)\n }\n }, [readerId, readers, props.registerId])\n\n // The amount defaults to whatever is still open; a split is the cashier\n // typing less than that.\n const typedCents = centsFromInput(amount)\n const chargeCents = typedCents > 0 ? Math.min(typedCents, sale.tenderableCents) : sale.tenderableCents\n const paid = sale.status === 'paid'\n const offline = props.offline === true\n\n const run = useCallback(\n async (\n action: PosTenderAction,\n body: Record<string, unknown> = {},\n starts = false,\n ): Promise<PosTenderResult | null> => {\n if (inFlight.current) return null\n inFlight.current = true\n setBusy(true)\n try {\n const result = await posTender(\n user,\n hostId,\n sale.orderId,\n action,\n starts && props.cashierAssertion ? { ...body, cashierAssertion: props.cashierAssertion } : body,\n starts ? newAttemptKey() : undefined,\n )\n onSale(result.sale)\n if (starts) {\n setAmount('')\n setTipCents(0)\n }\n return result\n } catch (error) {\n notify(error instanceof PosRequestError ? error.message : 'Something went wrong', 'error')\n return null\n } finally {\n inFlight.current = false\n setBusy(false)\n }\n },\n [user, hostId, sale.orderId, onSale, notify, props.cashierAssertion],\n )\n\n // Card payments still waiting are checked every two seconds: the reader,\n // the QR page and the typed card all settle on the server, and this is the\n // register's view of it (the webhook does the same thing when it lands).\n const pending = sale.payments.filter(\n (payment) => payment.status === 'pending' && CommerceModel.isCardPaymentMethod(payment.method),\n )\n const pendingKey = pending.map((payment) => payment.id).join(',')\n const latest = useRef({ user, onSale })\n latest.current = { user, onSale }\n useEffect(() => {\n if (!pendingKey) return undefined\n const timer = setInterval(async () => {\n for (const id of pendingKey.split(',')) {\n try {\n const result = await posTender(latest.current.user, hostId, sale.orderId, 'status', {\n paymentId: id,\n })\n latest.current.onSale(result.sale)\n } catch {\n // The next tick asks again.\n }\n }\n }, 2000)\n return () => clearInterval(timer)\n }, [pendingKey, hostId, sale.orderId])\n\n // The display shows \"tap your card\" while a reader payment waits, and the\n // running balance otherwise.\n const readerWaiting = pending.some((payment) => payment.method === 'card_present')\n useEffect(() => {\n if (!display.connected || display.asking) return\n if (readerWaiting) {\n void display.show({ mode: 'processing', processing: { message: 'Tap, insert or swipe your card on the reader.' } })\n }\n }, [readerWaiting, display])\n\n const askTip = useCallback(async () => {\n const base = chargeCents\n if (!(base > 0) || !settings) return\n const answer = await display.ask({\n mode: 'tip',\n tip: { baseCents: base, percentages: settings.tipPercentages, allowCustom: true },\n })\n if (answer) {\n setTipCents(answer.tipCents ?? 0)\n notify(answer.tipCents ? `Tip: ${usd(answer.tipCents)}` : 'No tip', 'info')\n }\n }, [chargeCents, settings, display, notify])\n\n const startCardPresent = useCallback(async () => {\n if (!readerId) return\n await run('card-present', { amountCents: chargeCents, tipCents, readerId }, true)\n }, [run, chargeCents, tipCents, readerId])\n\n const startBridge = useCallback(async () => {\n const bridge = posNativeBridge()\n if (!bridge) return\n const amountCents = chargeCents\n const result = await run('card-present-sdk', { amountCents, tipCents }, true)\n if (!result?.paymentIntentId || !result.clientSecret || !result.paymentId) return\n try {\n const collected = await bridge.collectCardPayment({\n paymentIntentId: result.paymentIntentId,\n clientSecret: result.clientSecret,\n amountCents: amountCents + tipCents,\n })\n if (collected.status !== 'collected') {\n notify(collected.message ?? 'The card was not taken.', 'warning')\n }\n } finally {\n // Settled by the server either way: the status poll captures an\n // authorized tap and records a decline or a cancel.\n await run('status', { paymentId: result.paymentId })\n }\n }, [run, chargeCents, tipCents, notify])\n\n const startKeyed = useCallback(async () => {\n const amountCents = chargeCents\n const result = await run('card-keyed', { amountCents, tipCents }, true)\n if (result?.clientSecret && result.paymentId) {\n setKeyed({\n clientSecret: result.clientSecret,\n amountCents: amountCents + tipCents,\n paymentId: result.paymentId,\n ...(result.stripeAccount ? { stripeAccount: result.stripeAccount } : {}),\n })\n }\n }, [run, chargeCents, tipCents])\n\n const startLink = useCallback(async () => {\n const amountCents = chargeCents\n const result = await run('card-link', { amountCents, tipCents }, true)\n const url = result?.sale.payments.find((payment) => payment.id === result.paymentId)?.checkoutUrl\n if (url) setQr({ url, amountCents: amountCents + tipCents })\n }, [run, chargeCents, tipCents])\n\n const tipOn = Boolean(settings?.tippingEnabled) && !paid\n\n return (\n <Stack spacing={1.5} sx={{ minHeight: 0 }}>\n <Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline' }}>\n <Typography variant=\"h6\">{paid ? 'Paid' : 'Balance due'}</Typography>\n <Typography variant=\"h4\" component=\"p\">\n {usd(paid ? sale.totalCents : sale.dueCents)}\n </Typography>\n </Box>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Total ${usd(sale.totalCents)} · paid ${usd(sale.paidCents)}` +\n (sale.tipCents ? ` · tips ${usd(sale.tipCents)}` : '')}\n </Typography>\n\n {sale.payments.length ? (\n <Stack spacing={1} aria-label=\"Payments\">\n {sale.payments.map((payment) => (\n <Box key={payment.id} sx={{ display: 'flex', alignItems: 'center', gap: 1, flexWrap: 'wrap' }}>\n <Typography variant=\"body2\" sx={{ flex: 1, minWidth: 140 }}>\n {CommerceModel.describeOrderPayment({ ...payment, atMs: 0 })}\n {payment.changeCents ? ` · change ${usd(payment.changeCents)}` : ''}\n </Typography>\n <Chip size=\"small\" label={STATUS_LABEL[payment.status]} color={STATUS_COLOR[payment.status]} />\n {payment.status === 'pending' && CommerceModel.isCardPaymentMethod(payment.method) ? (\n <>\n {payment.method === 'card_link' && payment.checkoutUrl ? (\n <Button\n size=\"small\"\n onClick={() => setQr({ url: payment.checkoutUrl as string, amountCents: payment.amountCents })}\n >\n {'Show QR'}\n </Button>\n ) : null}\n {payment.method === 'card_present' && payment.livemode === false && context?.terminal?.testMode ? (\n <Button size=\"small\" onClick={() => void run('simulate', { paymentId: payment.id })}>\n {'Simulate tap'}\n </Button>\n ) : null}\n <Button size=\"small\" color=\"error\" onClick={() => void run('cancel', { paymentId: payment.id })}>\n {'Cancel'}\n </Button>\n </>\n ) : null}\n {payment.status === 'failed' && payment.method === 'card_present' && !paid ? (\n <Button size=\"small\" onClick={() => void run('retry', { paymentId: payment.id })}>\n {'Retry'}\n </Button>\n ) : null}\n {payment.failureMessage && payment.status === 'failed' ? (\n <Typography variant=\"caption\" color=\"error\" sx={{ width: 1 }}>\n {payment.failureMessage}\n </Typography>\n ) : null}\n </Box>\n ))}\n </Stack>\n ) : null}\n\n {offline && !paid ? (\n <Alert\n severity=\"warning\"\n action={\n props.onSellOffline && sale.payments.length === 0 ? (\n <Button color=\"inherit\" size=\"small\" onClick={props.onSellOffline}>\n {'Sell for cash offline'}\n </Button>\n ) : null\n }\n >\n {sale.payments.length === 0\n ? 'Offline: card readers, typed cards, the QR link, gift cards, store credit and room charges are off. ' +\n 'Take this basket as an offline cash sale, or wait for the connection.'\n : 'Offline: this sale has a payment on it and finishes when the connection returns. ' +\n 'Card readers, typed cards, the QR link, gift cards, store credit and room charges are off.'}\n </Alert>\n ) : null}\n {!paid && !offline && cardsBlocked ? (\n <PrerequisiteNotice href={payments.href ?? undefined} actionLabel=\"Open Payments\">\n {`${cardsReason} Cash, gift cards and store credit work without it.`}\n </PrerequisiteNotice>\n ) : null}\n {!paid ? (\n <>\n <Divider />\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <TextField\n label=\"Amount to charge ($)\"\n placeholder={(sale.tenderableCents / 100).toFixed(2)}\n value={amount}\n onChange={(event) => setAmount(event.target.value.replace(/[^0-9.]/g, ''))}\n sx={{ flex: 1 }}\n helperText={\n typedCents > 0 && typedCents < sale.tenderableCents\n ? `Split: ${usd(sale.tenderableCents - typedCents)} stays open`\n : ' '\n }\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n </Stack>\n {tipOn ? (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}>\n <Typography variant=\"body2\" sx={{ mr: 1 }}>\n {`Tip ${usd(tipCents)}`}\n </Typography>\n {display.connected ? (\n <Button\n variant=\"outlined\"\n onClick={() => void askTip()}\n disabled={offline || busy || Boolean(display.asking)}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {display.asking === 'tip' ? 'Waiting for customer…' : 'Ask on display'}\n </Button>\n ) : null}\n {(settings?.tipPercentages ?? []).map((pct) => (\n <Button\n key={pct}\n variant={tipCents === CommerceModel.posTipFromPercent(chargeCents, pct) && tipCents > 0 ? 'contained' : 'outlined'}\n onClick={() => setTipCents(CommerceModel.posTipFromPercent(chargeCents, pct))}\n sx={{ minHeight: POS_TOUCH_PX }}\n >\n {`${pct}%`}\n </Button>\n ))}\n <Button onClick={() => setTipCents(0)} sx={{ minHeight: POS_TOUCH_PX }}>\n {'No tip'}\n </Button>\n </Stack>\n ) : null}\n <Box\n sx={{\n display: 'grid',\n gap: 1,\n gridTemplateColumns: 'repeat(auto-fill, minmax(140px, 1fr))',\n }}\n >\n <Button\n variant=\"contained\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => setDialog('cash')}\n sx={{ minHeight: 56 }}\n >\n {'Cash'}\n </Button>\n {context?.terminal?.available && readers.length ? (\n <BlockedControl blocked={cardsBlocked} reason={cardsReason} fullWidth>\n <Button\n variant=\"contained\"\n disabled={offline || busy || chargeCents <= 0 || !readerId}\n onClick={() => void startCardPresent()}\n sx={{ minHeight: 56 }}\n >\n {'Card reader'}\n </Button>\n </BlockedControl>\n ) : null}\n {posNativeBridge() ? (\n <BlockedControl blocked={cardsBlocked} reason={cardsReason} fullWidth>\n <Button\n variant=\"contained\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => void startBridge()}\n sx={{ minHeight: 56 }}\n >\n {'Tap to Pay / Bluetooth reader'}\n </Button>\n </BlockedControl>\n ) : null}\n {context?.publishableKey ? (\n <BlockedControl blocked={cardsBlocked} reason={cardsReason} fullWidth>\n <Button\n variant=\"outlined\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => void startKeyed()}\n sx={{ minHeight: 56 }}\n >\n {'Type card'}\n </Button>\n </BlockedControl>\n ) : null}\n <BlockedControl blocked={cardsBlocked} reason={cardsReason} fullWidth>\n <Button\n variant=\"outlined\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => void startLink()}\n sx={{ minHeight: 56 }}\n >\n {'Card (QR)'}\n </Button>\n </BlockedControl>\n <Button\n variant=\"outlined\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => setDialog('gift')}\n sx={{ minHeight: 56 }}\n >\n {'Gift card'}\n </Button>\n {(context?.credits ?? []).map((credit) => (\n <Button\n key={credit.providerId}\n variant=\"outlined\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => {\n setCreditProvider(credit)\n setDialog('credit')\n }}\n sx={{ minHeight: 56 }}\n >\n {credit.label}\n </Button>\n ))}\n {props.stays.length ? (\n <Button\n variant=\"outlined\"\n disabled={offline || busy || chargeCents <= 0}\n onClick={() => setDialog('folio')}\n sx={{ minHeight: 56 }}\n >\n {'Room'}\n </Button>\n ) : null}\n </Box>\n {context?.terminal?.available && readers.length > 1 ? (\n <TextField\n select\n size=\"small\"\n label=\"Card reader\"\n value={readerId}\n onChange={(event) => setReaderId(event.target.value)}\n >\n {readers.map((reader) => (\n <MenuItem key={reader.id} value={reader.id}>\n {`${reader.label}${reader.status === 'online' ? '' : ' (offline)'}`}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n {readers.some((reader) => reader.id === readerId && reader.status !== 'online') ? (\n <Alert severity=\"warning\">{'The selected card reader looks offline.'}</Alert>\n ) : null}\n <Button\n color=\"error\"\n disabled={offline || busy}\n onClick={async () => {\n const confirmed = await confirm({\n title: 'Void this sale?',\n description:\n 'Every payment taken on it is handed back: cards are refunded, gift ' +\n 'cards and store credit re-credited and room charges removed. Hand back any cash.',\n confirmationText: 'Void sale',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n const result = await run('void')\n if (result) {\n notify('Sale voided', 'info')\n props.onVoided()\n }\n }}\n sx={{ minHeight: POS_TOUCH_PX, alignSelf: 'flex-start' }}\n >\n {'Void sale'}\n </Button>\n </>\n ) : null}\n\n <PosCashDialog\n open={dialog === 'cash'}\n dueCents={chargeCents}\n tipCents={tipCents}\n busy={busy}\n onClose={() => setDialog(null)}\n onTake={async (tenderedCents) => {\n const result = await run(\n 'cash',\n {\n tenderedCents,\n ...(typedCents > 0 ? { amountCents: chargeCents } : {}),\n tipCents,\n },\n true,\n )\n if (result) {\n setDialog(null)\n const change = result.sale.payments.find((payment) => payment.id === result.paymentId)?.changeCents\n if (change) notify(`Change due: ${usd(change)}`, 'success')\n }\n }}\n />\n <PosGiftCardDialog\n open={dialog === 'gift'}\n busy={busy}\n onClose={() => setDialog(null)}\n onCheck={async (code) => {\n try {\n return await posGiftCardBalance(user, hostId, code)\n } catch (error) {\n notify(error instanceof PosRequestError ? error.message : 'Could not read that card', 'warning')\n return null\n }\n }}\n onApply={async (code) => {\n const result = await run('gift-card', { code, ...(typedCents > 0 ? { amountCents: chargeCents } : {}) }, true)\n if (result) setDialog(null)\n }}\n />\n <PosCreditDialog\n open={dialog === 'credit' && Boolean(creditProvider)}\n label={creditProvider?.label ?? 'Store credit'}\n canLookup={Boolean(creditProvider?.lookup)}\n busy={busy}\n onClose={() => setDialog(null)}\n onLookup={async (query) => {\n if (!creditProvider) return null\n try {\n return (await posCreditLookup(user, hostId, creditProvider.providerId, query)).accounts\n } catch (error) {\n notify(error instanceof PosRequestError ? error.message : 'Could not look that up', 'warning')\n return null\n }\n }}\n onApplyCode={async (code) => {\n const result = await run('credit', { code, ...(typedCents > 0 ? { amountCents: chargeCents } : {}) }, true)\n if (result) setDialog(null)\n }}\n onApplyAccount={async (account) => {\n if (!creditProvider) return\n const result = await run(\n 'credit',\n {\n providerId: creditProvider.providerId,\n reference: account.reference,\n ...(typedCents > 0 ? { amountCents: chargeCents } : {}),\n },\n true,\n )\n if (result) setDialog(null)\n }}\n />\n <PosFolioDialog\n open={dialog === 'folio'}\n amountCents={chargeCents}\n stays={props.stays}\n busy={busy}\n onClose={() => setDialog(null)}\n onCharge={async (reservationId) => {\n const result = await run(\n 'folio',\n { reservationId, ...(typedCents > 0 ? { amountCents: chargeCents } : {}) },\n true,\n )\n if (result) setDialog(null)\n }}\n />\n <PosQrDialog url={qr?.url ?? ''} amountCents={qr?.amountCents ?? 0} onClose={() => setQr(null)} />\n <PosKeyedCardDialog\n clientSecret={keyed?.clientSecret ?? ''}\n publishableKey={context?.publishableKey ?? ''}\n stripeAccount={keyed?.stripeAccount ?? ''}\n amountCents={keyed?.amountCents ?? 0}\n onClose={async () => {\n const open = keyed\n setKeyed(null)\n // Closing without paying releases the amount for another tender.\n if (open) await run('cancel', { paymentId: open.paymentId })\n }}\n onConfirmed={async () => {\n const open = keyed\n setKeyed(null)\n if (open) await run('status', { paymentId: open.paymentId })\n }}\n />\n </Stack>\n )\n}\nPosTenderPanel.displayName = 'PosTenderPanel'\n"],"names":["Alert","Box","Button","Chip","Divider","MenuItem","Stack","TextField","Typography","useConfirmationContext","BlockedControl","PrerequisiteNotice","useMerchantPayments","useCallback","useEffect","useRef","useState","CommerceModel","centsFromInput","newAttemptKey","posCreditLookup","posGiftCardBalance","posNativeBridge","posTender","PosRequestError","usd","POS_TOUCH_PX","PosCashDialog","PosCreditDialog","PosFolioDialog","PosGiftCardDialog","PosKeyedCardDialog","PosQrDialog","STATUS_LABEL","pending","succeeded","failed","canceled","reversed","STATUS_COLOR","PosTenderPanel","props","payments","context","user","hostId","sale","display","onSale","notify","settings","cardsBlocked","blocked","cardsReason","reason","amount","setAmount","tipCents","setTipCents","busy","setBusy","dialog","setDialog","creditProvider","setCreditProvider","qr","setQr","keyed","setKeyed","readerId","setReaderId","inFlight","confirm","onTipChange","readers","filter","reader","registerId","length","find","id","typedCents","chargeCents","Math","min","tenderableCents","paid","status","offline","run","action","body","starts","current","result","orderId","cashierAssertion","undefined","error","message","payment","isCardPaymentMethod","method","pendingKey","map","join","latest","timer","setInterval","split","paymentId","clearInterval","readerWaiting","some","connected","asking","show","mode","processing","askTip","base","answer","ask","tip","baseCents","percentages","tipPercentages","allowCustom","startCardPresent","amountCents","startBridge","bridge","paymentIntentId","clientSecret","collected","collectCardPayment","startKeyed","stripeAccount","startLink","url","checkoutUrl","tipOn","Boolean","tippingEnabled","spacing","sx","minHeight","justifyContent","alignItems","variant","component","totalCents","dueCents","color","paidCents","aria-label","gap","flexWrap","flex","minWidth","describeOrderPayment","atMs","changeCents","size","label","onClick","livemode","terminal","testMode","failureMessage","width","severity","onSellOffline","href","actionLabel","direction","placeholder","toFixed","value","onChange","event","target","replace","helperText","slotProps","htmlInput","inputMode","rowGap","mr","disabled","pct","posTipFromPercent","gridTemplateColumns","available","fullWidth","publishableKey","credits","credit","providerId","stays","select","confirmed","title","description","confirmationText","confirmationButtonProps","then","catch","onVoided","alignSelf","open","onClose","onTake","tenderedCents","change","onCheck","code","onApply","canLookup","lookup","onLookup","query","accounts","onApplyCode","onApplyAccount","account","reference","onCharge","reservationId","onConfirmed","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,OAAO,EACPC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,kBAAkB,QAAQ,gEAA+D;A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yBAAAA,MAAOkE,YAAY,oBAAI;gBACrC8D,cAAc,WAAExJ,2BAAAA,QAASwJ,cAAc,oBAAI;gBAC3C1D,aAAa,WAAEtE,yBAAAA,MAAOsE,aAAa,oBAAI;gBACvCR,WAAW,WAAE9D,yBAAAA,MAAO8D,WAAW,oBAAI;gBACnCkF,SAAS;oBACP,MAAMD,OAAO/I;oBACbC,SAAS;oBACT,iEAAiE;oBACjE,IAAI8I,MAAM,MAAMzH,IAAI,UAAU;wBAAEqB,WAAWoG,KAAKpG,SAAS;oBAAC;gBAC5D;gBACAuH,aAAa;oBACX,MAAMnB,OAAO/I;oBACbC,SAAS;oBACT,IAAI8I,MAAM,MAAMzH,IAAI,UAAU;wBAAEqB,WAAWoG,KAAKpG,SAAS;oBAAC;gBAC5D;;;;AAIR;AACAtE,eAAe8L,WAAW,GAAG"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as CommerceModel from '../../model';
|
|
2
|
+
import { type ProductMediaPick } from './product-builder-fields.component';
|
|
2
3
|
type Patch = Partial<CommerceModel.HostProduct>;
|
|
3
4
|
export interface ProductAddOnsFieldsProps {
|
|
4
5
|
modifierGroups: readonly CommerceModel.ProductModifierGroup[];
|
|
@@ -7,6 +8,8 @@ export interface ProductAddOnsFieldsProps {
|
|
|
7
8
|
/** The product's variants, each of which a choice may be priced on. */
|
|
8
9
|
variants: readonly Pick<CommerceModel.ProductVariant, 'id' | 'options'>[];
|
|
9
10
|
update: (patch: Patch) => void;
|
|
11
|
+
/** Opens the media browser for a choice's picture (AGL-4205); without it, no picture is chosen. */
|
|
12
|
+
pick?: ProductMediaPick;
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
15
|
* What a choice's per-variant prices are called (AGL-4100): by the one
|
|
@@ -22,6 +25,16 @@ export declare function newAddOnGroup(): CommerceModel.ProductModifierGroup;
|
|
|
22
25
|
* which refuses one).
|
|
23
26
|
*/
|
|
24
27
|
export declare function withVariantPrice(option: CommerceModel.ProductModifierOption, variantId: string, raw: string): CommerceModel.ProductModifierOption;
|
|
28
|
+
/**
|
|
29
|
+
* A choice with its card changed (AGL-4205): its picture, its note, or what
|
|
30
|
+
* it includes as a combo, typed one item per line. A cleared field is
|
|
31
|
+
* dropped, never stored as `undefined`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function withChoiceCard(option: CommerceModel.ProductModifierOption, patch: {
|
|
34
|
+
imageUrl?: string | null;
|
|
35
|
+
note?: string | null;
|
|
36
|
+
includes?: string | null;
|
|
37
|
+
}): CommerceModel.ProductModifierOption;
|
|
25
38
|
/**
|
|
26
39
|
* The product's add-ons (AGL-4100, from the register's modifiers of
|
|
27
40
|
* AGL-3607): choices added to the item that are not stocked variants — walls
|