@aglyn/plugins-commerce 1.0.0-beta.230 → 1.0.0-beta.231
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/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 +84 -5
- 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 +729 -657
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +51 -7
- 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 +12 -0
- 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/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 +47 -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 +127 -1
- package/src/lib/model/commerce-orders.js +24 -15
- 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 +88 -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 +15 -0
- package/src/lib/model/index.js +15 -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/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 +23 -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/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 +305 -0
- package/src/lib/server/product-catalog.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 +138 -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 +123 -0
- package/src/lib/testing/memory-firestore.js +274 -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/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,157 @@
|
|
|
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
|
+
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
17
|
+
import { hasPluginCheckoutExtras, quotePluginCheckoutExtras } from "@aglyn/aglyn/plugin-manager/plugin-checkout-extras";
|
|
18
|
+
import { firebaseAdmin } from "@aglyn/tenant-data-admin";
|
|
19
|
+
import { isDocumentId } from "@aglyn/tenant-data-admin/server/document-id";
|
|
20
|
+
import * as CommerceModel from "../model/index.js";
|
|
21
|
+
import { readCartId } from "./cart-cookie.js";
|
|
22
|
+
/**
|
|
23
|
+
* Optional lines another plugin offers at the cart (AGL-3635) — package
|
|
24
|
+
* protection is the first — through core's checkout-extras seam. Commerce
|
|
25
|
+
* names no insurer: it asks the seam, shows each offer as a box, and charges
|
|
26
|
+
* the ones the buyer ticked as ordinary lines on the session.
|
|
27
|
+
*
|
|
28
|
+
* Asked only for a basket that ships: an extra is about a parcel, and a cart
|
|
29
|
+
* of downloads has none.
|
|
30
|
+
*/ /** How long the cart and checkout wait for an offer before selling without it. */ export const CHECKOUT_EXTRAS_TIMEOUT_MS = 2500;
|
|
31
|
+
/** Every offer for a basket, or none. Never throws. */ export async function quoteCartExtras(input) {
|
|
32
|
+
var _ref, _ref1;
|
|
33
|
+
var _input_destination, _input_destination1;
|
|
34
|
+
if (!hasPluginCheckoutExtras()) return [];
|
|
35
|
+
const lines = input.lines.filter((line)=>line.quantity > 0 && line.unitCents >= 0);
|
|
36
|
+
if (!lines.some((line)=>line.physical)) return [];
|
|
37
|
+
const itemsCents = lines.reduce((sum, line)=>sum + line.unitCents * line.quantity, 0);
|
|
38
|
+
if (itemsCents <= 0) return [];
|
|
39
|
+
const country = String((_ref = (_input_destination = input.destination) == null ? void 0 : _input_destination.country) != null ? _ref : '').trim().toUpperCase().slice(0, 2);
|
|
40
|
+
const postalCode = String((_ref1 = (_input_destination1 = input.destination) == null ? void 0 : _input_destination1.postalCode) != null ? _ref1 : '').trim().slice(0, 12);
|
|
41
|
+
return quotePluginCheckoutExtras(_extends({
|
|
42
|
+
hostId: input.hostId,
|
|
43
|
+
// Every storefront session is charged in dollars today (`cart-checkout.ts`).
|
|
44
|
+
currency: 'usd',
|
|
45
|
+
itemsCents,
|
|
46
|
+
lines: lines.map((line)=>_extends({
|
|
47
|
+
itemId: line.productId,
|
|
48
|
+
name: line.name
|
|
49
|
+
}, line.sku ? {
|
|
50
|
+
sku: line.sku
|
|
51
|
+
} : {}, {
|
|
52
|
+
quantity: line.quantity,
|
|
53
|
+
unitCents: line.unitCents,
|
|
54
|
+
ships: line.physical
|
|
55
|
+
}))
|
|
56
|
+
}, country || postalCode ? {
|
|
57
|
+
destination: _extends({}, country ? {
|
|
58
|
+
country
|
|
59
|
+
} : {}, postalCode ? {
|
|
60
|
+
postalCode
|
|
61
|
+
} : {})
|
|
62
|
+
} : {}), {
|
|
63
|
+
timeoutMs: CHECKOUT_EXTRAS_TIMEOUT_MS
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export function cartExtraView(extra) {
|
|
67
|
+
return _extends({
|
|
68
|
+
id: extra.id,
|
|
69
|
+
label: extra.label
|
|
70
|
+
}, extra.description ? {
|
|
71
|
+
description: extra.description
|
|
72
|
+
} : {}, {
|
|
73
|
+
amountCents: extra.amountCents,
|
|
74
|
+
defaultSelected: extra.defaultSelected
|
|
75
|
+
}, extra.termsUrl ? {
|
|
76
|
+
termsUrl: extra.termsUrl
|
|
77
|
+
} : {});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* `GET /api/commerce/cart-extras?hostId=…` — the offers for the visitor's own
|
|
81
|
+
* cart (cookie). Asked by the cart when it is SHOWN, never by the badge on
|
|
82
|
+
* every page. A store with no offering plugin answers `[]` without reading a
|
|
83
|
+
* document. `private, no-store`: the answer is this basket's.
|
|
84
|
+
*/ export const cartExtrasHandler = async (req, res)=>{
|
|
85
|
+
var _req_query_hostId;
|
|
86
|
+
res.setHeader('Cache-Control', 'private, no-store');
|
|
87
|
+
if (req.method !== 'GET') return res.status(405).json({
|
|
88
|
+
error: 'Method not allowed'
|
|
89
|
+
});
|
|
90
|
+
const hostId = String((_req_query_hostId = req.query.hostId) != null ? _req_query_hostId : '');
|
|
91
|
+
if (!isDocumentId(hostId)) return res.status(400).json({
|
|
92
|
+
error: 'Missing or invalid hostId'
|
|
93
|
+
});
|
|
94
|
+
if (!hasPluginCheckoutExtras()) return res.status(200).json({
|
|
95
|
+
extras: []
|
|
96
|
+
});
|
|
97
|
+
const cartId = readCartId(req.cookies, hostId);
|
|
98
|
+
if (!cartId) return res.status(200).json({
|
|
99
|
+
extras: []
|
|
100
|
+
});
|
|
101
|
+
try {
|
|
102
|
+
var _data, _cart_lines, _req_query_country, _req_query_postalCode;
|
|
103
|
+
const hostRef = firebaseAdmin.app().firestore().collection('hosts').doc(hostId);
|
|
104
|
+
const cart = (_data = (await hostRef.collection('carts').doc(cartId).get()).data()) != null ? _data : {
|
|
105
|
+
lines: []
|
|
106
|
+
};
|
|
107
|
+
const lines = await resolveCartExtrasLines(hostRef, (_cart_lines = cart.lines) != null ? _cart_lines : []);
|
|
108
|
+
const extras = await quoteCartExtras({
|
|
109
|
+
hostId,
|
|
110
|
+
lines,
|
|
111
|
+
destination: {
|
|
112
|
+
country: String((_req_query_country = req.query.country) != null ? _req_query_country : ''),
|
|
113
|
+
postalCode: String((_req_query_postalCode = req.query.postalCode) != null ? _req_query_postalCode : '')
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return res.status(200).json({
|
|
117
|
+
extras: extras.map(cartExtraView)
|
|
118
|
+
});
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error('cart extras failed', error);
|
|
121
|
+
// An offer is never worth a broken cart.
|
|
122
|
+
return res.status(200).json({
|
|
123
|
+
extras: []
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
/** The cart's purchasable lines, priced from the product documents. */ async function resolveCartExtrasLines(hostRef, cartLines) {
|
|
128
|
+
const ids = [
|
|
129
|
+
...new Set(cartLines.map((line)=>line.productId))
|
|
130
|
+
].filter((id)=>isDocumentId(id));
|
|
131
|
+
const snapshots = await Promise.all(ids.map((id)=>hostRef.collection('products').doc(id).get()));
|
|
132
|
+
const products = new Map(snapshots.map((snapshot)=>[
|
|
133
|
+
snapshot.id,
|
|
134
|
+
snapshot.exists ? CommerceModel.liftLegacyProduct(snapshot.data()) : null
|
|
135
|
+
]));
|
|
136
|
+
const lines = [];
|
|
137
|
+
for (const line of cartLines){
|
|
138
|
+
var _product_type;
|
|
139
|
+
const product = products.get(line.productId);
|
|
140
|
+
if (!product || product.deletedAt || product.status !== 'active') continue;
|
|
141
|
+
const variant = line.variantId ? product.variants.find((item)=>item.id === line.variantId) : product.variants[0];
|
|
142
|
+
if (!variant || !CommerceModel.variantHasPrice(variant)) continue;
|
|
143
|
+
lines.push(_extends({
|
|
144
|
+
productId: line.productId,
|
|
145
|
+
name: product.name
|
|
146
|
+
}, variant.sku ? {
|
|
147
|
+
sku: variant.sku
|
|
148
|
+
} : {}, {
|
|
149
|
+
quantity: Math.max(0, Math.round(Number(line.quantity) || 0)),
|
|
150
|
+
unitCents: Math.round(Number(variant.priceUsd) * 100),
|
|
151
|
+
physical: ((_product_type = product.type) != null ? _product_type : 'physical') === 'physical'
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
return lines;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//# sourceMappingURL=checkout-extras.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/checkout-extras.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 type { PluginApiHandler } from '@aglyn/aglyn/server'\nimport {\n hasPluginCheckoutExtras,\n quotePluginCheckoutExtras,\n type QuotedPluginCheckoutExtra,\n} from '@aglyn/aglyn/plugin-manager/plugin-checkout-extras'\nimport { firebaseAdmin } from '@aglyn/tenant-data-admin'\nimport { isDocumentId } from '@aglyn/tenant-data-admin/server/document-id'\nimport * as CommerceModel from '../model'\nimport { readCartId } from './cart-cookie'\n\n/**\n * Optional lines another plugin offers at the cart (AGL-3635) — package\n * protection is the first — through core's checkout-extras seam. Commerce\n * names no insurer: it asks the seam, shows each offer as a box, and charges\n * the ones the buyer ticked as ordinary lines on the session.\n *\n * Asked only for a basket that ships: an extra is about a parcel, and a cart\n * of downloads has none.\n */\n\n/** How long the cart and checkout wait for an offer before selling without it. */\nexport const CHECKOUT_EXTRAS_TIMEOUT_MS = 2_500\n\n/** One cart line, priced, as the extras quote reads it. */\nexport interface CheckoutExtrasLine {\n productId: string\n name: string\n sku?: string\n quantity: number\n unitCents: number\n physical: boolean\n}\n\n/** Every offer for a basket, or none. Never throws. */\nexport async function quoteCartExtras(input: {\n hostId: string\n lines: CheckoutExtrasLine[]\n destination?: { country?: string; postalCode?: string }\n}): Promise<QuotedPluginCheckoutExtra[]> {\n if (!hasPluginCheckoutExtras()) return []\n const lines = input.lines.filter((line) => line.quantity > 0 && line.unitCents >= 0)\n if (!lines.some((line) => line.physical)) return []\n const itemsCents = lines.reduce((sum, line) => sum + line.unitCents * line.quantity, 0)\n if (itemsCents <= 0) return []\n const country = String(input.destination?.country ?? '').trim().toUpperCase().slice(0, 2)\n const postalCode = String(input.destination?.postalCode ?? '').trim().slice(0, 12)\n return quotePluginCheckoutExtras(\n {\n hostId: input.hostId,\n // Every storefront session is charged in dollars today (`cart-checkout.ts`).\n currency: 'usd',\n itemsCents,\n lines: lines.map((line) => ({\n itemId: line.productId,\n name: line.name,\n ...(line.sku ? { sku: line.sku } : {}),\n quantity: line.quantity,\n unitCents: line.unitCents,\n ships: line.physical,\n })),\n ...(country || postalCode\n ? { destination: { ...(country ? { country } : {}), ...(postalCode ? { postalCode } : {}) } }\n : {}),\n },\n { timeoutMs: CHECKOUT_EXTRAS_TIMEOUT_MS },\n )\n}\n\n/** What the cart shows of an offer: never the quote id. */\nexport interface CartExtraView {\n id: string\n label: string\n description?: string\n amountCents: number\n defaultSelected: boolean\n termsUrl?: string\n}\n\nexport function cartExtraView(extra: QuotedPluginCheckoutExtra): CartExtraView {\n return {\n id: extra.id,\n label: extra.label,\n ...(extra.description ? { description: extra.description } : {}),\n amountCents: extra.amountCents,\n defaultSelected: extra.defaultSelected,\n ...(extra.termsUrl ? { termsUrl: extra.termsUrl } : {}),\n }\n}\n\n/**\n * `GET /api/commerce/cart-extras?hostId=…` — the offers for the visitor's own\n * cart (cookie). Asked by the cart when it is SHOWN, never by the badge on\n * every page. A store with no offering plugin answers `[]` without reading a\n * document. `private, no-store`: the answer is this basket's.\n */\nexport const cartExtrasHandler: PluginApiHandler = async (req, res) => {\n res.setHeader('Cache-Control', 'private, no-store')\n if (req.method !== 'GET') return res.status(405).json({ error: 'Method not allowed' })\n const hostId = String(req.query.hostId ?? '')\n if (!isDocumentId(hostId)) return res.status(400).json({ error: 'Missing or invalid hostId' })\n if (!hasPluginCheckoutExtras()) return res.status(200).json({ extras: [] })\n const cartId = readCartId(req.cookies, hostId)\n if (!cartId) return res.status(200).json({ extras: [] })\n try {\n const hostRef = firebaseAdmin.app().firestore().collection('hosts').doc(hostId)\n const cart = ((await hostRef.collection('carts').doc(cartId).get()).data() as CommerceModel.HostCart | undefined) ?? {\n lines: [],\n }\n const lines = await resolveCartExtrasLines(hostRef, cart.lines ?? [])\n const extras = await quoteCartExtras({\n hostId,\n lines,\n destination: {\n country: String(req.query.country ?? ''),\n postalCode: String(req.query.postalCode ?? ''),\n },\n })\n return res.status(200).json({ extras: extras.map(cartExtraView) })\n } catch (error) {\n console.error('cart extras failed', error)\n // An offer is never worth a broken cart.\n return res.status(200).json({ extras: [] })\n }\n}\n\n/** The cart's purchasable lines, priced from the product documents. */\nasync function resolveCartExtrasLines(\n hostRef: FirebaseFirestore.DocumentReference,\n cartLines: CommerceModel.CartLine[],\n): Promise<CheckoutExtrasLine[]> {\n const ids = [...new Set(cartLines.map((line) => line.productId))].filter((id) => isDocumentId(id))\n const snapshots = await Promise.all(ids.map((id) => hostRef.collection('products').doc(id).get()))\n const products = new Map(\n snapshots.map((snapshot) => [\n snapshot.id,\n snapshot.exists ? CommerceModel.liftLegacyProduct(snapshot.data() as never) : null,\n ]),\n )\n const lines: CheckoutExtrasLine[] = []\n for (const line of cartLines) {\n const product = products.get(line.productId)\n if (!product || product.deletedAt || product.status !== 'active') continue\n const variant = line.variantId\n ? product.variants.find((item) => item.id === line.variantId)\n : product.variants[0]\n if (!variant || !CommerceModel.variantHasPrice(variant)) continue\n lines.push({\n productId: line.productId,\n name: product.name,\n ...(variant.sku ? { sku: variant.sku } : {}),\n quantity: Math.max(0, Math.round(Number(line.quantity) || 0)),\n unitCents: Math.round(Number(variant.priceUsd) * 100),\n physical: (product.type ?? 'physical') === 'physical',\n })\n }\n return lines\n}\n"],"names":["hasPluginCheckoutExtras","quotePluginCheckoutExtras","firebaseAdmin","isDocumentId","CommerceModel","readCartId","CHECKOUT_EXTRAS_TIMEOUT_MS","quoteCartExtras","input","lines","filter","line","quantity","unitCents","some","physical","itemsCents","reduce","sum","country","String","destination","trim","toUpperCase","slice","postalCode","hostId","currency","map","itemId","productId","name","sku","ships","timeoutMs","cartExtraView","extra","id","label","description","amountCents","defaultSelected","termsUrl","cartExtrasHandler","req","res","setHeader","method","status","json","error","query","extras","cartId","cookies","cart","hostRef","app","firestore","collection","doc","get","data","resolveCartExtrasLines","console","cartLines","ids","Set","snapshots","Promise","all","products","Map","snapshot","exists","liftLegacyProduct","product","deletedAt","variant","variantId","variants","find","item","variantHasPrice","push","Math","max","round","Number","priceUsd","type"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SACEA,uBAAuB,EACvBC,yBAAyB,QAEpB,qDAAoD;AAC3D,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,YAAY,QAAQ,8CAA6C;AAC1E,YAAYC,mBAAmB,oBAAU;AACzC,SAASC,UAAU,QAAQ,mBAAe;AAE1C;;;;;;;;CAQC,GAED,gFAAgF,GAChF,OAAO,MAAMC,6BAA6B,KAAK;AAY/C,qDAAqD,GACrD,OAAO,eAAeC,gBAAgBC,KAIrC;;QAMwBA,oBACGA;IAN1B,IAAI,CAACR,2BAA2B,OAAO,EAAE;IACzC,MAAMS,QAAQD,MAAMC,KAAK,CAACC,MAAM,CAAC,CAACC,OAASA,KAAKC,QAAQ,GAAG,KAAKD,KAAKE,SAAS,IAAI;IAClF,IAAI,CAACJ,MAAMK,IAAI,CAAC,CAACH,OAASA,KAAKI,QAAQ,GAAG,OAAO,EAAE;IACnD,MAAMC,aAAaP,MAAMQ,MAAM,CAAC,CAACC,KAAKP,OAASO,MAAMP,KAAKE,SAAS,GAAGF,KAAKC,QAAQ,EAAE;IACrF,IAAII,cAAc,GAAG,OAAO,EAAE;IAC9B,MAAMG,UAAUC,gBAAOZ,qBAAAA,MAAMa,WAAW,qBAAjBb,mBAAmBW,OAAO,mBAAI,IAAIG,IAAI,GAAGC,WAAW,GAAGC,KAAK,CAAC,GAAG;IACvF,MAAMC,aAAaL,iBAAOZ,sBAAAA,MAAMa,WAAW,qBAAjBb,oBAAmBiB,UAAU,oBAAI,IAAIH,IAAI,GAAGE,KAAK,CAAC,GAAG;IAC/E,OAAOvB,0BACL;QACEyB,QAAQlB,MAAMkB,MAAM;QACpB,6EAA6E;QAC7EC,UAAU;QACVX;QACAP,OAAOA,MAAMmB,GAAG,CAAC,CAACjB,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19
|
-
|
|
20
|
-
* namespace over active products — one item per product (default
|
|
21
|
-
* variant pricing; per-variant feeds can come later). Submit
|
|
22
|
-
* `https://{site}/api/commerce/feed?hostId={id}` in Merchant Center.
|
|
23
|
-
*/
|
|
24
|
-
export declare const feedHandler: PluginApiHandler;
|
|
18
|
+
export type CheckoutReturnStatus = 'open' | 'complete' | 'expired';
|
|
19
|
+
export declare const checkoutStatusHandler: PluginApiHandler;
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
* What became of a storefront Checkout Session, for the page Stripe returned
|
|
18
|
+
* the shopper to (AGL-3606).
|
|
19
|
+
*
|
|
20
|
+
* ## Why the return page has to ask
|
|
21
|
+
*
|
|
22
|
+
* The in-page checkout sends every successful confirm to `return_url` — the
|
|
23
|
+
* same `?order=success&session_id=…` the hosted redirect lands on. But a
|
|
24
|
+
* redirect-based payment method (a bank redirect, a wallet that leaves the
|
|
25
|
+
* page) comes back to that SAME url when the shopper abandons or fails the
|
|
26
|
+
* bank step, with the session still open and nothing charged. The url alone
|
|
27
|
+
* cannot tell the two apart, so a shopper whose bank step failed was shown a
|
|
28
|
+
* store that said nothing at all, and had no reason to try again.
|
|
29
|
+
*
|
|
30
|
+
* ## What it answers, and what it never does
|
|
31
|
+
*
|
|
32
|
+
* Only the session's `status` and `payment_status`, and only for a session
|
|
33
|
+
* this host created (`metadata[hostId]`, which both checkout routes set). No
|
|
34
|
+
* email, no address, no amount, and no client secret: the session id rides a
|
|
35
|
+
* url that lands in browser history and referrers, and must not become a key
|
|
36
|
+
* to the shopper's details or to paying for their basket.
|
|
37
|
+
*
|
|
38
|
+
* It does not fulfil, and its answer fulfils nothing: the order is still
|
|
39
|
+
* `checkout.session.completed` in `billing-webhook.ts`, and nothing here
|
|
40
|
+
* writes anywhere.
|
|
41
|
+
*/ const SESSION_ID = /^cs_(test|live)_[A-Za-z0-9]{8,255}$/;
|
|
42
|
+
export const checkoutStatusHandler = async (req, res)=>{
|
|
43
|
+
var _req_query_hostId, _req_query_sessionId, _process_env_STRIPE_SECRET_KEY;
|
|
44
|
+
if (req.method && req.method !== 'GET') {
|
|
45
|
+
res.setHeader('Allow', 'GET');
|
|
46
|
+
return res.status(405).json({
|
|
47
|
+
error: 'Method not allowed'
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const hostId = String((_req_query_hostId = req.query.hostId) != null ? _req_query_hostId : '').trim();
|
|
51
|
+
const sessionId = String((_req_query_sessionId = req.query.sessionId) != null ? _req_query_sessionId : '').trim();
|
|
52
|
+
if (!hostId || !sessionId) {
|
|
53
|
+
return res.status(400).json({
|
|
54
|
+
error: 'Missing hostId or sessionId'
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// Shape-checked before it is interpolated into a Stripe URL path.
|
|
58
|
+
if (!SESSION_ID.test(sessionId)) {
|
|
59
|
+
return res.status(400).json({
|
|
60
|
+
error: 'Invalid sessionId'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const secretKey = String((_process_env_STRIPE_SECRET_KEY = process.env.STRIPE_SECRET_KEY) != null ? _process_env_STRIPE_SECRET_KEY : '').trim();
|
|
64
|
+
if (!secretKey) {
|
|
65
|
+
return res.status(501).json({
|
|
66
|
+
error: 'Payments are not configured'
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
70
|
+
try {
|
|
71
|
+
var _ref, _session_status, _session_payment_status;
|
|
72
|
+
var _session_metadata;
|
|
73
|
+
const response = await fetch(`https://api.stripe.com/v1/checkout/sessions/${sessionId}`, {
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: `Bearer ${secretKey}`
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
// A test-mode id under a live key (or the reverse) is a 404 at Stripe,
|
|
80
|
+
// and so is an id that never existed. Both are "not ours".
|
|
81
|
+
return res.status(404).json({
|
|
82
|
+
error: 'Not found'
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const session = await response.json();
|
|
86
|
+
// The same 404 as a missing session, so this route cannot be used to
|
|
87
|
+
// learn that a session exists on ANOTHER merchant's storefront.
|
|
88
|
+
if (String((_ref = session == null ? void 0 : (_session_metadata = session.metadata) == null ? void 0 : _session_metadata.hostId) != null ? _ref : '') !== hostId) {
|
|
89
|
+
return res.status(404).json({
|
|
90
|
+
error: 'Not found'
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const status = String((_session_status = session.status) != null ? _session_status : '');
|
|
94
|
+
if (status !== 'open' && status !== 'complete' && status !== 'expired') {
|
|
95
|
+
return res.status(404).json({
|
|
96
|
+
error: 'Not found'
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return res.status(200).json({
|
|
100
|
+
status: status,
|
|
101
|
+
paymentStatus: String((_session_payment_status = session.payment_status) != null ? _session_payment_status : '')
|
|
102
|
+
});
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error('checkout-status lookup failed', error);
|
|
105
|
+
return res.status(502).json({
|
|
106
|
+
error: 'Lookup failed'
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=checkout-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/checkout-status.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 type { PluginApiHandler } from '@aglyn/aglyn/server'\n\n/**\n * What became of a storefront Checkout Session, for the page Stripe returned\n * the shopper to (AGL-3606).\n *\n * ## Why the return page has to ask\n *\n * The in-page checkout sends every successful confirm to `return_url` — the\n * same `?order=success&session_id=…` the hosted redirect lands on. But a\n * redirect-based payment method (a bank redirect, a wallet that leaves the\n * page) comes back to that SAME url when the shopper abandons or fails the\n * bank step, with the session still open and nothing charged. The url alone\n * cannot tell the two apart, so a shopper whose bank step failed was shown a\n * store that said nothing at all, and had no reason to try again.\n *\n * ## What it answers, and what it never does\n *\n * Only the session's `status` and `payment_status`, and only for a session\n * this host created (`metadata[hostId]`, which both checkout routes set). No\n * email, no address, no amount, and no client secret: the session id rides a\n * url that lands in browser history and referrers, and must not become a key\n * to the shopper's details or to paying for their basket.\n *\n * It does not fulfil, and its answer fulfils nothing: the order is still\n * `checkout.session.completed` in `billing-webhook.ts`, and nothing here\n * writes anywhere.\n */\n\nconst SESSION_ID = /^cs_(test|live)_[A-Za-z0-9]{8,255}$/\n\nexport type CheckoutReturnStatus = 'open' | 'complete' | 'expired'\n\nexport const checkoutStatusHandler: PluginApiHandler = async (req, res) => {\n if (req.method && req.method !== 'GET') {\n res.setHeader('Allow', 'GET')\n return res.status(405).json({ error: 'Method not allowed' })\n }\n const hostId = String(req.query.hostId ?? '').trim()\n const sessionId = String(req.query.sessionId ?? '').trim()\n if (!hostId || !sessionId) {\n return res.status(400).json({ error: 'Missing hostId or sessionId' })\n }\n // Shape-checked before it is interpolated into a Stripe URL path.\n if (!SESSION_ID.test(sessionId)) {\n return res.status(400).json({ error: 'Invalid sessionId' })\n }\n const secretKey = String(process.env.STRIPE_SECRET_KEY ?? '').trim()\n if (!secretKey) {\n return res.status(501).json({ error: 'Payments are not configured' })\n }\n res.setHeader('Cache-Control', 'no-store')\n try {\n const response = await fetch(\n `https://api.stripe.com/v1/checkout/sessions/${sessionId}`,\n { headers: { Authorization: `Bearer ${secretKey}` } },\n )\n if (!response.ok) {\n // A test-mode id under a live key (or the reverse) is a 404 at Stripe,\n // and so is an id that never existed. Both are \"not ours\".\n return res.status(404).json({ error: 'Not found' })\n }\n const session = (await response.json()) as {\n status?: string\n payment_status?: string\n metadata?: Record<string, string>\n }\n // The same 404 as a missing session, so this route cannot be used to\n // learn that a session exists on ANOTHER merchant's storefront.\n if (String(session?.metadata?.hostId ?? '') !== hostId) {\n return res.status(404).json({ error: 'Not found' })\n }\n const status = String(session.status ?? '')\n if (status !== 'open' && status !== 'complete' && status !== 'expired') {\n return res.status(404).json({ error: 'Not found' })\n }\n return res.status(200).json({\n status: status as CheckoutReturnStatus,\n paymentStatus: String(session.payment_status ?? ''),\n })\n } catch (error) {\n console.error('checkout-status lookup failed', error)\n return res.status(502).json({ error: 'Lookup failed' })\n }\n}\n"],"names":["SESSION_ID","checkoutStatusHandler","req","res","process","method","setHeader","status","json","error","hostId","String","query","trim","sessionId","test","secretKey","env","STRIPE_SECRET_KEY","session","response","fetch","headers","Authorization","ok","metadata","paymentStatus","payment_status","console"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GAED,MAAMA,aAAa;AAInB,OAAO,MAAMC,wBAA0C,OAAOC,KAAKC;QAK3CD,mBACGA,sBAQAE;IAbzB,IAAIF,IAAIG,MAAM,IAAIH,IAAIG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jBN,kBAAmBT,MAAM,mBAAI,QAAQA,QAAQ;YACtD,OAAOP,IAAII,MAAM,CAAC,KAAKC,IAAI,CAAC;gBAAEC,OAAO;YAAY;QACnD;QACA,MAAMF,SAASI,QAAOQ,kBAAAA,QAAQZ,MAAM,YAAdY,kBAAkB;QACxC,IAAIZ,WAAW,UAAUA,WAAW,cAAcA,WAAW,WAAW;YACtE,OAAOJ,IAAII,MAAM,CAAC,KAAKC,IAAI,CAAC;gBAAEC,OAAO;YAAY;QACnD;QACA,OAAON,IAAII,MAAM,CAAC,KAAKC,IAAI,CAAC;YAC1BD,QAAQA;YACRmB,eAAef,QAAOQ,0BAAAA,QAAQQ,cAAc,YAAtBR,0BAA0B;QAClD;IACF,EAAE,OAAOV,OAAO;QACdmB,QAAQnB,KAAK,CAAC,iCAAiCA;QAC/C,OAAON,IAAII,MAAM,CAAC,KAAKC,IAAI,CAAC;YAAEC,OAAO;QAAgB;IACvD;AACF,EAAC"}
|
|
@@ -21,11 +21,15 @@ import { claimAttempt, deriveStripeObjectKey } from "@aglyn/aglyn/server";
|
|
|
21
21
|
import { firebaseAdmin, getOrgForHost } from "@aglyn/tenant-data-admin";
|
|
22
22
|
import { merchantAccountIsReady } from "@aglyn/tenant-data-admin/server/payment-provider";
|
|
23
23
|
import { checkoutSessionCardAuthenticationParams } from "@aglyn/tenant-data-admin/server/stripe-card-authentication";
|
|
24
|
+
import { CARRIER_POSTAL_CODE_MESSAGE, planCheckoutShippingWithCarriers } from "./carrier-shipping.js";
|
|
24
25
|
import { readActiveMemberSession } from "./membership.js";
|
|
25
26
|
import { resolveManualTaxRateId } from "./manual-tax-rate.js";
|
|
27
|
+
import { taxEngineSessionMetadata } from "../model/commerce-tax-engine.js";
|
|
28
|
+
import { quoteSaleTaxWithEngine } from "./tax-engine-quote.js";
|
|
26
29
|
import { holdPromotionSlot, promotionHoldKey } from "./promotion-hold.js";
|
|
27
30
|
import { holdStock, stockHoldKey } from "./stock-hold.js";
|
|
28
31
|
import { applyNativeCheckoutParams, nativeCheckoutStripeHeaders, readCheckoutSessionPayload, resolveNativeCheckoutMode } from "./native-checkout.js";
|
|
32
|
+
import { ensureCheckoutDomain } from "./payment-method-domains.js";
|
|
29
33
|
/**
|
|
30
34
|
* Commerce Starter checkout (AGL-90): a site visitor buys a product. The
|
|
31
35
|
* price ALWAYS comes from the host's product doc (never the request), the
|
|
@@ -102,7 +106,7 @@ import { applyNativeCheckoutParams, nativeCheckoutStripeHeaders, readCheckoutSes
|
|
|
102
106
|
if (held) await held.release();
|
|
103
107
|
};
|
|
104
108
|
try {
|
|
105
|
-
var _variant_priceUsd, _req_headers_referer, _req_headers_host, _storeSettings_get, _ref1, _lifted_type, _variant_weightGrams, _lifted_type1, _lifted_type2, _product_name, _ref2;
|
|
109
|
+
var _variant_priceUsd, _req_headers_referer, _req_headers_host, _storeSettings_get, _lifted_name, _ref1, _lifted_type, _variant_weightGrams, _lifted_type1, _lifted_type2, _product_name, _ref2;
|
|
106
110
|
var _ownerOrg_org, _ownerOrg_org1, _ownerOrg_org2;
|
|
107
111
|
const firestore = firebaseAdmin.app().firestore();
|
|
108
112
|
const hostRef = firestore.collection('hosts').doc(hostId);
|
|
@@ -419,6 +423,36 @@ import { applyNativeCheckoutParams, nativeCheckoutStripeHeaders, readCheckoutSes
|
|
|
419
423
|
taxPct = rate.pct;
|
|
420
424
|
}
|
|
421
425
|
}
|
|
426
|
+
// The merchant's own tax service, where they connected one (AGL-3631),
|
|
427
|
+
// for a one-time sale. Taxed at the store's address, like the rate above:
|
|
428
|
+
// the shopper's address arrives inside Stripe Checkout, after this
|
|
429
|
+
// session exists. A subscription keeps the store's recurring rate — a
|
|
430
|
+
// quote taken today does not price next month's renewal. When the service
|
|
431
|
+
// does not answer, the rate above stands and the order says so.
|
|
432
|
+
const engineTax = taxSettings.mode === 'manual' && !lifted.taxExempt && !isSubscription ? await quoteSaleTaxWithEngine({
|
|
433
|
+
hostId,
|
|
434
|
+
settings: taxSettings,
|
|
435
|
+
channel: 'online',
|
|
436
|
+
lines: [
|
|
437
|
+
_extends({
|
|
438
|
+
id: '0',
|
|
439
|
+
productId
|
|
440
|
+
}, variantId ? {
|
|
441
|
+
variantId
|
|
442
|
+
} : {}, {
|
|
443
|
+
description: String((_lifted_name = lifted.name) != null ? _lifted_name : ''),
|
|
444
|
+
quantity,
|
|
445
|
+
amountCents
|
|
446
|
+
})
|
|
447
|
+
]
|
|
448
|
+
}) : {
|
|
449
|
+
quote: null,
|
|
450
|
+
stamp: null
|
|
451
|
+
};
|
|
452
|
+
if (engineTax.quote) {
|
|
453
|
+
taxCents = engineTax.quote.taxCents;
|
|
454
|
+
taxLabel = 'Sales tax';
|
|
455
|
+
}
|
|
422
456
|
// Recurring manual tax (AGL-1751). The manual tax cannot ride the
|
|
423
457
|
// `line_items[1]` product line on a SUBSCRIPTION session: a non-recurring
|
|
424
458
|
// price in `mode: subscription` is a one-time item, and Stripe bills
|
|
@@ -628,13 +662,38 @@ import { applyNativeCheckoutParams, nativeCheckoutStripeHeaders, readCheckoutSes
|
|
|
628
662
|
// the two lists, and refuses rather than guessing.
|
|
629
663
|
const shippingSettings = storeSettings.get('shipping');
|
|
630
664
|
const shipsPhysically = ((_lifted_type = lifted.type) != null ? _lifted_type : 'physical') === 'physical' && !isSubscription;
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
665
|
+
// Live carrier rates (AGL-3612) are quoted here, before the session,
|
|
666
|
+
// for the destination the shopper declared; see `carrier-shipping.ts`.
|
|
667
|
+
const shippingPlan = shipsPhysically ? await planCheckoutShippingWithCarriers({
|
|
668
|
+
hostId,
|
|
669
|
+
settings: shippingSettings,
|
|
670
|
+
cart: _extends({
|
|
671
|
+
subtotalCents: listUnitAmountCents * quantity,
|
|
672
|
+
totalGrams: Math.max(0, Number((_variant_weightGrams = variant.weightGrams) != null ? _variant_weightGrams : 0)) * quantity
|
|
673
|
+
}, quantity === 1 ? {
|
|
674
|
+
parcel: CommerceModel.productParcelDimensions(lifted)
|
|
675
|
+
} : {}),
|
|
676
|
+
destination: {
|
|
677
|
+
country: body.shippingCountry,
|
|
678
|
+
postalCode: body.shippingPostalCode
|
|
679
|
+
}
|
|
680
|
+
}) : {
|
|
635
681
|
countries: CommerceModel.CHECKOUT_SHIPPING_COUNTRIES,
|
|
636
682
|
options: []
|
|
637
683
|
};
|
|
684
|
+
if (shippingPlan.needsPostalCode) {
|
|
685
|
+
await releaseCouponSlot();
|
|
686
|
+
await releaseStock();
|
|
687
|
+
await claim.release();
|
|
688
|
+
return res.status(400).json({
|
|
689
|
+
error: CARRIER_POSTAL_CODE_MESSAGE,
|
|
690
|
+
needsShippingCountry: true,
|
|
691
|
+
needsShippingPostalCode: true,
|
|
692
|
+
shippingCountries: [
|
|
693
|
+
...CommerceModel.CHECKOUT_SHIPPING_COUNTRIES
|
|
694
|
+
]
|
|
695
|
+
});
|
|
696
|
+
}
|
|
638
697
|
if (shippingPlan.refusal === 'destination-required') {
|
|
639
698
|
// A deterministic ask the shopper answers and retries under the same
|
|
640
699
|
// key — released, not burned (AGL-1697). The tax rate possibly minted
|
|
@@ -806,7 +865,9 @@ import { applyNativeCheckoutParams, nativeCheckoutStripeHeaders, readCheckoutSes
|
|
|
806
865
|
} : {}, {
|
|
807
866
|
'metadata[quantity]': String(quantity),
|
|
808
867
|
'metadata[feeCents]': String(feeCents)
|
|
809
|
-
},
|
|
868
|
+
}, shippingPlan.quotedPostalCode ? {
|
|
869
|
+
'metadata[shippingQuotePostalCode]': shippingPlan.quotedPostalCode
|
|
870
|
+
} : {}, useStripeTax && !isSubscription ? {
|
|
810
871
|
'metadata[transferCents]': String(CommerceModel.platformLiableTransferCents({
|
|
811
872
|
feeCents,
|
|
812
873
|
merchantGoodsCents: amountCents,
|
|
@@ -831,7 +892,8 @@ import { applyNativeCheckoutParams, nativeCheckoutStripeHeaders, readCheckoutSes
|
|
|
831
892
|
// documented ground that the two are mutually exclusive, so carrying
|
|
832
893
|
// both would double-count the tax on the recorded sale.
|
|
833
894
|
'metadata[unitAmountCents]': String(listUnitAmountCents),
|
|
834
|
-
'metadata[taxCents]': String(isSubscription ? 0 : taxCents)
|
|
895
|
+
'metadata[taxCents]': String(isSubscription ? 0 : taxCents)
|
|
896
|
+
}, taxEngineSessionMetadata(engineTax.stamp), {
|
|
835
897
|
'metadata[discountCents]': String(discountCents)
|
|
836
898
|
}, appliedCoupon ? {
|
|
837
899
|
'metadata[couponCode]': appliedCoupon
|
|
@@ -868,6 +930,12 @@ import { applyNativeCheckoutParams, nativeCheckoutStripeHeaders, readCheckoutSes
|
|
|
868
930
|
amountCents: 0
|
|
869
931
|
})) : shippingPlan.options);
|
|
870
932
|
}
|
|
933
|
+
// The payment methods the merchant switched off (AGL-3629). Exclusions
|
|
934
|
+
// only: what stays on is whatever the platform's configuration offers for
|
|
935
|
+
// this order, so a store on the defaults sends what it always sent, bar
|
|
936
|
+
// the crypto opt-in. Works on the hosted page as well as the in-page one.
|
|
937
|
+
const paymentMethodControls = CommerceModel.resolveStorefrontPaymentMethodControls(CommerceModel.normalizeStorefrontPaymentMethodSettings(storeSettings.get('paymentMethods')));
|
|
938
|
+
CommerceModel.appendStorefrontPaymentMethodParams(params, paymentMethodControls);
|
|
871
939
|
// The Payment Element (AGL-1944), and the LAST thing done to the params on
|
|
872
940
|
// purpose. Everything above — price, coupon, tax, shipping, the Connect
|
|
873
941
|
// destination, the fee, every metadata key the webhook reads — is computed
|
|
@@ -883,19 +951,28 @@ import { applyNativeCheckoutParams, nativeCheckoutStripeHeaders, readCheckoutSes
|
|
|
883
951
|
if (nativeMode.native) {
|
|
884
952
|
applyNativeCheckoutParams(params, `${backUrl}${separator}order=success&session_id={CHECKOUT_SESSION_ID}`);
|
|
885
953
|
}
|
|
954
|
+
// Apple Pay shows on a registered domain only (AGL-3629). Started beside
|
|
955
|
+
// the session create rather than before it, inside a fixed budget, and
|
|
956
|
+
// never throws: a sale does not wait on, or fail for, a registration.
|
|
957
|
+
const domainRegistration = nativeMode.native ? ensureCheckoutDomain({
|
|
958
|
+
pageUrl: backUrl,
|
|
959
|
+
site: hostSnapshot.data == null ? void 0 : hostSnapshot.data.call(hostSnapshot),
|
|
960
|
+
hostId
|
|
961
|
+
}).catch(()=>null) : Promise.resolve(null);
|
|
886
962
|
const response = await fetch('https://api.stripe.com/v1/checkout/sessions', {
|
|
887
963
|
method: 'POST',
|
|
888
964
|
headers: _extends({
|
|
889
965
|
Authorization: `Bearer ${process.env.STRIPE_SECRET_KEY}`,
|
|
890
966
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
891
|
-
}, stripeKeyHeader('session'), nativeCheckoutStripeHeaders(nativeMode)),
|
|
967
|
+
}, stripeKeyHeader(engineTax.stamp ? `session-tax-${taxCents}-${engineTax.stamp.status}` : 'session'), nativeCheckoutStripeHeaders(nativeMode)),
|
|
892
968
|
body: params.toString()
|
|
893
969
|
});
|
|
894
970
|
const session = await response.json();
|
|
895
971
|
// `!session.url` was the liveness check, and a `ui_mode` session HAS no
|
|
896
972
|
// url — so the check moves with the mode rather than staying behind and
|
|
897
973
|
// reading every successful native session as a Stripe failure (AGL-1944).
|
|
898
|
-
|
|
974
|
+
await domainRegistration;
|
|
975
|
+
const payload = response.ok ? readCheckoutSessionPayload(session, nativeMode, paymentMethodControls.wallets) : null;
|
|
899
976
|
if (!payload) {
|
|
900
977
|
console.error('Stripe checkout error', session.error);
|
|
901
978
|
// Nothing was sold — hand the key back so one flaky moment does not
|