@nextblock-cms/ecom 0.20.3 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/_virtual/_rolldown/runtime.cjs +1 -0
- package/index.cjs +1 -0
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs +1 -0
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs +1 -0
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs +1 -0
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs +1 -0
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs +1 -0
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs +1 -0
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs +1 -0
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs +1 -0
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs +1 -0
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs +1 -0
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs +1 -0
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs +1 -0
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs +1 -0
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs +1 -0
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs +1 -0
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs +29 -0
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs +1 -0
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs +1 -0
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs +1 -0
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs +1 -0
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs +1 -0
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs +1 -0
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs +1 -0
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs +1 -0
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs +1 -0
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs +1 -0
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs +1 -0
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs +1 -0
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs +1 -0
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs +1 -0
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs +1 -0
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs +1 -0
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs +1 -0
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs +1 -0
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs +1 -0
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs +1 -0
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs +1 -0
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs +1 -0
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs +1 -0
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs +1 -0
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs +1 -0
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs +1 -0
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs +1 -0
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs +33 -0
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs +1 -0
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs +1 -0
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs +61 -0
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs +1 -0
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs +1 -0
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs +1 -0
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs +7 -0
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs +1 -0
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs +1 -0
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs +1 -0
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs +1 -0
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs +1 -0
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
- package/lib/pages/cms/products/actions.cjs +44 -0
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs +3 -0
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs +1 -0
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs +1 -0
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs +1 -0
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs +1 -0
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs +1 -0
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs +238 -0
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs +1 -0
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs +1 -0
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs +1 -0
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs +1 -0
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs +1 -0
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs +1 -0
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs +1 -0
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs +1 -0
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs +1 -0
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs +15 -0
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs +7 -0
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs +1 -0
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs +1 -0
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs +1 -0
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs +1 -0
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs +1 -0
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs +1 -0
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs +1 -0
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs +1 -0
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs +1 -0
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs +1 -0
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs +1 -0
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs +1 -0
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs +1 -0
- package/lib/zod-config.es.js +5 -6
- package/package.json +22 -21
- package/server.cjs +1 -0
- package/server.es.js +56 -211
- package/index.cjs.js +0 -1
- package/lib/CurrencyProvider.cjs.js +0 -1
- package/lib/PaymentReadinessProvider.cjs.js +0 -1
- package/lib/cart-store.cjs.js +0 -1
- package/lib/components/AccountNavigationMenu.cjs.js +0 -1
- package/lib/components/AddToCartButton.cjs.js +0 -1
- package/lib/components/Cart.cjs.js +0 -1
- package/lib/components/CartDrawer.cjs.js +0 -1
- package/lib/components/CartIcon.cjs.js +0 -1
- package/lib/components/Checkout.cjs.js +0 -1
- package/lib/components/CouponForm.cjs.js +0 -1
- package/lib/components/CurrencySwitcher.cjs.js +0 -1
- package/lib/components/CustomerProfileForm.cjs.js +0 -1
- package/lib/components/FeaturedProduct.cjs.js +0 -1
- package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
- package/lib/components/InvoiceDocument.cjs.js +0 -1
- package/lib/components/InvoiceViewerShell.cjs.js +0 -29
- package/lib/components/ProductCard.cjs.js +0 -1
- package/lib/components/ProductDetailsLayout.cjs.js +0 -1
- package/lib/components/ProductGallery.cjs.js +0 -1
- package/lib/components/ProductGrid.cjs.js +0 -1
- package/lib/components/ShippingEstimator.cjs.js +0 -1
- package/lib/components/ShortDescription.cjs.js +0 -1
- package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
- package/lib/components/SubscriptionSelector.cjs.js +0 -1
- package/lib/countries.cjs.js +0 -1
- package/lib/coupon-server.cjs.js +0 -1
- package/lib/coupons.cjs.js +0 -1
- package/lib/currency-constants.cjs.js +0 -1
- package/lib/currency-rest-client.cjs.js +0 -1
- package/lib/currency-store.cjs.js +0 -1
- package/lib/currency-sync.cjs.js +0 -1
- package/lib/currency.cjs.js +0 -1
- package/lib/customer-addresses.cjs.js +0 -1
- package/lib/customer-orders.cjs.js +0 -1
- package/lib/customer.cjs.js +0 -1
- package/lib/export-helpers.cjs.js +0 -1
- package/lib/factory.cjs.js +0 -1
- package/lib/freemius-coupons.cjs.js +0 -1
- package/lib/freemius-license-claim.cjs.js +0 -1
- package/lib/freemius-license.cjs.js +0 -1
- package/lib/freemius-order-sync.cjs.js +0 -1
- package/lib/freemius-trial-provision.cjs.js +0 -1
- package/lib/inventory-settings.cjs.js +0 -1
- package/lib/invoice-server.cjs.js +0 -33
- package/lib/invoice-ui.cjs.js +0 -1
- package/lib/invoice.cjs.js +0 -1
- package/lib/order-inventory.cjs.js +0 -61
- package/lib/order-tax-details.cjs.js +0 -1
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
- package/lib/pages/cms/coupons/actions.cjs.js +0 -1
- package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
- package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
- package/lib/pages/cms/orders/actions.cjs.js +0 -7
- package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
- package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
- package/lib/pages/cms/payments/actions.cjs.js +0 -1
- package/lib/pages/cms/payments/queries.cjs.js +0 -1
- package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
- package/lib/pages/cms/products/actions.cjs.js +0 -44
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
- package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
- package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
- package/lib/pages/cms/products/server-actions.cjs.js +0 -1
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
- package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
- package/lib/pages/cms/taxes/actions.cjs.js +0 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
- package/lib/payment-config.cjs.js +0 -1
- package/lib/product-actions.cjs.js +0 -238
- package/lib/product-context.cjs.js +0 -1
- package/lib/product-schema.cjs.js +0 -1
- package/lib/providers/freemius.cjs.js +0 -5
- package/lib/providers/stripe.cjs.js +0 -1
- package/lib/server-actions/coupon-actions.cjs.js +0 -1
- package/lib/server-actions/customer-actions.cjs.js +0 -1
- package/lib/server-actions/product-actions.cjs.js +0 -1
- package/lib/server-actions/shipping-actions.cjs.js +0 -1
- package/lib/server-actions/tax-actions.cjs.js +0 -1
- package/lib/shared-inventory.cjs.js +0 -15
- package/lib/shipping/resolver.cjs.js +0 -7
- package/lib/shipping-rate-currency.cjs.js +0 -1
- package/lib/states.cjs.js +0 -1
- package/lib/stripe/checkout.cjs.js +0 -1
- package/lib/stripe/client.cjs.js +0 -1
- package/lib/stripe/order-sync.cjs.js +0 -1
- package/lib/stripe/webhooks.cjs.js +0 -1
- package/lib/tax-calculation.cjs.js +0 -1
- package/lib/trials.cjs.js +0 -1
- package/lib/types.cjs.js +0 -1
- package/lib/use-cart.cjs.js +0 -1
- package/lib/use-price-formatter.cjs.js +0 -1
- package/lib/variation-utils.cjs.js +0 -1
- package/lib/zod-config.cjs.js +0 -1
- package/server.cjs.js +0 -1
|
@@ -1,482 +1,422 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { buildOrderTaxDetailsFromCalculation as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"fi",
|
|
26
|
-
"fil",
|
|
27
|
-
"fr",
|
|
28
|
-
"hr",
|
|
29
|
-
"hu",
|
|
30
|
-
"id",
|
|
31
|
-
"it",
|
|
32
|
-
"ja",
|
|
33
|
-
"ko",
|
|
34
|
-
"lt",
|
|
35
|
-
"lv",
|
|
36
|
-
"ms",
|
|
37
|
-
"mt",
|
|
38
|
-
"nb",
|
|
39
|
-
"nl",
|
|
40
|
-
"pl",
|
|
41
|
-
"pt",
|
|
42
|
-
"pt-BR",
|
|
43
|
-
"ro",
|
|
44
|
-
"ru",
|
|
45
|
-
"sk",
|
|
46
|
-
"sl",
|
|
47
|
-
"sv",
|
|
48
|
-
"th",
|
|
49
|
-
"tr",
|
|
50
|
-
"vi",
|
|
51
|
-
"zh",
|
|
52
|
-
"zh-HK",
|
|
53
|
-
"zh-TW"
|
|
54
|
-
]);
|
|
55
|
-
function pe(r) {
|
|
56
|
-
if (r)
|
|
57
|
-
return {
|
|
58
|
-
line1: r.line1 || void 0,
|
|
59
|
-
line2: r.line2 || void 0,
|
|
60
|
-
city: r.city || void 0,
|
|
61
|
-
state: r.state || void 0,
|
|
62
|
-
postal_code: r.postal_code || void 0,
|
|
63
|
-
country: r.country_code || void 0
|
|
64
|
-
};
|
|
1
|
+
import { isDigitalItem as e } from "../types.es.js";
|
|
2
|
+
import { convertMinorUnitAmount as t, getDefaultCurrency as n, normalizePriceMap as r, resolveEffectivePriceForCurrency as i } from "../currency.es.js";
|
|
3
|
+
import { getCartLineCouponKey as a } from "../coupons.es.js";
|
|
4
|
+
import { getCouponQuote as o, getQuoteLineDiscountMap as s, recordCouponRedemption as c } from "../coupon-server.es.js";
|
|
5
|
+
import { countries as l } from "../countries.es.js";
|
|
6
|
+
import { resolveTranslatedText as u } from "../variation-utils.es.js";
|
|
7
|
+
import { createInventoryInsufficientError as d, createInventoryUnavailableError as f, getEcommerceInventorySettings as ee } from "../inventory-settings.es.js";
|
|
8
|
+
import { STRIPE_TAX_CODE_NONTAXABLE as p, STRIPE_TAX_CODE_SHIPPING as te, calculateCheckoutTaxes as ne, getStripeTaxCodeForProduct as re } from "../tax-calculation.es.js";
|
|
9
|
+
import { normalizeOrderCustomerDetails as ie } from "../customer.es.js";
|
|
10
|
+
import { fillMissingUserProfileCheckoutDetails as ae, upsertDefaultUserAddresses as oe } from "../customer-addresses.es.js";
|
|
11
|
+
import { buildOrderTaxDetailsFromCalculation as se } from "../order-tax-details.es.js";
|
|
12
|
+
import { getStripeClient as m } from "../stripe/client.es.js";
|
|
13
|
+
import { createClient as ce } from "@supabase/supabase-js";
|
|
14
|
+
//#region src/lib/providers/stripe.ts
|
|
15
|
+
var le = l.map((e) => e.code), h = /* @__PURE__ */ new Set(/* @__PURE__ */ "bg.cs.da.de.el.en.en-GB.es.es-419.et.fi.fil.fr.hr.hu.id.it.ja.ko.lt.lv.ms.mt.nb.nl.pl.pt.pt-BR.ro.ru.sk.sl.sv.th.tr.vi.zh.zh-HK.zh-TW".split("."));
|
|
16
|
+
function g(e) {
|
|
17
|
+
if (e) return {
|
|
18
|
+
line1: e.line1 || void 0,
|
|
19
|
+
line2: e.line2 || void 0,
|
|
20
|
+
city: e.city || void 0,
|
|
21
|
+
state: e.state || void 0,
|
|
22
|
+
postal_code: e.postal_code || void 0,
|
|
23
|
+
country: e.country_code || void 0
|
|
24
|
+
};
|
|
65
25
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
26
|
+
function ue(e) {
|
|
27
|
+
let t = e?.trim().replace("_", "-");
|
|
28
|
+
if (!t) return;
|
|
29
|
+
let n = [
|
|
30
|
+
t,
|
|
31
|
+
t.toLowerCase(),
|
|
32
|
+
t.split("-")[0].toLowerCase()
|
|
33
|
+
];
|
|
34
|
+
for (let e of n) if (h.has(e)) return e;
|
|
74
35
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
r.name,
|
|
78
|
-
r.name_translations || null,
|
|
79
|
-
i
|
|
80
|
-
);
|
|
36
|
+
function de(e, t) {
|
|
37
|
+
return u(e.name, e.name_translations || null, t);
|
|
81
38
|
}
|
|
82
|
-
async function
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
} catch (u) {
|
|
106
|
-
return console.error("Failed to upsert Stripe customer for checkout prefill:", u), null;
|
|
107
|
-
}
|
|
39
|
+
async function fe(e) {
|
|
40
|
+
if (!e.email) return null;
|
|
41
|
+
let t = await m(), n = g(e.shippingAddress), r = e.shippingAddress?.recipient_name || e.billingAddress?.recipient_name || void 0, i = {
|
|
42
|
+
email: e.email,
|
|
43
|
+
name: e.billingAddress?.recipient_name || e.shippingAddress?.recipient_name || void 0,
|
|
44
|
+
phone: e.phone || void 0,
|
|
45
|
+
address: g(e.billingAddress),
|
|
46
|
+
metadata: e.userId ? { userId: e.userId } : void 0,
|
|
47
|
+
...n && r ? { shipping: {
|
|
48
|
+
name: r,
|
|
49
|
+
phone: e.phone || void 0,
|
|
50
|
+
address: n
|
|
51
|
+
} } : {}
|
|
52
|
+
};
|
|
53
|
+
try {
|
|
54
|
+
let n = (await t.customers.list({
|
|
55
|
+
email: e.email,
|
|
56
|
+
limit: 1
|
|
57
|
+
})).data[0];
|
|
58
|
+
return n ? (await t.customers.update(n.id, i), n.id) : (await t.customers.create(i)).id;
|
|
59
|
+
} catch (e) {
|
|
60
|
+
return console.error("Failed to upsert Stripe customer for checkout prefill:", e), null;
|
|
61
|
+
}
|
|
108
62
|
}
|
|
109
|
-
class
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
} catch (e) {
|
|
467
|
-
return console.error("Stripe session creation failed:", e), await a.from("orders").update({ status: "failed" }).eq("id", k), e?.name === "StripeNotConfiguredError" || e?.type === "StripeAuthenticationError" ? {
|
|
468
|
-
error: "This store is not able to take payments right now. Please contact the seller to complete your purchase.",
|
|
469
|
-
errorKey: "ecommerce.checkout_payments_unavailable",
|
|
470
|
-
errorStatus: 503,
|
|
471
|
-
url: null
|
|
472
|
-
} : {
|
|
473
|
-
error: "Something went wrong while preparing your checkout. Please try again.",
|
|
474
|
-
errorKey: "ecommerce.checkout_internal_server_error",
|
|
475
|
-
url: null
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
export {
|
|
481
|
-
ct as StripeProvider
|
|
63
|
+
var _ = class {
|
|
64
|
+
getProviderName() {
|
|
65
|
+
return "Stripe";
|
|
66
|
+
}
|
|
67
|
+
async createCheckoutSession({ items: l, customerEmail: u, customerPhone: h, userId: g, billingAddress: _, shippingAddress: v, shippingMethodId: pe, currencyCode: me, locale: he, couponCode: y, couponContextItems: b }) {
|
|
68
|
+
let ge = await m(), x = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, S = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY;
|
|
69
|
+
if (!x || !S) return console.error("Missing Supabase credentials for checkout (Service Key required)."), {
|
|
70
|
+
error: "Internal Server Error",
|
|
71
|
+
url: null
|
|
72
|
+
};
|
|
73
|
+
let C = ce(x, S), w = process.env.NEXT_PUBLIC_URL || "http://localhost:4200", T = l.some((t) => !e(t));
|
|
74
|
+
if (!l.length) return {
|
|
75
|
+
error: "Cart is empty",
|
|
76
|
+
url: null
|
|
77
|
+
};
|
|
78
|
+
let { data: _e, error: E } = await C.from("currencies").select("code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount").eq("is_active", !0).order("code", { ascending: !0 }), D = _e ?? [];
|
|
79
|
+
if (E || D.length === 0) return console.error("Error fetching currencies for checkout:", E), {
|
|
80
|
+
error: "Failed to resolve store currencies",
|
|
81
|
+
url: null
|
|
82
|
+
};
|
|
83
|
+
let O = n(D), k = D.find((e) => e.code === (me || "").toUpperCase()) ?? O, A = k.code.toLowerCase(), j = await ee(C), ve = l.map((e) => e.product_id), M = l.map((e) => e.variant_id).filter((e) => !!e), { data: N, error: P } = await C.from("products").select("id, title, sku, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at, stock, is_taxable").in("id", ve);
|
|
84
|
+
if (P || !N) return console.error("Error fetching products for validation:", P), {
|
|
85
|
+
error: "Failed to validate product prices",
|
|
86
|
+
url: null
|
|
87
|
+
};
|
|
88
|
+
let { data: ye, error: F } = M.length ? await C.from("product_variants").select("id, product_id, sku, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at, stock_quantity").in("id", M) : {
|
|
89
|
+
data: [],
|
|
90
|
+
error: null
|
|
91
|
+
};
|
|
92
|
+
if (F) return console.error("Error fetching variants for validation:", F), {
|
|
93
|
+
error: "Failed to validate product variants",
|
|
94
|
+
url: null
|
|
95
|
+
};
|
|
96
|
+
let I = new Map(N.map((e) => [e.id, e])), L = new Map((ye || []).map((e) => [e.id, e])), R = /* @__PURE__ */ new Set(), z = /* @__PURE__ */ new Map();
|
|
97
|
+
for (let e of l) {
|
|
98
|
+
let t = I.get(e.product_id);
|
|
99
|
+
if (!t) continue;
|
|
100
|
+
let n = (e.variant_id ? L.get(e.variant_id) : null)?.sku || t.sku;
|
|
101
|
+
n && (R.add(n), z.set(n, (z.get(n) ?? 0) + e.quantity));
|
|
102
|
+
}
|
|
103
|
+
let { data: be, error: B } = R.size ? await C.from("inventory_items").select("sku, quantity").in("sku", [...R]) : {
|
|
104
|
+
data: [],
|
|
105
|
+
error: null
|
|
106
|
+
};
|
|
107
|
+
if (B) return console.error("Error fetching SKU inventory for validation:", B), {
|
|
108
|
+
error: "Failed to validate SKU inventory",
|
|
109
|
+
url: null
|
|
110
|
+
};
|
|
111
|
+
let V = new Map((be || []).map((e) => [e.sku, Math.max(0, e.quantity ?? 0)])), H = [], U = [], W = [], G = 0, K = 0, q = null;
|
|
112
|
+
if (y) {
|
|
113
|
+
let e = await o({
|
|
114
|
+
client: C,
|
|
115
|
+
code: y,
|
|
116
|
+
items: b && b.length > 0 ? b : l,
|
|
117
|
+
currencyCode: k.code
|
|
118
|
+
});
|
|
119
|
+
if (!e.success) return {
|
|
120
|
+
error: e.error,
|
|
121
|
+
errorKey: e.errorKey,
|
|
122
|
+
errorStatus: 400,
|
|
123
|
+
url: null
|
|
124
|
+
};
|
|
125
|
+
q = e.quote;
|
|
126
|
+
}
|
|
127
|
+
let xe = s(q), Se = (e) => {
|
|
128
|
+
let t = e.unitAmount * e.quantity, n = Math.max(0, t - e.lineDiscount);
|
|
129
|
+
if (n <= 0) return;
|
|
130
|
+
let r = Math.floor(n / e.quantity), i = n - r * e.quantity, a = (t, n) => {
|
|
131
|
+
n <= 0 || t <= 0 || H.push({
|
|
132
|
+
price_data: {
|
|
133
|
+
currency: e.currency,
|
|
134
|
+
product_data: {
|
|
135
|
+
name: e.name,
|
|
136
|
+
tax_code: re(e.isTaxable),
|
|
137
|
+
metadata: {
|
|
138
|
+
productId: e.productId,
|
|
139
|
+
variantId: e.variantId || ""
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
tax_behavior: "exclusive",
|
|
143
|
+
unit_amount: t
|
|
144
|
+
},
|
|
145
|
+
quantity: n
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
a(r, e.quantity - i), a(r + 1, i);
|
|
149
|
+
};
|
|
150
|
+
for (let e of l) {
|
|
151
|
+
let t = I.get(e.product_id);
|
|
152
|
+
if (!t) return console.warn(`Product ${e.product_id} not found in DB.`), {
|
|
153
|
+
url: null,
|
|
154
|
+
...f(e.title)
|
|
155
|
+
};
|
|
156
|
+
let n = i({
|
|
157
|
+
prices: r(t.prices),
|
|
158
|
+
salePrices: t.sale_prices || {},
|
|
159
|
+
fallbackPrice: t.price,
|
|
160
|
+
fallbackSalePrice: t.sale_price,
|
|
161
|
+
saleStartAt: t.sale_start_at,
|
|
162
|
+
saleEndAt: t.sale_end_at,
|
|
163
|
+
scheduledPrice: t.scheduled_price,
|
|
164
|
+
scheduledPrices: r(t.scheduled_prices),
|
|
165
|
+
scheduledPriceAt: t.scheduled_price_at,
|
|
166
|
+
currencyCode: k.code,
|
|
167
|
+
currencies: D
|
|
168
|
+
}), o = n.sale_price ?? n.price, s = t.title, c = null;
|
|
169
|
+
if (e.variant_id) {
|
|
170
|
+
let n = L.get(e.variant_id);
|
|
171
|
+
if (!n || n.product_id !== e.product_id) return {
|
|
172
|
+
url: null,
|
|
173
|
+
...f(e.title)
|
|
174
|
+
};
|
|
175
|
+
let a = z.get(n.sku) ?? e.quantity, l = V.has(n.sku) ? V.get(n.sku) ?? 0 : Math.max(0, n.stock_quantity ?? 0);
|
|
176
|
+
if (j.trackQuantities && a > l) return {
|
|
177
|
+
url: null,
|
|
178
|
+
...d(e.title, l)
|
|
179
|
+
};
|
|
180
|
+
let u = i({
|
|
181
|
+
prices: r(n.prices),
|
|
182
|
+
salePrices: n.sale_prices || {},
|
|
183
|
+
fallbackPrice: n.price,
|
|
184
|
+
fallbackSalePrice: n.sale_price,
|
|
185
|
+
saleStartAt: n.sale_start_at,
|
|
186
|
+
saleEndAt: n.sale_end_at,
|
|
187
|
+
scheduledPrice: n.scheduled_price,
|
|
188
|
+
scheduledPrices: r(n.scheduled_prices),
|
|
189
|
+
scheduledPriceAt: n.scheduled_price_at,
|
|
190
|
+
currencyCode: k.code,
|
|
191
|
+
currencies: D
|
|
192
|
+
});
|
|
193
|
+
o = u.sale_price ?? u.price, c = n.id, s = e.variant_label ? `${t.title} - ${e.variant_label}` : `${t.title} - ${n.sku}`;
|
|
194
|
+
} else {
|
|
195
|
+
let n = z.get(t.sku) ?? e.quantity, r = V.has(t.sku) ? V.get(t.sku) ?? 0 : Math.max(0, t.stock ?? 0);
|
|
196
|
+
if (j.trackQuantities && n > r) return {
|
|
197
|
+
url: null,
|
|
198
|
+
...d(e.title, r)
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
let l = t.is_taxable ?? !0;
|
|
202
|
+
if (o < 0) return {
|
|
203
|
+
error: "A product variation produced an invalid price.",
|
|
204
|
+
url: null
|
|
205
|
+
};
|
|
206
|
+
let u = Math.min(o * e.quantity, xe.get(a(e)) ?? 0);
|
|
207
|
+
Se({
|
|
208
|
+
name: s,
|
|
209
|
+
currency: A,
|
|
210
|
+
productId: t.id,
|
|
211
|
+
variantId: c,
|
|
212
|
+
isTaxable: l,
|
|
213
|
+
unitAmount: o,
|
|
214
|
+
quantity: e.quantity,
|
|
215
|
+
lineDiscount: u
|
|
216
|
+
}), G += o * e.quantity, K += u, W.push({
|
|
217
|
+
product_id: t.id,
|
|
218
|
+
quantity: e.quantity,
|
|
219
|
+
price_at_purchase: o,
|
|
220
|
+
variant_id: c
|
|
221
|
+
}), U.push({
|
|
222
|
+
product_id: t.id,
|
|
223
|
+
quantity: e.quantity,
|
|
224
|
+
unit_amount: o,
|
|
225
|
+
discount_amount: u,
|
|
226
|
+
is_taxable: l
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
if (H.length === 0 && K >= G) return {
|
|
230
|
+
error: "This coupon would reduce the Stripe order to zero. Use a smaller discount for Stripe checkout.",
|
|
231
|
+
errorKey: "ecommerce.coupon_zero_total_not_supported",
|
|
232
|
+
errorStatus: 400,
|
|
233
|
+
url: null
|
|
234
|
+
};
|
|
235
|
+
if (H.length === 0) return {
|
|
236
|
+
error: "No valid items in cart",
|
|
237
|
+
url: null
|
|
238
|
+
};
|
|
239
|
+
let J = 0, Y = null;
|
|
240
|
+
if (pe) {
|
|
241
|
+
let { data: e, error: n } = await C.from("shipping_zone_methods").select("id, name, name_translations, cost_amount, cost_currency").eq("id", pe).single();
|
|
242
|
+
if (n) return console.error("Failed to load shipping method:", n), {
|
|
243
|
+
error: "Failed to load shipping method",
|
|
244
|
+
url: null
|
|
245
|
+
};
|
|
246
|
+
J = t({
|
|
247
|
+
amount: e.cost_amount ?? 0,
|
|
248
|
+
fromCurrencyCode: e.cost_currency || O.code,
|
|
249
|
+
toCurrencyCode: k.code,
|
|
250
|
+
currencies: D
|
|
251
|
+
}), Y = de(e, he);
|
|
252
|
+
}
|
|
253
|
+
let Ce = T ? v ?? _ : _, X;
|
|
254
|
+
try {
|
|
255
|
+
X = await ne(C, {
|
|
256
|
+
items: U,
|
|
257
|
+
destination: {
|
|
258
|
+
country_code: Ce?.country_code,
|
|
259
|
+
state: Ce?.state
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
} catch (e) {
|
|
263
|
+
return console.error("Failed to calculate checkout taxes:", e), {
|
|
264
|
+
error: "Failed to calculate taxes",
|
|
265
|
+
url: null
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
J > 0 && Y && H.push({
|
|
269
|
+
price_data: {
|
|
270
|
+
currency: A,
|
|
271
|
+
product_data: {
|
|
272
|
+
name: Y,
|
|
273
|
+
tax_code: X.enabled && X.mode === "automatic" ? te : p
|
|
274
|
+
},
|
|
275
|
+
tax_behavior: "exclusive",
|
|
276
|
+
unit_amount: J
|
|
277
|
+
},
|
|
278
|
+
quantity: 1
|
|
279
|
+
});
|
|
280
|
+
let Z = X.enabled && X.mode === "manual" && !X.isPendingExternalCalculation ? X.amount : 0;
|
|
281
|
+
Z > 0 && H.push({
|
|
282
|
+
price_data: {
|
|
283
|
+
currency: A,
|
|
284
|
+
product_data: {
|
|
285
|
+
name: "Tax",
|
|
286
|
+
tax_code: p
|
|
287
|
+
},
|
|
288
|
+
tax_behavior: "exclusive",
|
|
289
|
+
unit_amount: Z
|
|
290
|
+
},
|
|
291
|
+
quantity: 1
|
|
292
|
+
});
|
|
293
|
+
let we = ie({
|
|
294
|
+
email: u,
|
|
295
|
+
phone: h,
|
|
296
|
+
name: _?.recipient_name,
|
|
297
|
+
billing: _,
|
|
298
|
+
shipping: v
|
|
299
|
+
}), Te = k.code, Ee = se({
|
|
300
|
+
calculation: X,
|
|
301
|
+
subtotal: G,
|
|
302
|
+
shippingTotal: J,
|
|
303
|
+
total: Math.max(0, G - K) + J + Z,
|
|
304
|
+
currency: Te
|
|
305
|
+
}), De = Math.max(0, G - K) + J + Z, { data: Oe, error: ke } = await C.from("orders").insert({
|
|
306
|
+
status: "pending",
|
|
307
|
+
total: De,
|
|
308
|
+
currency: Te,
|
|
309
|
+
exchange_rate_at_purchase: k.exchange_rate,
|
|
310
|
+
subtotal: G,
|
|
311
|
+
shipping_total: J,
|
|
312
|
+
tax_total: Z,
|
|
313
|
+
tax_details: Ee,
|
|
314
|
+
coupon_id: q?.couponId ?? null,
|
|
315
|
+
coupon_code: q?.code ?? null,
|
|
316
|
+
discount_total: K,
|
|
317
|
+
discount_details: q ? {
|
|
318
|
+
code: q.code,
|
|
319
|
+
discount_type: q.discountType,
|
|
320
|
+
discount_amount: q.discountAmount,
|
|
321
|
+
provider: "stripe",
|
|
322
|
+
provider_discounts: q.providerDiscounts,
|
|
323
|
+
line_discounts: q.lineDiscounts
|
|
324
|
+
} : null,
|
|
325
|
+
provider: "stripe",
|
|
326
|
+
user_id: g,
|
|
327
|
+
customer_details: we
|
|
328
|
+
}).select("id").single();
|
|
329
|
+
if (ke || !Oe) return console.error("Failed to create pending order:", ke), {
|
|
330
|
+
error: "Failed to initiate order",
|
|
331
|
+
url: null
|
|
332
|
+
};
|
|
333
|
+
let Q = Oe.id, { error: Ae } = await C.from("order_items").insert(W.map((e) => ({
|
|
334
|
+
order_id: Q,
|
|
335
|
+
product_id: e.product_id,
|
|
336
|
+
variant_id: e.variant_id ?? null,
|
|
337
|
+
quantity: e.quantity,
|
|
338
|
+
price_at_purchase: e.price_at_purchase
|
|
339
|
+
})));
|
|
340
|
+
if (Ae) return console.error("Failed to insert order items:", Ae), await C.from("orders").update({ status: "failed" }).eq("id", Q), {
|
|
341
|
+
error: "Failed to record order items",
|
|
342
|
+
url: null
|
|
343
|
+
};
|
|
344
|
+
if (g) try {
|
|
345
|
+
await oe({
|
|
346
|
+
userId: g,
|
|
347
|
+
billingAddress: _,
|
|
348
|
+
shippingAddress: v,
|
|
349
|
+
client: C
|
|
350
|
+
}), await ae({
|
|
351
|
+
userId: g,
|
|
352
|
+
fullName: _?.recipient_name ?? v?.recipient_name ?? null,
|
|
353
|
+
phone: h,
|
|
354
|
+
client: C
|
|
355
|
+
});
|
|
356
|
+
} catch (e) {
|
|
357
|
+
console.error("Failed to sync checkout profile defaults before checkout:", e);
|
|
358
|
+
}
|
|
359
|
+
q && await c({
|
|
360
|
+
client: C,
|
|
361
|
+
quote: q,
|
|
362
|
+
orderId: Q,
|
|
363
|
+
provider: "stripe",
|
|
364
|
+
discountTotal: K,
|
|
365
|
+
userId: g,
|
|
366
|
+
customerEmail: u,
|
|
367
|
+
metadata: {
|
|
368
|
+
currency: k.code,
|
|
369
|
+
subtotal: G,
|
|
370
|
+
shipping_total: J,
|
|
371
|
+
tax_total: Z
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
let $ = await fe({
|
|
375
|
+
email: u,
|
|
376
|
+
phone: h,
|
|
377
|
+
userId: g,
|
|
378
|
+
billingAddress: _,
|
|
379
|
+
shippingAddress: v
|
|
380
|
+
});
|
|
381
|
+
try {
|
|
382
|
+
let e = await ge.checkout.sessions.create({
|
|
383
|
+
mode: "payment",
|
|
384
|
+
success_url: `${w}/checkout/success?session_id={CHECKOUT_SESSION_ID}`,
|
|
385
|
+
cancel_url: `${w}/checkout`,
|
|
386
|
+
locale: ue(he),
|
|
387
|
+
line_items: H,
|
|
388
|
+
automatic_tax: X.enabled && X.mode === "automatic" ? { enabled: !0 } : void 0,
|
|
389
|
+
billing_address_collection: "auto",
|
|
390
|
+
customer: $ || void 0,
|
|
391
|
+
customer_email: $ ? void 0 : u || void 0,
|
|
392
|
+
customer_creation: $ ? void 0 : "if_required",
|
|
393
|
+
customer_update: $ ? {
|
|
394
|
+
name: "auto",
|
|
395
|
+
address: "auto",
|
|
396
|
+
shipping: "auto"
|
|
397
|
+
} : void 0,
|
|
398
|
+
shipping_address_collection: T ? { allowed_countries: le } : void 0,
|
|
399
|
+
metadata: {
|
|
400
|
+
orderId: Q,
|
|
401
|
+
taxMode: X.mode,
|
|
402
|
+
currencyCode: k.code,
|
|
403
|
+
couponCode: q?.code || ""
|
|
404
|
+
}
|
|
405
|
+
}), { error: t } = await C.from("orders").update({ stripe_session_id: e.id }).eq("id", Q);
|
|
406
|
+
return t && console.error("Failed to save Stripe session ID on order:", t), { url: e.url };
|
|
407
|
+
} catch (e) {
|
|
408
|
+
return console.error("Stripe session creation failed:", e), await C.from("orders").update({ status: "failed" }).eq("id", Q), e?.name === "StripeNotConfiguredError" || e?.type === "StripeAuthenticationError" ? {
|
|
409
|
+
error: "This store is not able to take payments right now. Please contact the seller to complete your purchase.",
|
|
410
|
+
errorKey: "ecommerce.checkout_payments_unavailable",
|
|
411
|
+
errorStatus: 503,
|
|
412
|
+
url: null
|
|
413
|
+
} : {
|
|
414
|
+
error: "Something went wrong while preparing your checkout. Please try again.",
|
|
415
|
+
errorKey: "ecommerce.checkout_internal_server_error",
|
|
416
|
+
url: null
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
}
|
|
482
420
|
};
|
|
421
|
+
//#endregion
|
|
422
|
+
export { _ as StripeProvider };
|