@salifbiaye/create-boutique 0.1.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.
Files changed (316) hide show
  1. package/README.md +1 -0
  2. package/cli/dist/commands.js +382 -0
  3. package/cli/dist/create.js +194 -0
  4. package/cli/dist/docker.js +19 -0
  5. package/cli/dist/generate.js +322 -0
  6. package/cli/dist/guide.js +72 -0
  7. package/cli/dist/index.js +156 -0
  8. package/cli/dist/paths.js +29 -0
  9. package/cli/dist/ports.js +54 -0
  10. package/cli/dist/project.js +119 -0
  11. package/cli/dist/themes.js +24 -0
  12. package/docs/fiche-client.en.html +137 -0
  13. package/docs/fiche-client.html +137 -0
  14. package/docs/guide-complet.en.html +259 -0
  15. package/docs/guide-complet.fr.html +259 -0
  16. package/package.json +51 -0
  17. package/templates/backend/.dockerignore +9 -0
  18. package/templates/backend/Dockerfile +30 -0
  19. package/templates/backend/README.md +78 -0
  20. package/templates/backend/TEMPLATE_VERSION +1 -0
  21. package/templates/backend/docker/entrypoint.sh +28 -0
  22. package/templates/backend/instrumentation.ts +24 -0
  23. package/templates/backend/medusa-config.ts +114 -0
  24. package/templates/backend/package-lock.json +16222 -0
  25. package/templates/backend/package.json +39 -0
  26. package/templates/backend/src/admin/README.md +33 -0
  27. package/templates/backend/src/admin/components/image-field.tsx +61 -0
  28. package/templates/backend/src/admin/i18n/README.md +58 -0
  29. package/templates/backend/src/admin/i18n/index.ts +8 -0
  30. package/templates/backend/src/admin/i18n/json/en.json +66 -0
  31. package/templates/backend/src/admin/i18n/json/fr.json +66 -0
  32. package/templates/backend/src/admin/lib/client.ts +9 -0
  33. package/templates/backend/src/admin/routes/boutique-campaigns/campaign-drawer.tsx +286 -0
  34. package/templates/backend/src/admin/routes/boutique-campaigns/page.tsx +113 -0
  35. package/templates/backend/src/admin/tsconfig.json +24 -0
  36. package/templates/backend/src/admin/vite-env.d.ts +1 -0
  37. package/templates/backend/src/admin/widgets/category-image.tsx +56 -0
  38. package/templates/backend/src/api/README.md +135 -0
  39. package/templates/backend/src/api/admin/boutique-campaigns/[salesChannelId]/route.ts +30 -0
  40. package/templates/backend/src/api/admin/boutique-campaigns/route.ts +24 -0
  41. package/templates/backend/src/api/middlewares.ts +28 -0
  42. package/templates/backend/src/api/rate-limit.ts +30 -0
  43. package/templates/backend/src/api/route.ts +6 -0
  44. package/templates/backend/src/api/store/campaign/route.ts +25 -0
  45. package/templates/backend/src/api/store/order-lookup/route.ts +74 -0
  46. package/templates/backend/src/emails/en.json +64 -0
  47. package/templates/backend/src/emails/fr.json +64 -0
  48. package/templates/backend/src/jobs/README.md +38 -0
  49. package/templates/backend/src/lib/emails.ts +94 -0
  50. package/templates/backend/src/lib/notify.ts +148 -0
  51. package/templates/backend/src/lib/project.ts +146 -0
  52. package/templates/backend/src/links/README.md +26 -0
  53. package/templates/backend/src/links/campaign-sales-channel.ts +9 -0
  54. package/templates/backend/src/modules/README.md +117 -0
  55. package/templates/backend/src/modules/campaign/index.ts +9 -0
  56. package/templates/backend/src/modules/campaign/migrations/.snapshot-boutique-campaign.json +272 -0
  57. package/templates/backend/src/modules/campaign/migrations/Migration20260928141440.ts +16 -0
  58. package/templates/backend/src/modules/campaign/migrations/Migration20260928145243.ts +13 -0
  59. package/templates/backend/src/modules/campaign/models/campaign.ts +28 -0
  60. package/templates/backend/src/modules/campaign/service.ts +6 -0
  61. package/templates/backend/src/modules/campaign/validators.ts +94 -0
  62. package/templates/backend/src/modules/resend/index.ts +6 -0
  63. package/templates/backend/src/modules/resend/service.ts +63 -0
  64. package/templates/backend/src/scripts/README.md +63 -0
  65. package/templates/backend/src/scripts/campaign-export.ts +15 -0
  66. package/templates/backend/src/scripts/campaign-import.ts +38 -0
  67. package/templates/backend/src/scripts/price-report.ts +34 -0
  68. package/templates/backend/src/scripts/seed.ts +418 -0
  69. package/templates/backend/src/scripts/storage.ts +63 -0
  70. package/templates/backend/src/subscribers/README.md +61 -0
  71. package/templates/backend/src/subscribers/account-emails.ts +27 -0
  72. package/templates/backend/src/subscribers/fulfillment-emails.ts +42 -0
  73. package/templates/backend/src/subscribers/order-emails.ts +12 -0
  74. package/templates/backend/src/subscribers/return-refund-emails.ts +50 -0
  75. package/templates/backend/src/workflows/README.md +81 -0
  76. package/templates/backend/src/workflows/steps/upsert-campaign.ts +53 -0
  77. package/templates/backend/src/workflows/upsert-campaign.ts +30 -0
  78. package/templates/backend/tsconfig.json +36 -0
  79. package/templates/storefront/.dockerignore +7 -0
  80. package/templates/storefront/.github/ISSUE_TEMPLATE/bug-report.yml +71 -0
  81. package/templates/storefront/.prettierrc +8 -0
  82. package/templates/storefront/Dockerfile +37 -0
  83. package/templates/storefront/LICENSE +21 -0
  84. package/templates/storefront/README.md +127 -0
  85. package/templates/storefront/locales/en.json +269 -0
  86. package/templates/storefront/locales/fr.json +269 -0
  87. package/templates/storefront/next-env.d.ts +7 -0
  88. package/templates/storefront/next-sitemap.js +19 -0
  89. package/templates/storefront/next.config.js +29 -0
  90. package/templates/storefront/package-lock.json +9031 -0
  91. package/templates/storefront/package.json +49 -0
  92. package/templates/storefront/postcss.config.js +6 -0
  93. package/templates/storefront/public/favicon.ico +0 -0
  94. package/templates/storefront/scripts/sync-design.mjs +30 -0
  95. package/templates/storefront/src/app/(checkout)/checkout/page.tsx +31 -0
  96. package/templates/storefront/src/app/(checkout)/layout.tsx +29 -0
  97. package/templates/storefront/src/app/(checkout)/not-found.tsx +20 -0
  98. package/templates/storefront/src/app/(main)/account/@dashboard/addresses/page.tsx +34 -0
  99. package/templates/storefront/src/app/(main)/account/@dashboard/loading.tsx +9 -0
  100. package/templates/storefront/src/app/(main)/account/@dashboard/orders/details/[id]/page.tsx +33 -0
  101. package/templates/storefront/src/app/(main)/account/@dashboard/orders/page.tsx +37 -0
  102. package/templates/storefront/src/app/(main)/account/@dashboard/page.tsx +22 -0
  103. package/templates/storefront/src/app/(main)/account/@dashboard/profile/page.tsx +53 -0
  104. package/templates/storefront/src/app/(main)/account/@login/page.tsx +12 -0
  105. package/templates/storefront/src/app/(main)/account/layout.tsx +20 -0
  106. package/templates/storefront/src/app/(main)/account/loading.tsx +9 -0
  107. package/templates/storefront/src/app/(main)/cart/loading.tsx +5 -0
  108. package/templates/storefront/src/app/(main)/cart/not-found.tsx +21 -0
  109. package/templates/storefront/src/app/(main)/cart/page.tsx +21 -0
  110. package/templates/storefront/src/app/(main)/categories/[...category]/page.tsx +55 -0
  111. package/templates/storefront/src/app/(main)/collections/[handle]/page.tsx +55 -0
  112. package/templates/storefront/src/app/(main)/layout.tsx +43 -0
  113. package/templates/storefront/src/app/(main)/legal/[page]/page.tsx +42 -0
  114. package/templates/storefront/src/app/(main)/not-found.tsx +21 -0
  115. package/templates/storefront/src/app/(main)/order/[id]/confirmed/loading.tsx +5 -0
  116. package/templates/storefront/src/app/(main)/order/[id]/confirmed/page.tsx +23 -0
  117. package/templates/storefront/src/app/(main)/order/[id]/transfer/[token]/accept/page.tsx +42 -0
  118. package/templates/storefront/src/app/(main)/order/[id]/transfer/[token]/decline/page.tsx +42 -0
  119. package/templates/storefront/src/app/(main)/order/[id]/transfer/[token]/page.tsx +35 -0
  120. package/templates/storefront/src/app/(main)/order/track/page.tsx +32 -0
  121. package/templates/storefront/src/app/(main)/page.tsx +68 -0
  122. package/templates/storefront/src/app/(main)/products/[handle]/page.tsx +86 -0
  123. package/templates/storefront/src/app/(main)/store/page.tsx +28 -0
  124. package/templates/storefront/src/app/api/health/route.ts +13 -0
  125. package/templates/storefront/src/app/layout.tsx +42 -0
  126. package/templates/storefront/src/app/not-found.tsx +21 -0
  127. package/templates/storefront/src/app/opengraph-image.jpg +0 -0
  128. package/templates/storefront/src/app/twitter-image.jpg +0 -0
  129. package/templates/storefront/src/instrumentation-node.ts +18 -0
  130. package/templates/storefront/src/instrumentation.ts +9 -0
  131. package/templates/storefront/src/lib/boutique/campaign.ts +116 -0
  132. package/templates/storefront/src/lib/boutique/config.ts +152 -0
  133. package/templates/storefront/src/lib/boutique/fonts.ts +29 -0
  134. package/templates/storefront/src/lib/boutique/i18n-client.tsx +34 -0
  135. package/templates/storefront/src/lib/boutique/i18n.ts +43 -0
  136. package/templates/storefront/src/lib/boutique/schema.ts +131 -0
  137. package/templates/storefront/src/lib/config.ts +39 -0
  138. package/templates/storefront/src/lib/constants.tsx +75 -0
  139. package/templates/storefront/src/lib/context/modal-context.tsx +34 -0
  140. package/templates/storefront/src/lib/data/cart.ts +434 -0
  141. package/templates/storefront/src/lib/data/categories.ts +49 -0
  142. package/templates/storefront/src/lib/data/collections.ts +59 -0
  143. package/templates/storefront/src/lib/data/cookies.ts +103 -0
  144. package/templates/storefront/src/lib/data/customer.ts +261 -0
  145. package/templates/storefront/src/lib/data/fulfillment.ts +68 -0
  146. package/templates/storefront/src/lib/data/onboarding.ts +9 -0
  147. package/templates/storefront/src/lib/data/order-lookup.ts +34 -0
  148. package/templates/storefront/src/lib/data/orders.ts +112 -0
  149. package/templates/storefront/src/lib/data/payment.ts +35 -0
  150. package/templates/storefront/src/lib/data/products.ts +127 -0
  151. package/templates/storefront/src/lib/data/regions.ts +70 -0
  152. package/templates/storefront/src/lib/data/variants.ts +38 -0
  153. package/templates/storefront/src/lib/hooks/use-in-view.tsx +29 -0
  154. package/templates/storefront/src/lib/hooks/use-toggle-state.tsx +46 -0
  155. package/templates/storefront/src/lib/util/compare-addresses.ts +28 -0
  156. package/templates/storefront/src/lib/util/get-percentage-diff.ts +6 -0
  157. package/templates/storefront/src/lib/util/get-product-price.ts +79 -0
  158. package/templates/storefront/src/lib/util/isEmpty.ts +11 -0
  159. package/templates/storefront/src/lib/util/medusa-error.ts +22 -0
  160. package/templates/storefront/src/lib/util/money.ts +35 -0
  161. package/templates/storefront/src/lib/util/product.ts +5 -0
  162. package/templates/storefront/src/lib/util/repeat.ts +5 -0
  163. package/templates/storefront/src/lib/util/sort-products.ts +50 -0
  164. package/templates/storefront/src/modules/account/components/account-info/index.tsx +140 -0
  165. package/templates/storefront/src/modules/account/components/account-nav/index.tsx +198 -0
  166. package/templates/storefront/src/modules/account/components/address-book/index.tsx +28 -0
  167. package/templates/storefront/src/modules/account/components/address-card/add-address.tsx +169 -0
  168. package/templates/storefront/src/modules/account/components/address-card/edit-address-modal.tsx +241 -0
  169. package/templates/storefront/src/modules/account/components/login/index.tsx +65 -0
  170. package/templates/storefront/src/modules/account/components/order-card/index.tsx +88 -0
  171. package/templates/storefront/src/modules/account/components/order-overview/index.tsx +47 -0
  172. package/templates/storefront/src/modules/account/components/overview/index.tsx +169 -0
  173. package/templates/storefront/src/modules/account/components/profile-billing-address/index.tsx +193 -0
  174. package/templates/storefront/src/modules/account/components/profile-email/index.tsx +75 -0
  175. package/templates/storefront/src/modules/account/components/profile-name/index.tsx +79 -0
  176. package/templates/storefront/src/modules/account/components/profile-password/index.tsx +72 -0
  177. package/templates/storefront/src/modules/account/components/profile-phone/index.tsx +74 -0
  178. package/templates/storefront/src/modules/account/components/register/index.tsx +107 -0
  179. package/templates/storefront/src/modules/account/components/transfer-request-form/index.tsx +83 -0
  180. package/templates/storefront/src/modules/account/templates/account-layout.tsx +43 -0
  181. package/templates/storefront/src/modules/account/templates/login-template.tsx +27 -0
  182. package/templates/storefront/src/modules/cart/components/cart-item-select/index.tsx +75 -0
  183. package/templates/storefront/src/modules/cart/components/empty-cart-message/index.tsx +25 -0
  184. package/templates/storefront/src/modules/cart/components/item/index.tsx +144 -0
  185. package/templates/storefront/src/modules/cart/components/sign-in-prompt/index.tsx +27 -0
  186. package/templates/storefront/src/modules/cart/templates/index.tsx +51 -0
  187. package/templates/storefront/src/modules/cart/templates/items.tsx +58 -0
  188. package/templates/storefront/src/modules/cart/templates/preview.tsx +51 -0
  189. package/templates/storefront/src/modules/cart/templates/summary.tsx +50 -0
  190. package/templates/storefront/src/modules/categories/templates/index.tsx +94 -0
  191. package/templates/storefront/src/modules/checkout/components/address-select/index.tsx +117 -0
  192. package/templates/storefront/src/modules/checkout/components/addresses/index.tsx +186 -0
  193. package/templates/storefront/src/modules/checkout/components/billing_address/index.tsx +114 -0
  194. package/templates/storefront/src/modules/checkout/components/country-select/index.tsx +50 -0
  195. package/templates/storefront/src/modules/checkout/components/discount-code/index.tsx +181 -0
  196. package/templates/storefront/src/modules/checkout/components/error-message/index.tsx +13 -0
  197. package/templates/storefront/src/modules/checkout/components/payment/index.tsx +261 -0
  198. package/templates/storefront/src/modules/checkout/components/payment-button/index.tsx +195 -0
  199. package/templates/storefront/src/modules/checkout/components/payment-container/index.tsx +130 -0
  200. package/templates/storefront/src/modules/checkout/components/payment-test/index.tsx +12 -0
  201. package/templates/storefront/src/modules/checkout/components/payment-wrapper/index.tsx +42 -0
  202. package/templates/storefront/src/modules/checkout/components/payment-wrapper/stripe-wrapper.tsx +54 -0
  203. package/templates/storefront/src/modules/checkout/components/review/index.tsx +54 -0
  204. package/templates/storefront/src/modules/checkout/components/shipping/index.tsx +417 -0
  205. package/templates/storefront/src/modules/checkout/components/shipping-address/index.tsx +219 -0
  206. package/templates/storefront/src/modules/checkout/components/submit-button/index.tsx +32 -0
  207. package/templates/storefront/src/modules/checkout/templates/checkout-form/index.tsx +38 -0
  208. package/templates/storefront/src/modules/checkout/templates/checkout-summary/index.tsx +31 -0
  209. package/templates/storefront/src/modules/collections/templates/index.tsx +44 -0
  210. package/templates/storefront/src/modules/common/components/cart-totals/index.tsx +84 -0
  211. package/templates/storefront/src/modules/common/components/checkbox/index.tsx +44 -0
  212. package/templates/storefront/src/modules/common/components/delete-button/index.tsx +42 -0
  213. package/templates/storefront/src/modules/common/components/divider/index.tsx +9 -0
  214. package/templates/storefront/src/modules/common/components/filter-radio-group/index.tsx +61 -0
  215. package/templates/storefront/src/modules/common/components/input/index.tsx +79 -0
  216. package/templates/storefront/src/modules/common/components/interactive-link/index.tsx +33 -0
  217. package/templates/storefront/src/modules/common/components/line-item-options/index.tsx +26 -0
  218. package/templates/storefront/src/modules/common/components/line-item-price/index.tsx +63 -0
  219. package/templates/storefront/src/modules/common/components/line-item-unit-price/index.tsx +62 -0
  220. package/templates/storefront/src/modules/common/components/localized-client-link/index.tsx +29 -0
  221. package/templates/storefront/src/modules/common/components/modal/index.tsx +118 -0
  222. package/templates/storefront/src/modules/common/components/native-select/index.tsx +76 -0
  223. package/templates/storefront/src/modules/common/components/radio/index.tsx +27 -0
  224. package/templates/storefront/src/modules/common/icons/back.tsx +37 -0
  225. package/templates/storefront/src/modules/common/icons/bancontact.tsx +26 -0
  226. package/templates/storefront/src/modules/common/icons/chevron-down.tsx +30 -0
  227. package/templates/storefront/src/modules/common/icons/eye-off.tsx +37 -0
  228. package/templates/storefront/src/modules/common/icons/eye.tsx +37 -0
  229. package/templates/storefront/src/modules/common/icons/fast-delivery.tsx +65 -0
  230. package/templates/storefront/src/modules/common/icons/ideal.tsx +26 -0
  231. package/templates/storefront/src/modules/common/icons/map-pin.tsx +37 -0
  232. package/templates/storefront/src/modules/common/icons/package.tsx +44 -0
  233. package/templates/storefront/src/modules/common/icons/paypal.tsx +30 -0
  234. package/templates/storefront/src/modules/common/icons/placeholder-image.tsx +44 -0
  235. package/templates/storefront/src/modules/common/icons/refresh.tsx +51 -0
  236. package/templates/storefront/src/modules/common/icons/spinner.tsx +37 -0
  237. package/templates/storefront/src/modules/common/icons/trash.tsx +51 -0
  238. package/templates/storefront/src/modules/common/icons/user.tsx +37 -0
  239. package/templates/storefront/src/modules/common/icons/x.tsx +37 -0
  240. package/templates/storefront/src/modules/layout/components/cart-mismatch-banner/index.tsx +59 -0
  241. package/templates/storefront/src/modules/order/components/help/index.tsx +26 -0
  242. package/templates/storefront/src/modules/order/components/item/index.tsx +57 -0
  243. package/templates/storefront/src/modules/order/components/items/index.tsx +44 -0
  244. package/templates/storefront/src/modules/order/components/onboarding-cta/index.tsx +28 -0
  245. package/templates/storefront/src/modules/order/components/order-details/index.tsx +64 -0
  246. package/templates/storefront/src/modules/order/components/order-summary/index.tsx +61 -0
  247. package/templates/storefront/src/modules/order/components/payment-details/index.tsx +64 -0
  248. package/templates/storefront/src/modules/order/components/shipping-details/index.tsx +74 -0
  249. package/templates/storefront/src/modules/order/components/transfer-actions/index.tsx +83 -0
  250. package/templates/storefront/src/modules/order/components/transfer-image/index.tsx +275 -0
  251. package/templates/storefront/src/modules/order/templates/order-completed-template.tsx +53 -0
  252. package/templates/storefront/src/modules/order/templates/order-details-template.tsx +46 -0
  253. package/templates/storefront/src/modules/products/components/thumbnail/index.tsx +70 -0
  254. package/templates/storefront/src/modules/products/templates/index.tsx +118 -0
  255. package/templates/storefront/src/modules/shipping/components/free-shipping-price-nudge/index.tsx +285 -0
  256. package/templates/storefront/src/modules/skeletons/components/skeleton-button/index.tsx +5 -0
  257. package/templates/storefront/src/modules/skeletons/components/skeleton-card-details/index.tsx +10 -0
  258. package/templates/storefront/src/modules/skeletons/components/skeleton-cart-item/index.tsx +35 -0
  259. package/templates/storefront/src/modules/skeletons/components/skeleton-cart-totals/index.tsx +30 -0
  260. package/templates/storefront/src/modules/skeletons/components/skeleton-code-form/index.tsx +13 -0
  261. package/templates/storefront/src/modules/skeletons/components/skeleton-line-item/index.tsx +35 -0
  262. package/templates/storefront/src/modules/skeletons/components/skeleton-order-confirmed-header/index.tsx +14 -0
  263. package/templates/storefront/src/modules/skeletons/components/skeleton-order-information/index.tsx +36 -0
  264. package/templates/storefront/src/modules/skeletons/components/skeleton-order-items/index.tsx +43 -0
  265. package/templates/storefront/src/modules/skeletons/components/skeleton-order-summary/index.tsx +15 -0
  266. package/templates/storefront/src/modules/skeletons/components/skeleton-product-preview/index.tsx +15 -0
  267. package/templates/storefront/src/modules/skeletons/templates/skeleton-cart-page/index.tsx +65 -0
  268. package/templates/storefront/src/modules/skeletons/templates/skeleton-order-confirmed/index.tsx +21 -0
  269. package/templates/storefront/src/modules/skeletons/templates/skeleton-product-grid/index.tsx +23 -0
  270. package/templates/storefront/src/modules/store/components/pagination/index.tsx +114 -0
  271. package/templates/storefront/src/modules/store/components/refinement-list/index.tsx +41 -0
  272. package/templates/storefront/src/modules/store/components/refinement-list/sort-products/index.tsx +48 -0
  273. package/templates/storefront/src/modules/store/templates/index.tsx +42 -0
  274. package/templates/storefront/src/modules/store/templates/paginated-products.tsx +80 -0
  275. package/templates/storefront/src/modules/ub/button.tsx +41 -0
  276. package/templates/storefront/src/modules/ub/campaign-blocks.tsx +197 -0
  277. package/templates/storefront/src/modules/ub/campaign-ended.tsx +28 -0
  278. package/templates/storefront/src/modules/ub/category-tiles.tsx +41 -0
  279. package/templates/storefront/src/modules/ub/countdown.tsx +46 -0
  280. package/templates/storefront/src/modules/ub/footer.tsx +56 -0
  281. package/templates/storefront/src/modules/ub/icons.tsx +42 -0
  282. package/templates/storefront/src/modules/ub/nav.tsx +90 -0
  283. package/templates/storefront/src/modules/ub/pdp/buy-box.tsx +140 -0
  284. package/templates/storefront/src/modules/ub/pdp/gallery.tsx +40 -0
  285. package/templates/storefront/src/modules/ub/product-card.tsx +66 -0
  286. package/templates/storefront/src/modules/ub/top-bar.tsx +20 -0
  287. package/templates/storefront/src/modules/ub/track-form.tsx +92 -0
  288. package/templates/storefront/src/proxy.ts +89 -0
  289. package/templates/storefront/src/styles/globals.css +98 -0
  290. package/templates/storefront/src/styles/ub/bundle.css +372 -0
  291. package/templates/storefront/src/styles/ub/fonts.css +17 -0
  292. package/templates/storefront/src/styles/ub/medusa-ui.css +90 -0
  293. package/templates/storefront/src/styles/ub/overrides.css +12 -0
  294. package/templates/storefront/src/styles/ub/tokens.css +9 -0
  295. package/templates/storefront/src/types/global.ts +24 -0
  296. package/templates/storefront/src/types/icon.ts +4 -0
  297. package/templates/storefront/tailwind.config.js +164 -0
  298. package/templates/storefront/themes/black-friday/campaign.en.json +31 -0
  299. package/templates/storefront/themes/black-friday/campaign.fr.json +31 -0
  300. package/templates/storefront/themes/black-friday/theme.json +9 -0
  301. package/templates/storefront/themes/cyber-monday/campaign.en.json +31 -0
  302. package/templates/storefront/themes/cyber-monday/campaign.fr.json +31 -0
  303. package/templates/storefront/themes/cyber-monday/theme.json +9 -0
  304. package/templates/storefront/themes/halloween/campaign.en.json +31 -0
  305. package/templates/storefront/themes/halloween/campaign.fr.json +31 -0
  306. package/templates/storefront/themes/halloween/theme.json +9 -0
  307. package/templates/storefront/themes/noel/campaign.en.json +31 -0
  308. package/templates/storefront/themes/noel/campaign.fr.json +31 -0
  309. package/templates/storefront/themes/noel/theme.json +9 -0
  310. package/templates/storefront/themes/nouvel-an/campaign.en.json +31 -0
  311. package/templates/storefront/themes/nouvel-an/campaign.fr.json +31 -0
  312. package/templates/storefront/themes/nouvel-an/theme.json +9 -0
  313. package/templates/storefront/themes/thanksgiving/campaign.en.json +31 -0
  314. package/templates/storefront/themes/thanksgiving/campaign.fr.json +31 -0
  315. package/templates/storefront/themes/thanksgiving/theme.json +9 -0
  316. package/templates/storefront/tsconfig.json +53 -0
