@aglyn/plugins-commerce 1.0.0-beta.230 → 1.0.0-beta.232
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/package.json +13 -13
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/index.js.map +1 -1
- package/src/lib/barcode/barcode-decode.d.ts +71 -0
- package/src/lib/barcode/barcode-decode.js +498 -0
- package/src/lib/barcode/barcode-decode.js.map +1 -0
- package/src/lib/barcode/barcode-encode.d.ts +44 -0
- package/src/lib/barcode/barcode-encode.js +138 -0
- package/src/lib/barcode/barcode-encode.js.map +1 -0
- package/src/lib/barcode/barcode-scanner.component.d.ts +23 -0
- package/src/lib/barcode/barcode-scanner.component.js +260 -0
- package/src/lib/barcode/barcode-scanner.component.js.map +1 -0
- package/src/lib/barcode/scan-button.component.d.ts +10 -0
- package/src/lib/barcode/scan-button.component.js +62 -0
- package/src/lib/barcode/scan-button.component.js.map +1 -0
- package/src/lib/barcode/scanner-wedge.d.ts +35 -0
- package/src/lib/barcode/scanner-wedge.js +108 -0
- package/src/lib/barcode/scanner-wedge.js.map +1 -0
- package/src/lib/components/account.js +10 -1
- package/src/lib/components/account.js.map +1 -1
- package/src/lib/components/cart-extras.d.ts +45 -0
- package/src/lib/components/cart-extras.js +127 -0
- package/src/lib/components/cart-extras.js.map +1 -0
- package/src/lib/components/cart.js +82 -15
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/checkout-return-notice.d.ts +26 -0
- package/src/lib/components/checkout-return-notice.js +48 -0
- package/src/lib/components/checkout-return-notice.js.map +1 -0
- package/src/lib/components/commerce-console-page.js +124 -0
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/commerce-console-sections.d.ts +1 -1
- package/src/lib/components/commerce-console-sections.js +4 -0
- package/src/lib/components/commerce-console-sections.js.map +1 -1
- package/src/lib/components/console/bulk-fulfill.d.ts +44 -0
- package/src/lib/components/console/bulk-fulfill.js +84 -0
- package/src/lib/components/console/bulk-fulfill.js.map +1 -0
- package/src/lib/components/console/catalog-organization-card.component.js +1 -0
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
- package/src/lib/components/console/customer-notifications-card.component.d.ts +19 -0
- package/src/lib/components/console/customer-notifications-card.component.js +149 -0
- package/src/lib/components/console/customer-notifications-card.component.js.map +1 -0
- package/src/lib/components/console/host-orders-card.component.js +88 -6
- package/src/lib/components/console/host-orders-card.component.js.map +1 -1
- package/src/lib/components/console/locations-card.component.js +164 -57
- package/src/lib/components/console/locations-card.component.js.map +1 -1
- package/src/lib/components/console/order-detail-dialog.component.js +209 -61
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/order-fulfillment-panel.component.d.ts +48 -0
- package/src/lib/components/console/order-fulfillment-panel.component.js +542 -0
- package/src/lib/components/console/order-fulfillment-panel.component.js.map +1 -0
- package/src/lib/components/console/order-invoice.component.d.ts +33 -0
- package/src/lib/components/console/order-invoice.component.js +81 -0
- package/src/lib/components/console/order-invoice.component.js.map +1 -0
- package/src/lib/components/console/order-receipt-resend.component.d.ts +21 -0
- package/src/lib/components/console/order-receipt-resend.component.js +203 -0
- package/src/lib/components/console/order-receipt-resend.component.js.map +1 -0
- package/src/lib/components/console/order-returns.component.d.ts +36 -0
- package/src/lib/components/console/order-returns.component.js +142 -0
- package/src/lib/components/console/order-returns.component.js.map +1 -0
- package/src/lib/components/console/order-shipping-actions.component.d.ts +54 -0
- package/src/lib/components/console/order-shipping-actions.component.js +149 -0
- package/src/lib/components/console/order-shipping-actions.component.js.map +1 -0
- package/src/lib/components/console/order-webhooks-card.component.d.ts +50 -0
- package/src/lib/components/console/order-webhooks-card.component.js +623 -0
- package/src/lib/components/console/order-webhooks-card.component.js.map +1 -0
- package/src/lib/components/console/order-zones.d.ts +155 -0
- package/src/lib/components/console/order-zones.js +40 -0
- package/src/lib/components/console/order-zones.js.map +1 -0
- package/src/lib/components/console/payment-methods-card.component.d.ts +67 -0
- package/src/lib/components/console/payment-methods-card.component.js +395 -0
- package/src/lib/components/console/payment-methods-card.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-api.d.ts +124 -0
- package/src/lib/components/console/pos/pos-api.js +101 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +36 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.js +160 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.d.ts +39 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.js +352 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-product-grid.component.d.ts +47 -0
- package/src/lib/components/console/pos/pos-product-grid.component.js +272 -0
- package/src/lib/components/console/pos/pos-product-grid.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.d.ts +27 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.js +282 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +53 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js +445 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.d.ts +31 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.js +640 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/use-pos-display.d.ts +43 -0
- package/src/lib/components/console/pos/use-pos-display.js +161 -0
- package/src/lib/components/console/pos/use-pos-display.js.map +1 -0
- package/src/lib/components/console/pos-devices-card.component.d.ts +14 -0
- package/src/lib/components/console/pos-devices-card.component.js +546 -0
- package/src/lib/components/console/pos-devices-card.component.js.map +1 -0
- package/src/lib/components/console/pos-display/brand-screen.d.ts +33 -0
- package/src/lib/components/console/pos-display/brand-screen.js +85 -0
- package/src/lib/components/console/pos-display/brand-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/cart-screen.d.ts +29 -0
- package/src/lib/components/console/pos-display/cart-screen.js +166 -0
- package/src/lib/components/console/pos-display/cart-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/pairing-screen.d.ts +24 -0
- package/src/lib/components/console/pos-display/pairing-screen.js +127 -0
- package/src/lib/components/console/pos-display/pairing-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/pos-display-api.d.ts +90 -0
- package/src/lib/components/console/pos-display/pos-display-api.js +140 -0
- package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -0
- package/src/lib/components/console/pos-display/receipt-screen.d.ts +35 -0
- package/src/lib/components/console/pos-display/receipt-screen.js +200 -0
- package/src/lib/components/console/pos-display/receipt-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/tip-screen.d.ts +36 -0
- package/src/lib/components/console/pos-display/tip-screen.js +211 -0
- package/src/lib/components/console/pos-display/tip-screen.js.map +1 -0
- package/src/lib/components/console/pos-display-page.component.d.ts +16 -0
- package/src/lib/components/console/pos-display-page.component.js +407 -0
- package/src/lib/components/console/pos-display-page.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.d.ts +40 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js +289 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.d.ts +34 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.js +61 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +38 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +129 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.d.ts +37 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.js +60 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.d.ts +48 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.js +220 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.d.ts +63 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js +186 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-receipt.d.ts +39 -0
- package/src/lib/components/console/pos-ops/pos-receipt.js +182 -0
- package/src/lib/components/console/pos-ops/pos-receipt.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.d.ts +40 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.js +465 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.d.ts +29 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js +253 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +34 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +494 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.d.ts +37 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.js +102 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.d.ts +30 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js +277 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/register-ops.d.ts +28 -0
- package/src/lib/components/console/pos-ops/register-ops.js +28 -0
- package/src/lib/components/console/pos-ops/register-ops.js.map +1 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.d.ts +46 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.js +128 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.js.map +1 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.d.ts +36 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js +64 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js.map +1 -0
- package/src/lib/components/console/pos-page.component.d.ts +13 -5
- package/src/lib/components/console/pos-page.component.js +756 -654
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/pos-zones.d.ts +23 -0
- package/src/lib/components/console/pos-zones.js +31 -0
- package/src/lib/components/console/pos-zones.js.map +1 -0
- package/src/lib/components/console/product-editor-dialog.component.js +61 -71
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-labels-dialog.component.d.ts +13 -0
- package/src/lib/components/console/product-labels-dialog.component.js +197 -0
- package/src/lib/components/console/product-labels-dialog.component.js.map +1 -0
- package/src/lib/components/console/product-register-fields.component.d.ts +19 -0
- package/src/lib/components/console/product-register-fields.component.js +241 -0
- package/src/lib/components/console/product-register-fields.component.js.map +1 -0
- package/src/lib/components/console/product-zones.d.ts +44 -0
- package/src/lib/components/console/product-zones.js.map +1 -1
- package/src/lib/components/console/products-hub-card.component.js +23 -20
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/register-hardware-card.component.d.ts +33 -0
- package/src/lib/components/console/register-hardware-card.component.js +826 -0
- package/src/lib/components/console/register-hardware-card.component.js.map +1 -0
- package/src/lib/components/console/registers-card.component.js +24 -5
- package/src/lib/components/console/registers-card.component.js.map +1 -1
- package/src/lib/components/console/return-actions.d.ts +38 -0
- package/src/lib/components/console/return-actions.js +76 -0
- package/src/lib/components/console/return-actions.js.map +1 -0
- package/src/lib/components/console/return-detail-dialog.component.d.ts +34 -0
- package/src/lib/components/console/return-detail-dialog.component.js +718 -0
- package/src/lib/components/console/return-detail-dialog.component.js.map +1 -0
- package/src/lib/components/console/return-settings-card.component.d.ts +34 -0
- package/src/lib/components/console/return-settings-card.component.js +195 -0
- package/src/lib/components/console/return-settings-card.component.js.map +1 -0
- package/src/lib/components/console/return-zones.d.ts +87 -0
- package/src/lib/components/console/return-zones.js +31 -0
- package/src/lib/components/console/return-zones.js.map +1 -0
- package/src/lib/components/console/returns-card.component.d.ts +45 -0
- package/src/lib/components/console/returns-card.component.js +159 -0
- package/src/lib/components/console/returns-card.component.js.map +1 -0
- package/src/lib/components/console/shipping-settings-card.component.js +161 -5
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
- package/src/lib/components/console/shippingeasy-card.component.d.ts +59 -0
- package/src/lib/components/console/shippingeasy-card.component.js +378 -0
- package/src/lib/components/console/shippingeasy-card.component.js.map +1 -0
- package/src/lib/components/console/shipstation-card.component.d.ts +35 -0
- package/src/lib/components/console/shipstation-card.component.js +345 -0
- package/src/lib/components/console/shipstation-card.component.js.map +1 -0
- package/src/lib/components/console/start-return-dialog.component.d.ts +40 -0
- package/src/lib/components/console/start-return-dialog.component.js +243 -0
- package/src/lib/components/console/start-return-dialog.component.js.map +1 -0
- package/src/lib/components/console/stock-movements-card.component.js +2 -1
- package/src/lib/components/console/stock-movements-card.component.js.map +1 -1
- package/src/lib/components/console/store-settings-card.component.js +2 -66
- package/src/lib/components/console/store-settings-card.component.js.map +1 -1
- package/src/lib/components/console/store-zones.d.ts +42 -0
- package/src/lib/components/console/store-zones.js +39 -0
- package/src/lib/components/console/store-zones.js.map +1 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.js +1 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.js.map +1 -1
- package/src/lib/components/order-status.d.ts +36 -0
- package/src/lib/components/order-status.js +502 -0
- package/src/lib/components/order-status.js.map +1 -0
- package/src/lib/components/product-detail.js +41 -2
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/return-request.d.ts +32 -0
- package/src/lib/components/return-request.js +576 -0
- package/src/lib/components/return-request.js.map +1 -0
- package/src/lib/components/storefront-payment-appearance.d.ts +32 -0
- package/src/lib/components/storefront-payment-appearance.js +114 -0
- package/src/lib/components/storefront-payment-appearance.js.map +1 -0
- package/src/lib/components/storefront-payment-element.d.ts +57 -1
- package/src/lib/components/storefront-payment-element.js +332 -33
- package/src/lib/components/storefront-payment-element.js.map +1 -1
- package/src/lib/constants/order-status.d.ts +22 -0
- package/src/lib/constants/order-status.js +22 -0
- package/src/lib/constants/order-status.js.map +1 -0
- package/src/lib/constants/return-request.d.ts +27 -0
- package/src/lib/constants/return-request.js +32 -0
- package/src/lib/constants/return-request.js.map +1 -0
- package/src/lib/constants/stock-movement-query.js +2 -1
- package/src/lib/constants/stock-movement-query.js.map +1 -1
- package/src/lib/declarations.console-server.js +9 -0
- package/src/lib/declarations.console-server.js.map +1 -1
- package/src/lib/declarations.server.d.ts +2 -1
- package/src/lib/declarations.server.js +68 -1
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/buyer-notifications.d.ts +59 -0
- package/src/lib/model/buyer-notifications.js +97 -0
- package/src/lib/model/buyer-notifications.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +171 -2
- package/src/lib/model/commerce-orders.js +26 -16
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-payment-methods.d.ts +146 -0
- package/src/lib/model/commerce-payment-methods.js +247 -0
- package/src/lib/model/commerce-payment-methods.js.map +1 -0
- package/src/lib/model/commerce-pos-ops.d.ts +437 -0
- package/src/lib/model/commerce-pos-ops.js +721 -0
- package/src/lib/model/commerce-pos-ops.js.map +1 -0
- package/src/lib/model/commerce-pos.d.ts +263 -0
- package/src/lib/model/commerce-pos.js +375 -0
- package/src/lib/model/commerce-pos.js.map +1 -0
- package/src/lib/model/commerce-printers.d.ts +211 -0
- package/src/lib/model/commerce-printers.js +181 -0
- package/src/lib/model/commerce-printers.js.map +1 -0
- package/src/lib/model/commerce-receipt.d.ts +97 -0
- package/src/lib/model/commerce-receipt.js +180 -0
- package/src/lib/model/commerce-receipt.js.map +1 -0
- package/src/lib/model/commerce-returns.d.ts +207 -0
- package/src/lib/model/commerce-returns.js +300 -0
- package/src/lib/model/commerce-returns.js.map +1 -0
- package/src/lib/model/commerce-shipping.d.ts +44 -1
- package/src/lib/model/commerce-shipping.js +53 -9
- package/src/lib/model/commerce-shipping.js.map +1 -1
- package/src/lib/model/commerce-tax-engine.d.ts +90 -0
- package/src/lib/model/commerce-tax-engine.js +129 -0
- package/src/lib/model/commerce-tax-engine.js.map +1 -0
- package/src/lib/model/commerce.d.ts +91 -2
- package/src/lib/model/commerce.js +89 -1
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +16 -0
- package/src/lib/model/index.js +16 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/order-events.d.ts +154 -0
- package/src/lib/model/order-events.js +153 -0
- package/src/lib/model/order-events.js.map +1 -0
- package/src/lib/model/order-fulfillment.d.ts +117 -0
- package/src/lib/model/order-fulfillment.js +217 -0
- package/src/lib/model/order-fulfillment.js.map +1 -0
- package/src/lib/model/order-history.d.ts +58 -0
- package/src/lib/model/order-history.js +22 -0
- package/src/lib/model/order-history.js.map +1 -0
- package/src/lib/model/order-list-fields.d.ts +9 -1
- package/src/lib/model/order-list-fields.js +7 -1
- package/src/lib/model/order-list-fields.js.map +1 -1
- package/src/lib/model/order-shipping-export.d.ts +91 -0
- package/src/lib/model/order-shipping-export.js +192 -0
- package/src/lib/model/order-shipping-export.js.map +1 -0
- package/src/lib/model/order-status-view.d.ts +103 -0
- package/src/lib/model/order-status-view.js +156 -0
- package/src/lib/model/order-status-view.js.map +1 -0
- package/src/lib/model/order-webhooks.d.ts +142 -0
- package/src/lib/model/order-webhooks.js +91 -0
- package/src/lib/model/order-webhooks.js.map +1 -0
- package/src/lib/model/product-channel.d.ts +56 -0
- package/src/lib/model/product-channel.js +86 -0
- package/src/lib/model/product-channel.js.map +1 -0
- package/src/lib/model/product-modifiers.d.ts +80 -0
- package/src/lib/model/product-modifiers.js +140 -0
- package/src/lib/model/product-modifiers.js.map +1 -0
- package/src/lib/model/product-write.d.ts +186 -0
- package/src/lib/model/product-write.js +116 -0
- package/src/lib/model/product-write.js.map +1 -0
- package/src/lib/model/shippingeasy.d.ts +94 -0
- package/src/lib/model/shippingeasy.js +267 -0
- package/src/lib/model/shippingeasy.js.map +1 -0
- package/src/lib/model/shipstation.d.ts +125 -0
- package/src/lib/model/shipstation.js +399 -0
- package/src/lib/model/shipstation.js.map +1 -0
- package/src/lib/model/smart-collection-reads.d.ts +32 -0
- package/src/lib/model/smart-collection-reads.js +63 -0
- package/src/lib/model/smart-collection-reads.js.map +1 -0
- package/src/lib/model/tracking-url.d.ts +74 -0
- package/src/lib/model/tracking-url.js +159 -0
- package/src/lib/model/tracking-url.js.map +1 -0
- package/src/lib/plugin-config.d.ts +13 -0
- package/src/lib/plugin-config.js +77 -5
- package/src/lib/plugin-config.js.map +1 -1
- package/src/lib/plugin.js +26 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/pos-ops-config.d.ts +39 -0
- package/src/lib/pos-ops-config.js +88 -0
- package/src/lib/pos-ops-config.js.map +1 -0
- package/src/lib/printing/print-document.d.ts +106 -0
- package/src/lib/printing/print-document.js +464 -0
- package/src/lib/printing/print-document.js.map +1 -0
- package/src/lib/printing/product-labels.d.ts +58 -0
- package/src/lib/printing/product-labels.js +116 -0
- package/src/lib/printing/product-labels.js.map +1 -0
- package/src/lib/printing/render-epson.d.ts +57 -0
- package/src/lib/printing/render-epson.js +135 -0
- package/src/lib/printing/render-epson.js.map +1 -0
- package/src/lib/printing/render-star.d.ts +45 -0
- package/src/lib/printing/render-star.js +100 -0
- package/src/lib/printing/render-star.js.map +1 -0
- package/src/lib/printing/render-text.d.ts +25 -0
- package/src/lib/printing/render-text.js +53 -0
- package/src/lib/printing/render-text.js.map +1 -0
- package/src/lib/server/api-v1/openapi.js +27 -4
- package/src/lib/server/api-v1/openapi.js.map +1 -1
- package/src/lib/server/api-v1/order-view.d.ts +67 -0
- package/src/lib/server/api-v1/order-view.js +120 -0
- package/src/lib/server/api-v1/order-view.js.map +1 -0
- package/src/lib/server/api-v1/orders-and-products.js +58 -65
- package/src/lib/server/api-v1/orders-and-products.js.map +1 -1
- package/src/lib/server/billing-webhook.js +135 -28
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +29 -0
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/carrier-rates-availability.d.ts +26 -0
- package/src/lib/server/carrier-rates-availability.js +76 -0
- package/src/lib/server/carrier-rates-availability.js.map +1 -0
- package/src/lib/server/carrier-shipping.d.ts +84 -0
- package/src/lib/server/carrier-shipping.js +135 -0
- package/src/lib/server/carrier-shipping.js.map +1 -0
- package/src/lib/server/cart-checkout.d.ts +2 -0
- package/src/lib/server/cart-checkout.js +226 -22
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/channel-order-updates.d.ts +50 -0
- package/src/lib/server/channel-order-updates.js +290 -0
- package/src/lib/server/channel-order-updates.js.map +1 -0
- package/src/lib/server/channel-orders.d.ts +85 -0
- package/src/lib/server/channel-orders.js +543 -0
- package/src/lib/server/channel-orders.js.map +1 -0
- package/src/lib/server/checkout-extras.d.ts +64 -0
- package/src/lib/server/checkout-extras.js +157 -0
- package/src/lib/server/checkout-extras.js.map +1 -0
- package/src/lib/server/{feed.d.ts → checkout-status.d.ts} +2 -7
- package/src/lib/server/checkout-status.js +111 -0
- package/src/lib/server/checkout-status.js.map +1 -0
- package/src/lib/server/checkout.js +86 -9
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/draft-order.js +34 -5
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/fulfill-order.d.ts +127 -10
- package/src/lib/server/fulfill-order.js +451 -49
- package/src/lib/server/fulfill-order.js.map +1 -1
- package/src/lib/server/legacy-feed.d.ts +28 -0
- package/src/lib/server/legacy-feed.js +52 -0
- package/src/lib/server/legacy-feed.js.map +1 -0
- package/src/lib/server/native-checkout.d.ts +34 -15
- package/src/lib/server/native-checkout.js +32 -17
- package/src/lib/server/native-checkout.js.map +1 -1
- package/src/lib/server/order-event-host-emit.d.ts +23 -0
- package/src/lib/server/order-event-host-emit.js +30 -0
- package/src/lib/server/order-event-host-emit.js.map +1 -0
- package/src/lib/server/order-event-triggers.d.ts +37 -0
- package/src/lib/server/order-event-triggers.js +119 -0
- package/src/lib/server/order-event-triggers.js.map +1 -0
- package/src/lib/server/order-events.d.ts +62 -0
- package/src/lib/server/order-events.js +109 -0
- package/src/lib/server/order-events.js.map +1 -0
- package/src/lib/server/order-history.d.ts +23 -0
- package/src/lib/server/order-history.js +65 -0
- package/src/lib/server/order-history.js.map +1 -0
- package/src/lib/server/order-notifications.d.ts +185 -0
- package/src/lib/server/order-notifications.js +567 -0
- package/src/lib/server/order-notifications.js.map +1 -0
- package/src/lib/server/order-receipt-send.d.ts +39 -0
- package/src/lib/server/order-receipt-send.js +151 -0
- package/src/lib/server/order-receipt-send.js.map +1 -0
- package/src/lib/server/order-status-token.d.ts +31 -0
- package/src/lib/server/order-status-token.js +75 -0
- package/src/lib/server/order-status-token.js.map +1 -0
- package/src/lib/server/order-status.d.ts +58 -0
- package/src/lib/server/order-status.js +141 -0
- package/src/lib/server/order-status.js.map +1 -0
- package/src/lib/server/order-webhooks.d.ts +108 -0
- package/src/lib/server/order-webhooks.js +622 -0
- package/src/lib/server/order-webhooks.js.map +1 -0
- package/src/lib/server/orders-shipping-prepare.d.ts +26 -0
- package/src/lib/server/orders-shipping-prepare.js +121 -0
- package/src/lib/server/orders-shipping-prepare.js.map +1 -0
- package/src/lib/server/payment-method-domains.d.ts +209 -0
- package/src/lib/server/payment-method-domains.js +444 -0
- package/src/lib/server/payment-method-domains.js.map +1 -0
- package/src/lib/server/payment-methods.d.ts +77 -0
- package/src/lib/server/payment-methods.js +284 -0
- package/src/lib/server/payment-methods.js.map +1 -0
- package/src/lib/server/pos-auth.d.ts +50 -0
- package/src/lib/server/pos-auth.js +121 -0
- package/src/lib/server/pos-auth.js.map +1 -0
- package/src/lib/server/pos-customer.d.ts +49 -0
- package/src/lib/server/pos-customer.js +257 -0
- package/src/lib/server/pos-customer.js.map +1 -0
- package/src/lib/server/pos-display.d.ts +57 -0
- package/src/lib/server/pos-display.js +419 -0
- package/src/lib/server/pos-display.js.map +1 -0
- package/src/lib/server/pos-fee-month.d.ts +34 -0
- package/src/lib/server/pos-fee-month.js +36 -0
- package/src/lib/server/pos-fee-month.js.map +1 -0
- package/src/lib/server/pos-ops-gate.d.ts +161 -0
- package/src/lib/server/pos-ops-gate.js +295 -0
- package/src/lib/server/pos-ops-gate.js.map +1 -0
- package/src/lib/server/pos-ops-routes.d.ts +22 -0
- package/src/lib/server/pos-ops-routes.js +36 -0
- package/src/lib/server/pos-ops-routes.js.map +1 -0
- package/src/lib/server/pos-order.d.ts +1 -18
- package/src/lib/server/pos-order.js +222 -42
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.d.ts +39 -0
- package/src/lib/server/pos-payment.js +922 -0
- package/src/lib/server/pos-payment.js.map +1 -0
- package/src/lib/server/pos-print.d.ts +82 -0
- package/src/lib/server/pos-print.js +193 -0
- package/src/lib/server/pos-print.js.map +1 -0
- package/src/lib/server/pos-readers.d.ts +27 -0
- package/src/lib/server/pos-readers.js +276 -0
- package/src/lib/server/pos-readers.js.map +1 -0
- package/src/lib/server/pos-refund-authority.d.ts +60 -0
- package/src/lib/server/pos-refund-authority.js +72 -0
- package/src/lib/server/pos-refund-authority.js.map +1 -0
- package/src/lib/server/pos-return.d.ts +58 -0
- package/src/lib/server/pos-return.js +891 -0
- package/src/lib/server/pos-return.js.map +1 -0
- package/src/lib/server/pos-sale-stamp.d.ts +66 -0
- package/src/lib/server/pos-sale-stamp.js +84 -0
- package/src/lib/server/pos-sale-stamp.js.map +1 -0
- package/src/lib/server/pos-sale.d.ts +170 -0
- package/src/lib/server/pos-sale.js +461 -0
- package/src/lib/server/pos-sale.js.map +1 -0
- package/src/lib/server/pos-shift.d.ts +45 -0
- package/src/lib/server/pos-shift.js +484 -0
- package/src/lib/server/pos-shift.js.map +1 -0
- package/src/lib/server/pos-staff-pin.d.ts +26 -0
- package/src/lib/server/pos-staff-pin.js +339 -0
- package/src/lib/server/pos-staff-pin.js.map +1 -0
- package/src/lib/server/pos-stripe.d.ts +91 -0
- package/src/lib/server/pos-stripe.js +129 -0
- package/src/lib/server/pos-stripe.js.map +1 -0
- package/src/lib/server/pos-terminal-connection-token.d.ts +48 -0
- package/src/lib/server/pos-terminal-connection-token.js +166 -0
- package/src/lib/server/pos-terminal-connection-token.js.map +1 -0
- package/src/lib/server/pos-terminal.d.ts +218 -0
- package/src/lib/server/pos-terminal.js +1014 -0
- package/src/lib/server/pos-terminal.js.map +1 -0
- package/src/lib/server/print-queue.d.ts +124 -0
- package/src/lib/server/print-queue.js +301 -0
- package/src/lib/server/print-queue.js.map +1 -0
- package/src/lib/server/printer-poll.d.ts +75 -0
- package/src/lib/server/printer-poll.js +325 -0
- package/src/lib/server/printer-poll.js.map +1 -0
- package/src/lib/server/printer-secret.d.ts +39 -0
- package/src/lib/server/printer-secret.js +56 -0
- package/src/lib/server/printer-secret.js.map +1 -0
- package/src/lib/server/printers.d.ts +114 -0
- package/src/lib/server/printers.js +546 -0
- package/src/lib/server/printers.js.map +1 -0
- package/src/lib/server/product-catalog.d.ts +42 -0
- package/src/lib/server/product-catalog.js +309 -0
- package/src/lib/server/product-catalog.js.map +1 -0
- package/src/lib/server/product-drafts.d.ts +5 -1
- package/src/lib/server/product-drafts.js +3 -3
- package/src/lib/server/product-drafts.js.map +1 -1
- package/src/lib/server/product-writer.d.ts +19 -0
- package/src/lib/server/product-writer.js +261 -0
- package/src/lib/server/product-writer.js.map +1 -0
- package/src/lib/server/products-write.d.ts +61 -0
- package/src/lib/server/products-write.js +375 -0
- package/src/lib/server/products-write.js.map +1 -0
- package/src/lib/server/refund.js +110 -45
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/reserve.js +2 -0
- package/src/lib/server/reserve.js.map +1 -1
- package/src/lib/server/return-status-action.d.ts +37 -0
- package/src/lib/server/return-status-action.js +57 -0
- package/src/lib/server/return-status-action.js.map +1 -0
- package/src/lib/server/returns.d.ts +119 -0
- package/src/lib/server/returns.js +938 -0
- package/src/lib/server/returns.js.map +1 -0
- package/src/lib/server/shipment-records.d.ts +36 -0
- package/src/lib/server/shipment-records.js +289 -0
- package/src/lib/server/shipment-records.js.map +1 -0
- package/src/lib/server/shipping-connector-gates.d.ts +40 -0
- package/src/lib/server/shipping-connector-gates.js +97 -0
- package/src/lib/server/shipping-connector-gates.js.map +1 -0
- package/src/lib/server/shipping-connectors.d.ts +29 -0
- package/src/lib/server/shipping-connectors.js +236 -0
- package/src/lib/server/shipping-connectors.js.map +1 -0
- package/src/lib/server/shippingeasy.d.ts +238 -0
- package/src/lib/server/shippingeasy.js +787 -0
- package/src/lib/server/shippingeasy.js.map +1 -0
- package/src/lib/server/shipstation.d.ts +129 -0
- package/src/lib/server/shipstation.js +483 -0
- package/src/lib/server/shipstation.js.map +1 -0
- package/src/lib/server/site-page-resolver.d.ts +5 -0
- package/src/lib/server/site-page-resolver.js +156 -1
- package/src/lib/server/site-page-resolver.js.map +1 -1
- package/src/lib/server/stock-levels.d.ts +21 -0
- package/src/lib/server/stock-levels.js +263 -0
- package/src/lib/server/stock-levels.js.map +1 -0
- package/src/lib/server/stripe-refund.d.ts +47 -0
- package/src/lib/server/stripe-refund.js +87 -0
- package/src/lib/server/stripe-refund.js.map +1 -0
- package/src/lib/server/supplier-update.js +46 -5
- package/src/lib/server/supplier-update.js.map +1 -1
- package/src/lib/server/tax-engine-quote.d.ts +47 -0
- package/src/lib/server/tax-engine-quote.js +105 -0
- package/src/lib/server/tax-engine-quote.js.map +1 -0
- package/src/lib/server.js +143 -2
- package/src/lib/server.js.map +1 -1
- package/src/lib/site.js +12 -0
- package/src/lib/site.js.map +1 -1
- package/src/lib/subprocessors.d.ts +26 -0
- package/src/lib/subprocessors.js +50 -0
- package/src/lib/subprocessors.js.map +1 -0
- package/src/lib/tenant-emails.js +461 -3
- package/src/lib/tenant-emails.js.map +1 -1
- package/src/lib/testing/fake-firestore.d.ts +45 -0
- package/src/lib/testing/fake-firestore.js +189 -0
- package/src/lib/testing/fake-firestore.js.map +1 -0
- package/src/lib/testing/memory-firestore.d.ts +136 -0
- package/src/lib/testing/memory-firestore.js +282 -0
- package/src/lib/testing/memory-firestore.js.map +1 -0
- package/src/lib/testing/pos-ops-harness.d.ts +50 -0
- package/src/lib/testing/pos-ops-harness.js +184 -0
- package/src/lib/testing/pos-ops-harness.js.map +1 -0
- package/src/lib/testing/pos-ops-memory-firestore.d.ts +55 -0
- package/src/lib/testing/pos-ops-memory-firestore.js +376 -0
- package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -0
- package/src/lib/transfer/products.server.d.ts +5 -0
- package/src/lib/transfer/products.server.js +2 -2
- package/src/lib/transfer/products.server.js.map +1 -1
- package/src/lib/transfer/records-transfer.d.ts +11 -1
- package/src/lib/transfer/records-transfer.js +127 -5
- package/src/lib/transfer/records-transfer.js.map +1 -1
- package/src/lib/transfer/records.server.d.ts +9 -2
- package/src/lib/transfer/records.server.js +58 -7
- package/src/lib/transfer/records.server.js.map +1 -1
- package/src/lib/transfer/register-transfer-resources.js +40 -1
- package/src/lib/transfer/register-transfer-resources.js.map +1 -1
- package/src/lib/transfer/register-transfer-ui.js +4 -1
- package/src/lib/transfer/register-transfer-ui.js.map +1 -1
- package/src/lib/transfer/shipping-presets.d.ts +23 -0
- package/src/lib/transfer/shipping-presets.js +156 -0
- package/src/lib/transfer/shipping-presets.js.map +1 -0
- package/src/lib/transfer/tracking-transfer.d.ts +101 -0
- package/src/lib/transfer/tracking-transfer.js +546 -0
- package/src/lib/transfer/tracking-transfer.js.map +1 -0
- package/src/lib/transfer/tracking.server.d.ts +37 -0
- package/src/lib/transfer/tracking.server.js +393 -0
- package/src/lib/transfer/tracking.server.js.map +1 -0
- package/src/lib/transfer/transfer-keys.d.ts +2 -1
- package/src/lib/transfer/transfer-keys.js +6 -2
- package/src/lib/transfer/transfer-keys.js.map +1 -1
- package/src/lib/utils/code128.d.ts +37 -0
- package/src/lib/utils/code128.js +199 -0
- package/src/lib/utils/code128.js.map +1 -0
- package/src/lib/utils/order-invoice.d.ts +55 -0
- package/src/lib/utils/order-invoice.js +127 -0
- package/src/lib/utils/order-invoice.js.map +1 -0
- package/src/lib/utils/use-checkout-return-notice.d.ts +34 -0
- package/src/lib/utils/use-checkout-return-notice.js +78 -0
- package/src/lib/utils/use-checkout-return-notice.js.map +1 -0
- package/src/lib/server/feed.js +0 -69
- package/src/lib/server/feed.js.map +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { PluginApiHandler } from '@aglyn/aglyn/server';
|
|
18
|
+
import { type PosStaff } from './pos-auth';
|
|
19
|
+
import { type PosTerminalAddress } from './pos-terminal';
|
|
20
|
+
/**
|
|
21
|
+
* `POST /api/commerce/pos-terminal-connection-token` (AGL-3618): what the
|
|
22
|
+
* native Aglyn POS app's Stripe Terminal SDK (iOS and Android) needs to drive
|
|
23
|
+
* Tap to Pay and Bluetooth readers for ONE site.
|
|
24
|
+
*
|
|
25
|
+
* Gated exactly like a register sale (`authorizePosStaff`): a site role that
|
|
26
|
+
* may sell, `managePos`, and the `pos` entitlement. The app holds no key and
|
|
27
|
+
* no privileged path. Every token is scoped to the site's own Terminal
|
|
28
|
+
* Location, so the SDK can connect only to readers in that Location, and the
|
|
29
|
+
* PaymentIntents it collects are the server's own (`card-present-sdk`).
|
|
30
|
+
*
|
|
31
|
+
* Actions:
|
|
32
|
+
* - `token` (the default): the secret, the Location id, the merchant's
|
|
33
|
+
* account id and display name, and test mode; or a 409 whose `code` names
|
|
34
|
+
* what is missing: `terminal-unavailable`, `merchant-not-ready`,
|
|
35
|
+
* `location-required`.
|
|
36
|
+
* - `status`: the same readiness as booleans, minting nothing.
|
|
37
|
+
* - `location`: registers the site's Location from an address, once.
|
|
38
|
+
*/
|
|
39
|
+
export declare const posTerminalConnectionTokenHandler: PluginApiHandler;
|
|
40
|
+
/** Readiness as the native POS app's readers panel draws it. */
|
|
41
|
+
export declare function terminalReadiness(staff: PosStaff): Promise<{
|
|
42
|
+
available: boolean;
|
|
43
|
+
testMode: boolean;
|
|
44
|
+
merchantReady: boolean;
|
|
45
|
+
locationReady: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
/** An address from the native POS app, bounded the way `pos-readers` bounds it. */
|
|
48
|
+
export declare function readPosTerminalAddress(raw: unknown): PosTerminalAddress | undefined;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Aglyn LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/ import { firebaseAdmin } from "@aglyn/tenant-data-admin";
|
|
18
|
+
import { authorizePosStaff, posRequestBody } from "./pos-auth.js";
|
|
19
|
+
import { posStripeTestMode, posTerminalAvailable } from "./pos-stripe.js";
|
|
20
|
+
import { createPosTerminalConnectionToken, ensurePosTerminalLocation, posMerchantAccount, posTerminalLocationId } from "./pos-terminal.js";
|
|
21
|
+
/**
|
|
22
|
+
* `POST /api/commerce/pos-terminal-connection-token` (AGL-3618): what the
|
|
23
|
+
* native Aglyn POS app's Stripe Terminal SDK (iOS and Android) needs to drive
|
|
24
|
+
* Tap to Pay and Bluetooth readers for ONE site.
|
|
25
|
+
*
|
|
26
|
+
* Gated exactly like a register sale (`authorizePosStaff`): a site role that
|
|
27
|
+
* may sell, `managePos`, and the `pos` entitlement. The app holds no key and
|
|
28
|
+
* no privileged path. Every token is scoped to the site's own Terminal
|
|
29
|
+
* Location, so the SDK can connect only to readers in that Location, and the
|
|
30
|
+
* PaymentIntents it collects are the server's own (`card-present-sdk`).
|
|
31
|
+
*
|
|
32
|
+
* Actions:
|
|
33
|
+
* - `token` (the default): the secret, the Location id, the merchant's
|
|
34
|
+
* account id and display name, and test mode; or a 409 whose `code` names
|
|
35
|
+
* what is missing: `terminal-unavailable`, `merchant-not-ready`,
|
|
36
|
+
* `location-required`.
|
|
37
|
+
* - `status`: the same readiness as booleans, minting nothing.
|
|
38
|
+
* - `location`: registers the site's Location from an address, once.
|
|
39
|
+
*/ export const posTerminalConnectionTokenHandler = async (req, res)=>{
|
|
40
|
+
var _body_hostId, _body_action;
|
|
41
|
+
if (req.method !== 'POST') return res.status(405).json({
|
|
42
|
+
error: 'Method not allowed'
|
|
43
|
+
});
|
|
44
|
+
const body = posRequestBody(req);
|
|
45
|
+
const gate = await authorizePosStaff(req, String((_body_hostId = body['hostId']) != null ? _body_hostId : ''));
|
|
46
|
+
if ('error' in gate) return res.status(gate.status).json({
|
|
47
|
+
error: gate.error
|
|
48
|
+
});
|
|
49
|
+
const staff = gate.staff;
|
|
50
|
+
const action = String((_body_action = body['action']) != null ? _body_action : 'token');
|
|
51
|
+
try {
|
|
52
|
+
switch(action){
|
|
53
|
+
case 'token':
|
|
54
|
+
return await mintToken(staff, res);
|
|
55
|
+
case 'status':
|
|
56
|
+
return res.status(200).json(await terminalReadiness(staff));
|
|
57
|
+
case 'location':
|
|
58
|
+
return await registerLocation(staff, body, res);
|
|
59
|
+
default:
|
|
60
|
+
return res.status(400).json({
|
|
61
|
+
error: 'Unknown action'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error('[pos-terminal-connection-token]', action, error);
|
|
66
|
+
return res.status(500).json({
|
|
67
|
+
error: 'Card readers could not be reached. Try again.'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
async function hostName(hostId) {
|
|
72
|
+
var _ref, _host_get;
|
|
73
|
+
const host = await firebaseAdmin.app().firestore().collection('hosts').doc(hostId).get();
|
|
74
|
+
return String((_ref = (_host_get = host.get('name')) != null ? _host_get : host.get('title')) != null ? _ref : '').trim().slice(0, 100) || 'Store';
|
|
75
|
+
}
|
|
76
|
+
/** Readiness as the native POS app's readers panel draws it. */ export async function terminalReadiness(staff) {
|
|
77
|
+
const available = posTerminalAvailable();
|
|
78
|
+
const [merchant, locationId] = await Promise.all([
|
|
79
|
+
posMerchantAccount(staff.hostId, staff.org),
|
|
80
|
+
posTerminalLocationId(staff.hostId)
|
|
81
|
+
]);
|
|
82
|
+
return {
|
|
83
|
+
available,
|
|
84
|
+
testMode: posStripeTestMode(),
|
|
85
|
+
merchantReady: Boolean(merchant),
|
|
86
|
+
locationReady: Boolean(locationId)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async function mintToken(staff, res) {
|
|
90
|
+
if (!posTerminalAvailable()) {
|
|
91
|
+
return res.status(409).json({
|
|
92
|
+
error: 'Card readers are not available yet.',
|
|
93
|
+
code: 'terminal-unavailable'
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// A reader that connects for a store that cannot take card payments would
|
|
97
|
+
// only fail at the first sale, in front of a customer.
|
|
98
|
+
const merchantAccountId = await posMerchantAccount(staff.hostId, staff.org);
|
|
99
|
+
if (!merchantAccountId) {
|
|
100
|
+
return res.status(409).json({
|
|
101
|
+
error: 'Finish setting up payments in the console before taking cards.',
|
|
102
|
+
code: 'merchant-not-ready'
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const token = await createPosTerminalConnectionToken(staff.hostId);
|
|
106
|
+
if (!token) {
|
|
107
|
+
const locationId = await posTerminalLocationId(staff.hostId);
|
|
108
|
+
return locationId ? res.status(502).json({
|
|
109
|
+
error: 'Stripe did not answer. Try again.'
|
|
110
|
+
}) : res.status(409).json({
|
|
111
|
+
error: 'Add the store address card readers are used at.',
|
|
112
|
+
code: 'location-required'
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return res.status(200).json({
|
|
116
|
+
secret: token.secret,
|
|
117
|
+
locationId: token.locationId,
|
|
118
|
+
// Identifies the merchant only. It is never the SDK's `onBehalfOf`:
|
|
119
|
+
// card-present charges settle on Aglyn's platform account (AGL-3607), and
|
|
120
|
+
// an intent collected under a different account would be refused.
|
|
121
|
+
merchantAccountId,
|
|
122
|
+
merchantDisplayName: await hostName(staff.hostId),
|
|
123
|
+
testMode: posStripeTestMode()
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** An address from the native POS app, bounded the way `pos-readers` bounds it. */ export function readPosTerminalAddress(raw) {
|
|
127
|
+
if (!raw || typeof raw !== 'object') return undefined;
|
|
128
|
+
const address = raw;
|
|
129
|
+
const text = (value, max)=>String(value != null ? value : '').trim().slice(0, max);
|
|
130
|
+
return _extends({
|
|
131
|
+
line1: text(address['line1'], 200)
|
|
132
|
+
}, text(address['line2'], 200) ? {
|
|
133
|
+
line2: text(address['line2'], 200)
|
|
134
|
+
} : {}, {
|
|
135
|
+
city: text(address['city'], 100)
|
|
136
|
+
}, text(address['state'], 100) ? {
|
|
137
|
+
state: text(address['state'], 100)
|
|
138
|
+
} : {}, {
|
|
139
|
+
postalCode: text(address['postalCode'], 20),
|
|
140
|
+
country: text(address['country'], 2).toUpperCase()
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async function registerLocation(staff, body, res) {
|
|
144
|
+
if (!posTerminalAvailable()) {
|
|
145
|
+
return res.status(409).json({
|
|
146
|
+
error: 'Card readers are not available yet.',
|
|
147
|
+
code: 'terminal-unavailable'
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const address = readPosTerminalAddress(body['address']);
|
|
151
|
+
const location = await ensurePosTerminalLocation(_extends({
|
|
152
|
+
hostId: staff.hostId,
|
|
153
|
+
orgId: staff.orgId,
|
|
154
|
+
displayName: await hostName(staff.hostId)
|
|
155
|
+
}, address ? {
|
|
156
|
+
address
|
|
157
|
+
} : {}));
|
|
158
|
+
if ('error' in location) return res.status(location.status).json({
|
|
159
|
+
error: location.error
|
|
160
|
+
});
|
|
161
|
+
return res.status(200).json({
|
|
162
|
+
locationId: location.locationId
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//# sourceMappingURL=pos-terminal-connection-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/pos-terminal-connection-token.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 { firebaseAdmin } from '@aglyn/tenant-data-admin'\nimport type { PluginApiHandler } from '@aglyn/aglyn/server'\nimport { authorizePosStaff, posRequestBody, type PosStaff } from './pos-auth'\nimport { posStripeTestMode, posTerminalAvailable } from './pos-stripe'\nimport {\n createPosTerminalConnectionToken,\n ensurePosTerminalLocation,\n posMerchantAccount,\n posTerminalLocationId,\n type PosTerminalAddress,\n} from './pos-terminal'\n\n/**\n * `POST /api/commerce/pos-terminal-connection-token` (AGL-3618): what the\n * native Aglyn POS app's Stripe Terminal SDK (iOS and Android) needs to drive\n * Tap to Pay and Bluetooth readers for ONE site.\n *\n * Gated exactly like a register sale (`authorizePosStaff`): a site role that\n * may sell, `managePos`, and the `pos` entitlement. The app holds no key and\n * no privileged path. Every token is scoped to the site's own Terminal\n * Location, so the SDK can connect only to readers in that Location, and the\n * PaymentIntents it collects are the server's own (`card-present-sdk`).\n *\n * Actions:\n * - `token` (the default): the secret, the Location id, the merchant's\n * account id and display name, and test mode; or a 409 whose `code` names\n * what is missing: `terminal-unavailable`, `merchant-not-ready`,\n * `location-required`.\n * - `status`: the same readiness as booleans, minting nothing.\n * - `location`: registers the site's Location from an address, once.\n */\nexport const posTerminalConnectionTokenHandler: PluginApiHandler = async (req, res) => {\n if (req.method !== 'POST') return res.status(405).json({ error: 'Method not allowed' })\n const body = posRequestBody(req)\n const gate = await authorizePosStaff(req, String(body['hostId'] ?? ''))\n if ('error' in gate) return res.status(gate.status).json({ error: gate.error })\n const staff = gate.staff\n const action = String(body['action'] ?? 'token')\n try {\n switch (action) {\n case 'token':\n return await mintToken(staff, res)\n case 'status':\n return res.status(200).json(await terminalReadiness(staff))\n case 'location':\n return await registerLocation(staff, body, res)\n default:\n return res.status(400).json({ error: 'Unknown action' })\n }\n } catch (error) {\n console.error('[pos-terminal-connection-token]', action, error)\n return res.status(500).json({ error: 'Card readers could not be reached. Try again.' })\n }\n}\n\nasync function hostName(hostId: string): Promise<string> {\n const host = await firebaseAdmin.app().firestore().collection('hosts').doc(hostId).get()\n return String(host.get('name') ?? host.get('title') ?? '').trim().slice(0, 100) || 'Store'\n}\n\n/** Readiness as the native POS app's readers panel draws it. */\nexport async function terminalReadiness(staff: PosStaff) {\n const available = posTerminalAvailable()\n const [merchant, locationId] = await Promise.all([\n posMerchantAccount(staff.hostId, staff.org),\n posTerminalLocationId(staff.hostId),\n ])\n return {\n available,\n testMode: posStripeTestMode(),\n merchantReady: Boolean(merchant),\n locationReady: Boolean(locationId),\n }\n}\n\ntype Res = Parameters<PluginApiHandler>[1]\n\nasync function mintToken(staff: PosStaff, res: Res) {\n if (!posTerminalAvailable()) {\n return res\n .status(409)\n .json({ error: 'Card readers are not available yet.', code: 'terminal-unavailable' })\n }\n // A reader that connects for a store that cannot take card payments would\n // only fail at the first sale, in front of a customer.\n const merchantAccountId = await posMerchantAccount(staff.hostId, staff.org)\n if (!merchantAccountId) {\n return res.status(409).json({\n error: 'Finish setting up payments in the console before taking cards.',\n code: 'merchant-not-ready',\n })\n }\n const token = await createPosTerminalConnectionToken(staff.hostId)\n if (!token) {\n const locationId = await posTerminalLocationId(staff.hostId)\n return locationId\n ? res.status(502).json({ error: 'Stripe did not answer. Try again.' })\n : res.status(409).json({\n error: 'Add the store address card readers are used at.',\n code: 'location-required',\n })\n }\n return res.status(200).json({\n secret: token.secret,\n locationId: token.locationId,\n // Identifies the merchant only. It is never the SDK's `onBehalfOf`:\n // card-present charges settle on Aglyn's platform account (AGL-3607), and\n // an intent collected under a different account would be refused.\n merchantAccountId,\n merchantDisplayName: await hostName(staff.hostId),\n testMode: posStripeTestMode(),\n })\n}\n\n/** An address from the native POS app, bounded the way `pos-readers` bounds it. */\nexport function readPosTerminalAddress(raw: unknown): PosTerminalAddress | undefined {\n if (!raw || typeof raw !== 'object') return undefined\n const address = raw as Record<string, unknown>\n const text = (value: unknown, max: number) => String(value ?? '').trim().slice(0, max)\n return {\n line1: text(address['line1'], 200),\n ...(text(address['line2'], 200) ? { line2: text(address['line2'], 200) } : {}),\n city: text(address['city'], 100),\n ...(text(address['state'], 100) ? { state: text(address['state'], 100) } : {}),\n postalCode: text(address['postalCode'], 20),\n country: text(address['country'], 2).toUpperCase(),\n }\n}\n\nasync function registerLocation(staff: PosStaff, body: Record<string, unknown>, res: Res) {\n if (!posTerminalAvailable()) {\n return res\n .status(409)\n .json({ error: 'Card readers are not available yet.', code: 'terminal-unavailable' })\n }\n const address = readPosTerminalAddress(body['address'])\n const location = await ensurePosTerminalLocation({\n hostId: staff.hostId,\n orgId: staff.orgId,\n displayName: await hostName(staff.hostId),\n ...(address ? { address } : {}),\n })\n if ('error' in location) return res.status(location.status).json({ error: location.error })\n return res.status(200).json({ locationId: location.locationId })\n}\n"],"names":["firebaseAdmin","authorizePosStaff","posRequestBody","posStripeTestMode","posTerminalAvailable","createPosTerminalConnectionToken","ensurePosTerminalLocation","posMerchantAccount","posTerminalLocationId","posTerminalConnectionTokenHandler","req","res","body","method","status","json","error","gate","String","staff","action","mintToken","terminalReadiness","registerLocation","console","hostName","hostId","host","app","firestore","collection","doc","get","trim","slice","available","merchant","locationId","Promise","all","org","testMode","merchantReady","Boolean","locationReady","code","merchantAccountId","token","secret","merchantDisplayName","readPosTerminalAddress","raw","undefined","address","text","value","max","line1","line2","city","state","postalCode","country","toUpperCase","location","orgId","displayName"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAQ,2BAA0B;AAExD,SAASC,iBAAiB,EAAEC,cAAc,QAAuB,gBAAY;AAC7E,SAASC,iBAAiB,EAAEC,oBAAoB,QAAQ,kBAAc;AACtE,SACEC,gCAAgC,EAChCC,yBAAyB,EACzBC,kBAAkB,EAClBC,qBAAqB,QAEhB,oBAAgB;AAEvB;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAMC,oCAAsD,OAAOC,KAAKC;QAG5BC,cAG3BA;IALtB,IAAIF,IAAIG,MAAM,KAAK,QAAQ,OAAOF,IAAIG,MAAM,CAAC,KAAKC,IAAI,CAAC;QAAEC,OAAO;IAAqB;IACrF,MAAMJ,OAAOV,eAAeQ;IAC5B,MAAMO,OAAO,MAAMhB,kBAAkBS,KAAKQ,QAAON,eAAAA,IAAI,CAAC,SAAS,YAAdA,eAAkB;IACnE,IAAI,WAAWK,MAAM,OAAON,IAAIG,MAAM,CAACG,KAAKH,MAAM,EAAEC,IAAI,CAAC;QAAEC,OAAOC,KAAKD,KAAK;IAAC;IAC7E,MAAMG,QAAQF,KAAKE,KAAK;IACxB,MAAMC,SAASF,QAAON,eAAAA,IAAI,CAAC,SAAS,YAAdA,eAAkB;IACxC,IAAI;QACF,OAAQQ;YACN,KAAK;gBACH,OAAO,MAAMC,UAAUF,OAAOR;YAChC,KAAK;gBACH,OAAOA,IAAIG,MAAM,CAAC,KAAKC,IAAI,CAAC,MAAMO,kBAAkBH;YACtD,KAAK;gBACH,OAAO,MAAMI,iBAAiBJ,OAAOP,MAAMD;YAC7C;gBACE,OAAOA,IAAIG,MAAM,CAAC,KAAKC,IAAI,CAAC;oBAAEC,OAAO;gBAAiB;QAC1D;IACF,EAAE,OAAOA,OAAO;QACdQ,QAAQR,KAAK,CAAC,mCAAmCI,QAAQJ;QACzD,OAAOL,IAAIG,MAAM,CAAC,KAAKC,IAAI,CAAC;YAAEC,OAAO;QAAgD;IACvF;AACF,EAAC;AAED,eAAeS,SAASC,MAAc;QAEtBC,MAAAA;IADd,MAAMA,OAAO,MAAM3B,cAAc4B,GAAG,GAAGC,SAAS,GAAGC,UAAU,CAAC,SAASC,GAAG,CAACL,QAAQM,GAAG;IACtF,OAAOd,QAAOS,QAAAA,YAAAA,KAAKK,GAAG,CAAC,mBAATL,YAAoBA,KAAKK,GAAG,CAAC,oBAA7BL,OAAyC,IAAIM,IAAI,GAAGC,KAAK,CAAC,GAAG,QAAQ;AACrF;AAEA,8DAA8D,GAC9D,OAAO,eAAeZ,kBAAkBH,KAAe;IACrD,MAAMgB,YAAY/B;IAClB,MAAM,CAACgC,UAAUC,WAAW,GAAG,MAAMC,QAAQC,GAAG,CAAC;QAC/ChC,mBAAmBY,MAAMO,MAAM,EAAEP,MAAMqB,GAAG;QAC1ChC,sBAAsBW,MAAMO,MAAM;KACnC;IACD,OAAO;QACLS;QACAM,UAAUtC;QACVuC,eAAeC,QAAQP;QACvBQ,eAAeD,QAAQN;IACzB;AACF;AAIA,eAAehB,UAAUF,KAAe,EAAER,GAAQ;IAChD,IAAI,CAACP,wBAAwB;QAC3B,OAAOO,IACJG,MAAM,CAAC,KACPC,IAAI,CAAC;YAAEC,OAAO;YAAuC6B,MAAM;QAAuB;IACvF;IACA,0EAA0E;IAC1E,uDAAuD;IACvD,MAAMC,oBAAoB,MAAMvC,mBAAmBY,MAAMO,MAAM,EAAEP,MAAMqB,GAAG;IAC1E,IAAI,CAACM,mBAAmB;QACtB,OAAOnC,IAAIG,MAAM,CAAC,KAAKC,IAAI,CAAC;YAC1BC,OAAO;YACP6B,MAAM;QACR;IACF;IACA,MAAME,QAAQ,MAAM1C,iCAAiCc,MAAMO,MAAM;IACjE,IAAI,CAACqB,OAAO;QACV,MAAMV,aAAa,MAAM7B,sBAAsBW,MAAMO,MAAM;QAC3D,OAAOW,aACH1B,IAAIG,MAAM,CAAC,KAAKC,IAAI,CAAC;YAAEC,OAAO;QAAoC,KAClEL,IAAIG,MAAM,CAAC,KAAKC,IAAI,CAAC;YACnBC,OAAO;YACP6B,MAAM;QACR;IACN;IACA,OAAOlC,IAAIG,MAAM,CAAC,KAAKC,IAAI,CAAC;QAC1BiC,QAAQD,MAAMC,MAAM;QACpBX,YAAYU,MAAMV,UAAU;QAC5B,oEAAoE;QACpE,0EAA0E;QAC1E,kEAAkE;QAClES;QACAG,qBAAqB,MAAMxB,SAASN,MAAMO,MAAM;QAChDe,UAAUtC;IACZ;AACF;AAEA,iFAAiF,GACjF,OAAO,SAAS+C,uBAAuBC,GAAY;IACjD,IAAI,CAACA,OAAO,OAAOA,QAAQ,UAAU,OAAOC;IAC5C,MAAMC,UAAUF;IAChB,MAAMG,OAAO,CAACC,OAAgBC,MAAgBtC,OAAOqC,gBAAAA,QAAS,IAAItB,IAAI,GAAGC,KAAK,CAAC,GAAGsB;IAClF,OAAO;QACLC,OAAOH,KAAKD,OAAO,CAAC,QAAQ,EAAE;OAC1BC,KAAKD,OAAO,CAAC,QAAQ,EAAE,OAAO;QAAEK,OAAOJ,KAAKD,OAAO,CAAC,QAAQ,EAAE;IAAK,IAAI,CAAC;QAC5EM,MAAML,KAAKD,OAAO,CAAC,OAAO,EAAE;OACxBC,KAAKD,OAAO,CAAC,QAAQ,EAAE,OAAO;QAAEO,OAAON,KAAKD,OAAO,CAAC,QAAQ,EAAE;IAAK,IAAI,CAAC;QAC5EQ,YAAYP,KAAKD,OAAO,CAAC,aAAa,EAAE;QACxCS,SAASR,KAAKD,OAAO,CAAC,UAAU,EAAE,GAAGU,WAAW;;AAEpD;AAEA,eAAexC,iBAAiBJ,KAAe,EAAEP,IAA6B,EAAED,GAAQ;IACtF,IAAI,CAACP,wBAAwB;QAC3B,OAAOO,IACJG,MAAM,CAAC,KACPC,IAAI,CAAC;YAAEC,OAAO;YAAuC6B,MAAM;QAAuB;IACvF;IACA,MAAMQ,UAAUH,uBAAuBtC,IAAI,CAAC,UAAU;IACtD,MAAMoD,WAAW,MAAM1D,0BAA0B;QAC/CoB,QAAQP,MAAMO,MAAM;QACpBuC,OAAO9C,MAAM8C,KAAK;QAClBC,aAAa,MAAMzC,SAASN,MAAMO,MAAM;OACpC2B,UAAU;QAAEA;IAAQ,IAAI,CAAC;IAE/B,IAAI,WAAWW,UAAU,OAAOrD,IAAIG,MAAM,CAACkD,SAASlD,MAAM,EAAEC,IAAI,CAAC;QAAEC,OAAOgD,SAAShD,KAAK;IAAC;IACzF,OAAOL,IAAIG,MAAM,CAAC,KAAKC,IAAI,CAAC;QAAEsB,YAAY2B,SAAS3B,UAAU;IAAC;AAChE"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import * as CommerceModel from '../model';
|
|
18
|
+
import type { PosRegisterSettings } from '../plugin-config';
|
|
19
|
+
import { type PosLiftedOrder, type PosPaymentOutcome } from './pos-sale';
|
|
20
|
+
/** `hosts/{hostId}/terminalReaders/{readerId}`. */
|
|
21
|
+
export interface PosTerminalReader {
|
|
22
|
+
label: string;
|
|
23
|
+
registerId?: string;
|
|
24
|
+
stripeLocationId: string;
|
|
25
|
+
deviceType?: string;
|
|
26
|
+
serialNumber?: string;
|
|
27
|
+
status?: 'online' | 'offline' | string;
|
|
28
|
+
livemode: boolean;
|
|
29
|
+
createdAtMs: number;
|
|
30
|
+
createdBy?: string;
|
|
31
|
+
lastSeenAtMs?: number;
|
|
32
|
+
}
|
|
33
|
+
/** The merchant's connected account, when it can take card payments now. */
|
|
34
|
+
export declare function posMerchantAccount(hostId: string, org: Record<string, any> | null): Promise<string | null>;
|
|
35
|
+
/** A reader id as Stripe mints them; anything else never reaches Stripe. */
|
|
36
|
+
export declare function isTerminalReaderId(value: unknown): value is string;
|
|
37
|
+
/** The reader, when it is THIS site's; null for anyone else's or none. */
|
|
38
|
+
export declare function ownedTerminalReader(hostId: string, readerId: unknown): Promise<(PosTerminalReader & {
|
|
39
|
+
id: string;
|
|
40
|
+
}) | null>;
|
|
41
|
+
/** A Terminal Location's address, as the console sends it. */
|
|
42
|
+
export interface PosTerminalAddress {
|
|
43
|
+
line1: string;
|
|
44
|
+
line2?: string;
|
|
45
|
+
city: string;
|
|
46
|
+
state?: string;
|
|
47
|
+
postalCode: string;
|
|
48
|
+
country: string;
|
|
49
|
+
}
|
|
50
|
+
export declare function posTerminalAddressProblem(address: Partial<PosTerminalAddress> | undefined): string | null;
|
|
51
|
+
/**
|
|
52
|
+
* The site's Terminal Location, created on first use (on the PLATFORM, with
|
|
53
|
+
* the merchant named in metadata). Its address is the store's, because Stripe
|
|
54
|
+
* uses it to configure the reader for the right country.
|
|
55
|
+
*/
|
|
56
|
+
export declare function ensurePosTerminalLocation(options: {
|
|
57
|
+
hostId: string;
|
|
58
|
+
orgId: string;
|
|
59
|
+
displayName: string;
|
|
60
|
+
address?: PosTerminalAddress;
|
|
61
|
+
}): Promise<{
|
|
62
|
+
ok: true;
|
|
63
|
+
locationId: string;
|
|
64
|
+
} | {
|
|
65
|
+
ok: false;
|
|
66
|
+
status: number;
|
|
67
|
+
error: string;
|
|
68
|
+
}>;
|
|
69
|
+
/** The tipping a reader shows: Stripe offers three buttons, so three presets. */
|
|
70
|
+
export declare function posReaderTippingKey(settings: PosRegisterSettings): string;
|
|
71
|
+
/**
|
|
72
|
+
* Keeps the site's reader tipping in step with the merchant's settings: one
|
|
73
|
+
* Terminal Configuration per site, assigned to its Location, rewritten only
|
|
74
|
+
* when the presets changed. Never fatal: a reader that keeps the previous
|
|
75
|
+
* presets still takes the payment.
|
|
76
|
+
*/
|
|
77
|
+
export declare function syncPosReaderTipping(hostId: string, settings: PosRegisterSettings): Promise<void>;
|
|
78
|
+
/** Reads a reader from Stripe and keeps its status on the site's document. */
|
|
79
|
+
export declare function refreshPosReaderStatus(hostId: string, readerId: string): Promise<{
|
|
80
|
+
status: string;
|
|
81
|
+
action: any;
|
|
82
|
+
} | null>;
|
|
83
|
+
interface CardStart {
|
|
84
|
+
hostId: string;
|
|
85
|
+
orderId: string;
|
|
86
|
+
paymentId: string;
|
|
87
|
+
amountCents: number;
|
|
88
|
+
/** A tip already chosen (on the customer display or by the cashier). */
|
|
89
|
+
tipCents: number;
|
|
90
|
+
cashierId: string;
|
|
91
|
+
org: Record<string, any> | null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Creates (or finds) the card-present PaymentIntent for one payment WITHOUT
|
|
95
|
+
* choosing how the card is collected: reserves the amount in the ledger and
|
|
96
|
+
* creates a manual-capture destination charge to the merchant (settled on
|
|
97
|
+
* Aglyn's platform account, with no `on_behalf_of`, as ToS §10.7 states),
|
|
98
|
+
* keyed by the payment so a retry returns the same intent.
|
|
99
|
+
*
|
|
100
|
+
* Two collectors use it. {@link startCardPresentPayment} pushes the intent
|
|
101
|
+
* to a smart reader the site owns; a native companion app (AGL-3618)
|
|
102
|
+
* collects it with the Stripe Terminal SDK (Tap to Pay, Bluetooth readers)
|
|
103
|
+
* using the returned `clientSecret`. However the card is collected, the
|
|
104
|
+
* payment is recorded by {@link refreshPosCardPayment}, keyed on the intent's
|
|
105
|
+
* metadata, from the register's poll or the webhook alike.
|
|
106
|
+
*/
|
|
107
|
+
export declare function createCardPresentIntent(start: CardStart & {
|
|
108
|
+
readerId?: string;
|
|
109
|
+
}): Promise<PosPaymentOutcome & {
|
|
110
|
+
clientSecret?: string;
|
|
111
|
+
paymentIntentId?: string;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* A smart-reader payment: the card-present intent from
|
|
115
|
+
* {@link createCardPresentIntent}, pushed to a reader THIS site owns. The
|
|
116
|
+
* register then polls {@link refreshPosCardPayment} until the reader answers;
|
|
117
|
+
* webhooks land on the same function.
|
|
118
|
+
*/
|
|
119
|
+
export declare function startCardPresentPayment(start: CardStart & {
|
|
120
|
+
readerId: string;
|
|
121
|
+
settings: PosRegisterSettings;
|
|
122
|
+
}): Promise<PosPaymentOutcome>;
|
|
123
|
+
/** The site's Terminal Location id, or null before a reader was ever set up. */
|
|
124
|
+
export declare function posTerminalLocationId(hostId: string): Promise<string | null>;
|
|
125
|
+
/**
|
|
126
|
+
* A Terminal SDK connection token scoped to the site's own Location, for a
|
|
127
|
+
* native companion app's SDK (AGL-3618). Scoping it to the Location is what
|
|
128
|
+
* keeps one store's app from discovering another store's readers: Stripe
|
|
129
|
+
* only lets a location-scoped token connect to readers in that Location.
|
|
130
|
+
* Null when the site has no Location yet, never an unscoped token.
|
|
131
|
+
*/
|
|
132
|
+
export declare function createPosTerminalConnectionToken(hostId: string): Promise<{
|
|
133
|
+
secret: string;
|
|
134
|
+
locationId: string;
|
|
135
|
+
} | null>;
|
|
136
|
+
/**
|
|
137
|
+
* Re-arms a declined or failed reader payment on the SAME PaymentIntent, as
|
|
138
|
+
* Stripe asks (a new one per attempt risks a double charge).
|
|
139
|
+
*/
|
|
140
|
+
export declare function retryCardPresentPayment(input: {
|
|
141
|
+
hostId: string;
|
|
142
|
+
orderId: string;
|
|
143
|
+
paymentId: string;
|
|
144
|
+
settings: PosRegisterSettings;
|
|
145
|
+
}): Promise<PosPaymentOutcome>;
|
|
146
|
+
/**
|
|
147
|
+
* A typed card (card not present): a PaymentIntent the console confirms with
|
|
148
|
+
* the Payment Element. No MOTO: the card is keyed into Stripe's own field and
|
|
149
|
+
* goes through Stripe's normal online checks, 3-D Secure included.
|
|
150
|
+
*/
|
|
151
|
+
export declare function startCardKeyedPayment(start: CardStart): Promise<PosPaymentOutcome & {
|
|
152
|
+
clientSecret?: string;
|
|
153
|
+
}>;
|
|
154
|
+
/**
|
|
155
|
+
* The customer pays on their own phone from a QR code: a Stripe payment page
|
|
156
|
+
* for this payment's amount (and tip, as its own line). Settled by
|
|
157
|
+
* `checkout.session.completed` or by the register's poll.
|
|
158
|
+
*/
|
|
159
|
+
export declare function startCardLinkPayment(start: CardStart & {
|
|
160
|
+
returnUrl: string;
|
|
161
|
+
}): Promise<PosPaymentOutcome>;
|
|
162
|
+
/** The tip on an intent: what the display chose plus what the reader added. */
|
|
163
|
+
export declare function posIntentTipCents(intent: any): number;
|
|
164
|
+
/**
|
|
165
|
+
* The fee a register card charge is captured with: the payment's share of the
|
|
166
|
+
* take (fixed at reservation, the sale's share and never the tip's) plus the
|
|
167
|
+
* card processing cost on the whole amount, tip included.
|
|
168
|
+
*/
|
|
169
|
+
export declare function posCaptureFeeCents(payment: CommerceModel.OrderPayment, intent: any): number;
|
|
170
|
+
/**
|
|
171
|
+
* Brings one card payment up to date with Stripe, from a webhook or the
|
|
172
|
+
* register's poll alike: captures an authorized reader payment with its final
|
|
173
|
+
* fee, records a success, a decline or a cancellation. Idempotent: the
|
|
174
|
+
* capture is keyed by the intent, and the ledger change is a no-op when the
|
|
175
|
+
* payment already says what Stripe says.
|
|
176
|
+
*/
|
|
177
|
+
export declare function refreshPosCardPayment(input: {
|
|
178
|
+
hostId: string;
|
|
179
|
+
orderId: string;
|
|
180
|
+
paymentId: string;
|
|
181
|
+
}): Promise<PosPaymentOutcome>;
|
|
182
|
+
/**
|
|
183
|
+
* Stops a card payment that has not been paid: clears the reader, cancels the
|
|
184
|
+
* intent, expires the payment page. A charge that already went through is
|
|
185
|
+
* left alone and recorded as paid, never cancelled under the customer.
|
|
186
|
+
*/
|
|
187
|
+
export declare function cancelPosCardPayment(input: {
|
|
188
|
+
hostId: string;
|
|
189
|
+
orderId: string;
|
|
190
|
+
paymentId: string;
|
|
191
|
+
}): Promise<PosPaymentOutcome>;
|
|
192
|
+
/**
|
|
193
|
+
* TEST MODE ONLY: Stripe's simulated reader is "tapped" with a test card.
|
|
194
|
+
* Refused outright on a live key, whatever the request says.
|
|
195
|
+
*/
|
|
196
|
+
export declare function simulatePosReaderTap(input: {
|
|
197
|
+
hostId: string;
|
|
198
|
+
orderId: string;
|
|
199
|
+
paymentId: string;
|
|
200
|
+
/** `4000000000000002` declines; anything else Stripe's default approves. */
|
|
201
|
+
cardNumber?: string;
|
|
202
|
+
}): Promise<PosPaymentOutcome>;
|
|
203
|
+
/**
|
|
204
|
+
* The register's Stripe events: a reader finished or failed an action, a
|
|
205
|
+
* register PaymentIntent was authorized, paid, declined or cancelled, or a
|
|
206
|
+
* register QR page was paid or expired. Each resolves to ONE payment and is
|
|
207
|
+
* answered by re-reading Stripe through {@link refreshPosCardPayment}, never
|
|
208
|
+
* by trusting the event's own copy (whose API version predates the tip
|
|
209
|
+
* fields). Returns the site when the event was the register's, so the
|
|
210
|
+
* dispatcher can count it as claimed; null for every other event.
|
|
211
|
+
*/
|
|
212
|
+
export declare function handlePosStripeEvent(input: {
|
|
213
|
+
type: string;
|
|
214
|
+
object: any;
|
|
215
|
+
}): Promise<{
|
|
216
|
+
hostId: string;
|
|
217
|
+
} | null>;
|
|
218
|
+
export type { PosLiftedOrder };
|