@nextblock-cms/ecom 0.8.6 → 0.8.11

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.
Files changed (277) hide show
  1. package/index.cjs.js +1 -1
  2. package/index.es.js +136 -533
  3. package/lib/CurrencyProvider.cjs.js +1 -0
  4. package/lib/CurrencyProvider.es.js +99 -0
  5. package/lib/cart-store.cjs.js +1 -0
  6. package/{cart-store.es.js → lib/cart-store.es.js} +13 -13
  7. package/lib/components/AccountNavigationMenu.cjs.js +1 -0
  8. package/lib/components/AccountNavigationMenu.es.js +44 -0
  9. package/lib/components/AddToCartButton.cjs.js +1 -0
  10. package/{AddToCartButton-ffE0DhHu.js → lib/components/AddToCartButton.es.js} +14 -13
  11. package/lib/components/Cart.cjs.js +1 -0
  12. package/lib/components/Cart.es.js +148 -0
  13. package/lib/components/CartDrawer.cjs.js +1 -0
  14. package/{components → lib/components}/CartDrawer.es.js +15 -14
  15. package/{components → lib/components}/CartIcon.cjs.js +1 -1
  16. package/{components → lib/components}/CartIcon.es.js +1 -0
  17. package/lib/components/Checkout.cjs.js +1 -0
  18. package/{components → lib/components}/Checkout.es.js +330 -363
  19. package/lib/components/CouponForm.cjs.js +1 -0
  20. package/lib/components/CouponForm.es.js +136 -0
  21. package/lib/components/CurrencySwitcher.cjs.js +1 -0
  22. package/{components → lib/components}/CurrencySwitcher.es.js +5 -4
  23. package/lib/components/CustomerProfileForm.cjs.js +1 -0
  24. package/lib/components/CustomerProfileForm.es.js +355 -0
  25. package/lib/components/FeaturedProduct.cjs.js +1 -0
  26. package/{components → lib/components}/FeaturedProduct.es.js +9 -8
  27. package/lib/components/InvoiceDocument.cjs.js +1 -0
  28. package/lib/components/InvoiceDocument.es.js +196 -0
  29. package/lib/components/InvoiceViewerShell.cjs.js +29 -0
  30. package/lib/components/InvoiceViewerShell.es.js +100 -0
  31. package/lib/components/ProductCard.cjs.js +1 -0
  32. package/lib/components/ProductCard.es.js +119 -0
  33. package/lib/components/ProductDetailsLayout.cjs.js +1 -0
  34. package/lib/components/ProductDetailsLayout.es.js +361 -0
  35. package/lib/components/ProductGallery.cjs.js +1 -0
  36. package/lib/components/ProductGallery.es.js +41 -0
  37. package/lib/components/ProductGrid.cjs.js +1 -0
  38. package/lib/components/ProductGrid.es.js +19 -0
  39. package/lib/components/ShippingEstimator.cjs.js +1 -0
  40. package/lib/components/ShippingEstimator.es.js +125 -0
  41. package/lib/components/SubscriptionSelector.cjs.js +1 -0
  42. package/lib/components/SubscriptionSelector.es.js +140 -0
  43. package/lib/countries.cjs.js +1 -0
  44. package/lib/countries.es.js +77 -0
  45. package/lib/coupon-server.cjs.js +1 -0
  46. package/{coupon-server-DUKVtyYs.js → lib/coupon-server.es.js} +68 -82
  47. package/lib/coupons.cjs.js +1 -0
  48. package/lib/coupons.es.js +17 -0
  49. package/lib/currency-store.cjs.js +1 -0
  50. package/lib/currency-store.es.js +27 -0
  51. package/lib/currency-sync.cjs.js +1 -0
  52. package/lib/currency-sync.es.js +180 -0
  53. package/lib/customer-addresses.cjs.js +1 -0
  54. package/lib/customer-addresses.es.js +116 -0
  55. package/lib/customer-orders.cjs.js +1 -0
  56. package/lib/customer-orders.es.js +45 -0
  57. package/lib/customer.cjs.js +1 -0
  58. package/{customer-C3xccjUg.js → lib/customer.es.js} +15 -14
  59. package/lib/export-helpers.cjs.js +1 -0
  60. package/lib/export-helpers.es.js +56 -0
  61. package/lib/factory.cjs.js +1 -0
  62. package/lib/factory.es.js +8 -0
  63. package/lib/freemius-coupons.cjs.js +1 -0
  64. package/lib/freemius-coupons.es.js +272 -0
  65. package/lib/freemius-order-sync.cjs.js +1 -0
  66. package/lib/freemius-order-sync.es.js +284 -0
  67. package/lib/inventory-settings.cjs.js +1 -0
  68. package/lib/inventory-settings.es.js +86 -0
  69. package/lib/invoice-server.cjs.js +33 -0
  70. package/lib/invoice-server.es.js +141 -0
  71. package/lib/invoice-ui.cjs.js +1 -0
  72. package/lib/invoice-ui.es.js +71 -0
  73. package/lib/invoice.cjs.js +1 -0
  74. package/lib/invoice.es.js +102 -0
  75. package/lib/order-inventory.cjs.js +61 -0
  76. package/lib/order-inventory.es.js +128 -0
  77. package/lib/order-tax-details.cjs.js +1 -0
  78. package/lib/order-tax-details.es.js +164 -0
  79. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -0
  80. package/lib/pages/cms/coupons/CouponEditorForm.es.js +189 -0
  81. package/lib/pages/cms/coupons/CouponsPage.cjs.js +5 -0
  82. package/lib/pages/cms/coupons/CouponsPage.es.js +171 -0
  83. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -0
  84. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -0
  85. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -0
  86. package/lib/pages/cms/coupons/EditCouponPage.es.js +48 -0
  87. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -0
  88. package/lib/pages/cms/coupons/ProductScopePicker.es.js +120 -0
  89. package/lib/pages/cms/coupons/actions.cjs.js +1 -0
  90. package/lib/pages/cms/coupons/actions.es.js +128 -0
  91. package/lib/pages/cms/coupons/product-options.cjs.js +1 -0
  92. package/lib/pages/cms/coupons/product-options.es.js +27 -0
  93. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -0
  94. package/lib/pages/cms/orders/ExportReportsDialog.es.js +130 -0
  95. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -0
  96. package/lib/pages/cms/orders/OrderDetailPage.es.js +137 -0
  97. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -0
  98. package/lib/pages/cms/orders/OrderPrintButton.es.js +22 -0
  99. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -0
  100. package/lib/pages/cms/orders/OrderStatusForm.es.js +71 -0
  101. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -0
  102. package/lib/pages/cms/orders/OrdersPage.es.js +104 -0
  103. package/lib/pages/cms/orders/actions.cjs.js +7 -0
  104. package/lib/pages/cms/orders/actions.es.js +71 -0
  105. package/lib/pages/cms/orders/export-actions.cjs.js +1 -0
  106. package/lib/pages/cms/orders/export-actions.es.js +27 -0
  107. package/lib/pages/cms/orders/server-actions.cjs.js +1 -0
  108. package/lib/pages/cms/orders/server-actions.es.js +55 -0
  109. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -0
  110. package/lib/pages/cms/payments/PaymentsClient.es.js +188 -0
  111. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -0
  112. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -0
  113. package/lib/pages/cms/payments/actions.cjs.js +1 -0
  114. package/lib/pages/cms/payments/actions.es.js +23 -0
  115. package/lib/pages/cms/payments/queries.cjs.js +1 -0
  116. package/lib/pages/cms/payments/queries.es.js +30 -0
  117. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -0
  118. package/lib/pages/cms/products/ProductsPage.es.js +46 -0
  119. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -0
  120. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +156 -0
  121. package/lib/pages/cms/products/actions.cjs.js +44 -0
  122. package/lib/pages/cms/products/actions.es.js +175 -0
  123. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -0
  124. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +48 -0
  125. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -0
  126. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +291 -0
  127. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -0
  128. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +36 -0
  129. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -0
  130. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +263 -0
  131. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -0
  132. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +114 -0
  133. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -0
  134. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +107 -0
  135. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -0
  136. package/lib/pages/cms/products/components/DeleteProductButton.es.js +48 -0
  137. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -0
  138. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +86 -0
  139. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -0
  140. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +160 -0
  141. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -0
  142. package/lib/pages/cms/products/components/ProductForm.es.js +702 -0
  143. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -0
  144. package/lib/pages/cms/products/components/ProductMediaManager.es.js +104 -0
  145. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -0
  146. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +228 -0
  147. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -0
  148. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +137 -0
  149. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -0
  150. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +36 -0
  151. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +1 -0
  152. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +40 -0
  153. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -0
  154. package/lib/pages/cms/products/components/VariationsEditor.es.js +408 -0
  155. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -0
  156. package/lib/pages/cms/products/inventory/InventoryPage.es.js +16 -0
  157. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -0
  158. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +214 -0
  159. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -0
  160. package/lib/pages/cms/products/inventory/actions.es.js +95 -0
  161. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -0
  162. package/lib/pages/cms/products/new/NewProductPage.es.js +76 -0
  163. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -0
  164. package/lib/pages/cms/products/product-price-sync.es.js +98 -0
  165. package/lib/pages/cms/products/server-actions.cjs.js +1 -0
  166. package/lib/pages/cms/products/server-actions.es.js +193 -0
  167. package/lib/pages/cms/shipping/ShippingPage.cjs.js +5 -0
  168. package/lib/pages/cms/shipping/ShippingPage.es.js +211 -0
  169. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -0
  170. package/lib/pages/cms/shipping/components/RateForm.es.js +441 -0
  171. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -0
  172. package/lib/pages/cms/shipping/components/ZoneForm.es.js +228 -0
  173. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -0
  174. package/lib/pages/cms/shipping/server-actions.es.js +159 -0
  175. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -0
  176. package/lib/pages/cms/taxes/TaxesPage.es.js +172 -0
  177. package/lib/pages/cms/taxes/actions.cjs.js +1 -0
  178. package/lib/pages/cms/taxes/actions.es.js +57 -0
  179. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -0
  180. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +100 -0
  181. package/lib/product-actions.cjs.js +237 -0
  182. package/lib/product-actions.es.js +524 -0
  183. package/lib/product-context.cjs.js +1 -0
  184. package/lib/product-context.es.js +16 -0
  185. package/lib/product-schema.cjs.js +1 -0
  186. package/lib/product-schema.es.js +134 -0
  187. package/lib/providers/freemius.cjs.js +5 -0
  188. package/lib/providers/freemius.es.js +538 -0
  189. package/lib/providers/stripe.cjs.js +1 -0
  190. package/lib/providers/stripe.es.js +473 -0
  191. package/lib/server-actions/coupon-actions.cjs.js +1 -0
  192. package/lib/server-actions/coupon-actions.es.js +23 -0
  193. package/lib/server-actions/customer-actions.cjs.js +1 -0
  194. package/lib/server-actions/customer-actions.es.js +30 -0
  195. package/lib/server-actions/product-actions.cjs.js +1 -0
  196. package/{server-actions → lib/server-actions}/product-actions.es.js +5 -4
  197. package/lib/server-actions/shipping-actions.cjs.js +1 -0
  198. package/{shipping-actions-BnHjlo2q.js → lib/server-actions/shipping-actions.es.js} +9 -7
  199. package/lib/server-actions/tax-actions.cjs.js +1 -0
  200. package/lib/server-actions/tax-actions.es.js +40 -0
  201. package/lib/shared-inventory.cjs.js +15 -0
  202. package/lib/shared-inventory.es.js +171 -0
  203. package/lib/shipping/resolver.cjs.js +7 -0
  204. package/lib/shipping/resolver.es.js +62 -0
  205. package/lib/shipping-rate-currency.cjs.js +1 -0
  206. package/lib/shipping-rate-currency.es.js +72 -0
  207. package/lib/states.cjs.js +1 -0
  208. package/{states-DlHJezQ1.js → lib/states.es.js} +27 -100
  209. package/lib/stripe/checkout.cjs.js +1 -0
  210. package/lib/stripe/checkout.es.js +182 -0
  211. package/lib/stripe/client.cjs.js +1 -0
  212. package/lib/stripe/client.es.js +7 -0
  213. package/lib/stripe/order-sync.cjs.js +1 -0
  214. package/lib/stripe/order-sync.es.js +130 -0
  215. package/lib/stripe/webhooks.cjs.js +1 -0
  216. package/lib/stripe/webhooks.es.js +30 -0
  217. package/lib/tax-calculation.cjs.js +1 -0
  218. package/lib/tax-calculation.es.js +101 -0
  219. package/lib/trials.cjs.js +1 -0
  220. package/{trials-RDcRAZKx.js → lib/trials.es.js} +9 -9
  221. package/{use-cart.es.js → lib/use-cart.es.js} +1 -0
  222. package/lib/zod-config.cjs.js +1 -0
  223. package/lib/zod-config.es.js +6 -0
  224. package/package.json +6 -6
  225. package/server.cjs.js +1 -110
  226. package/server.es.js +178 -6052
  227. package/AddToCartButton-DsSEH9yp.cjs +0 -1
  228. package/CouponForm-BI_5SBHQ.js +0 -152
  229. package/CouponForm-D_uu2bLP.cjs +0 -1
  230. package/CurrencyProvider-Cg-Q6ucj.cjs +0 -1
  231. package/CurrencyProvider-OzlRN96V.js +0 -120
  232. package/CurrencyProvider.cjs.js +0 -1
  233. package/CurrencyProvider.es.js +0 -10
  234. package/ProductDetailsLayout-BxJH_BxR.cjs +0 -1
  235. package/ProductDetailsLayout-Dg8dRTYp.js +0 -530
  236. package/ProductGrid-BdL7iglO.cjs +0 -1
  237. package/ProductGrid-D3AWM8sr.js +0 -130
  238. package/actions-AHmBrS5e.cjs +0 -48
  239. package/actions-j5fuSZX-.js +0 -820
  240. package/cart-store.cjs.js +0 -1
  241. package/components/Cart.cjs.js +0 -1
  242. package/components/Cart.es.js +0 -259
  243. package/components/CartDrawer.cjs.js +0 -1
  244. package/components/Checkout.cjs.js +0 -1
  245. package/components/CurrencySwitcher.cjs.js +0 -1
  246. package/components/FeaturedProduct.cjs.js +0 -1
  247. package/components/ProductDetailsLayout.cjs.js +0 -1
  248. package/components/ProductDetailsLayout.es.js +0 -19
  249. package/components/ProductGrid.cjs.js +0 -1
  250. package/components/ProductGrid.es.js +0 -6
  251. package/coupon-server-C9ySm3I5.cjs +0 -1
  252. package/customer-C-UPvrYN.cjs +0 -1
  253. package/invoice-ui-CAnJPu6n.cjs +0 -29
  254. package/invoice-ui-DtpbTJE1.js +0 -2886
  255. package/product-actions-CONBF8i6.cjs +0 -251
  256. package/product-actions-DjlIWCMH.js +0 -691
  257. package/resolver-Fz_FKsfX.cjs +0 -7
  258. package/resolver-cfrCaHpE.js +0 -128
  259. package/server-actions/product-actions.cjs.js +0 -1
  260. package/shipping-actions-D6zt20gg.cjs +0 -1
  261. package/states-CWYRxV4B.cjs +0 -1
  262. package/tax-calculation-Dab89aHd.js +0 -181
  263. package/tax-calculation-MkDKOEkL.cjs +0 -1
  264. package/trials-DvZaOtNy.cjs +0 -1
  265. /package/{components → lib/components}/SimpleTiptapRenderer.cjs.js +0 -0
  266. /package/{components → lib/components}/SimpleTiptapRenderer.es.js +0 -0
  267. /package/{currency-constants.cjs.js → lib/currency-constants.cjs.js} +0 -0
  268. /package/{currency-constants.es.js → lib/currency-constants.es.js} +0 -0
  269. /package/{currency-rest-client-uolJxUkL.cjs → lib/currency-rest-client.cjs.js} +0 -0
  270. /package/{currency-rest-client-CwoqdgAP.js → lib/currency-rest-client.es.js} +0 -0
  271. /package/{currency.cjs.js → lib/currency.cjs.js} +0 -0
  272. /package/{currency.es.js → lib/currency.es.js} +0 -0
  273. /package/{types.cjs.js → lib/types.cjs.js} +0 -0
  274. /package/{types.es.js → lib/types.es.js} +0 -0
  275. /package/{use-cart.cjs.js → lib/use-cart.cjs.js} +0 -0
  276. /package/{variation-utils.cjs.js → lib/variation-utils.cjs.js} +0 -0
  277. /package/{variation-utils.es.js → lib/variation-utils.es.js} +0 -0