@@ -0,0 +1,261 @@
1
+ "use client"
2
+
3
+
4
+ import { T } from "@lib/boutique/i18n-client"
5
+ import { RadioGroup } from "@headlessui/react"
6
+ import { isStripeLike, paymentInfoMap } from "@lib/constants"
7
+ import { initiatePaymentSession } from "@lib/data/cart"
8
+ import { CheckCircleSolid, CreditCard } from "@medusajs/icons"
9
+ import { Button, Container, Heading, Text, clx } from "@medusajs/ui"
10
+ import ErrorMessage from "@modules/checkout/components/error-message"
11
+ import PaymentContainer, {
12
+ StripeCardContainer,
13
+ } from "@modules/checkout/components/payment-container"
14
+ import Divider from "@modules/common/components/divider"
15
+ import { usePathname, useRouter, useSearchParams } from "next/navigation"
16
+ import { useCallback, useEffect, useState } from "react"
17
+
18
+ const Payment = ({
19
+ cart,
20
+ availablePaymentMethods,
21
+ }: {
22
+ cart: any
23
+ availablePaymentMethods: any[]
24
+ }) => {
25
+ const activeSession = cart.payment_collection?.payment_sessions?.find(
26
+ (paymentSession: any) => paymentSession.status === "pending"
27
+ )
28
+
29
+ const [isLoading, setIsLoading] = useState(false)
30
+ const [error, setError] = useState<string | null>(null)
31
+ const [cardBrand, setCardBrand] = useState<string | null>(null)
32
+ const [cardComplete, setCardComplete] = useState(false)
33
+ const [selectedPaymentMethod, setSelectedPaymentMethod] = useState(
34
+ activeSession?.provider_id ?? ""
35
+ )
36
+
37
+ const searchParams = useSearchParams()
38
+ const router = useRouter()
39
+ const pathname = usePathname()
40
+
41
+ const isOpen = searchParams.get("step") === "payment"
42
+
43
+ const setPaymentMethod = async (method: string) => {
44
+ setError(null)
45
+ setSelectedPaymentMethod(method)
46
+ if (isStripeLike(method)) {
47
+ await initiatePaymentSession(cart, {
48
+ provider_id: method,
49
+ })
50
+ }
51
+ }
52
+
53
+ const paidByGiftcard =
54
+ cart?.gift_cards && cart?.gift_cards?.length > 0 && cart?.total === 0
55
+
56
+ const paymentReady =
57
+ (activeSession && cart?.shipping_methods.length !== 0) || paidByGiftcard
58
+
59
+ const createQueryString = useCallback(
60
+ (name: string, value: string) => {
61
+ const params = new URLSearchParams(searchParams)
62
+ params.set(name, value)
63
+
64
+ return params.toString()
65
+ },
66
+ [searchParams]
67
+ )
68
+
69
+ const handleEdit = () => {
70
+ router.push(pathname + "?" + createQueryString("step", "payment"), {
71
+ scroll: false,
72
+ })
73
+ }
74
+
75
+ const handleSubmit = async () => {
76
+ setIsLoading(true)
77
+ try {
78
+ const shouldInputCard =
79
+ isStripeLike(selectedPaymentMethod) && !activeSession
80
+
81
+ const checkActiveSession =
82
+ activeSession?.provider_id === selectedPaymentMethod
83
+
84
+ if (!checkActiveSession) {
85
+ await initiatePaymentSession(cart, {
86
+ provider_id: selectedPaymentMethod,
87
+ })
88
+ }
89
+
90
+ if (!shouldInputCard) {
91
+ return router.push(
92
+ pathname + "?" + createQueryString("step", "review"),
93
+ {
94
+ scroll: false,
95
+ }
96
+ )
97
+ }
98
+ } catch (err: any) {
99
+ setError(err.message)
100
+ } finally {
101
+ setIsLoading(false)
102
+ }
103
+ }
104
+
105
+ useEffect(() => {
106
+ setError(null)
107
+ }, [isOpen])
108
+
109
+ return (
110
+ <div className="bg-white">
111
+ <div className="flex flex-row items-center justify-between mb-6">
112
+ <Heading
113
+ level="h2"
114
+ className={clx(
115
+ "flex flex-row text-3xl-regular gap-x-2 items-baseline",
116
+ {
117
+ "opacity-50 pointer-events-none select-none":
118
+ !isOpen && !paymentReady,
119
+ }
120
+ )}
121
+ >
122
+ <T k="checkout.payment" />
123
+ {!isOpen && paymentReady && <CheckCircleSolid />}
124
+ </Heading>
125
+ {!isOpen && paymentReady && (
126
+ <Text>
127
+ <button
128
+ onClick={handleEdit}
129
+ className="text-ui-fg-interactive hover:text-ui-fg-interactive-hover"
130
+ data-testid="edit-payment-button"
131
+ >
132
+ <T k="form.edit" />
133
+ </button>
134
+ </Text>
135
+ )}
136
+ </div>
137
+ <div>
138
+ <div className={isOpen ? "block" : "hidden"}>
139
+ {!paidByGiftcard && availablePaymentMethods?.length && (
140
+ <>
141
+ <RadioGroup
142
+ value={selectedPaymentMethod}
143
+ onChange={(value: string) => setPaymentMethod(value)}
144
+ >
145
+ {availablePaymentMethods.map((paymentMethod) => (
146
+ <div key={paymentMethod.id}>
147
+ {isStripeLike(paymentMethod.id) ? (
148
+ <StripeCardContainer
149
+ paymentProviderId={paymentMethod.id}
150
+ selectedPaymentOptionId={selectedPaymentMethod}
151
+ paymentInfoMap={paymentInfoMap}
152
+ setCardBrand={setCardBrand}
153
+ setError={setError}
154
+ setCardComplete={setCardComplete}
155
+ />
156
+ ) : (
157
+ <PaymentContainer
158
+ paymentInfoMap={paymentInfoMap}
159
+ paymentProviderId={paymentMethod.id}
160
+ selectedPaymentOptionId={selectedPaymentMethod}
161
+ />
162
+ )}
163
+ </div>
164
+ ))}
165
+ </RadioGroup>
166
+ </>
167
+ )}
168
+
169
+ {paidByGiftcard && (
170
+ <div className="flex flex-col w-1/3">
171
+ <Text className="txt-medium-plus text-ui-fg-base mb-1">
172
+ <T k="checkout.paymentMethod" />
173
+ </Text>
174
+ <Text
175
+ className="txt-medium text-ui-fg-subtle"
176
+ data-testid="payment-method-summary"
177
+ >
178
+ <T k="checkout.giftCard" />
179
+ </Text>
180
+ </div>
181
+ )}
182
+
183
+ <ErrorMessage
184
+ error={error}
185
+ data-testid="payment-method-error-message"
186
+ />
187
+
188
+ <Button
189
+ size="large"
190
+ className="mt-6"
191
+ onClick={handleSubmit}
192
+ isLoading={isLoading}
193
+ disabled={
194
+ (isStripeLike(selectedPaymentMethod) && !cardComplete) ||
195
+ (!selectedPaymentMethod && !paidByGiftcard)
196
+ }
197
+ data-testid="submit-payment-button"
198
+ >
199
+ {!activeSession && isStripeLike(selectedPaymentMethod)
200
+ ? <T k="checkout.enterCard" />
201
+ : <T k="checkout.continueReview" />}
202
+ </Button>
203
+ </div>
204
+
205
+ <div className={isOpen ? "hidden" : "block"}>
206
+ {cart && paymentReady && activeSession ? (
207
+ <div className="flex items-start gap-x-1 w-full">
208
+ <div className="flex flex-col w-1/3">
209
+ <Text className="txt-medium-plus text-ui-fg-base mb-1">
210
+ <T k="checkout.paymentMethod" />
211
+ </Text>
212
+ <Text
213
+ className="txt-medium text-ui-fg-subtle"
214
+ data-testid="payment-method-summary"
215
+ >
216
+ {paymentInfoMap[activeSession?.provider_id]?.title ||
217
+ activeSession?.provider_id}
218
+ </Text>
219
+ </div>
220
+ <div className="flex flex-col w-1/3">
221
+ <Text className="txt-medium-plus text-ui-fg-base mb-1">
222
+ <T k="checkout.paymentDetails" />
223
+ </Text>
224
+ <div
225
+ className="flex gap-2 txt-medium text-ui-fg-subtle items-center"
226
+ data-testid="payment-details-summary"
227
+ >
228
+ <Container className="flex items-center h-7 w-fit p-2 bg-ui-button-neutral-hover">
229
+ {paymentInfoMap[selectedPaymentMethod]?.icon || (
230
+ <CreditCard />
231
+ )}
232
+ </Container>
233
+ <Text>
234
+ {isStripeLike(selectedPaymentMethod) && cardBrand
235
+ ? cardBrand
236
+ : <T k="checkout.anotherStep" />}
237
+ </Text>
238
+ </div>
239
+ </div>
240
+ </div>
241
+ ) : paidByGiftcard ? (
242
+ <div className="flex flex-col w-1/3">
243
+ <Text className="txt-medium-plus text-ui-fg-base mb-1">
244
+ <T k="checkout.paymentMethod" />
245
+ </Text>
246
+ <Text
247
+ className="txt-medium text-ui-fg-subtle"
248
+ data-testid="payment-method-summary"
249
+ >
250
+ <T k="checkout.giftCard" />
251
+ </Text>
252
+ </div>
253
+ ) : null}
254
+ </div>
255
+ </div>
256
+ <Divider className="mt-8" />
257
+ </div>
258
+ )
259
+ }
260
+
261
+ export default Payment
@@ -0,0 +1,195 @@
1
+ "use client"
2
+
3
+
4
+ import { T } from "@lib/boutique/i18n-client"
5
+ import { isManual, isStripeLike } from "@lib/constants"
6
+ import { placeOrder } from "@lib/data/cart"
7
+ import { HttpTypes } from "@medusajs/types"
8
+ import { Button } from "@medusajs/ui"
9
+ import { useElements, useStripe } from "@stripe/react-stripe-js"
10
+ import React, { useState } from "react"
11
+ import ErrorMessage from "../error-message"
12
+
13
+ type PaymentButtonProps = {
14
+ cart: HttpTypes.StoreCart
15
+ "data-testid": string
16
+ }
17
+
18
+ const PaymentButton: React.FC<PaymentButtonProps> = ({
19
+ cart,
20
+ "data-testid": dataTestId,
21
+ }) => {
22
+ const notReady =
23
+ !cart ||
24
+ !cart.shipping_address ||
25
+ !cart.billing_address ||
26
+ !cart.email ||
27
+ (cart.shipping_methods?.length ?? 0) < 1
28
+
29
+ const paymentSession = cart.payment_collection?.payment_sessions?.[0]
30
+
31
+ switch (true) {
32
+ case isStripeLike(paymentSession?.provider_id):
33
+ return (
34
+ <StripePaymentButton
35
+ notReady={notReady}
36
+ cart={cart}
37
+ data-testid={dataTestId}
38
+ />
39
+ )
40
+ case isManual(paymentSession?.provider_id):
41
+ return (
42
+ <ManualTestPaymentButton notReady={notReady} data-testid={dataTestId} />
43
+ )
44
+ default:
45
+ return <Button disabled><T k="checkout.selectPayment" /></Button>
46
+ }
47
+ }
48
+
49
+ const StripePaymentButton = ({
50
+ cart,
51
+ notReady,
52
+ "data-testid": dataTestId,
53
+ }: {
54
+ cart: HttpTypes.StoreCart
55
+ notReady: boolean
56
+ "data-testid"?: string
57
+ }) => {
58
+ const [submitting, setSubmitting] = useState(false)
59
+ const [errorMessage, setErrorMessage] = useState<string | null>(null)
60
+
61
+ const onPaymentCompleted = async () => {
62
+ await placeOrder()
63
+ .catch((err) => {
64
+ setErrorMessage(err.message)
65
+ })
66
+ .finally(() => {
67
+ setSubmitting(false)
68
+ })
69
+ }
70
+
71
+ const stripe = useStripe()
72
+ const elements = useElements()
73
+ const card = elements?.getElement("card")
74
+
75
+ const session = cart.payment_collection?.payment_sessions?.find(
76
+ (s) => s.status === "pending"
77
+ )
78
+
79
+ const disabled = !stripe || !elements ? true : false
80
+
81
+ const handlePayment = async () => {
82
+ setSubmitting(true)
83
+
84
+ if (!stripe || !elements || !card || !cart) {
85
+ setSubmitting(false)
86
+ return
87
+ }
88
+
89
+ await stripe
90
+ .confirmCardPayment(session?.data.client_secret as string, {
91
+ payment_method: {
92
+ card: card,
93
+ billing_details: {
94
+ name:
95
+ cart.billing_address?.first_name +
96
+ " " +
97
+ cart.billing_address?.last_name,
98
+ address: {
99
+ city: cart.billing_address?.city ?? undefined,
100
+ country: cart.billing_address?.country_code ?? undefined,
101
+ line1: cart.billing_address?.address_1 ?? undefined,
102
+ line2: cart.billing_address?.address_2 ?? undefined,
103
+ postal_code: cart.billing_address?.postal_code ?? undefined,
104
+ state: cart.billing_address?.province ?? undefined,
105
+ },
106
+ email: cart.email,
107
+ phone: cart.billing_address?.phone ?? undefined,
108
+ },
109
+ },
110
+ })
111
+ .then(({ error, paymentIntent }) => {
112
+ if (error) {
113
+ const pi = error.payment_intent
114
+
115
+ if (
116
+ (pi && pi.status === "requires_capture") ||
117
+ (pi && pi.status === "succeeded")
118
+ ) {
119
+ onPaymentCompleted()
120
+ }
121
+
122
+ setErrorMessage(error.message || null)
123
+ return
124
+ }
125
+
126
+ if (
127
+ (paymentIntent && paymentIntent.status === "requires_capture") ||
128
+ paymentIntent.status === "succeeded"
129
+ ) {
130
+ return onPaymentCompleted()
131
+ }
132
+
133
+ return
134
+ })
135
+ }
136
+
137
+ return (
138
+ <>
139
+ <Button
140
+ disabled={disabled || notReady}
141
+ onClick={handlePayment}
142
+ size="large"
143
+ isLoading={submitting}
144
+ data-testid={dataTestId}
145
+ >
146
+ <T k="checkout.placeOrder" />
147
+ </Button>
148
+ <ErrorMessage
149
+ error={errorMessage}
150
+ data-testid="stripe-payment-error-message"
151
+ />
152
+ </>
153
+ )
154
+ }
155
+
156
+ const ManualTestPaymentButton = ({ notReady }: { notReady: boolean }) => {
157
+ const [submitting, setSubmitting] = useState(false)
158
+ const [errorMessage, setErrorMessage] = useState<string | null>(null)
159
+
160
+ const onPaymentCompleted = async () => {
161
+ await placeOrder()
162
+ .catch((err) => {
163
+ setErrorMessage(err.message)
164
+ })
165
+ .finally(() => {
166
+ setSubmitting(false)
167
+ })
168
+ }
169
+
170
+ const handlePayment = () => {
171
+ setSubmitting(true)
172
+
173
+ onPaymentCompleted()
174
+ }
175
+
176
+ return (
177
+ <>
178
+ <Button
179
+ disabled={notReady}
180
+ isLoading={submitting}
181
+ onClick={handlePayment}
182
+ size="large"
183
+ data-testid="submit-order-button"
184
+ >
185
+ <T k="checkout.placeOrder" />
186
+ </Button>
187
+ <ErrorMessage
188
+ error={errorMessage}
189
+ data-testid="manual-payment-error-message"
190
+ />
191
+ </>
192
+ )
193
+ }
194
+
195
+ export default PaymentButton
@@ -0,0 +1,130 @@
1
+ import { T } from "@lib/boutique/i18n-client"
2
+ import { Radio as RadioGroupOption } from "@headlessui/react"
3
+ import { Text, clx } from "@medusajs/ui"
4
+ import React, { useContext, useMemo, type JSX } from "react"
5
+
6
+ import Radio from "@modules/common/components/radio"
7
+
8
+ import { isManual } from "@lib/constants"
9
+ import SkeletonCardDetails from "@modules/skeletons/components/skeleton-card-details"
10
+ import { CardElement } from "@stripe/react-stripe-js"
11
+ import { StripeCardElementOptions } from "@stripe/stripe-js"
12
+ import PaymentTest from "../payment-test"
13
+ import { StripeContext } from "../payment-wrapper/stripe-wrapper"
14
+
15
+ type PaymentContainerProps = {
16
+ paymentProviderId: string
17
+ selectedPaymentOptionId: string | null
18
+ disabled?: boolean
19
+ paymentInfoMap: Record<string, { title: string; icon: JSX.Element }>
20
+ children?: React.ReactNode
21
+ }
22
+
23
+ const PaymentContainer: React.FC<PaymentContainerProps> = ({
24
+ paymentProviderId,
25
+ selectedPaymentOptionId,
26
+ paymentInfoMap,
27
+ disabled = false,
28
+ children,
29
+ }) => {
30
+ const isDevelopment = process.env.NODE_ENV === "development"
31
+
32
+ return (
33
+ <RadioGroupOption
34
+ key={paymentProviderId}
35
+ value={paymentProviderId}
36
+ disabled={disabled}
37
+ className={clx(
38
+ "flex flex-col gap-y-2 text-small-regular cursor-pointer py-4 border rounded-rounded px-8 mb-2 hover:shadow-borders-interactive-with-active",
39
+ {
40
+ "border-ui-border-interactive":
41
+ selectedPaymentOptionId === paymentProviderId,
42
+ }
43
+ )}
44
+ >
45
+ <div className="flex items-center justify-between ">
46
+ <div className="flex items-center gap-x-4">
47
+ <Radio checked={selectedPaymentOptionId === paymentProviderId} />
48
+ <Text className="text-base-regular">
49
+ {paymentInfoMap[paymentProviderId]?.title || paymentProviderId}
50
+ </Text>
51
+ {isManual(paymentProviderId) && isDevelopment && (
52
+ <PaymentTest className="hidden small:block" />
53
+ )}
54
+ </div>
55
+ <span className="justify-self-end text-ui-fg-base">
56
+ {paymentInfoMap[paymentProviderId]?.icon}
57
+ </span>
58
+ </div>
59
+ {isManual(paymentProviderId) && isDevelopment && (
60
+ <PaymentTest className="small:hidden text-[10px]" />
61
+ )}
62
+ {children}
63
+ </RadioGroupOption>
64
+ )
65
+ }
66
+
67
+ export default PaymentContainer
68
+
69
+ export const StripeCardContainer = ({
70
+ paymentProviderId,
71
+ selectedPaymentOptionId,
72
+ paymentInfoMap,
73
+ disabled = false,
74
+ setCardBrand,
75
+ setError,
76
+ setCardComplete,
77
+ }: Omit<PaymentContainerProps, "children"> & {
78
+ setCardBrand: (brand: string) => void
79
+ setError: (error: string | null) => void
80
+ setCardComplete: (complete: boolean) => void
81
+ }) => {
82
+ const stripeReady = useContext(StripeContext)
83
+
84
+ const useOptions: StripeCardElementOptions = useMemo(() => {
85
+ return {
86
+ style: {
87
+ base: {
88
+ fontFamily: "inherit",
89
+ color: "#424270",
90
+ "::placeholder": {
91
+ color: "rgb(107 114 128)",
92
+ },
93
+ },
94
+ },
95
+ classes: {
96
+ base: "pt-3 pb-1 block w-full h-11 px-4 mt-0 bg-ui-bg-field border rounded-md appearance-none focus:outline-none focus:ring-0 focus:shadow-borders-interactive-with-active border-ui-border-base hover:bg-ui-bg-field-hover transition-all duration-300 ease-in-out",
97
+ },
98
+ }
99
+ }, [])
100
+
101
+ return (
102
+ <PaymentContainer
103
+ paymentProviderId={paymentProviderId}
104
+ selectedPaymentOptionId={selectedPaymentOptionId}
105
+ paymentInfoMap={paymentInfoMap}
106
+ disabled={disabled}
107
+ >
108
+ {selectedPaymentOptionId === paymentProviderId &&
109
+ (stripeReady ? (
110
+ <div className="my-4 transition-all duration-150 ease-in-out">
111
+ <Text className="txt-medium-plus text-ui-fg-base mb-1">
112
+ <T k="checkout.cardDetails" />
113
+ </Text>
114
+ <CardElement
115
+ options={useOptions as StripeCardElementOptions}
116
+ onChange={(e) => {
117
+ setCardBrand(
118
+ e.brand && e.brand.charAt(0).toUpperCase() + e.brand.slice(1)
119
+ )
120
+ setError(e.error?.message || null)
121
+ setCardComplete(e.complete)
122
+ }}
123
+ />
124
+ </div>
125
+ ) : (
126
+ <SkeletonCardDetails />
127
+ ))}
128
+ </PaymentContainer>
129
+ )
130
+ }
@@ -0,0 +1,12 @@
1
+ import { Badge } from "@medusajs/ui"
2
+
3
+ const PaymentTest = ({ className }: { className?: string }) => {
4
+ return (
5
+ <Badge color="orange" className={className}>
6
+ <span className="font-semibold">Attention:</span> For testing purposes
7
+ only.
8
+ </Badge>
9
+ )
10
+ }
11
+
12
+ export default PaymentTest
@@ -0,0 +1,42 @@
1
+ "use client"
2
+
3
+ import { loadStripe } from "@stripe/stripe-js"
4
+ import React, { useMemo } from "react"
5
+ import StripeWrapper from "./stripe-wrapper"
6
+ import { HttpTypes } from "@medusajs/types"
7
+ import { isStripeLike } from "@lib/constants"
8
+
9
+ type PaymentWrapperProps = {
10
+ cart: HttpTypes.StoreCart
11
+ /** Clé publique Stripe lue à l'exécution côté serveur (STRIPE_PUBLISHABLE_KEY) : pas de NEXT_PUBLIC_* figée au build. */
12
+ stripeKey?: string
13
+ children: React.ReactNode
14
+ }
15
+
16
+ const PaymentWrapper: React.FC<PaymentWrapperProps> = ({ cart, stripeKey, children }) => {
17
+ const stripePromise = useMemo(() => (stripeKey ? loadStripe(stripeKey) : null), [stripeKey])
18
+
19
+ const paymentSession = cart.payment_collection?.payment_sessions?.find(
20
+ (s) => s.status === "pending"
21
+ )
22
+
23
+ if (
24
+ isStripeLike(paymentSession?.provider_id) &&
25
+ paymentSession &&
26
+ stripePromise
27
+ ) {
28
+ return (
29
+ <StripeWrapper
30
+ paymentSession={paymentSession}
31
+ stripeKey={stripeKey}
32
+ stripePromise={stripePromise}
33
+ >
34
+ {children}
35
+ </StripeWrapper>
36
+ )
37
+ }
38
+
39
+ return <div>{children}</div>
40
+ }
41
+
42
+ export default PaymentWrapper
@@ -0,0 +1,54 @@
1
+ "use client"
2
+
3
+ import { Stripe, StripeElementsOptions } from "@stripe/stripe-js"
4
+ import { Elements } from "@stripe/react-stripe-js"
5
+ import { HttpTypes } from "@medusajs/types"
6
+ import { createContext } from "react"
7
+
8
+ type StripeWrapperProps = {
9
+ paymentSession: HttpTypes.StorePaymentSession
10
+ stripeKey?: string
11
+ stripePromise: Promise<Stripe | null> | null
12
+ children: React.ReactNode
13
+ }
14
+
15
+ export const StripeContext = createContext(false)
16
+
17
+ const StripeWrapper: React.FC<StripeWrapperProps> = ({
18
+ paymentSession,
19
+ stripeKey,
20
+ stripePromise,
21
+ children,
22
+ }) => {
23
+ const options: StripeElementsOptions = {
24
+ clientSecret: paymentSession!.data?.client_secret as string | undefined,
25
+ }
26
+
27
+ if (!stripeKey) {
28
+ throw new Error(
29
+ "Stripe key is missing. Set STRIPE_PUBLISHABLE_KEY in the project .env."
30
+ )
31
+ }
32
+
33
+ if (!stripePromise) {
34
+ throw new Error(
35
+ "Stripe promise is missing. Make sure you have provided a valid Stripe key."
36
+ )
37
+ }
38
+
39
+ if (!paymentSession?.data?.client_secret) {
40
+ throw new Error(
41
+ "Stripe client secret is missing. Cannot initialize Stripe."
42
+ )
43
+ }
44
+
45
+ return (
46
+ <StripeContext.Provider value={true}>
47
+ <Elements options={options} stripe={stripePromise}>
48
+ {children}
49
+ </Elements>
50
+ </StripeContext.Provider>
51
+ )
52
+ }
53
+
54
+ export default StripeWrapper