@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,182 +1,126 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"MX",
|
|
125
|
-
"BR",
|
|
126
|
-
"AR",
|
|
127
|
-
"CL",
|
|
128
|
-
"CO",
|
|
129
|
-
"PE",
|
|
130
|
-
"ZA",
|
|
131
|
-
"NG",
|
|
132
|
-
"KE",
|
|
133
|
-
"IN",
|
|
134
|
-
"JP",
|
|
135
|
-
"KR",
|
|
136
|
-
"CN",
|
|
137
|
-
"SG",
|
|
138
|
-
"MY",
|
|
139
|
-
"PH",
|
|
140
|
-
"TH",
|
|
141
|
-
"VN",
|
|
142
|
-
"ID",
|
|
143
|
-
"AE",
|
|
144
|
-
"SA",
|
|
145
|
-
"EG",
|
|
146
|
-
"MA",
|
|
147
|
-
"DZ",
|
|
148
|
-
"TN",
|
|
149
|
-
"PT",
|
|
150
|
-
"NL",
|
|
151
|
-
"BE",
|
|
152
|
-
"CH",
|
|
153
|
-
"AT",
|
|
154
|
-
"SE",
|
|
155
|
-
"NO",
|
|
156
|
-
"DK",
|
|
157
|
-
"FI",
|
|
158
|
-
"PL",
|
|
159
|
-
"CZ",
|
|
160
|
-
"HU",
|
|
161
|
-
"RO",
|
|
162
|
-
"BG",
|
|
163
|
-
"GR",
|
|
164
|
-
"TR",
|
|
165
|
-
"IL",
|
|
166
|
-
"CY",
|
|
167
|
-
"MT"
|
|
168
|
-
]
|
|
169
|
-
},
|
|
170
|
-
shipping_options: _.length > 0 ? _ : void 0,
|
|
171
|
-
metadata: {
|
|
172
|
-
orderId: c.id
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
return await t.from("orders").update({ stripe_session_id: r.id }).eq("id", c.id), { url: r.url };
|
|
176
|
-
} catch (e) {
|
|
177
|
-
return console.error("Stripe session creation failed:", e), { error: e.message, url: null };
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
export {
|
|
181
|
-
M as createCheckoutSession
|
|
1
|
+
import { getDefaultCurrency as e, resolveEffectivePriceForCurrency as t } from "../currency.es.js";
|
|
2
|
+
import { resolveShippingOptions as n } from "../shipping/resolver.es.js";
|
|
3
|
+
import { getStripeClient as r } from "./client.es.js";
|
|
4
|
+
import { verifyPackageOnline as i } from "@nextblock-cms/db/server";
|
|
5
|
+
import { createClient as a } from "@supabase/supabase-js";
|
|
6
|
+
//#region src/lib/stripe/checkout.ts
|
|
7
|
+
var o = async (o, s, c, l) => {
|
|
8
|
+
let u = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, d = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY;
|
|
9
|
+
if (!u || !d) return console.error("Missing Supabase credentials for checkout (Service Key required)."), {
|
|
10
|
+
error: "Internal Server Error",
|
|
11
|
+
url: null
|
|
12
|
+
};
|
|
13
|
+
let f = a(u, d), p = process.env.NEXT_PUBLIC_URL || "http://localhost:4200";
|
|
14
|
+
if (!o.length) return {
|
|
15
|
+
error: "Cart is empty",
|
|
16
|
+
url: null
|
|
17
|
+
};
|
|
18
|
+
let { data: m } = await f.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 }), h = m ?? [], g = e(h), _ = h.find((e) => e.code === (l || "").toUpperCase()) ?? g;
|
|
19
|
+
if (!await i("ecommerce")) return {
|
|
20
|
+
error: "E-Commerce Package not active. Please purchase a license to accept payments.",
|
|
21
|
+
url: null
|
|
22
|
+
};
|
|
23
|
+
let v = o.map((e) => e.product_id), { data: y, error: b } = await f.from("products").select("id, title, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at").in("id", v);
|
|
24
|
+
if (b || !y) return console.error("Error fetching products for validation:", b), {
|
|
25
|
+
error: "Failed to validate product prices",
|
|
26
|
+
url: null
|
|
27
|
+
};
|
|
28
|
+
let x = new Map(y.map((e) => [e.id, e])), S = [], C = 0, w = [];
|
|
29
|
+
for (let e of o) {
|
|
30
|
+
let n = x.get(e.product_id);
|
|
31
|
+
if (!n) {
|
|
32
|
+
console.warn(`Product ${e.product_id} not found in DB, skipping.`);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
let r = t({
|
|
36
|
+
prices: n.prices || {},
|
|
37
|
+
salePrices: n.sale_prices || {},
|
|
38
|
+
fallbackPrice: n.price,
|
|
39
|
+
fallbackSalePrice: n.sale_price,
|
|
40
|
+
saleStartAt: n.sale_start_at,
|
|
41
|
+
saleEndAt: n.sale_end_at,
|
|
42
|
+
scheduledPrice: n.scheduled_price,
|
|
43
|
+
scheduledPrices: n.scheduled_prices || {},
|
|
44
|
+
scheduledPriceAt: n.scheduled_price_at,
|
|
45
|
+
currencyCode: _.code,
|
|
46
|
+
currencies: h
|
|
47
|
+
}), i = r.sale_price ?? r.price;
|
|
48
|
+
i <= 0 && console.warn(`[Checkout Session Warning] Product ${n.title} has zero or negative price!`), S.push({
|
|
49
|
+
price_data: {
|
|
50
|
+
currency: _.code.toLowerCase(),
|
|
51
|
+
product_data: {
|
|
52
|
+
name: n.title,
|
|
53
|
+
images: [],
|
|
54
|
+
metadata: { productId: n.id }
|
|
55
|
+
},
|
|
56
|
+
unit_amount: i
|
|
57
|
+
},
|
|
58
|
+
quantity: e.quantity
|
|
59
|
+
}), C += i * e.quantity, w.push({
|
|
60
|
+
product_id: n.id,
|
|
61
|
+
quantity: e.quantity,
|
|
62
|
+
price_at_purchase: i
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (S.length === 0) return {
|
|
66
|
+
error: "No valid items in cart",
|
|
67
|
+
url: null
|
|
68
|
+
};
|
|
69
|
+
let { data: T, error: E } = await f.from("orders").insert({
|
|
70
|
+
total: C,
|
|
71
|
+
user_id: s,
|
|
72
|
+
currency: _.code,
|
|
73
|
+
exchange_rate_at_purchase: _.exchange_rate
|
|
74
|
+
}).select("id").single();
|
|
75
|
+
if (E || !T) return console.error("Failed to create pending order:", E), console.error("Order Data attempted:", {
|
|
76
|
+
status: "pending",
|
|
77
|
+
total: C
|
|
78
|
+
}), {
|
|
79
|
+
error: `Failed to initiate order: ${E?.message || "Unknown error"}`,
|
|
80
|
+
url: null
|
|
81
|
+
};
|
|
82
|
+
let D = w.map((e) => ({
|
|
83
|
+
order_id: T.id,
|
|
84
|
+
product_id: e.product_id,
|
|
85
|
+
quantity: e.quantity,
|
|
86
|
+
price_at_purchase: e.price_at_purchase
|
|
87
|
+
})), { error: O } = await f.from("order_items").insert(D);
|
|
88
|
+
O && console.error("Failed to insert order items:", O);
|
|
89
|
+
let k = [], A = c;
|
|
90
|
+
if (!A && s) {
|
|
91
|
+
let { data: e } = await f.from("user_addresses").select("country_code, state_code, postal_code").eq("user_id", s).eq("address_type", "shipping").limit(1).single();
|
|
92
|
+
e && (A = {
|
|
93
|
+
country: e.country_code,
|
|
94
|
+
state: e.state_code,
|
|
95
|
+
postal_code: e.postal_code
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
A && (k = (await n(C, A, null, _.code)).map((e) => ({ shipping_rate_data: {
|
|
99
|
+
type: "fixed_amount",
|
|
100
|
+
fixed_amount: {
|
|
101
|
+
amount: e.amount,
|
|
102
|
+
currency: e.currency.toLowerCase()
|
|
103
|
+
},
|
|
104
|
+
display_name: e.name
|
|
105
|
+
} })));
|
|
106
|
+
try {
|
|
107
|
+
let e = await (await r()).checkout.sessions.create({
|
|
108
|
+
mode: "payment",
|
|
109
|
+
success_url: `${p}/checkout/success?session_id={CHECKOUT_SESSION_ID}`,
|
|
110
|
+
cancel_url: `${p}/`,
|
|
111
|
+
line_items: S,
|
|
112
|
+
billing_address_collection: "required",
|
|
113
|
+
shipping_address_collection: { allowed_countries: /* @__PURE__ */ "US.CA.GB.AU.NZ.IE.FR.DE.IT.ES.MX.BR.AR.CL.CO.PE.ZA.NG.KE.IN.JP.KR.CN.SG.MY.PH.TH.VN.ID.AE.SA.EG.MA.DZ.TN.PT.NL.BE.CH.AT.SE.NO.DK.FI.PL.CZ.HU.RO.BG.GR.TR.IL.CY.MT".split(".") },
|
|
114
|
+
shipping_options: k.length > 0 ? k : void 0,
|
|
115
|
+
metadata: { orderId: T.id }
|
|
116
|
+
});
|
|
117
|
+
return await f.from("orders").update({ stripe_session_id: e.id }).eq("id", T.id), { url: e.url };
|
|
118
|
+
} catch (e) {
|
|
119
|
+
return console.error("Stripe session creation failed:", e), {
|
|
120
|
+
error: e.message,
|
|
121
|
+
url: null
|
|
122
|
+
};
|
|
123
|
+
}
|
|
182
124
|
};
|
|
125
|
+
//#endregion
|
|
126
|
+
export { o as createCheckoutSession };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../payment-config.cjs");let n=require("stripe");n=e.__toESM(n,1);var r=null,i=null,a=class extends Error{constructor(){super(`Stripe is not configured: no secret key found in CMS → Payments or STRIPE_SECRET_KEY.`),this.name=`StripeNotConfiguredError`}};async function o(){let e=await t.resolveStripeSecretKey();if(!e)throw new a;return r&&i===e?r:(r=new n.default(e,{typescript:!0}),i=e,r)}exports.StripeNotConfiguredError=a,exports.getStripeClient=o;
|
package/lib/stripe/client.es.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
), this.name = "StripeNotConfiguredError";
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
async function p() {
|
|
12
|
-
const e = await o();
|
|
13
|
-
if (!e)
|
|
14
|
-
throw new i();
|
|
15
|
-
return r && t === e || (r = new n(e, { typescript: !0 }), t = e), r;
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
i as StripeNotConfiguredError,
|
|
19
|
-
p as getStripeClient
|
|
1
|
+
import { resolveStripeSecretKey as e } from "../payment-config.es.js";
|
|
2
|
+
import t from "stripe";
|
|
3
|
+
//#region src/lib/stripe/client.ts
|
|
4
|
+
var n = null, r = null, i = class extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("Stripe is not configured: no secret key found in CMS → Payments or STRIPE_SECRET_KEY."), this.name = "StripeNotConfiguredError";
|
|
7
|
+
}
|
|
20
8
|
};
|
|
9
|
+
async function a() {
|
|
10
|
+
let a = await e();
|
|
11
|
+
if (!a) throw new i();
|
|
12
|
+
return n && r === a ? n : (n = new t(a, { typescript: !0 }), r = a, n);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { i as StripeNotConfiguredError, a as getStripeClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../customer.cjs"),t=require("../customer-addresses.cjs"),n=require("../order-tax-details.cjs"),r=require("./client.cjs"),i=require("../order-inventory.cjs"),a=require("../invoice-server.cjs");let o=require("@supabase/supabase-js");var s=[`total_details.breakdown`],c=[`data.taxes.rate`];function l(){let e=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL,t=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.SUPABASE_SECRET_KEY;if(!e||!t)throw Error(`Missing Supabase Service Role environment variables`);return(0,o.createClient)(e,t,{auth:{autoRefreshToken:!1,persistSession:!1}})}function u(t,n){return t?e.normalizeCustomerAddress({recipient_name:n,line1:t.line1??null,line2:t.line2??null,city:t.city??null,state:t.state??null,postal_code:t.postal_code??null,country_code:t.country??null}):null}function d(t){let n=t??{};return e.normalizeOrderCustomerDetails({email:typeof n.email==`string`?n.email:null,name:typeof n.name==`string`?n.name:null,phone:typeof n.phone==`string`?n.phone:null,billing:n.billing??null,shipping:n.shipping??null})}async function f(o){let f=l(),p=await r.getStripeClient(),m=o;try{m=await p.checkout.sessions.retrieve(o.id,{expand:[...s]})}catch(e){console.error(`[Stripe Sync] Failed to rehydrate session tax details:`,e)}let h=m.metadata?.orderId,g=f.from(`orders`).select(`id, user_id, status, total, currency, subtotal, shipping_total, tax_total, tax_details, customer_details`).eq(`stripe_session_id`,o.id).maybeSingle();h&&(g=f.from(`orders`).select(`id, user_id, status, total, currency, subtotal, shipping_total, tax_total, tax_details, customer_details`).eq(`id`,h).maybeSingle());let{data:_,error:v}=await g;if(v||!_)throw Error(v?.message||`Order lookup failed`);let y=d(_.customer_details),b=n.normalizeOrderTaxDetails(_.tax_details),x=u(m.customer_details?.address,m.customer_details?.name??y.name),S=m.shipping_details,C=m.collected_information?.shipping_details??S??null,w=u(C?.address,C?.name??y.name),T=e.normalizeOrderCustomerDetails({email:m.customer_details?.email??y.email,name:m.customer_details?.name??y.name,phone:m.customer_details?.phone??y.phone,billing:y.billing??x,shipping:y.shipping??w}),E=_.status===`paid`,D=await p.checkout.sessions.listLineItems(m.id,{limit:100,expand:[...c]}),O=n.buildOrderTaxDetailsFromStripeSession({session:m,lineItems:D.data,subtotal:typeof _.subtotal==`number`?_.subtotal:b?.subtotal??0,shippingTotal:typeof _.shipping_total==`number`?_.shipping_total:b?.shipping_total??0,fallbackMode:b?.mode??`automatic`,currency:(m.currency??_.currency??b?.currency??`USD`).toUpperCase()}),k=O.tax_total>0||O.lines.length>0?O:b??O,A=k?.tax_total??(typeof _.tax_total==`number`?_.tax_total:0),j=(m.currency??_.currency??k?.currency??`USD`).toUpperCase(),M={status:`paid`,stripe_session_id:m.id,payment_intent_id:typeof m.payment_intent==`string`?m.payment_intent:null,provider:`stripe`,customer_details:T,total:typeof m.amount_total==`number`?m.amount_total:_.total,currency:j,tax_total:A,tax_details:k},{error:N}=await f.from(`orders`).update(M).eq(`id`,_.id);if(N)throw Error(N.message);if(_.user_id)try{await t.upsertDefaultUserAddresses({userId:_.user_id,billingAddress:T.billing,shippingAddress:T.shipping,client:f})}catch(e){console.error(`[Stripe Sync] Failed to refresh saved customer addresses:`,e)}let P=await a.assignInvoiceMetadata({orderId:_.id,client:f});return await i.applyOrderInventoryDeduction(f,_.id),{orderId:_.id,alreadyPaid:E,customerDetails:T,order:{id:_.id,invoice_number:P.invoiceNumber,paid_at:P.paidAt,total:M.total,currency:j,subtotal:typeof _.subtotal==`number`?_.subtotal:k?.subtotal??0,shipping_total:typeof _.shipping_total==`number`?_.shipping_total:k?.shipping_total??0,tax_total:A,tax_details:k}}}exports.syncStripeOrderFromSession=f;
|
|
@@ -1,130 +1,110 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { assignInvoiceMetadata as
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
});
|
|
1
|
+
import { normalizeCustomerAddress as e, normalizeOrderCustomerDetails as t } from "../customer.es.js";
|
|
2
|
+
import { upsertDefaultUserAddresses as n } from "../customer-addresses.es.js";
|
|
3
|
+
import { buildOrderTaxDetailsFromStripeSession as r, normalizeOrderTaxDetails as i } from "../order-tax-details.es.js";
|
|
4
|
+
import { getStripeClient as a } from "./client.es.js";
|
|
5
|
+
import { applyOrderInventoryDeduction as o } from "../order-inventory.es.js";
|
|
6
|
+
import { assignInvoiceMetadata as s } from "../invoice-server.es.js";
|
|
7
|
+
import { createClient as c } from "@supabase/supabase-js";
|
|
8
|
+
//#region src/lib/stripe/order-sync.ts
|
|
9
|
+
var l = ["total_details.breakdown"], u = ["data.taxes.rate"];
|
|
10
|
+
function d() {
|
|
11
|
+
let e = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, t = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY;
|
|
12
|
+
if (!e || !t) throw Error("Missing Supabase Service Role environment variables");
|
|
13
|
+
return c(e, t, { auth: {
|
|
14
|
+
autoRefreshToken: !1,
|
|
15
|
+
persistSession: !1
|
|
16
|
+
} });
|
|
19
17
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
function f(t, n) {
|
|
19
|
+
return t ? e({
|
|
20
|
+
recipient_name: n,
|
|
21
|
+
line1: t.line1 ?? null,
|
|
22
|
+
line2: t.line2 ?? null,
|
|
23
|
+
city: t.city ?? null,
|
|
24
|
+
state: t.state ?? null,
|
|
25
|
+
postal_code: t.postal_code ?? null,
|
|
26
|
+
country_code: t.country ?? null
|
|
27
|
+
}) : null;
|
|
30
28
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
function p(e) {
|
|
30
|
+
let n = e ?? {};
|
|
31
|
+
return t({
|
|
32
|
+
email: typeof n.email == "string" ? n.email : null,
|
|
33
|
+
name: typeof n.name == "string" ? n.name : null,
|
|
34
|
+
phone: typeof n.phone == "string" ? n.phone : null,
|
|
35
|
+
billing: n.billing ?? null,
|
|
36
|
+
shipping: n.shipping ?? null
|
|
37
|
+
});
|
|
40
38
|
}
|
|
41
|
-
async function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
return await w(t, e.id), {
|
|
112
|
-
orderId: e.id,
|
|
113
|
-
alreadyPaid: T,
|
|
114
|
-
customerDetails: n,
|
|
115
|
-
order: {
|
|
116
|
-
id: e.id,
|
|
117
|
-
invoice_number: h.invoiceNumber,
|
|
118
|
-
paid_at: h.paidAt,
|
|
119
|
-
total: g.total,
|
|
120
|
-
currency: f,
|
|
121
|
-
subtotal: typeof e.subtotal == "number" ? e.subtotal : s?.subtotal ?? 0,
|
|
122
|
-
shipping_total: typeof e.shipping_total == "number" ? e.shipping_total : s?.shipping_total ?? 0,
|
|
123
|
-
tax_total: y,
|
|
124
|
-
tax_details: s
|
|
125
|
-
}
|
|
126
|
-
};
|
|
39
|
+
async function m(e) {
|
|
40
|
+
let c = d(), m = await a(), h = e;
|
|
41
|
+
try {
|
|
42
|
+
h = await m.checkout.sessions.retrieve(e.id, { expand: [...l] });
|
|
43
|
+
} catch (e) {
|
|
44
|
+
console.error("[Stripe Sync] Failed to rehydrate session tax details:", e);
|
|
45
|
+
}
|
|
46
|
+
let g = h.metadata?.orderId, _ = c.from("orders").select("id, user_id, status, total, currency, subtotal, shipping_total, tax_total, tax_details, customer_details").eq("stripe_session_id", e.id).maybeSingle();
|
|
47
|
+
g && (_ = c.from("orders").select("id, user_id, status, total, currency, subtotal, shipping_total, tax_total, tax_details, customer_details").eq("id", g).maybeSingle());
|
|
48
|
+
let { data: v, error: y } = await _;
|
|
49
|
+
if (y || !v) throw Error(y?.message || "Order lookup failed");
|
|
50
|
+
let b = p(v.customer_details), x = i(v.tax_details), S = f(h.customer_details?.address, h.customer_details?.name ?? b.name), C = h.shipping_details, w = h.collected_information?.shipping_details ?? C ?? null, T = f(w?.address, w?.name ?? b.name), E = t({
|
|
51
|
+
email: h.customer_details?.email ?? b.email,
|
|
52
|
+
name: h.customer_details?.name ?? b.name,
|
|
53
|
+
phone: h.customer_details?.phone ?? b.phone,
|
|
54
|
+
billing: b.billing ?? S,
|
|
55
|
+
shipping: b.shipping ?? T
|
|
56
|
+
}), D = v.status === "paid", O = await m.checkout.sessions.listLineItems(h.id, {
|
|
57
|
+
limit: 100,
|
|
58
|
+
expand: [...u]
|
|
59
|
+
}), k = r({
|
|
60
|
+
session: h,
|
|
61
|
+
lineItems: O.data,
|
|
62
|
+
subtotal: typeof v.subtotal == "number" ? v.subtotal : x?.subtotal ?? 0,
|
|
63
|
+
shippingTotal: typeof v.shipping_total == "number" ? v.shipping_total : x?.shipping_total ?? 0,
|
|
64
|
+
fallbackMode: x?.mode ?? "automatic",
|
|
65
|
+
currency: (h.currency ?? v.currency ?? x?.currency ?? "USD").toUpperCase()
|
|
66
|
+
}), A = k.tax_total > 0 || k.lines.length > 0 ? k : x ?? k, j = A?.tax_total ?? (typeof v.tax_total == "number" ? v.tax_total : 0), M = (h.currency ?? v.currency ?? A?.currency ?? "USD").toUpperCase(), N = {
|
|
67
|
+
status: "paid",
|
|
68
|
+
stripe_session_id: h.id,
|
|
69
|
+
payment_intent_id: typeof h.payment_intent == "string" ? h.payment_intent : null,
|
|
70
|
+
provider: "stripe",
|
|
71
|
+
customer_details: E,
|
|
72
|
+
total: typeof h.amount_total == "number" ? h.amount_total : v.total,
|
|
73
|
+
currency: M,
|
|
74
|
+
tax_total: j,
|
|
75
|
+
tax_details: A
|
|
76
|
+
}, { error: P } = await c.from("orders").update(N).eq("id", v.id);
|
|
77
|
+
if (P) throw Error(P.message);
|
|
78
|
+
if (v.user_id) try {
|
|
79
|
+
await n({
|
|
80
|
+
userId: v.user_id,
|
|
81
|
+
billingAddress: E.billing,
|
|
82
|
+
shippingAddress: E.shipping,
|
|
83
|
+
client: c
|
|
84
|
+
});
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.error("[Stripe Sync] Failed to refresh saved customer addresses:", e);
|
|
87
|
+
}
|
|
88
|
+
let F = await s({
|
|
89
|
+
orderId: v.id,
|
|
90
|
+
client: c
|
|
91
|
+
});
|
|
92
|
+
return await o(c, v.id), {
|
|
93
|
+
orderId: v.id,
|
|
94
|
+
alreadyPaid: D,
|
|
95
|
+
customerDetails: E,
|
|
96
|
+
order: {
|
|
97
|
+
id: v.id,
|
|
98
|
+
invoice_number: F.invoiceNumber,
|
|
99
|
+
paid_at: F.paidAt,
|
|
100
|
+
total: N.total,
|
|
101
|
+
currency: M,
|
|
102
|
+
subtotal: typeof v.subtotal == "number" ? v.subtotal : A?.subtotal ?? 0,
|
|
103
|
+
shipping_total: typeof v.shipping_total == "number" ? v.shipping_total : A?.shipping_total ?? 0,
|
|
104
|
+
tax_total: j,
|
|
105
|
+
tax_details: A
|
|
106
|
+
}
|
|
107
|
+
};
|
|
127
108
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
109
|
+
//#endregion
|
|
110
|
+
export { m as syncStripeOrderFromSession };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../payment-config.cjs"),t=require("./client.cjs"),n=require("./order-sync.cjs");var r=async(r,i)=>{let a=await e.resolveStripeWebhookSecret();if(!a)return console.error(`Missing Stripe webhook secret (configure it in CMS or STRIPE_WEBHOOK_SECRET)`),{received:!1,error:`Server configuration error`};let o=await t.getStripeClient(),s;try{s=o.webhooks.constructEvent(i,r,a)}catch(e){return console.error(`Webhook signature verification failed: ${e.message}`),{received:!1,error:`Webhook Error: ${e.message}`}}switch(s.type){case`checkout.session.completed`:{let e=s.data.object;try{await n.syncStripeOrderFromSession(e)}catch(e){return console.error(`[Stripe Webhook Error] Failed to sync completed session:`,e),{received:!1,error:e.message||`Failed to sync Stripe session`}}break}default:console.log(`Unhandled event type ${s.type}`)}return{received:!0}};exports.handleStripeWebhook=r;
|