@@ -0,0 +1,182 @@
1
+ import { stripe as N } from "./client.es.js";
2
+ import { createClient as R } from "@supabase/supabase-js";
3
+ import { verifyPackageOnline as k } from "@nextblock-cms/db/server";
4
+ import { resolveShippingOptions as L } from "../shipping/resolver.es.js";
5
+ import { getDefaultCurrency as D, resolveEffectivePriceForCurrency as T } from "../currency.es.js";
6
+ const M = async (n, d, S, P) => {
7
+ const m = process.env.NEXT_PUBLIC_SUPABASE_URL, h = process.env.SUPABASE_SERVICE_ROLE_KEY;
8
+ if (!m || !h)
9
+ return console.error("Missing Supabase credentials for checkout (Service Key required)."), { error: "Internal Server Error", url: null };
10
+ const t = R(m, h), f = process.env.NEXT_PUBLIC_URL || "http://localhost:4200";
11
+ if (!n.length)
12
+ return { error: "Cart is empty", url: null };
13
+ const { data: A } = await t.from("currencies").select(
14
+ "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"
15
+ ).eq("is_active", !0).order("code", { ascending: !0 }), u = A ?? [], w = D(u), o = u.find((e) => e.code === (P || "").toUpperCase()) ?? w;
16
+ if (!await k("ecommerce"))
17
+ return { error: "E-Commerce Package not active. Please purchase a license to accept payments.", url: null };
18
+ const I = n.map((e) => e.product_id), { data: g, error: y } = await t.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", I);
19
+ if (y || !g)
20
+ return console.error("Error fetching products for validation:", y), { error: "Failed to validate product prices", url: null };
21
+ const U = new Map(g.map((e) => [e.id, e])), l = [];
22
+ let c = 0;
23
+ const E = [];
24
+ for (const e of n) {
25
+ const r = U.get(e.product_id);
26
+ if (!r) {
27
+ console.warn(`Product ${e.product_id} not found in DB, skipping.`);
28
+ continue;
29
+ }
30
+ const v = T({
31
+ prices: r.prices || {},
32
+ salePrices: r.sale_prices || {},
33
+ fallbackPrice: r.price,
34
+ fallbackSalePrice: r.sale_price,
35
+ saleStartAt: r.sale_start_at,
36
+ saleEndAt: r.sale_end_at,
37
+ scheduledPrice: r.scheduled_price,
38
+ scheduledPrices: r.scheduled_prices || {},
39
+ scheduledPriceAt: r.scheduled_price_at,
40
+ currencyCode: o.code,
41
+ currencies: u
42
+ }), a = v.sale_price ?? v.price;
43
+ a <= 0 && console.warn(`[Checkout Session Warning] Product ${r.title} has zero or negative price!`), l.push({
44
+ price_data: {
45
+ currency: o.code.toLowerCase(),
46
+ product_data: {
47
+ name: r.title,
48
+ images: [],
49
+ // Images temporarily removed due to schema mismatch (requires relation join)
50
+ metadata: {
51
+ productId: r.id
52
+ }
53
+ },
54
+ unit_amount: a
55
+ },
56
+ quantity: e.quantity
57
+ }), c += a * e.quantity, E.push({
58
+ product_id: r.id,
59
+ quantity: e.quantity,
60
+ price_at_purchase: a
61
+ });
62
+ }
63
+ if (l.length === 0)
64
+ return { error: "No valid items in cart", url: null };
65
+ const { data: s, error: p } = await t.from("orders").insert({
66
+ total: c,
67
+ user_id: d,
68
+ currency: o.code,
69
+ exchange_rate_at_purchase: o.exchange_rate
70
+ }).select("id").single();
71
+ if (p || !s)
72
+ return console.error("Failed to create pending order:", p), console.error("Order Data attempted:", { status: "pending", total: c }), { error: `Failed to initiate order: ${p?.message || "Unknown error"}`, url: null };
73
+ const q = E.map((e) => ({
74
+ order_id: s.id,
75
+ product_id: e.product_id,
76
+ quantity: e.quantity,
77
+ price_at_purchase: e.price_at_purchase
78
+ })), { error: C } = await t.from("order_items").insert(q);
79
+ C && console.error("Failed to insert order items:", C);
80
+ let _ = [], i = S;
81
+ if (!i && d) {
82
+ const { data: e } = await t.from("user_addresses").select("country_code, state_code, postal_code").eq("user_id", d).eq("address_type", "shipping").limit(1).single();
83
+ e && (i = {
84
+ country: e.country_code,
85
+ state: e.state_code,
86
+ postal_code: e.postal_code
87
+ });
88
+ }
89
+ i && (_ = (await L(
90
+ c,
91
+ i,
92
+ null,
93
+ o.code
94
+ )).map((r) => ({
95
+ shipping_rate_data: {
96
+ type: "fixed_amount",
97
+ fixed_amount: {
98
+ amount: r.amount,
99
+ currency: r.currency.toLowerCase()
100
+ },
101
+ display_name: r.name
102
+ // delivery_estimate: { ... } // Could be added in future modules
103
+ }
104
+ })));
105
+ try {
106
+ const e = await N.checkout.sessions.create({
107
+ mode: "payment",
108
+ success_url: `${f}/checkout/success?session_id={CHECKOUT_SESSION_ID}`,
109
+ cancel_url: `${f}/`,
110
+ line_items: l,
111
+ billing_address_collection: "required",
112
+ shipping_address_collection: {
113
+ allowed_countries: [
114
+ "US",
115
+ "CA",
116
+ "GB",
117
+ "AU",
118
+ "NZ",
119
+ "IE",
120
+ "FR",
121
+ "DE",
122
+ "IT",
123
+ "ES",
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: s.id
173
+ }
174
+ });
175
+ return await t.from("orders").update({ stripe_session_id: e.id }).eq("id", s.id), { url: e.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
182
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("stripe"),t=new e(process.env.STRIPE_SECRET_KEY||"sk_test_dummy",{typescript:!0});exports.stripe=t;
@@ -0,0 +1,7 @@
1
+ import t from "stripe";
2
+ const r = new t(process.env.STRIPE_SECRET_KEY || "sk_test_dummy", {
3
+ typescript: !0
4
+ });
5
+ export {
6
+ r as stripe
7
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("@supabase/supabase-js"),c=require("../customer.cjs.js"),C=require("../customer-addresses.cjs.js"),w=require("../order-inventory.cjs.js"),f=require("../order-tax-details.cjs.js"),O=require("../invoice-server.cjs.js"),x=require("./client.cjs.js"),U=["total_details.breakdown"],R=["data.taxes.rate"];function q(){const r=process.env.NEXT_PUBLIC_SUPABASE_URL,t=process.env.SUPABASE_SERVICE_ROLE_KEY;if(!r||!t)throw new Error("Missing Supabase Service Role environment variables");return A.createClient(r,t,{auth:{autoRefreshToken:!1,persistSession:!1}})}function E(r,t){return r?c.normalizeCustomerAddress({recipient_name:t,line1:r.line1??null,line2:r.line2??null,city:r.city??null,state:r.state??null,postal_code:r.postal_code??null,country_code:r.country??null}):null}function P(r){const t=r??{};return c.normalizeOrderCustomerDetails({email:typeof t.email=="string"?t.email:null,name:typeof t.name=="string"?t.name:null,phone:typeof t.phone=="string"?t.phone:null,billing:t.billing??null,shipping:t.shipping??null})}async function z(r){const t=q();let i=r;try{i=await x.stripe.checkout.sessions.retrieve(r.id,{expand:[...U]})}catch(d){console.error("[Stripe Sync] Failed to rehydrate session tax details:",d)}const u=i.metadata?.orderId;let p=t.from("orders").select("id, user_id, status, total, currency, subtotal, shipping_total, tax_total, tax_details, customer_details").eq("stripe_session_id",r.id).maybeSingle();u&&(p=t.from("orders").select("id, user_id, status, total, currency, subtotal, shipping_total, tax_total, tax_details, customer_details").eq("id",u).maybeSingle());const{data:e,error:m}=await p;if(m||!e)throw new Error(m?.message||"Order lookup failed");const s=P(e.customer_details),n=f.normalizeOrderTaxDetails(e.tax_details),v=E(i.customer_details?.address,i.customer_details?.name??s.name),_=i,D=E(_.shipping_details?.address,_.shipping_details?.name??s.name),o=c.normalizeOrderCustomerDetails({email:i.customer_details?.email??s.email,name:i.customer_details?.name??s.name,phone:i.customer_details?.phone??s.phone,billing:s.billing??v,shipping:s.shipping??D}),T=e.status==="paid",I=await x.stripe.checkout.sessions.listLineItems(i.id,{limit:100,expand:[...R]}),l=f.buildOrderTaxDetailsFromStripeSession({session:i,lineItems:I.data,subtotal:typeof e.subtotal=="number"?e.subtotal:n?.subtotal??0,shippingTotal:typeof e.shipping_total=="number"?e.shipping_total:n?.shipping_total??0,fallbackMode:n?.mode??"automatic",currency:(i.currency??e.currency??n?.currency??"USD").toUpperCase()}),a=l.tax_total>0||l.lines.length>0?l:n??l,y=a?.tax_total??(typeof e.tax_total=="number"?e.tax_total:0),g=(i.currency??e.currency??a?.currency??"USD").toUpperCase(),S={status:"paid",stripe_session_id:i.id,payment_intent_id:typeof i.payment_intent=="string"?i.payment_intent:null,provider:"stripe",customer_details:o,total:typeof i.amount_total=="number"?i.amount_total:e.total,currency:g,tax_total:y,tax_details:a},{error:h}=await t.from("orders").update(S).eq("id",e.id);if(h)throw new Error(h.message);if(e.user_id)try{await C.upsertDefaultUserAddresses({userId:e.user_id,billingAddress:o.billing,shippingAddress:o.shipping,client:t})}catch(d){console.error("[Stripe Sync] Failed to refresh saved customer addresses:",d)}const b=await O.assignInvoiceMetadata({orderId:e.id,client:t});return await w.applyOrderInventoryDeduction(t,e.id),{orderId:e.id,alreadyPaid:T,customerDetails:o,order:{id:e.id,invoice_number:b.invoiceNumber,paid_at:b.paidAt,total:S.total,currency:g,subtotal:typeof e.subtotal=="number"?e.subtotal:a?.subtotal??0,shipping_total:typeof e.shipping_total=="number"?e.shipping_total:a?.shipping_total??0,tax_total:y,tax_details:a}}}exports.syncStripeOrderFromSession=z;
@@ -0,0 +1,130 @@
1
+ import { createClient as A } from "@supabase/supabase-js";
2
+ import { normalizeOrderCustomerDetails as x, normalizeCustomerAddress as v } from "../customer.es.js";
3
+ import { upsertDefaultUserAddresses as w } from "../customer-addresses.es.js";
4
+ import { applyOrderInventoryDeduction as C } from "../order-inventory.es.js";
5
+ import { normalizeOrderTaxDetails as U, buildOrderTaxDetailsFromStripeSession as R } from "../order-tax-details.es.js";
6
+ import { assignInvoiceMetadata as O } from "../invoice-server.es.js";
7
+ import { stripe as b } from "./client.es.js";
8
+ const P = ["total_details.breakdown"], z = ["data.taxes.rate"];
9
+ function k() {
10
+ const r = process.env.NEXT_PUBLIC_SUPABASE_URL, t = process.env.SUPABASE_SERVICE_ROLE_KEY;
11
+ if (!r || !t)
12
+ throw new Error("Missing Supabase Service Role environment variables");
13
+ return A(r, t, {
14
+ auth: {
15
+ autoRefreshToken: !1,
16
+ persistSession: !1
17
+ }
18
+ });
19
+ }
20
+ function S(r, t) {
21
+ return r ? v({
22
+ recipient_name: t,
23
+ line1: r.line1 ?? null,
24
+ line2: r.line2 ?? null,
25
+ city: r.city ?? null,
26
+ state: r.state ?? null,
27
+ postal_code: r.postal_code ?? null,
28
+ country_code: r.country ?? null
29
+ }) : null;
30
+ }
31
+ function N(r) {
32
+ const t = r ?? {};
33
+ return x({
34
+ email: typeof t.email == "string" ? t.email : null,
35
+ name: typeof t.name == "string" ? t.name : null,
36
+ phone: typeof t.phone == "string" ? t.phone : null,
37
+ billing: t.billing ?? null,
38
+ shipping: t.shipping ?? null
39
+ });
40
+ }
41
+ async function H(r) {
42
+ const t = k();
43
+ let i = r;
44
+ try {
45
+ i = await b.checkout.sessions.retrieve(r.id, {
46
+ expand: [...P]
47
+ });
48
+ } catch (d) {
49
+ console.error("[Stripe Sync] Failed to rehydrate session tax details:", d);
50
+ }
51
+ const p = i.metadata?.orderId;
52
+ let c = t.from("orders").select(
53
+ "id, user_id, status, total, currency, subtotal, shipping_total, tax_total, tax_details, customer_details"
54
+ ).eq("stripe_session_id", r.id).maybeSingle();
55
+ p && (c = t.from("orders").select(
56
+ "id, user_id, status, total, currency, subtotal, shipping_total, tax_total, tax_details, customer_details"
57
+ ).eq("id", p).maybeSingle());
58
+ const { data: e, error: u } = await c;
59
+ if (u || !e)
60
+ throw new Error(u?.message || "Order lookup failed");
61
+ const a = N(e.customer_details), o = U(e.tax_details), E = S(
62
+ i.customer_details?.address,
63
+ i.customer_details?.name ?? a.name
64
+ ), m = i, D = S(
65
+ m.shipping_details?.address,
66
+ m.shipping_details?.name ?? a.name
67
+ ), n = x({
68
+ email: i.customer_details?.email ?? a.email,
69
+ name: i.customer_details?.name ?? a.name,
70
+ phone: i.customer_details?.phone ?? a.phone,
71
+ billing: a.billing ?? E,
72
+ shipping: a.shipping ?? D
73
+ }), I = e.status === "paid", T = await b.checkout.sessions.listLineItems(i.id, {
74
+ limit: 100,
75
+ expand: [...z]
76
+ }), l = R({
77
+ session: i,
78
+ lineItems: T.data,
79
+ subtotal: typeof e.subtotal == "number" ? e.subtotal : o?.subtotal ?? 0,
80
+ shippingTotal: typeof e.shipping_total == "number" ? e.shipping_total : o?.shipping_total ?? 0,
81
+ fallbackMode: o?.mode ?? "automatic",
82
+ currency: (i.currency ?? e.currency ?? o?.currency ?? "USD").toUpperCase()
83
+ }), s = l.tax_total > 0 || l.lines.length > 0 ? l : o ?? l, _ = s?.tax_total ?? (typeof e.tax_total == "number" ? e.tax_total : 0), y = (i.currency ?? e.currency ?? s?.currency ?? "USD").toUpperCase(), f = {
84
+ status: "paid",
85
+ stripe_session_id: i.id,
86
+ payment_intent_id: typeof i.payment_intent == "string" ? i.payment_intent : null,
87
+ provider: "stripe",
88
+ customer_details: n,
89
+ total: typeof i.amount_total == "number" ? i.amount_total : e.total,
90
+ currency: y,
91
+ tax_total: _,
92
+ tax_details: s
93
+ }, { error: g } = await t.from("orders").update(f).eq("id", e.id);
94
+ if (g)
95
+ throw new Error(g.message);
96
+ if (e.user_id)
97
+ try {
98
+ await w({
99
+ userId: e.user_id,
100
+ billingAddress: n.billing,
101
+ shippingAddress: n.shipping,
102
+ client: t
103
+ });
104
+ } catch (d) {
105
+ console.error("[Stripe Sync] Failed to refresh saved customer addresses:", d);
106
+ }
107
+ const h = await O({
108
+ orderId: e.id,
109
+ client: t
110
+ });
111
+ return await C(t, e.id), {
112
+ orderId: e.id,
113
+ alreadyPaid: I,
114
+ customerDetails: n,
115
+ order: {
116
+ id: e.id,
117
+ invoice_number: h.invoiceNumber,
118
+ paid_at: h.paidAt,
119
+ total: f.total,
120
+ currency: y,
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: _,
124
+ tax_details: s
125
+ }
126
+ };
127
+ }
128
+ export {
129
+ H as syncStripeOrderFromSession
130
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./client.cjs.js"),i=require("./order-sync.cjs.js"),a=async(s,n)=>{const o=process.env.STRIPE_WEBHOOK_SECRET;if(!o)return console.error("Missing STRIPE_WEBHOOK_SECRET"),{received:!1,error:"Server configuration error"};let e;try{e=c.stripe.webhooks.constructEvent(n,s,o)}catch(r){return console.error(`Webhook signature verification failed: ${r.message}`),{received:!1,error:`Webhook Error: ${r.message}`}}switch(e.type){case"checkout.session.completed":{const r=e.data.object;try{await i.syncStripeOrderFromSession(r)}catch(t){return console.error("[Stripe Webhook Error] Failed to sync completed session:",t),{received:!1,error:t.message||"Failed to sync Stripe session"}}break}default:console.log(`Unhandled event type ${e.type}`)}return{received:!0}};exports.handleStripeWebhook=a;
@@ -0,0 +1,30 @@
1
+ import { stripe as c } from "./client.es.js";
2
+ import { syncStripeOrderFromSession as i } from "./order-sync.es.js";
3
+ const d = async (t, n) => {
4
+ const o = process.env.STRIPE_WEBHOOK_SECRET;
5
+ if (!o)
6
+ return console.error("Missing STRIPE_WEBHOOK_SECRET"), { received: !1, error: "Server configuration error" };
7
+ let e;
8
+ try {
9
+ e = c.webhooks.constructEvent(n, t, o);
10
+ } catch (r) {
11
+ return console.error(`Webhook signature verification failed: ${r.message}`), { received: !1, error: `Webhook Error: ${r.message}` };
12
+ }
13
+ switch (e.type) {
14
+ case "checkout.session.completed": {
15
+ const r = e.data.object;
16
+ try {
17
+ await i(r);
18
+ } catch (s) {
19
+ return console.error("[Stripe Webhook Error] Failed to sync completed session:", s), { received: !1, error: s.message || "Failed to sync Stripe session" };
20
+ }
21
+ break;
22
+ }
23
+ default:
24
+ console.log(`Unhandled event type ${e.type}`);
25
+ }
26
+ return { received: !0 };
27
+ };
28
+ export {
29
+ d as handleStripeWebhook
30
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./countries.cjs.js"),m=require("./currency.cjs.js"),T=require("./inventory-settings.cjs.js"),E=require("./states.cjs.js"),b=require("./coupons.cjs.js"),p="txcd_99999999",x="txcd_00000000",P="txcd_92010001";function S(s){return s?p:x}async function y(s,r,i,a,u){if(!r.length)return[];const d=[...new Set(r.map(o=>o.product_id))],{data:c,error:l}=await s.from("products").select("id, is_taxable").in("id",d);if(l)throw new Error(l.message);const _=new Map((c||[]).map(o=>[o.id,o]));return r.reduce((o,e)=>{const t=_.get(e.product_id);if(!t)return o;const n=m.resolveEffectivePriceForCurrency({prices:e.prices,salePrices:e.sale_prices,fallbackPrice:e.price,fallbackSalePrice:e.sale_price,saleStartAt:e.sale_start_at,saleEndAt:e.sale_end_at,scheduledPrice:e.scheduled_price,scheduledPrices:e.scheduled_prices,scheduledPriceAt:e.scheduled_price_at,currencyCode:i,currencies:a});return o.push({product_id:t.id,quantity:e.quantity,unit_amount:n.sale_price??n.price,discount_amount:u?.get(b.getCartLineCouponKey(e))??0,is_taxable:t.is_taxable??!0}),o},[])}async function f(s,r){const i=await T.getEcommerceInventorySettings(s),a=r.items.reduce((t,n)=>n.is_taxable?t+Math.max(0,n.unit_amount*n.quantity-(n.discount_amount??0)):t,0);if(!i.enableTaxes||a<=0)return{enabled:!1,mode:i.taxCalculationMode,amount:0,taxableSubtotal:a,lines:[]};if(i.taxCalculationMode==="automatic")return{enabled:!0,mode:"automatic",amount:0,taxableSubtotal:a,lines:[],isPendingExternalCalculation:!0};const u=C.normalizeCountryCode(r.destination?.country_code),d=E.normalizeSubdivisionCode(u,r.destination?.state)||null;if(!u)return{enabled:!0,mode:"manual",amount:0,taxableSubtotal:a,lines:[]};let c=s.from("tax_rates").select("id, country_code, state_code, tax_name, tax_rate, created_at, updated_at").eq("country_code",u);c=d?c.or(`state_code.is.null,state_code.eq.${d}`):c.is("state_code",null);const{data:l,error:_}=await c;if(_)throw new Error(_.message);const e=(l||[]).map(t=>({id:t.id,name:t.tax_name,rate:Number(t.tax_rate),amount:Math.round(a*Number(t.tax_rate)/100),country_code:t.country_code,state_code:t.state_code??null}));return{enabled:!0,mode:"manual",amount:e.reduce((t,n)=>t+n.amount,0),taxableSubtotal:a,lines:e}}exports.STRIPE_TAX_CODE_NONTAXABLE=x;exports.STRIPE_TAX_CODE_SHIPPING=P;exports.STRIPE_TAX_CODE_TAXABLE_GOODS=p;exports.buildCheckoutTaxableItemsFromCart=y;exports.calculateCheckoutTaxes=f;exports.getStripeTaxCodeForProduct=S;
@@ -0,0 +1,101 @@
1
+ import { normalizeCountryCode as m } from "./countries.es.js";
2
+ import { resolveEffectivePriceForCurrency as p } from "./currency.es.js";
3
+ import { getEcommerceInventorySettings as f } from "./inventory-settings.es.js";
4
+ import { normalizeSubdivisionCode as x } from "./states.es.js";
5
+ import { getCartLineCouponKey as C } from "./coupons.es.js";
6
+ const b = "txcd_99999999", y = "txcd_00000000", g = "txcd_92010001";
7
+ function A(i) {
8
+ return i ? b : y;
9
+ }
10
+ async function w(i, r, s, n, c) {
11
+ if (!r.length)
12
+ return [];
13
+ const u = [...new Set(r.map((o) => o.product_id))], { data: d, error: l } = await i.from("products").select("id, is_taxable").in("id", u);
14
+ if (l)
15
+ throw new Error(l.message);
16
+ const _ = new Map(
17
+ (d || []).map((o) => [o.id, o])
18
+ );
19
+ return r.reduce((o, e) => {
20
+ const t = _.get(e.product_id);
21
+ if (!t)
22
+ return o;
23
+ const a = p({
24
+ prices: e.prices,
25
+ salePrices: e.sale_prices,
26
+ fallbackPrice: e.price,
27
+ fallbackSalePrice: e.sale_price,
28
+ saleStartAt: e.sale_start_at,
29
+ saleEndAt: e.sale_end_at,
30
+ scheduledPrice: e.scheduled_price,
31
+ scheduledPrices: e.scheduled_prices,
32
+ scheduledPriceAt: e.scheduled_price_at,
33
+ currencyCode: s,
34
+ currencies: n
35
+ });
36
+ return o.push({
37
+ product_id: t.id,
38
+ quantity: e.quantity,
39
+ unit_amount: a.sale_price ?? a.price,
40
+ discount_amount: c?.get(C(e)) ?? 0,
41
+ is_taxable: t.is_taxable ?? !0
42
+ }), o;
43
+ }, []);
44
+ }
45
+ async function q(i, r) {
46
+ const s = await f(i), n = r.items.reduce((t, a) => a.is_taxable ? t + Math.max(0, a.unit_amount * a.quantity - (a.discount_amount ?? 0)) : t, 0);
47
+ if (!s.enableTaxes || n <= 0)
48
+ return {
49
+ enabled: !1,
50
+ mode: s.taxCalculationMode,
51
+ amount: 0,
52
+ taxableSubtotal: n,
53
+ lines: []
54
+ };
55
+ if (s.taxCalculationMode === "automatic")
56
+ return {
57
+ enabled: !0,
58
+ mode: "automatic",
59
+ amount: 0,
60
+ taxableSubtotal: n,
61
+ lines: [],
62
+ isPendingExternalCalculation: !0
63
+ };
64
+ const c = m(r.destination?.country_code), u = x(c, r.destination?.state) || null;
65
+ if (!c)
66
+ return {
67
+ enabled: !0,
68
+ mode: "manual",
69
+ amount: 0,
70
+ taxableSubtotal: n,
71
+ lines: []
72
+ };
73
+ let d = i.from("tax_rates").select("id, country_code, state_code, tax_name, tax_rate, created_at, updated_at").eq("country_code", c);
74
+ d = u ? d.or(`state_code.is.null,state_code.eq.${u}`) : d.is("state_code", null);
75
+ const { data: l, error: _ } = await d;
76
+ if (_)
77
+ throw new Error(_.message);
78
+ const e = (l || []).map((t) => ({
79
+ id: t.id,
80
+ name: t.tax_name,
81
+ rate: Number(t.tax_rate),
82
+ amount: Math.round(n * Number(t.tax_rate) / 100),
83
+ country_code: t.country_code,
84
+ state_code: t.state_code ?? null
85
+ }));
86
+ return {
87
+ enabled: !0,
88
+ mode: "manual",
89
+ amount: e.reduce((t, a) => t + a.amount, 0),
90
+ taxableSubtotal: n,
91
+ lines: e
92
+ };
93
+ }
94
+ export {
95
+ y as STRIPE_TAX_CODE_NONTAXABLE,
96
+ g as STRIPE_TAX_CODE_SHIPPING,
97
+ b as STRIPE_TAX_CODE_TAXABLE_GOODS,
98
+ w as buildCheckoutTaxableItemsFromCart,
99
+ q as calculateCheckoutTaxes,
100
+ A as getStripeTaxCodeForProduct
101
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(e){const r=Number(e?.trial_period_days??0);return!Number.isFinite(r)||r<=0?0:Math.round(r)}function i(e){return t(e)===0?null:e?.trial_requires_payment_method?"paid":"free"}function a(e){const r=t(typeof e=="number"?{trial_period_days:e}:e);return r>0?`${r}-day free trial`:null}function n(e){return e?.trial_requires_payment_method?"Payment method required":"No credit card required"}function o(e){const r=a(e);return r?{label:r,paymentRequirementLabel:n(e),checkoutMode:i(e)}:null}exports.getTrialCheckoutMode=i;exports.getTrialLabel=a;exports.getTrialPaymentRequirementLabel=n;exports.getTrialPeriodDays=t;exports.getTrialSummary=o;
@@ -5,25 +5,25 @@ function t(e) {
5
5
  function i(e) {
6
6
  return t(e) === 0 ? null : e?.trial_requires_payment_method ? "paid" : "free";
7
7
  }
8
- function a(e) {
8
+ function n(e) {
9
9
  const r = t(typeof e == "number" ? { trial_period_days: e } : e);
10
10
  return r > 0 ? `${r}-day free trial` : null;
11
11
  }
12
- function n(e) {
12
+ function a(e) {
13
13
  return e?.trial_requires_payment_method ? "Payment method required" : "No credit card required";
14
14
  }
15
15
  function o(e) {
16
- const r = a(e);
16
+ const r = n(e);
17
17
  return r ? {
18
18
  label: r,
19
- paymentRequirementLabel: n(e),
19
+ paymentRequirementLabel: a(e),
20
20
  checkoutMode: i(e)
21
21
  } : null;
22
22
  }
23
23
  export {
24
- a,
25
- n as b,
26
- t as c,
27
- o as d,
28
- i as g
24
+ i as getTrialCheckoutMode,
25
+ n as getTrialLabel,
26
+ a as getTrialPaymentRequirementLabel,
27
+ t as getTrialPeriodDays,
28
+ o as getTrialSummary
29
29
  };
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { useState as u, useEffect as a } from "react";
2
3
  import { useCartStore as d } from "./cart-store.es.js";
3
4
  let s = null;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod");e.z.config({jitless:!0});Object.defineProperty(exports,"z",{enumerable:!0,get:()=>e.z});
@@ -0,0 +1,6 @@
1
+ import { z as o } from "zod";
2
+ import { z as f } from "zod";
3
+ o.config({ jitless: !0 });
4
+ export {
5
+ f as z
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextblock-cms/ecom",
3
- "version": "0.8.6",
3
+ "version": "0.8.11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -10,9 +10,9 @@
10
10
  },
11
11
  "type": "module",
12
12
  "dependencies": {
13
- "@nextblock-cms/db": "^0.8.6",
14
- "@nextblock-cms/ui": "^0.8.6",
15
- "@nextblock-cms/utils": "^0.8.6",
13
+ "@nextblock-cms/db": "^0.8.11",
14
+ "@nextblock-cms/ui": "^0.8.11",
15
+ "@nextblock-cms/utils": "^0.8.11",
16
16
  "@freemius/checkout": "^1.4.1",
17
17
  "@freemius/sdk": "^0.3.0",
18
18
  "@hookform/resolvers": "^5.2.2",
@@ -49,8 +49,8 @@
49
49
  "./package.json": "./package.json",
50
50
  "./*": {
51
51
  "types": "./lib/*.d.ts",
52
- "import": "./*.es.js",
53
- "require": "./*.cjs.js"
52
+ "import": "./lib/*.es.js",
53
+ "require": "./lib/*.cjs.js"
54
54
  }
55
55
  }
56
56
  }