@merchi/cart 1.4.4

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 (372) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +134 -0
  3. package/esm/Cart.js +62 -0
  4. package/esm/CartAlert.js +47 -0
  5. package/esm/CartHeader.js +29 -0
  6. package/esm/CartProvider.js +1101 -0
  7. package/esm/CartTotals.js +89 -0
  8. package/esm/assets/merchi-monster-loader.gif +0 -0
  9. package/esm/assets/merchi-swipe-outline.png +0 -0
  10. package/esm/assets/product-not-found.png +0 -0
  11. package/esm/assets/stripe-payment-secure.png +0 -0
  12. package/esm/buttons/Button.js +23 -0
  13. package/esm/buttons/ButtonBack.js +35 -0
  14. package/esm/buttons/ButtonClearCart.js +17 -0
  15. package/esm/buttons/ButtonInvoiceDownload.js +88 -0
  16. package/esm/buttons/ButtonNext.js +39 -0
  17. package/esm/buttons/ButtonNextDynamic.js +19 -0
  18. package/esm/buttons/ButtonOpenCartMerchiCartModal.js +47 -0
  19. package/esm/buttons/ButtonPay.js +26 -0
  20. package/esm/buttons/ButtonShipmentTabNext.js +28 -0
  21. package/esm/buttons/index.js +7 -0
  22. package/esm/components/Alert.js +26 -0
  23. package/esm/components/CartBody.js +14 -0
  24. package/esm/components/CartClient.js +62 -0
  25. package/esm/components/CartFooter.js +12 -0
  26. package/esm/components/CartItemRow.js +230 -0
  27. package/esm/components/CartPaymentSettingsInvalid.js +13 -0
  28. package/esm/components/CartShipment.js +52 -0
  29. package/esm/components/CartTabContent.js +12 -0
  30. package/esm/components/CartTabPanel.js +25 -0
  31. package/esm/components/CartTableContainer.js +12 -0
  32. package/esm/components/CartTitle.js +26 -0
  33. package/esm/components/CartTotalsListGroup.js +71 -0
  34. package/esm/components/Collapse.js +32 -0
  35. package/esm/components/CustomCartProductForm.js +128 -0
  36. package/esm/components/CustomerCheckoutMethodTabs.js +94 -0
  37. package/esm/components/DiscountInputGroup.js +293 -0
  38. package/esm/components/LoadingTemplate.js +23 -0
  39. package/esm/components/NoCartItems.js +20 -0
  40. package/esm/components/ShipmentGroupCard.js +207 -0
  41. package/esm/components/Table.js +13 -0
  42. package/esm/components/containers.js +31 -0
  43. package/esm/components/index.js +18 -0
  44. package/esm/components/product-form-sdk-externals.js +36 -0
  45. package/esm/forms/FormNewCustomer.js +243 -0
  46. package/esm/forms/FormReturningCustomer.js +165 -0
  47. package/esm/forms/FormShipmentAddressAndNotes.js +195 -0
  48. package/esm/forms/FormSquarePayment.js +19 -0
  49. package/esm/forms/FormStripePayment.js +19 -0
  50. package/esm/forms/FormWhatsappCustomer.js +253 -0
  51. package/esm/forms/InputAcceptUserTermsAndConditions.js +35 -0
  52. package/esm/forms/InputError.js +16 -0
  53. package/esm/forms/InputSelect.js +48 -0
  54. package/esm/forms/InputText.js +56 -0
  55. package/esm/forms/InputsAddress.js +476 -0
  56. package/esm/forms/index.js +8 -0
  57. package/esm/index.js +13 -0
  58. package/esm/modals.js +51 -0
  59. package/esm/panels/PanelCartItems.js +49 -0
  60. package/esm/panels/PanelCartShipment.js +66 -0
  61. package/esm/panels/PanelClearCart.js +56 -0
  62. package/esm/panels/PanelClientCheckout.js +81 -0
  63. package/esm/panels/PanelEditCartItem.js +199 -0
  64. package/esm/panels/PanelPaymentSuccess.js +63 -0
  65. package/esm/panels/index.js +7 -0
  66. package/esm/square/SquareCard.js +106 -0
  67. package/esm/stripe/LegacyStripeCardForm.js +157 -0
  68. package/esm/stripe/StripeCardFields.js +126 -0
  69. package/esm/stripe/StripeCardForm.js +33 -0
  70. package/esm/stripe/StripePaymentButtons.js +98 -0
  71. package/esm/stripe/actions.js +192 -0
  72. package/esm/stripe/utils.js +20 -0
  73. package/esm/styles/globals.css +463 -0
  74. package/esm/styles/globals.css.map +1 -0
  75. package/esm/tabs/CartNav.js +28 -0
  76. package/esm/tabs/NavTab.js +31 -0
  77. package/esm/types/assets.d.js +0 -0
  78. package/esm/types/index.js +1 -0
  79. package/esm/types/merchi_product_form/index.d.js +0 -0
  80. package/esm/types/merchi_sdk_ts/index.d.js +0 -0
  81. package/esm/types/react-redux/index.d.js +0 -0
  82. package/esm/utilities/address.js +457 -0
  83. package/esm/utilities/area.js +297 -0
  84. package/esm/utilities/cart.js +95 -0
  85. package/esm/utilities/company.js +6 -0
  86. package/esm/utilities/cookie.js +156 -0
  87. package/esm/utilities/currency.js +219 -0
  88. package/esm/utilities/customForm.js +57 -0
  89. package/esm/utilities/helpers.js +229 -0
  90. package/esm/utilities/index.js +14 -0
  91. package/esm/utilities/invoice.js +112 -0
  92. package/esm/utilities/job.js +9 -0
  93. package/esm/utilities/local_storage.js +85 -0
  94. package/esm/utilities/product.js +13 -0
  95. package/esm/utilities/shipment.js +11 -0
  96. package/esm/utilities/tabs.js +51 -0
  97. package/esm/utilities/user.js +65 -0
  98. package/esm/utilities/variations.js +58 -0
  99. package/lib/Cart.d.ts +9 -0
  100. package/lib/Cart.js +69 -0
  101. package/lib/CartAlert.d.ts +3 -0
  102. package/lib/CartAlert.js +53 -0
  103. package/lib/CartHeader.d.ts +3 -0
  104. package/lib/CartHeader.js +37 -0
  105. package/lib/CartProvider.d.ts +236 -0
  106. package/lib/CartProvider.js +1107 -0
  107. package/lib/CartTotals.d.ts +7 -0
  108. package/lib/CartTotals.js +96 -0
  109. package/lib/assets/merchi-monster-loader.gif +0 -0
  110. package/lib/assets/merchi-swipe-outline.png +0 -0
  111. package/lib/assets/product-not-found.png +0 -0
  112. package/lib/assets/stripe-payment-secure.png +0 -0
  113. package/lib/buttons/Button.d.ts +11 -0
  114. package/lib/buttons/Button.js +31 -0
  115. package/lib/buttons/ButtonBack.d.ts +6 -0
  116. package/lib/buttons/ButtonBack.js +44 -0
  117. package/lib/buttons/ButtonClearCart.d.ts +3 -0
  118. package/lib/buttons/ButtonClearCart.js +24 -0
  119. package/lib/buttons/ButtonInvoiceDownload.d.ts +3 -0
  120. package/lib/buttons/ButtonInvoiceDownload.js +96 -0
  121. package/lib/buttons/ButtonNext.d.ts +3 -0
  122. package/lib/buttons/ButtonNext.js +48 -0
  123. package/lib/buttons/ButtonNextDynamic.d.ts +3 -0
  124. package/lib/buttons/ButtonNextDynamic.js +28 -0
  125. package/lib/buttons/ButtonOpenCartMerchiCartModal.d.ts +9 -0
  126. package/lib/buttons/ButtonOpenCartMerchiCartModal.js +57 -0
  127. package/lib/buttons/ButtonPay.d.ts +7 -0
  128. package/lib/buttons/ButtonPay.js +35 -0
  129. package/lib/buttons/ButtonShipmentTabNext.d.ts +2 -0
  130. package/lib/buttons/ButtonShipmentTabNext.js +37 -0
  131. package/lib/buttons/index.d.ts +7 -0
  132. package/lib/buttons/index.js +48 -0
  133. package/lib/components/Alert.d.ts +7 -0
  134. package/lib/components/Alert.js +34 -0
  135. package/lib/components/CartBody.d.ts +7 -0
  136. package/lib/components/CartBody.js +22 -0
  137. package/lib/components/CartClient.d.ts +4 -0
  138. package/lib/components/CartClient.js +71 -0
  139. package/lib/components/CartFooter.d.ts +6 -0
  140. package/lib/components/CartFooter.js +20 -0
  141. package/lib/components/CartItemRow.d.ts +7 -0
  142. package/lib/components/CartItemRow.js +236 -0
  143. package/lib/components/CartPaymentSettingsInvalid.d.ts +2 -0
  144. package/lib/components/CartPaymentSettingsInvalid.js +21 -0
  145. package/lib/components/CartShipment.d.ts +6 -0
  146. package/lib/components/CartShipment.js +59 -0
  147. package/lib/components/CartTabContent.d.ts +6 -0
  148. package/lib/components/CartTabContent.js +20 -0
  149. package/lib/components/CartTabPanel.d.ts +7 -0
  150. package/lib/components/CartTabPanel.js +31 -0
  151. package/lib/components/CartTableContainer.d.ts +6 -0
  152. package/lib/components/CartTableContainer.js +20 -0
  153. package/lib/components/CartTitle.d.ts +2 -0
  154. package/lib/components/CartTitle.js +34 -0
  155. package/lib/components/CartTotalsListGroup.d.ts +3 -0
  156. package/lib/components/CartTotalsListGroup.js +78 -0
  157. package/lib/components/Collapse.d.ts +3 -0
  158. package/lib/components/Collapse.js +40 -0
  159. package/lib/components/CustomCartProductForm.d.ts +18 -0
  160. package/lib/components/CustomCartProductForm.js +136 -0
  161. package/lib/components/CustomerCheckoutMethodTabs.d.ts +6 -0
  162. package/lib/components/CustomerCheckoutMethodTabs.js +103 -0
  163. package/lib/components/DiscountInputGroup.d.ts +2 -0
  164. package/lib/components/DiscountInputGroup.js +301 -0
  165. package/lib/components/LoadingTemplate.d.ts +7 -0
  166. package/lib/components/LoadingTemplate.js +30 -0
  167. package/lib/components/NoCartItems.d.ts +3 -0
  168. package/lib/components/NoCartItems.js +27 -0
  169. package/lib/components/ShipmentGroupCard.d.ts +7 -0
  170. package/lib/components/ShipmentGroupCard.js +215 -0
  171. package/lib/components/Table.d.ts +7 -0
  172. package/lib/components/Table.js +19 -0
  173. package/lib/components/containers.d.ts +14 -0
  174. package/lib/components/containers.js +40 -0
  175. package/lib/components/index.d.ts +18 -0
  176. package/lib/components/index.js +133 -0
  177. package/lib/components/product-form-sdk-externals.d.ts +46 -0
  178. package/lib/components/product-form-sdk-externals.js +43 -0
  179. package/lib/forms/FormNewCustomer.d.ts +4 -0
  180. package/lib/forms/FormNewCustomer.js +252 -0
  181. package/lib/forms/FormReturningCustomer.d.ts +3 -0
  182. package/lib/forms/FormReturningCustomer.js +173 -0
  183. package/lib/forms/FormShipmentAddressAndNotes.d.ts +15 -0
  184. package/lib/forms/FormShipmentAddressAndNotes.js +203 -0
  185. package/lib/forms/FormSquarePayment.d.ts +3 -0
  186. package/lib/forms/FormSquarePayment.js +27 -0
  187. package/lib/forms/FormStripePayment.d.ts +3 -0
  188. package/lib/forms/FormStripePayment.js +27 -0
  189. package/lib/forms/FormWhatsappCustomer.d.ts +3 -0
  190. package/lib/forms/FormWhatsappCustomer.js +261 -0
  191. package/lib/forms/InputAcceptUserTermsAndConditions.d.ts +7 -0
  192. package/lib/forms/InputAcceptUserTermsAndConditions.js +41 -0
  193. package/lib/forms/InputError.d.ts +8 -0
  194. package/lib/forms/InputError.js +24 -0
  195. package/lib/forms/InputSelect.d.ts +14 -0
  196. package/lib/forms/InputSelect.js +55 -0
  197. package/lib/forms/InputText.d.ts +12 -0
  198. package/lib/forms/InputText.js +63 -0
  199. package/lib/forms/InputsAddress.d.ts +11 -0
  200. package/lib/forms/InputsAddress.js +485 -0
  201. package/lib/forms/index.d.ts +8 -0
  202. package/lib/forms/index.js +63 -0
  203. package/lib/index.d.ts +13 -0
  204. package/lib/index.js +93 -0
  205. package/lib/modals.d.ts +17 -0
  206. package/lib/modals.js +59 -0
  207. package/lib/panels/PanelCartItems.d.ts +3 -0
  208. package/lib/panels/PanelCartItems.js +56 -0
  209. package/lib/panels/PanelCartShipment.d.ts +3 -0
  210. package/lib/panels/PanelCartShipment.js +72 -0
  211. package/lib/panels/PanelClearCart.d.ts +3 -0
  212. package/lib/panels/PanelClearCart.js +62 -0
  213. package/lib/panels/PanelClientCheckout.d.ts +3 -0
  214. package/lib/panels/PanelClientCheckout.js +88 -0
  215. package/lib/panels/PanelEditCartItem.d.ts +6 -0
  216. package/lib/panels/PanelEditCartItem.js +206 -0
  217. package/lib/panels/PanelPaymentSuccess.d.ts +3 -0
  218. package/lib/panels/PanelPaymentSuccess.js +69 -0
  219. package/lib/panels/index.d.ts +7 -0
  220. package/lib/panels/index.js +48 -0
  221. package/lib/square/SquareCard.d.ts +3 -0
  222. package/lib/square/SquareCard.js +114 -0
  223. package/lib/stripe/LegacyStripeCardForm.d.ts +3 -0
  224. package/lib/stripe/LegacyStripeCardForm.js +166 -0
  225. package/lib/stripe/StripeCardFields.d.ts +15 -0
  226. package/lib/stripe/StripeCardFields.js +135 -0
  227. package/lib/stripe/StripeCardForm.d.ts +2 -0
  228. package/lib/stripe/StripeCardForm.js +42 -0
  229. package/lib/stripe/StripePaymentButtons.d.ts +8 -0
  230. package/lib/stripe/StripePaymentButtons.js +106 -0
  231. package/lib/stripe/actions.d.ts +4 -0
  232. package/lib/stripe/actions.js +200 -0
  233. package/lib/stripe/utils.d.ts +18 -0
  234. package/lib/stripe/utils.js +27 -0
  235. package/lib/styles/globals.css +463 -0
  236. package/lib/styles/globals.css.map +1 -0
  237. package/lib/tabs/CartNav.d.ts +3 -0
  238. package/lib/tabs/CartNav.js +36 -0
  239. package/lib/tabs/NavTab.d.ts +9 -0
  240. package/lib/tabs/NavTab.js +39 -0
  241. package/lib/types/index.d.ts +13 -0
  242. package/lib/types/index.js +1 -0
  243. package/lib/utilities/address.d.ts +30 -0
  244. package/lib/utilities/address.js +468 -0
  245. package/lib/utilities/area.d.ts +77 -0
  246. package/lib/utilities/area.js +328 -0
  247. package/lib/utilities/cart.d.ts +9 -0
  248. package/lib/utilities/cart.js +108 -0
  249. package/lib/utilities/company.d.ts +2 -0
  250. package/lib/utilities/company.js +13 -0
  251. package/lib/utilities/cookie.d.ts +4 -0
  252. package/lib/utilities/cookie.js +165 -0
  253. package/lib/utilities/currency.d.ts +5 -0
  254. package/lib/utilities/currency.js +229 -0
  255. package/lib/utilities/customForm.d.ts +17 -0
  256. package/lib/utilities/customForm.js +64 -0
  257. package/lib/utilities/helpers.d.ts +24 -0
  258. package/lib/utilities/helpers.js +240 -0
  259. package/lib/utilities/index.d.ts +14 -0
  260. package/lib/utilities/index.js +159 -0
  261. package/lib/utilities/invoice.d.ts +3 -0
  262. package/lib/utilities/invoice.js +118 -0
  263. package/lib/utilities/job.d.ts +1 -0
  264. package/lib/utilities/job.js +15 -0
  265. package/lib/utilities/local_storage.d.ts +31 -0
  266. package/lib/utilities/local_storage.js +96 -0
  267. package/lib/utilities/product.d.ts +2 -0
  268. package/lib/utilities/product.js +21 -0
  269. package/lib/utilities/shipment.d.ts +2 -0
  270. package/lib/utilities/shipment.js +18 -0
  271. package/lib/utilities/tabs.d.ts +14 -0
  272. package/lib/utilities/tabs.js +60 -0
  273. package/lib/utilities/user.d.ts +5 -0
  274. package/lib/utilities/user.js +75 -0
  275. package/lib/utilities/variations.d.ts +18 -0
  276. package/lib/utilities/variations.js +66 -0
  277. package/package.json +109 -0
  278. package/src/Cart.tsx +96 -0
  279. package/src/CartAlert.tsx +35 -0
  280. package/src/CartHeader.tsx +28 -0
  281. package/src/CartProvider.tsx +992 -0
  282. package/src/CartTotals.tsx +102 -0
  283. package/src/assets/merchi-monster-loader.gif +0 -0
  284. package/src/assets/merchi-swipe-outline.png +0 -0
  285. package/src/assets/product-not-found.png +0 -0
  286. package/src/assets/stripe-payment-secure.png +0 -0
  287. package/src/buttons/Button.tsx +35 -0
  288. package/src/buttons/ButtonBack.tsx +42 -0
  289. package/src/buttons/ButtonClearCart.tsx +17 -0
  290. package/src/buttons/ButtonInvoiceDownload.tsx +60 -0
  291. package/src/buttons/ButtonNext.tsx +35 -0
  292. package/src/buttons/ButtonNextDynamic.tsx +31 -0
  293. package/src/buttons/ButtonOpenCartMerchiCartModal.tsx +61 -0
  294. package/src/buttons/ButtonPay.tsx +32 -0
  295. package/src/buttons/ButtonShipmentTabNext.tsx +24 -0
  296. package/src/buttons/index.ts +15 -0
  297. package/src/components/Alert.tsx +31 -0
  298. package/src/components/CartBody.tsx +16 -0
  299. package/src/components/CartClient.tsx +52 -0
  300. package/src/components/CartFooter.tsx +15 -0
  301. package/src/components/CartItemRow.tsx +212 -0
  302. package/src/components/CartPaymentSettingsInvalid.tsx +12 -0
  303. package/src/components/CartShipment.tsx +56 -0
  304. package/src/components/CartTabContent.tsx +15 -0
  305. package/src/components/CartTabPanel.tsx +25 -0
  306. package/src/components/CartTableContainer.tsx +15 -0
  307. package/src/components/CartTitle.tsx +22 -0
  308. package/src/components/CartTotalsListGroup.tsx +58 -0
  309. package/src/components/Collapse.tsx +23 -0
  310. package/src/components/CustomCartProductForm.tsx +123 -0
  311. package/src/components/CustomerCheckoutMethodTabs.tsx +106 -0
  312. package/src/components/DiscountInputGroup.tsx +160 -0
  313. package/src/components/LoadingTemplate.tsx +22 -0
  314. package/src/components/NoCartItems.tsx +20 -0
  315. package/src/components/ShipmentGroupCard.tsx +170 -0
  316. package/src/components/Table.tsx +15 -0
  317. package/src/components/containers.tsx +40 -0
  318. package/src/components/index.ts +38 -0
  319. package/src/components/product-form-sdk-externals.ts +67 -0
  320. package/src/forms/FormNewCustomer.tsx +170 -0
  321. package/src/forms/FormReturningCustomer.tsx +117 -0
  322. package/src/forms/FormShipmentAddressAndNotes.tsx +165 -0
  323. package/src/forms/FormSquarePayment.tsx +19 -0
  324. package/src/forms/FormStripePayment.tsx +19 -0
  325. package/src/forms/FormWhatsappCustomer.tsx +179 -0
  326. package/src/forms/InputAcceptUserTermsAndConditions.tsx +43 -0
  327. package/src/forms/InputError.tsx +23 -0
  328. package/src/forms/InputSelect.tsx +58 -0
  329. package/src/forms/InputText.tsx +56 -0
  330. package/src/forms/InputsAddress.tsx +438 -0
  331. package/src/forms/index.ts +18 -0
  332. package/src/index.ts +31 -0
  333. package/src/modals.tsx +65 -0
  334. package/src/panels/PanelCartItems.tsx +56 -0
  335. package/src/panels/PanelCartShipment.tsx +86 -0
  336. package/src/panels/PanelClearCart.tsx +50 -0
  337. package/src/panels/PanelClientCheckout.tsx +102 -0
  338. package/src/panels/PanelEditCartItem.tsx +172 -0
  339. package/src/panels/PanelPaymentSuccess.tsx +66 -0
  340. package/src/panels/index.ts +15 -0
  341. package/src/square/SquareCard.tsx +84 -0
  342. package/src/stripe/LegacyStripeCardForm.tsx +91 -0
  343. package/src/stripe/StripeCardFields.tsx +173 -0
  344. package/src/stripe/StripeCardForm.tsx +18 -0
  345. package/src/stripe/StripePaymentButtons.tsx +117 -0
  346. package/src/stripe/actions.ts +94 -0
  347. package/src/stripe/utils.ts +22 -0
  348. package/src/styles/globals.scss +475 -0
  349. package/src/tabs/CartNav.tsx +18 -0
  350. package/src/tabs/NavTab.tsx +36 -0
  351. package/src/types/assets.d.ts +4 -0
  352. package/src/types/index.ts +15 -0
  353. package/src/types/merchi_product_form/index.d.ts +1 -0
  354. package/src/types/merchi_sdk_ts/index.d.ts +1 -0
  355. package/src/types/react-redux/index.d.ts +0 -0
  356. package/src/utilities/address.ts +463 -0
  357. package/src/utilities/area.ts +359 -0
  358. package/src/utilities/cart.ts +80 -0
  359. package/src/utilities/company.ts +8 -0
  360. package/src/utilities/cookie.ts +58 -0
  361. package/src/utilities/currency.ts +216 -0
  362. package/src/utilities/customForm.ts +71 -0
  363. package/src/utilities/helpers.ts +213 -0
  364. package/src/utilities/index.ts +14 -0
  365. package/src/utilities/invoice.ts +60 -0
  366. package/src/utilities/job.ts +13 -0
  367. package/src/utilities/local_storage.ts +130 -0
  368. package/src/utilities/product.ts +14 -0
  369. package/src/utilities/shipment.ts +11 -0
  370. package/src/utilities/tabs.ts +38 -0
  371. package/src/utilities/user.ts +33 -0
  372. package/src/utilities/variations.ts +80 -0
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _containers = require("../components/containers");
8
+ var _tabs = require("../utilities/tabs");
9
+ var _company = require("../utilities/company");
10
+ var _reactFontawesome = require("@fortawesome/react-fontawesome");
11
+ var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
12
+ var _buttons = require("../buttons");
13
+ var _components = require("../components");
14
+ var _CartProvider = require("../CartProvider");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ function PanelPaymentSuccess() {
17
+ var _useCartContext = (0, _CartProvider.useCartContext)(),
18
+ classNameBtnPrimary = _useCartContext.classNameBtnPrimary,
19
+ customSuccessMessage = _useCartContext.customSuccessMessage,
20
+ fetchingCart = _useCartContext.fetchingCart,
21
+ invoiceJson = _useCartContext.invoiceJson,
22
+ setCartComplete = _useCartContext.setCartComplete,
23
+ urlTrackingPage = _useCartContext.urlTrackingPage;
24
+ var domain = invoiceJson.domain,
25
+ id = invoiceJson.id,
26
+ unpaid = invoiceJson.unpaid;
27
+ var email = domain && domain.company ? (0, _company.companyPrimaryAddress)(domain.company) : null;
28
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CartTabPanel, {
29
+ tabId: _tabs.tabIdPaymentSuccess,
30
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.CartBody, {
31
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_containers.CheckoutContainer, {
32
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_containers.InnerContainer, {
33
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
34
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
35
+ icon: _freeSolidSvgIcons.faCheckCircle
36
+ })
37
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
38
+ children: ["Order #", id]
39
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("h4", {
40
+ children: "Payment Received!"
41
+ }), customSuccessMessage ? /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
42
+ className: "merchi-cart-success-message ",
43
+ children: customSuccessMessage
44
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
45
+ className: "merchi-cart-success-message ",
46
+ children: ["Your order #", id, " is being processed and you should receive an email from us shortly. If you haven't heard from us within 24 hours please feel free to contact us", email ? " at ".concat(email.emailAddress, ".") : '.']
47
+ }), !unpaid && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
48
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_buttons.ButtonInvoiceDownload, {})
49
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
50
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_buttons.Button, {
51
+ className: classNameBtnPrimary,
52
+ disabled: fetchingCart,
53
+ onClick: setCartComplete,
54
+ children: fetchingCart ? 'Loading...' : 'Done'
55
+ })
56
+ })]
57
+ })
58
+ }), urlTrackingPage && /*#__PURE__*/(0, _jsxRuntime.jsx)("iframe", {
59
+ style: {
60
+ height: '1px',
61
+ left: '0px',
62
+ width: '1px'
63
+ },
64
+ src: urlTrackingPage
65
+ })]
66
+ })
67
+ });
68
+ }
69
+ var _default = exports["default"] = PanelPaymentSuccess;
@@ -0,0 +1,7 @@
1
+ import PanelCartItems from "./PanelCartItems";
2
+ import PanelCartShipment from "./PanelCartShipment";
3
+ import PanelClearCart from "./PanelClearCart";
4
+ import PanelClientCheckout from "./PanelClientCheckout";
5
+ import PanelEditCartItem from "./PanelEditCartItem";
6
+ import PanelPaymentSuccess from "./PanelPaymentSuccess";
7
+ export { PanelCartItems, PanelCartShipment, PanelClearCart, PanelClientCheckout, PanelPaymentSuccess, PanelEditCartItem, };
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "PanelCartItems", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _PanelCartItems["default"];
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "PanelCartShipment", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _PanelCartShipment["default"];
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "PanelClearCart", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _PanelClearCart["default"];
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PanelClientCheckout", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _PanelClientCheckout["default"];
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "PanelEditCartItem", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _PanelEditCartItem["default"];
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "PanelPaymentSuccess", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _PanelPaymentSuccess["default"];
40
+ }
41
+ });
42
+ var _PanelCartItems = _interopRequireDefault(require("./PanelCartItems"));
43
+ var _PanelCartShipment = _interopRequireDefault(require("./PanelCartShipment"));
44
+ var _PanelClearCart = _interopRequireDefault(require("./PanelClearCart"));
45
+ var _PanelClientCheckout = _interopRequireDefault(require("./PanelClientCheckout"));
46
+ var _PanelEditCartItem = _interopRequireDefault(require("./PanelEditCartItem"));
47
+ var _PanelPaymentSuccess = _interopRequireDefault(require("./PanelPaymentSuccess"));
48
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ declare function SquareCard(): React.JSX.Element;
3
+ export default SquareCard;
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _reactSquareWebPaymentsSdk = require("react-square-web-payments-sdk");
10
+ var _currency = require("../utilities/currency");
11
+ var _CartProvider = require("../CartProvider");
12
+ var _tabs = require("../utilities/tabs");
13
+ var _sdk = require("@merchi/sdk");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
16
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
17
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
18
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
19
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
20
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
21
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
23
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
24
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
25
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
26
+ function SquareCard() {
27
+ var _useCartContext = (0, _CartProvider.useCartContext)(),
28
+ alertError = _useCartContext.alertError,
29
+ cart = _useCartContext.cart,
30
+ setActiveTabIndex = _useCartContext.setActiveTabIndex,
31
+ setInvoiceJson = _useCartContext.setInvoiceJson;
32
+ var currency = cart.currency,
33
+ domain = cart.domain,
34
+ totalCost = cart.totalCost;
35
+ var _React$useState = React.useState(false),
36
+ _React$useState2 = _slicedToArray(_React$useState, 2),
37
+ loading = _React$useState2[0],
38
+ setLoading = _React$useState2[1];
39
+ var company = domain.company;
40
+ function ButtonText() {
41
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
42
+ children: ["Pay ", _currency.currencyMap[currency], totalCost, /*#__PURE__*/(0, _jsxRuntime.jsx)("small", {
43
+ children: " / inc tax"
44
+ })]
45
+ });
46
+ }
47
+ var squareWebLocationId = company.squareWebLocationId;
48
+ function callbackCreditCardPaymentSuccess(invoiceJson) {
49
+ setInvoiceJson(invoiceJson);
50
+ setActiveTabIndex(_tabs.tabIdPaymentSuccess);
51
+ }
52
+ function actionSquarePaymentProcess(_x, _x2) {
53
+ return _actionSquarePaymentProcess.apply(this, arguments);
54
+ }
55
+ function _actionSquarePaymentProcess() {
56
+ _actionSquarePaymentProcess = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sourceId, callbackPaymentSuccess) {
57
+ var url, fetchOptions, merchi, r, _t;
58
+ return _regenerator().w(function (_context) {
59
+ while (1) switch (_context.p = _context.n) {
60
+ case 0:
61
+ setLoading(true);
62
+ url = "/cart/".concat(cart.id, "/square/payment/");
63
+ fetchOptions = {
64
+ method: 'GET',
65
+ query: [['sourceId', sourceId], ['cart_token', cart.token]]
66
+ };
67
+ _context.p = 1;
68
+ merchi = new _sdk.Merchi();
69
+ _context.n = 2;
70
+ return merchi.authenticatedFetch(url, fetchOptions);
71
+ case 2:
72
+ r = _context.v;
73
+ callbackPaymentSuccess(r.invoice);
74
+ _context.n = 4;
75
+ break;
76
+ case 3:
77
+ _context.p = 3;
78
+ _t = _context.v;
79
+ alertError(_t.errorMessage || _t.message || 'Server eror.');
80
+ case 4:
81
+ _context.p = 4;
82
+ setLoading(false);
83
+ return _context.f(4);
84
+ case 5:
85
+ return _context.a(2);
86
+ }
87
+ }, _callee, null, [[1, 3, 4, 5]]);
88
+ }));
89
+ return _actionSquarePaymentProcess.apply(this, arguments);
90
+ }
91
+ return squareWebLocationId ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactSquareWebPaymentsSdk.PaymentForm
92
+ /**
93
+ * Identifies the calling form with a verified application ID generated from
94
+ * the Square Application Dashboard.
95
+ */, {
96
+ applicationId: SQUARE_APPLICATION_ID
97
+ /**
98
+ * Invoked when payment form receives the result of a tokenize generation
99
+ * request. The result will be a valid credit card or wallet token, or an error.
100
+ */,
101
+ cardTokenizeResponseReceived: function cardTokenizeResponseReceived(token, buyer) {
102
+ return actionSquarePaymentProcess(token.token, callbackCreditCardPaymentSuccess);
103
+ }
104
+ /**
105
+ * Identifies the location of the merchant that is taking the payment.
106
+ * Obtained from the Square Application Dashboard - Locations tab.
107
+ */,
108
+ locationId: squareWebLocationId,
109
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactSquareWebPaymentsSdk.CreditCard, {
110
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonText, {})
111
+ })
112
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
113
+ }
114
+ var _default = exports["default"] = SquareCard;
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ declare function StripeCardForm(): React.JSX.Element;
3
+ export default StripeCardForm;
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var React = _react;
10
+ var _buttons = require("../buttons");
11
+ var _StripeCardFields = _interopRequireDefault(require("./StripeCardFields"));
12
+ var _actions = require("./actions");
13
+ var _utils = require("./utils");
14
+ var _CartProvider = require("../CartProvider");
15
+ var _tabs = require("../utilities/tabs");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
18
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t3 in e) "default" !== _t3 && {}.hasOwnProperty.call(e, _t3) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t3)) && (i.get || i.set) ? o(f, _t3, i) : f[_t3] = e[_t3]); return f; })(e, t); }
19
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
20
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
21
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
22
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
23
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
24
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
26
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
27
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
28
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
29
+ function PaymentButton(_ref) {
30
+ var loading = _ref.loading;
31
+ var _useCartContext = (0, _CartProvider.useCartContext)(),
32
+ cart = _useCartContext.cart;
33
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
34
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_buttons.ButtonPay, {
35
+ cart: cart,
36
+ loading: loading
37
+ })
38
+ });
39
+ }
40
+ var badgeTestMode = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
41
+ style: {
42
+ color: 'red'
43
+ },
44
+ children: "Test mode"
45
+ });
46
+ function StripeCardForm() {
47
+ var _useCartContext2 = (0, _CartProvider.useCartContext)(),
48
+ alertError = _useCartContext2.alertError,
49
+ apiUrl = _useCartContext2.apiUrl,
50
+ cart = _useCartContext2.cart,
51
+ setActiveTabIndex = _useCartContext2.setActiveTabIndex,
52
+ setInvoiceJson = _useCartContext2.setInvoiceJson;
53
+ var domain = cart.domain;
54
+ var _useState = (0, _react.useState)({}),
55
+ _useState2 = _slicedToArray(_useState, 2),
56
+ error = _useState2[0],
57
+ setError = _useState2[1];
58
+ var company = domain.company;
59
+ var hasCompanyPubKey = Boolean(company.isStripeValid && (0, _utils.companyStripePubKeyOrTestPubKey)(company));
60
+ var companyPubKey = hasCompanyPubKey ? (0, _utils.companyStripePubKeyOrTestPubKey)(company) : '';
61
+ var canUseConnect = !!company.stripeAccountId;
62
+ var _useState3 = (0, _react.useState)(false),
63
+ _useState4 = _slicedToArray(_useState3, 2),
64
+ loadingStripePayment = _useState4[0],
65
+ setLoadingStripePayment = _useState4[1];
66
+ var _useState5 = (0, _react.useState)(false),
67
+ _useState6 = _slicedToArray(_useState5, 2),
68
+ loadingStripePaymentButtons = _useState6[0],
69
+ setLoadingStripePaymentButtons = _useState6[1];
70
+ var url = apiUrl || '';
71
+ function callbackCreditCardPaymentSuccess(invoiceJson) {
72
+ setInvoiceJson(invoiceJson);
73
+ setActiveTabIndex(_tabs.tabIdPaymentSuccess);
74
+ }
75
+ function doStripePayment(_x) {
76
+ return _doStripePayment.apply(this, arguments);
77
+ }
78
+ function _doStripePayment() {
79
+ _doStripePayment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(r) {
80
+ var response, _t;
81
+ return _regenerator().w(function (_context) {
82
+ while (1) switch (_context.p = _context.n) {
83
+ case 0:
84
+ setLoadingStripePayment(true);
85
+ setError({});
86
+ _context.p = 1;
87
+ _context.n = 2;
88
+ return (0, _actions.stripeCardFormSubmit)(url, r.stripe, r.card, cart);
89
+ case 2:
90
+ response = _context.v;
91
+ callbackCreditCardPaymentSuccess(response);
92
+ setLoadingStripePayment(false);
93
+ _context.n = 4;
94
+ break;
95
+ case 3:
96
+ _context.p = 3;
97
+ _t = _context.v;
98
+ setLoadingStripePayment(false);
99
+ alertError(_t.message);
100
+ setError({
101
+ message: _t.errorMessage || _t.message || 'Unable to process card.'
102
+ });
103
+ case 4:
104
+ return _context.a(2);
105
+ }
106
+ }, _callee, null, [[1, 3]]);
107
+ }));
108
+ return _doStripePayment.apply(this, arguments);
109
+ }
110
+ function doStripePaymentRequestForButton(_x2, _x3) {
111
+ return _doStripePaymentRequestForButton.apply(this, arguments);
112
+ }
113
+ function _doStripePaymentRequestForButton() {
114
+ _doStripePaymentRequestForButton = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(stripe, event) {
115
+ var response, _t2;
116
+ return _regenerator().w(function (_context2) {
117
+ while (1) switch (_context2.p = _context2.n) {
118
+ case 0:
119
+ setLoadingStripePaymentButtons(true);
120
+ setError({});
121
+ _context2.p = 1;
122
+ _context2.n = 2;
123
+ return (0, _actions.stripePaymentButtonSubmit)(url, stripe, cart, event);
124
+ case 2:
125
+ response = _context2.v;
126
+ callbackCreditCardPaymentSuccess(response);
127
+ setLoadingStripePaymentButtons(false);
128
+ _context2.n = 4;
129
+ break;
130
+ case 3:
131
+ _context2.p = 3;
132
+ _t2 = _context2.v;
133
+ setLoadingStripePaymentButtons(false);
134
+ alertError(_t2.message);
135
+ setError({
136
+ message: _t2.errorMessage || _t2.message || 'Unable to process card.'
137
+ });
138
+ case 4:
139
+ return _context2.a(2);
140
+ }
141
+ }, _callee2, null, [[1, 3]]);
142
+ }));
143
+ return _doStripePaymentRequestForButton.apply(this, arguments);
144
+ }
145
+ var _useState7 = (0, _react.useState)(companyPubKey),
146
+ _useState8 = _slicedToArray(_useState7, 2),
147
+ stripePublicKey = _useState8[0],
148
+ setStripePublicKey = _useState8[1];
149
+ (0, _react.useEffect)(function () {
150
+ if (!stripePublicKey && canUseConnect) (0, _actions.stripeInitPromise)(url).then(setStripePublicKey);
151
+ }, [stripePublicKey, canUseConnect]);
152
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
153
+ children: [company.isTesting && badgeTestMode, /*#__PURE__*/(0, _jsxRuntime.jsx)(_StripeCardFields["default"], {
154
+ doStripePayment: doStripePayment,
155
+ doStripePaymentRequestForButton: doStripePaymentRequestForButton,
156
+ cart: cart,
157
+ error: error,
158
+ loadingStripePayment: loadingStripePayment,
159
+ loadingStripePaymentButtons: loadingStripePaymentButtons,
160
+ PaymentButton: PaymentButton,
161
+ setLoadingStripePayment: setLoadingStripePayment,
162
+ stripePubKey: stripePublicKey
163
+ })]
164
+ });
165
+ }
166
+ var _default = exports["default"] = StripeCardForm;
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import { PaymentRequestPaymentMethodEvent } from "@stripe/stripe-js";
3
+ interface Props {
4
+ doStripePayment: (values: any) => void;
5
+ doStripePaymentRequestForButton?: (stripe: any, event: PaymentRequestPaymentMethodEvent) => void;
6
+ cart: any;
7
+ error: any;
8
+ loadingStripePayment: boolean;
9
+ loadingStripePaymentButtons: boolean;
10
+ PaymentButton?: any;
11
+ setLoadingStripePayment: (loading: boolean) => void;
12
+ stripePubKey: string;
13
+ }
14
+ declare function FormStripeCardFields({ doStripePayment, doStripePaymentRequestForButton, cart, error, loadingStripePayment, loadingStripePaymentButtons, PaymentButton, setLoadingStripePayment, stripePubKey, }: Props): React.JSX.Element;
15
+ export default FormStripeCardFields;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _StripePaymentButtons = _interopRequireDefault(require("./StripePaymentButtons"));
10
+ var _reactStripeJs = require("@stripe/react-stripe-js");
11
+ var _stripeJs = require("@stripe/stripe-js");
12
+ var _utils = require("./utils");
13
+ var _stripePaymentSecure = _interopRequireDefault(require("../assets/stripe-payment-secure.png"));
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
+ function InnerForm(_ref) {
18
+ var doStripePayment = _ref.doStripePayment,
19
+ doStripePaymentRequestForButton = _ref.doStripePaymentRequestForButton,
20
+ cart = _ref.cart,
21
+ error = _ref.error,
22
+ loadingStripePayment = _ref.loadingStripePayment,
23
+ loadingStripePaymentButtons = _ref.loadingStripePaymentButtons,
24
+ PaymentButton = _ref.PaymentButton,
25
+ setLoadingStripePayment = _ref.setLoadingStripePayment;
26
+ var inputClass = "form-control p-t-8 stripe-form-control";
27
+ var stripe = (0, _reactStripeJs.useStripe)();
28
+ var elements = (0, _reactStripeJs.useElements)();
29
+ function paymentStart(e) {
30
+ var card = elements.getElement(_reactStripeJs.CardElement);
31
+ setLoadingStripePayment(true);
32
+ e.preventDefault();
33
+ if (!stripe || !elements) {
34
+ setLoadingStripePayment(false);
35
+ return;
36
+ }
37
+ doStripePayment({
38
+ card: card,
39
+ cart: cart,
40
+ stripe: stripe
41
+ });
42
+ }
43
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
44
+ children: loadingStripePaymentButtons ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
45
+ style: {
46
+ alignItems: "center"
47
+ },
48
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
49
+ style: {
50
+ alignItems: "center",
51
+ display: "flex",
52
+ justifyContent: "center",
53
+ marginBottom: "1rem",
54
+ textAlign: "center"
55
+ },
56
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
57
+ className: "spinner-merchi-small"
58
+ })
59
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
60
+ style: {
61
+ fontSize: "14px",
62
+ fontWeight: 600,
63
+ textAlign: "center"
64
+ },
65
+ children: "Processing payment"
66
+ })]
67
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
68
+ children: [!!(cart && doStripePaymentRequestForButton) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_StripePaymentButtons["default"], {
69
+ doPaymentRequest: function doPaymentRequest(event) {
70
+ return doStripePaymentRequestForButton(stripe, event);
71
+ },
72
+ cart: cart
73
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("form", {
74
+ onSubmit: paymentStart,
75
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
76
+ className: "merchi-cart-stripe-input-container",
77
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactStripeJs.CardElement, {
78
+ className: inputClass,
79
+ options: _utils.CARD_ELEMENT_OPTIONS
80
+ }), error.message && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
81
+ className: "merchi-cart-stripe-input-error",
82
+ children: error.message
83
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(PaymentButton, {
84
+ loading: loadingStripePayment
85
+ }), _stripePaymentSecure["default"] && /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
86
+ src: (_stripePaymentSecure["default"] && "src" in _stripePaymentSecure["default"] ? _stripePaymentSecure["default"].src : _stripePaymentSecure["default"]) || "",
87
+ width: 250,
88
+ alt: "Secure credit card payments by Stripe"
89
+ })]
90
+ })
91
+ })]
92
+ })
93
+ });
94
+ }
95
+ function FormStripeCardFields(_ref2) {
96
+ var doStripePayment = _ref2.doStripePayment,
97
+ doStripePaymentRequestForButton = _ref2.doStripePaymentRequestForButton,
98
+ cart = _ref2.cart,
99
+ error = _ref2.error,
100
+ loadingStripePayment = _ref2.loadingStripePayment,
101
+ loadingStripePaymentButtons = _ref2.loadingStripePaymentButtons,
102
+ PaymentButton = _ref2.PaymentButton,
103
+ setLoadingStripePayment = _ref2.setLoadingStripePayment,
104
+ stripePubKey = _ref2.stripePubKey;
105
+ return stripePubKey ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactStripeJs.Elements, {
106
+ stripe: (0, _stripeJs.loadStripe)(stripePubKey),
107
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(InnerForm, {
108
+ doStripePayment: doStripePayment,
109
+ doStripePaymentRequestForButton: doStripePaymentRequestForButton,
110
+ cart: cart,
111
+ error: error,
112
+ loadingStripePayment: loadingStripePayment,
113
+ loadingStripePaymentButtons: loadingStripePaymentButtons,
114
+ setLoadingStripePayment: setLoadingStripePayment,
115
+ PaymentButton: PaymentButton
116
+ })
117
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
118
+ style: {
119
+ alignItems: "center"
120
+ },
121
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
122
+ style: {
123
+ alignItems: "center",
124
+ display: "flex",
125
+ justifyContent: "center",
126
+ marginBottom: "1rem",
127
+ textAlign: "center"
128
+ },
129
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
130
+ className: "spinner-merchi-small"
131
+ })
132
+ })
133
+ });
134
+ }
135
+ var _default = exports["default"] = FormStripeCardFields;
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export default function StripeCardForm(): React.JSX.Element;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = StripeCardForm;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _invoice = require("@merchi/invoice");
10
+ var _LegacyStripeCardForm = _interopRequireDefault(require("./LegacyStripeCardForm"));
11
+ var _CartProvider = require("../CartProvider");
12
+ var _tabs = require("../utilities/tabs");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
+ function StripeCardForm() {
17
+ var _useCartContext = (0, _CartProvider.useCartContext)(),
18
+ alertError = _useCartContext.alertError,
19
+ apiUrl = _useCartContext.apiUrl,
20
+ cart = _useCartContext.cart,
21
+ setActiveTabIndex = _useCartContext.setActiveTabIndex,
22
+ setInvoiceJson = _useCartContext.setInvoiceJson;
23
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_invoice.StripePaymentGate, {
24
+ engine: cart.stripePaymentEngine,
25
+ apiUrl: apiUrl || 'https://api.merchi.co/v6/',
26
+ resource: "cart",
27
+ resourceId: cart.id,
28
+ resourceToken: cart.token || cart.cartToken,
29
+ legacy: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LegacyStripeCardForm["default"], {}),
30
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_invoice.StripePaymentForm, {
31
+ apiUrl: apiUrl || 'https://api.merchi.co/v6/',
32
+ resource: "cart",
33
+ resourceId: cart.id,
34
+ resourceToken: cart.token || cart.cartToken,
35
+ onError: alertError,
36
+ onSuccess: function onSuccess(invoice) {
37
+ setInvoiceJson(invoice);
38
+ setActiveTabIndex(_tabs.tabIdPaymentSuccess);
39
+ }
40
+ })
41
+ });
42
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { PaymentRequestPaymentMethodEvent } from '@stripe/stripe-js';
3
+ interface PropsStripePaymentButtons {
4
+ doPaymentRequest: (event: PaymentRequestPaymentMethodEvent) => void;
5
+ cart: any;
6
+ }
7
+ declare function StripePaymentButtons({ doPaymentRequest, cart, }: PropsStripePaymentButtons): React.JSX.Element;
8
+ export default StripePaymentButtons;