@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.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/esm/Cart.js +62 -0
- package/esm/CartAlert.js +47 -0
- package/esm/CartHeader.js +29 -0
- package/esm/CartProvider.js +1101 -0
- package/esm/CartTotals.js +89 -0
- package/esm/assets/merchi-monster-loader.gif +0 -0
- package/esm/assets/merchi-swipe-outline.png +0 -0
- package/esm/assets/product-not-found.png +0 -0
- package/esm/assets/stripe-payment-secure.png +0 -0
- package/esm/buttons/Button.js +23 -0
- package/esm/buttons/ButtonBack.js +35 -0
- package/esm/buttons/ButtonClearCart.js +17 -0
- package/esm/buttons/ButtonInvoiceDownload.js +88 -0
- package/esm/buttons/ButtonNext.js +39 -0
- package/esm/buttons/ButtonNextDynamic.js +19 -0
- package/esm/buttons/ButtonOpenCartMerchiCartModal.js +47 -0
- package/esm/buttons/ButtonPay.js +26 -0
- package/esm/buttons/ButtonShipmentTabNext.js +28 -0
- package/esm/buttons/index.js +7 -0
- package/esm/components/Alert.js +26 -0
- package/esm/components/CartBody.js +14 -0
- package/esm/components/CartClient.js +62 -0
- package/esm/components/CartFooter.js +12 -0
- package/esm/components/CartItemRow.js +230 -0
- package/esm/components/CartPaymentSettingsInvalid.js +13 -0
- package/esm/components/CartShipment.js +52 -0
- package/esm/components/CartTabContent.js +12 -0
- package/esm/components/CartTabPanel.js +25 -0
- package/esm/components/CartTableContainer.js +12 -0
- package/esm/components/CartTitle.js +26 -0
- package/esm/components/CartTotalsListGroup.js +71 -0
- package/esm/components/Collapse.js +32 -0
- package/esm/components/CustomCartProductForm.js +128 -0
- package/esm/components/CustomerCheckoutMethodTabs.js +94 -0
- package/esm/components/DiscountInputGroup.js +293 -0
- package/esm/components/LoadingTemplate.js +23 -0
- package/esm/components/NoCartItems.js +20 -0
- package/esm/components/ShipmentGroupCard.js +207 -0
- package/esm/components/Table.js +13 -0
- package/esm/components/containers.js +31 -0
- package/esm/components/index.js +18 -0
- package/esm/components/product-form-sdk-externals.js +36 -0
- package/esm/forms/FormNewCustomer.js +243 -0
- package/esm/forms/FormReturningCustomer.js +165 -0
- package/esm/forms/FormShipmentAddressAndNotes.js +195 -0
- package/esm/forms/FormSquarePayment.js +19 -0
- package/esm/forms/FormStripePayment.js +19 -0
- package/esm/forms/FormWhatsappCustomer.js +253 -0
- package/esm/forms/InputAcceptUserTermsAndConditions.js +35 -0
- package/esm/forms/InputError.js +16 -0
- package/esm/forms/InputSelect.js +48 -0
- package/esm/forms/InputText.js +56 -0
- package/esm/forms/InputsAddress.js +476 -0
- package/esm/forms/index.js +8 -0
- package/esm/index.js +13 -0
- package/esm/modals.js +51 -0
- package/esm/panels/PanelCartItems.js +49 -0
- package/esm/panels/PanelCartShipment.js +66 -0
- package/esm/panels/PanelClearCart.js +56 -0
- package/esm/panels/PanelClientCheckout.js +81 -0
- package/esm/panels/PanelEditCartItem.js +199 -0
- package/esm/panels/PanelPaymentSuccess.js +63 -0
- package/esm/panels/index.js +7 -0
- package/esm/square/SquareCard.js +106 -0
- package/esm/stripe/LegacyStripeCardForm.js +157 -0
- package/esm/stripe/StripeCardFields.js +126 -0
- package/esm/stripe/StripeCardForm.js +33 -0
- package/esm/stripe/StripePaymentButtons.js +98 -0
- package/esm/stripe/actions.js +192 -0
- package/esm/stripe/utils.js +20 -0
- package/esm/styles/globals.css +463 -0
- package/esm/styles/globals.css.map +1 -0
- package/esm/tabs/CartNav.js +28 -0
- package/esm/tabs/NavTab.js +31 -0
- package/esm/types/assets.d.js +0 -0
- package/esm/types/index.js +1 -0
- package/esm/types/merchi_product_form/index.d.js +0 -0
- package/esm/types/merchi_sdk_ts/index.d.js +0 -0
- package/esm/types/react-redux/index.d.js +0 -0
- package/esm/utilities/address.js +457 -0
- package/esm/utilities/area.js +297 -0
- package/esm/utilities/cart.js +95 -0
- package/esm/utilities/company.js +6 -0
- package/esm/utilities/cookie.js +156 -0
- package/esm/utilities/currency.js +219 -0
- package/esm/utilities/customForm.js +57 -0
- package/esm/utilities/helpers.js +229 -0
- package/esm/utilities/index.js +14 -0
- package/esm/utilities/invoice.js +112 -0
- package/esm/utilities/job.js +9 -0
- package/esm/utilities/local_storage.js +85 -0
- package/esm/utilities/product.js +13 -0
- package/esm/utilities/shipment.js +11 -0
- package/esm/utilities/tabs.js +51 -0
- package/esm/utilities/user.js +65 -0
- package/esm/utilities/variations.js +58 -0
- package/lib/Cart.d.ts +9 -0
- package/lib/Cart.js +69 -0
- package/lib/CartAlert.d.ts +3 -0
- package/lib/CartAlert.js +53 -0
- package/lib/CartHeader.d.ts +3 -0
- package/lib/CartHeader.js +37 -0
- package/lib/CartProvider.d.ts +236 -0
- package/lib/CartProvider.js +1107 -0
- package/lib/CartTotals.d.ts +7 -0
- package/lib/CartTotals.js +96 -0
- package/lib/assets/merchi-monster-loader.gif +0 -0
- package/lib/assets/merchi-swipe-outline.png +0 -0
- package/lib/assets/product-not-found.png +0 -0
- package/lib/assets/stripe-payment-secure.png +0 -0
- package/lib/buttons/Button.d.ts +11 -0
- package/lib/buttons/Button.js +31 -0
- package/lib/buttons/ButtonBack.d.ts +6 -0
- package/lib/buttons/ButtonBack.js +44 -0
- package/lib/buttons/ButtonClearCart.d.ts +3 -0
- package/lib/buttons/ButtonClearCart.js +24 -0
- package/lib/buttons/ButtonInvoiceDownload.d.ts +3 -0
- package/lib/buttons/ButtonInvoiceDownload.js +96 -0
- package/lib/buttons/ButtonNext.d.ts +3 -0
- package/lib/buttons/ButtonNext.js +48 -0
- package/lib/buttons/ButtonNextDynamic.d.ts +3 -0
- package/lib/buttons/ButtonNextDynamic.js +28 -0
- package/lib/buttons/ButtonOpenCartMerchiCartModal.d.ts +9 -0
- package/lib/buttons/ButtonOpenCartMerchiCartModal.js +57 -0
- package/lib/buttons/ButtonPay.d.ts +7 -0
- package/lib/buttons/ButtonPay.js +35 -0
- package/lib/buttons/ButtonShipmentTabNext.d.ts +2 -0
- package/lib/buttons/ButtonShipmentTabNext.js +37 -0
- package/lib/buttons/index.d.ts +7 -0
- package/lib/buttons/index.js +48 -0
- package/lib/components/Alert.d.ts +7 -0
- package/lib/components/Alert.js +34 -0
- package/lib/components/CartBody.d.ts +7 -0
- package/lib/components/CartBody.js +22 -0
- package/lib/components/CartClient.d.ts +4 -0
- package/lib/components/CartClient.js +71 -0
- package/lib/components/CartFooter.d.ts +6 -0
- package/lib/components/CartFooter.js +20 -0
- package/lib/components/CartItemRow.d.ts +7 -0
- package/lib/components/CartItemRow.js +236 -0
- package/lib/components/CartPaymentSettingsInvalid.d.ts +2 -0
- package/lib/components/CartPaymentSettingsInvalid.js +21 -0
- package/lib/components/CartShipment.d.ts +6 -0
- package/lib/components/CartShipment.js +59 -0
- package/lib/components/CartTabContent.d.ts +6 -0
- package/lib/components/CartTabContent.js +20 -0
- package/lib/components/CartTabPanel.d.ts +7 -0
- package/lib/components/CartTabPanel.js +31 -0
- package/lib/components/CartTableContainer.d.ts +6 -0
- package/lib/components/CartTableContainer.js +20 -0
- package/lib/components/CartTitle.d.ts +2 -0
- package/lib/components/CartTitle.js +34 -0
- package/lib/components/CartTotalsListGroup.d.ts +3 -0
- package/lib/components/CartTotalsListGroup.js +78 -0
- package/lib/components/Collapse.d.ts +3 -0
- package/lib/components/Collapse.js +40 -0
- package/lib/components/CustomCartProductForm.d.ts +18 -0
- package/lib/components/CustomCartProductForm.js +136 -0
- package/lib/components/CustomerCheckoutMethodTabs.d.ts +6 -0
- package/lib/components/CustomerCheckoutMethodTabs.js +103 -0
- package/lib/components/DiscountInputGroup.d.ts +2 -0
- package/lib/components/DiscountInputGroup.js +301 -0
- package/lib/components/LoadingTemplate.d.ts +7 -0
- package/lib/components/LoadingTemplate.js +30 -0
- package/lib/components/NoCartItems.d.ts +3 -0
- package/lib/components/NoCartItems.js +27 -0
- package/lib/components/ShipmentGroupCard.d.ts +7 -0
- package/lib/components/ShipmentGroupCard.js +215 -0
- package/lib/components/Table.d.ts +7 -0
- package/lib/components/Table.js +19 -0
- package/lib/components/containers.d.ts +14 -0
- package/lib/components/containers.js +40 -0
- package/lib/components/index.d.ts +18 -0
- package/lib/components/index.js +133 -0
- package/lib/components/product-form-sdk-externals.d.ts +46 -0
- package/lib/components/product-form-sdk-externals.js +43 -0
- package/lib/forms/FormNewCustomer.d.ts +4 -0
- package/lib/forms/FormNewCustomer.js +252 -0
- package/lib/forms/FormReturningCustomer.d.ts +3 -0
- package/lib/forms/FormReturningCustomer.js +173 -0
- package/lib/forms/FormShipmentAddressAndNotes.d.ts +15 -0
- package/lib/forms/FormShipmentAddressAndNotes.js +203 -0
- package/lib/forms/FormSquarePayment.d.ts +3 -0
- package/lib/forms/FormSquarePayment.js +27 -0
- package/lib/forms/FormStripePayment.d.ts +3 -0
- package/lib/forms/FormStripePayment.js +27 -0
- package/lib/forms/FormWhatsappCustomer.d.ts +3 -0
- package/lib/forms/FormWhatsappCustomer.js +261 -0
- package/lib/forms/InputAcceptUserTermsAndConditions.d.ts +7 -0
- package/lib/forms/InputAcceptUserTermsAndConditions.js +41 -0
- package/lib/forms/InputError.d.ts +8 -0
- package/lib/forms/InputError.js +24 -0
- package/lib/forms/InputSelect.d.ts +14 -0
- package/lib/forms/InputSelect.js +55 -0
- package/lib/forms/InputText.d.ts +12 -0
- package/lib/forms/InputText.js +63 -0
- package/lib/forms/InputsAddress.d.ts +11 -0
- package/lib/forms/InputsAddress.js +485 -0
- package/lib/forms/index.d.ts +8 -0
- package/lib/forms/index.js +63 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +93 -0
- package/lib/modals.d.ts +17 -0
- package/lib/modals.js +59 -0
- package/lib/panels/PanelCartItems.d.ts +3 -0
- package/lib/panels/PanelCartItems.js +56 -0
- package/lib/panels/PanelCartShipment.d.ts +3 -0
- package/lib/panels/PanelCartShipment.js +72 -0
- package/lib/panels/PanelClearCart.d.ts +3 -0
- package/lib/panels/PanelClearCart.js +62 -0
- package/lib/panels/PanelClientCheckout.d.ts +3 -0
- package/lib/panels/PanelClientCheckout.js +88 -0
- package/lib/panels/PanelEditCartItem.d.ts +6 -0
- package/lib/panels/PanelEditCartItem.js +206 -0
- package/lib/panels/PanelPaymentSuccess.d.ts +3 -0
- package/lib/panels/PanelPaymentSuccess.js +69 -0
- package/lib/panels/index.d.ts +7 -0
- package/lib/panels/index.js +48 -0
- package/lib/square/SquareCard.d.ts +3 -0
- package/lib/square/SquareCard.js +114 -0
- package/lib/stripe/LegacyStripeCardForm.d.ts +3 -0
- package/lib/stripe/LegacyStripeCardForm.js +166 -0
- package/lib/stripe/StripeCardFields.d.ts +15 -0
- package/lib/stripe/StripeCardFields.js +135 -0
- package/lib/stripe/StripeCardForm.d.ts +2 -0
- package/lib/stripe/StripeCardForm.js +42 -0
- package/lib/stripe/StripePaymentButtons.d.ts +8 -0
- package/lib/stripe/StripePaymentButtons.js +106 -0
- package/lib/stripe/actions.d.ts +4 -0
- package/lib/stripe/actions.js +200 -0
- package/lib/stripe/utils.d.ts +18 -0
- package/lib/stripe/utils.js +27 -0
- package/lib/styles/globals.css +463 -0
- package/lib/styles/globals.css.map +1 -0
- package/lib/tabs/CartNav.d.ts +3 -0
- package/lib/tabs/CartNav.js +36 -0
- package/lib/tabs/NavTab.d.ts +9 -0
- package/lib/tabs/NavTab.js +39 -0
- package/lib/types/index.d.ts +13 -0
- package/lib/types/index.js +1 -0
- package/lib/utilities/address.d.ts +30 -0
- package/lib/utilities/address.js +468 -0
- package/lib/utilities/area.d.ts +77 -0
- package/lib/utilities/area.js +328 -0
- package/lib/utilities/cart.d.ts +9 -0
- package/lib/utilities/cart.js +108 -0
- package/lib/utilities/company.d.ts +2 -0
- package/lib/utilities/company.js +13 -0
- package/lib/utilities/cookie.d.ts +4 -0
- package/lib/utilities/cookie.js +165 -0
- package/lib/utilities/currency.d.ts +5 -0
- package/lib/utilities/currency.js +229 -0
- package/lib/utilities/customForm.d.ts +17 -0
- package/lib/utilities/customForm.js +64 -0
- package/lib/utilities/helpers.d.ts +24 -0
- package/lib/utilities/helpers.js +240 -0
- package/lib/utilities/index.d.ts +14 -0
- package/lib/utilities/index.js +159 -0
- package/lib/utilities/invoice.d.ts +3 -0
- package/lib/utilities/invoice.js +118 -0
- package/lib/utilities/job.d.ts +1 -0
- package/lib/utilities/job.js +15 -0
- package/lib/utilities/local_storage.d.ts +31 -0
- package/lib/utilities/local_storage.js +96 -0
- package/lib/utilities/product.d.ts +2 -0
- package/lib/utilities/product.js +21 -0
- package/lib/utilities/shipment.d.ts +2 -0
- package/lib/utilities/shipment.js +18 -0
- package/lib/utilities/tabs.d.ts +14 -0
- package/lib/utilities/tabs.js +60 -0
- package/lib/utilities/user.d.ts +5 -0
- package/lib/utilities/user.js +75 -0
- package/lib/utilities/variations.d.ts +18 -0
- package/lib/utilities/variations.js +66 -0
- package/package.json +109 -0
- package/src/Cart.tsx +96 -0
- package/src/CartAlert.tsx +35 -0
- package/src/CartHeader.tsx +28 -0
- package/src/CartProvider.tsx +992 -0
- package/src/CartTotals.tsx +102 -0
- package/src/assets/merchi-monster-loader.gif +0 -0
- package/src/assets/merchi-swipe-outline.png +0 -0
- package/src/assets/product-not-found.png +0 -0
- package/src/assets/stripe-payment-secure.png +0 -0
- package/src/buttons/Button.tsx +35 -0
- package/src/buttons/ButtonBack.tsx +42 -0
- package/src/buttons/ButtonClearCart.tsx +17 -0
- package/src/buttons/ButtonInvoiceDownload.tsx +60 -0
- package/src/buttons/ButtonNext.tsx +35 -0
- package/src/buttons/ButtonNextDynamic.tsx +31 -0
- package/src/buttons/ButtonOpenCartMerchiCartModal.tsx +61 -0
- package/src/buttons/ButtonPay.tsx +32 -0
- package/src/buttons/ButtonShipmentTabNext.tsx +24 -0
- package/src/buttons/index.ts +15 -0
- package/src/components/Alert.tsx +31 -0
- package/src/components/CartBody.tsx +16 -0
- package/src/components/CartClient.tsx +52 -0
- package/src/components/CartFooter.tsx +15 -0
- package/src/components/CartItemRow.tsx +212 -0
- package/src/components/CartPaymentSettingsInvalid.tsx +12 -0
- package/src/components/CartShipment.tsx +56 -0
- package/src/components/CartTabContent.tsx +15 -0
- package/src/components/CartTabPanel.tsx +25 -0
- package/src/components/CartTableContainer.tsx +15 -0
- package/src/components/CartTitle.tsx +22 -0
- package/src/components/CartTotalsListGroup.tsx +58 -0
- package/src/components/Collapse.tsx +23 -0
- package/src/components/CustomCartProductForm.tsx +123 -0
- package/src/components/CustomerCheckoutMethodTabs.tsx +106 -0
- package/src/components/DiscountInputGroup.tsx +160 -0
- package/src/components/LoadingTemplate.tsx +22 -0
- package/src/components/NoCartItems.tsx +20 -0
- package/src/components/ShipmentGroupCard.tsx +170 -0
- package/src/components/Table.tsx +15 -0
- package/src/components/containers.tsx +40 -0
- package/src/components/index.ts +38 -0
- package/src/components/product-form-sdk-externals.ts +67 -0
- package/src/forms/FormNewCustomer.tsx +170 -0
- package/src/forms/FormReturningCustomer.tsx +117 -0
- package/src/forms/FormShipmentAddressAndNotes.tsx +165 -0
- package/src/forms/FormSquarePayment.tsx +19 -0
- package/src/forms/FormStripePayment.tsx +19 -0
- package/src/forms/FormWhatsappCustomer.tsx +179 -0
- package/src/forms/InputAcceptUserTermsAndConditions.tsx +43 -0
- package/src/forms/InputError.tsx +23 -0
- package/src/forms/InputSelect.tsx +58 -0
- package/src/forms/InputText.tsx +56 -0
- package/src/forms/InputsAddress.tsx +438 -0
- package/src/forms/index.ts +18 -0
- package/src/index.ts +31 -0
- package/src/modals.tsx +65 -0
- package/src/panels/PanelCartItems.tsx +56 -0
- package/src/panels/PanelCartShipment.tsx +86 -0
- package/src/panels/PanelClearCart.tsx +50 -0
- package/src/panels/PanelClientCheckout.tsx +102 -0
- package/src/panels/PanelEditCartItem.tsx +172 -0
- package/src/panels/PanelPaymentSuccess.tsx +66 -0
- package/src/panels/index.ts +15 -0
- package/src/square/SquareCard.tsx +84 -0
- package/src/stripe/LegacyStripeCardForm.tsx +91 -0
- package/src/stripe/StripeCardFields.tsx +173 -0
- package/src/stripe/StripeCardForm.tsx +18 -0
- package/src/stripe/StripePaymentButtons.tsx +117 -0
- package/src/stripe/actions.ts +94 -0
- package/src/stripe/utils.ts +22 -0
- package/src/styles/globals.scss +475 -0
- package/src/tabs/CartNav.tsx +18 -0
- package/src/tabs/NavTab.tsx +36 -0
- package/src/types/assets.d.ts +4 -0
- package/src/types/index.ts +15 -0
- package/src/types/merchi_product_form/index.d.ts +1 -0
- package/src/types/merchi_sdk_ts/index.d.ts +1 -0
- package/src/types/react-redux/index.d.ts +0 -0
- package/src/utilities/address.ts +463 -0
- package/src/utilities/area.ts +359 -0
- package/src/utilities/cart.ts +80 -0
- package/src/utilities/company.ts +8 -0
- package/src/utilities/cookie.ts +58 -0
- package/src/utilities/currency.ts +216 -0
- package/src/utilities/customForm.ts +71 -0
- package/src/utilities/helpers.ts +213 -0
- package/src/utilities/index.ts +14 -0
- package/src/utilities/invoice.ts +60 -0
- package/src/utilities/job.ts +13 -0
- package/src/utilities/local_storage.ts +130 -0
- package/src/utilities/product.ts +14 -0
- package/src/utilities/shipment.ts +11 -0
- package/src/utilities/tabs.ts +38 -0
- package/src/utilities/user.ts +33 -0
- package/src/utilities/variations.ts +80 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
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 }; })(); }
|
|
2
|
+
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); }
|
|
3
|
+
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); }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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; } }
|
|
8
|
+
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; }
|
|
9
|
+
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; } }
|
|
10
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { useEffect, useState } from 'react';
|
|
13
|
+
import { ButtonPay } from '../buttons';
|
|
14
|
+
import FormStripeCardFields from './StripeCardFields';
|
|
15
|
+
import { stripeCardFormSubmit, stripeInitPromise, stripePaymentButtonSubmit } from './actions';
|
|
16
|
+
import { companyStripePubKeyOrTestPubKey } from './utils';
|
|
17
|
+
import { useCartContext } from '../CartProvider';
|
|
18
|
+
import { tabIdPaymentSuccess } from '../utilities/tabs';
|
|
19
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
+
function PaymentButton(_ref) {
|
|
21
|
+
var loading = _ref.loading;
|
|
22
|
+
var _useCartContext = useCartContext(),
|
|
23
|
+
cart = _useCartContext.cart;
|
|
24
|
+
return /*#__PURE__*/_jsx("div", {
|
|
25
|
+
children: /*#__PURE__*/_jsx(ButtonPay, {
|
|
26
|
+
cart: cart,
|
|
27
|
+
loading: loading
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
var badgeTestMode = /*#__PURE__*/_jsx("div", {
|
|
32
|
+
style: {
|
|
33
|
+
color: 'red'
|
|
34
|
+
},
|
|
35
|
+
children: "Test mode"
|
|
36
|
+
});
|
|
37
|
+
function StripeCardForm() {
|
|
38
|
+
var _useCartContext2 = useCartContext(),
|
|
39
|
+
alertError = _useCartContext2.alertError,
|
|
40
|
+
apiUrl = _useCartContext2.apiUrl,
|
|
41
|
+
cart = _useCartContext2.cart,
|
|
42
|
+
setActiveTabIndex = _useCartContext2.setActiveTabIndex,
|
|
43
|
+
setInvoiceJson = _useCartContext2.setInvoiceJson;
|
|
44
|
+
var domain = cart.domain;
|
|
45
|
+
var _useState = useState({}),
|
|
46
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
+
error = _useState2[0],
|
|
48
|
+
setError = _useState2[1];
|
|
49
|
+
var company = domain.company;
|
|
50
|
+
var hasCompanyPubKey = Boolean(company.isStripeValid && companyStripePubKeyOrTestPubKey(company));
|
|
51
|
+
var companyPubKey = hasCompanyPubKey ? companyStripePubKeyOrTestPubKey(company) : '';
|
|
52
|
+
var canUseConnect = !!company.stripeAccountId;
|
|
53
|
+
var _useState3 = useState(false),
|
|
54
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
55
|
+
loadingStripePayment = _useState4[0],
|
|
56
|
+
setLoadingStripePayment = _useState4[1];
|
|
57
|
+
var _useState5 = useState(false),
|
|
58
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
59
|
+
loadingStripePaymentButtons = _useState6[0],
|
|
60
|
+
setLoadingStripePaymentButtons = _useState6[1];
|
|
61
|
+
var url = apiUrl || '';
|
|
62
|
+
function callbackCreditCardPaymentSuccess(invoiceJson) {
|
|
63
|
+
setInvoiceJson(invoiceJson);
|
|
64
|
+
setActiveTabIndex(tabIdPaymentSuccess);
|
|
65
|
+
}
|
|
66
|
+
function doStripePayment(_x) {
|
|
67
|
+
return _doStripePayment.apply(this, arguments);
|
|
68
|
+
}
|
|
69
|
+
function _doStripePayment() {
|
|
70
|
+
_doStripePayment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(r) {
|
|
71
|
+
var response, _t;
|
|
72
|
+
return _regenerator().w(function (_context) {
|
|
73
|
+
while (1) switch (_context.p = _context.n) {
|
|
74
|
+
case 0:
|
|
75
|
+
setLoadingStripePayment(true);
|
|
76
|
+
setError({});
|
|
77
|
+
_context.p = 1;
|
|
78
|
+
_context.n = 2;
|
|
79
|
+
return stripeCardFormSubmit(url, r.stripe, r.card, cart);
|
|
80
|
+
case 2:
|
|
81
|
+
response = _context.v;
|
|
82
|
+
callbackCreditCardPaymentSuccess(response);
|
|
83
|
+
setLoadingStripePayment(false);
|
|
84
|
+
_context.n = 4;
|
|
85
|
+
break;
|
|
86
|
+
case 3:
|
|
87
|
+
_context.p = 3;
|
|
88
|
+
_t = _context.v;
|
|
89
|
+
setLoadingStripePayment(false);
|
|
90
|
+
alertError(_t.message);
|
|
91
|
+
setError({
|
|
92
|
+
message: _t.errorMessage || _t.message || 'Unable to process card.'
|
|
93
|
+
});
|
|
94
|
+
case 4:
|
|
95
|
+
return _context.a(2);
|
|
96
|
+
}
|
|
97
|
+
}, _callee, null, [[1, 3]]);
|
|
98
|
+
}));
|
|
99
|
+
return _doStripePayment.apply(this, arguments);
|
|
100
|
+
}
|
|
101
|
+
function doStripePaymentRequestForButton(_x2, _x3) {
|
|
102
|
+
return _doStripePaymentRequestForButton.apply(this, arguments);
|
|
103
|
+
}
|
|
104
|
+
function _doStripePaymentRequestForButton() {
|
|
105
|
+
_doStripePaymentRequestForButton = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(stripe, event) {
|
|
106
|
+
var response, _t2;
|
|
107
|
+
return _regenerator().w(function (_context2) {
|
|
108
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
109
|
+
case 0:
|
|
110
|
+
setLoadingStripePaymentButtons(true);
|
|
111
|
+
setError({});
|
|
112
|
+
_context2.p = 1;
|
|
113
|
+
_context2.n = 2;
|
|
114
|
+
return stripePaymentButtonSubmit(url, stripe, cart, event);
|
|
115
|
+
case 2:
|
|
116
|
+
response = _context2.v;
|
|
117
|
+
callbackCreditCardPaymentSuccess(response);
|
|
118
|
+
setLoadingStripePaymentButtons(false);
|
|
119
|
+
_context2.n = 4;
|
|
120
|
+
break;
|
|
121
|
+
case 3:
|
|
122
|
+
_context2.p = 3;
|
|
123
|
+
_t2 = _context2.v;
|
|
124
|
+
setLoadingStripePaymentButtons(false);
|
|
125
|
+
alertError(_t2.message);
|
|
126
|
+
setError({
|
|
127
|
+
message: _t2.errorMessage || _t2.message || 'Unable to process card.'
|
|
128
|
+
});
|
|
129
|
+
case 4:
|
|
130
|
+
return _context2.a(2);
|
|
131
|
+
}
|
|
132
|
+
}, _callee2, null, [[1, 3]]);
|
|
133
|
+
}));
|
|
134
|
+
return _doStripePaymentRequestForButton.apply(this, arguments);
|
|
135
|
+
}
|
|
136
|
+
var _useState7 = useState(companyPubKey),
|
|
137
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
138
|
+
stripePublicKey = _useState8[0],
|
|
139
|
+
setStripePublicKey = _useState8[1];
|
|
140
|
+
useEffect(function () {
|
|
141
|
+
if (!stripePublicKey && canUseConnect) stripeInitPromise(url).then(setStripePublicKey);
|
|
142
|
+
}, [stripePublicKey, canUseConnect]);
|
|
143
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
144
|
+
children: [company.isTesting && badgeTestMode, /*#__PURE__*/_jsx(FormStripeCardFields, {
|
|
145
|
+
doStripePayment: doStripePayment,
|
|
146
|
+
doStripePaymentRequestForButton: doStripePaymentRequestForButton,
|
|
147
|
+
cart: cart,
|
|
148
|
+
error: error,
|
|
149
|
+
loadingStripePayment: loadingStripePayment,
|
|
150
|
+
loadingStripePaymentButtons: loadingStripePaymentButtons,
|
|
151
|
+
PaymentButton: PaymentButton,
|
|
152
|
+
setLoadingStripePayment: setLoadingStripePayment,
|
|
153
|
+
stripePubKey: stripePublicKey
|
|
154
|
+
})]
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
export default StripeCardForm;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import StripePaymentButtons from "./StripePaymentButtons";
|
|
3
|
+
import { CardElement, Elements, useStripe, useElements } from "@stripe/react-stripe-js";
|
|
4
|
+
import { loadStripe } from "@stripe/stripe-js";
|
|
5
|
+
import { CARD_ELEMENT_OPTIONS } from "./utils";
|
|
6
|
+
import pngStripe from "../assets/stripe-payment-secure.png";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
|
+
function InnerForm(_ref) {
|
|
9
|
+
var doStripePayment = _ref.doStripePayment,
|
|
10
|
+
doStripePaymentRequestForButton = _ref.doStripePaymentRequestForButton,
|
|
11
|
+
cart = _ref.cart,
|
|
12
|
+
error = _ref.error,
|
|
13
|
+
loadingStripePayment = _ref.loadingStripePayment,
|
|
14
|
+
loadingStripePaymentButtons = _ref.loadingStripePaymentButtons,
|
|
15
|
+
PaymentButton = _ref.PaymentButton,
|
|
16
|
+
setLoadingStripePayment = _ref.setLoadingStripePayment;
|
|
17
|
+
var inputClass = "form-control p-t-8 stripe-form-control";
|
|
18
|
+
var stripe = useStripe();
|
|
19
|
+
var elements = useElements();
|
|
20
|
+
function paymentStart(e) {
|
|
21
|
+
var card = elements.getElement(CardElement);
|
|
22
|
+
setLoadingStripePayment(true);
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
if (!stripe || !elements) {
|
|
25
|
+
setLoadingStripePayment(false);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
doStripePayment({
|
|
29
|
+
card: card,
|
|
30
|
+
cart: cart,
|
|
31
|
+
stripe: stripe
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
35
|
+
children: loadingStripePaymentButtons ? /*#__PURE__*/_jsxs("div", {
|
|
36
|
+
style: {
|
|
37
|
+
alignItems: "center"
|
|
38
|
+
},
|
|
39
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
40
|
+
style: {
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
display: "flex",
|
|
43
|
+
justifyContent: "center",
|
|
44
|
+
marginBottom: "1rem",
|
|
45
|
+
textAlign: "center"
|
|
46
|
+
},
|
|
47
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
48
|
+
className: "spinner-merchi-small"
|
|
49
|
+
})
|
|
50
|
+
}), /*#__PURE__*/_jsx("p", {
|
|
51
|
+
style: {
|
|
52
|
+
fontSize: "14px",
|
|
53
|
+
fontWeight: 600,
|
|
54
|
+
textAlign: "center"
|
|
55
|
+
},
|
|
56
|
+
children: "Processing payment"
|
|
57
|
+
})]
|
|
58
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
59
|
+
children: [!!(cart && doStripePaymentRequestForButton) && /*#__PURE__*/_jsx(StripePaymentButtons, {
|
|
60
|
+
doPaymentRequest: function doPaymentRequest(event) {
|
|
61
|
+
return doStripePaymentRequestForButton(stripe, event);
|
|
62
|
+
},
|
|
63
|
+
cart: cart
|
|
64
|
+
}), /*#__PURE__*/_jsx("form", {
|
|
65
|
+
onSubmit: paymentStart,
|
|
66
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
67
|
+
className: "merchi-cart-stripe-input-container",
|
|
68
|
+
children: [/*#__PURE__*/_jsx(CardElement, {
|
|
69
|
+
className: inputClass,
|
|
70
|
+
options: CARD_ELEMENT_OPTIONS
|
|
71
|
+
}), error.message && /*#__PURE__*/_jsx("div", {
|
|
72
|
+
className: "merchi-cart-stripe-input-error",
|
|
73
|
+
children: error.message
|
|
74
|
+
}), /*#__PURE__*/_jsx(PaymentButton, {
|
|
75
|
+
loading: loadingStripePayment
|
|
76
|
+
}), pngStripe && /*#__PURE__*/_jsx("img", {
|
|
77
|
+
src: (pngStripe && "src" in pngStripe ? pngStripe.src : pngStripe) || "",
|
|
78
|
+
width: 250,
|
|
79
|
+
alt: "Secure credit card payments by Stripe"
|
|
80
|
+
})]
|
|
81
|
+
})
|
|
82
|
+
})]
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function FormStripeCardFields(_ref2) {
|
|
87
|
+
var doStripePayment = _ref2.doStripePayment,
|
|
88
|
+
doStripePaymentRequestForButton = _ref2.doStripePaymentRequestForButton,
|
|
89
|
+
cart = _ref2.cart,
|
|
90
|
+
error = _ref2.error,
|
|
91
|
+
loadingStripePayment = _ref2.loadingStripePayment,
|
|
92
|
+
loadingStripePaymentButtons = _ref2.loadingStripePaymentButtons,
|
|
93
|
+
PaymentButton = _ref2.PaymentButton,
|
|
94
|
+
setLoadingStripePayment = _ref2.setLoadingStripePayment,
|
|
95
|
+
stripePubKey = _ref2.stripePubKey;
|
|
96
|
+
return stripePubKey ? /*#__PURE__*/_jsx(Elements, {
|
|
97
|
+
stripe: loadStripe(stripePubKey),
|
|
98
|
+
children: /*#__PURE__*/_jsx(InnerForm, {
|
|
99
|
+
doStripePayment: doStripePayment,
|
|
100
|
+
doStripePaymentRequestForButton: doStripePaymentRequestForButton,
|
|
101
|
+
cart: cart,
|
|
102
|
+
error: error,
|
|
103
|
+
loadingStripePayment: loadingStripePayment,
|
|
104
|
+
loadingStripePaymentButtons: loadingStripePaymentButtons,
|
|
105
|
+
setLoadingStripePayment: setLoadingStripePayment,
|
|
106
|
+
PaymentButton: PaymentButton
|
|
107
|
+
})
|
|
108
|
+
}) : /*#__PURE__*/_jsx("div", {
|
|
109
|
+
style: {
|
|
110
|
+
alignItems: "center"
|
|
111
|
+
},
|
|
112
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
113
|
+
style: {
|
|
114
|
+
alignItems: "center",
|
|
115
|
+
display: "flex",
|
|
116
|
+
justifyContent: "center",
|
|
117
|
+
marginBottom: "1rem",
|
|
118
|
+
textAlign: "center"
|
|
119
|
+
},
|
|
120
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
121
|
+
className: "spinner-merchi-small"
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
export default FormStripeCardFields;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { StripePaymentForm, StripePaymentGate } from '@merchi/invoice';
|
|
3
|
+
import LegacyStripeCardForm from './LegacyStripeCardForm';
|
|
4
|
+
import { useCartContext } from '../CartProvider';
|
|
5
|
+
import { tabIdPaymentSuccess } from '../utilities/tabs';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export default function StripeCardForm() {
|
|
8
|
+
var _useCartContext = useCartContext(),
|
|
9
|
+
alertError = _useCartContext.alertError,
|
|
10
|
+
apiUrl = _useCartContext.apiUrl,
|
|
11
|
+
cart = _useCartContext.cart,
|
|
12
|
+
setActiveTabIndex = _useCartContext.setActiveTabIndex,
|
|
13
|
+
setInvoiceJson = _useCartContext.setInvoiceJson;
|
|
14
|
+
return /*#__PURE__*/_jsx(StripePaymentGate, {
|
|
15
|
+
engine: cart.stripePaymentEngine,
|
|
16
|
+
apiUrl: apiUrl || 'https://api.merchi.co/v6/',
|
|
17
|
+
resource: "cart",
|
|
18
|
+
resourceId: cart.id,
|
|
19
|
+
resourceToken: cart.token || cart.cartToken,
|
|
20
|
+
legacy: /*#__PURE__*/_jsx(LegacyStripeCardForm, {}),
|
|
21
|
+
children: /*#__PURE__*/_jsx(StripePaymentForm, {
|
|
22
|
+
apiUrl: apiUrl || 'https://api.merchi.co/v6/',
|
|
23
|
+
resource: "cart",
|
|
24
|
+
resourceId: cart.id,
|
|
25
|
+
resourceToken: cart.token || cart.cartToken,
|
|
26
|
+
onError: alertError,
|
|
27
|
+
onSuccess: function onSuccess(invoice) {
|
|
28
|
+
setInvoiceJson(invoice);
|
|
29
|
+
setActiveTabIndex(tabIdPaymentSuccess);
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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; } }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
9
|
+
import { PaymentRequestButtonElement, useStripe } from '@stripe/react-stripe-js';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
function useOptions(paymentRequest) {
|
|
12
|
+
var options = useMemo(function () {
|
|
13
|
+
return {
|
|
14
|
+
paymentRequest: paymentRequest,
|
|
15
|
+
style: {
|
|
16
|
+
paymentRequestButton: {
|
|
17
|
+
theme: 'dark',
|
|
18
|
+
height: '48px',
|
|
19
|
+
type: 'buy'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}, [paymentRequest]);
|
|
24
|
+
return options;
|
|
25
|
+
}
|
|
26
|
+
function usePaymentRequest(_ref) {
|
|
27
|
+
var options = _ref.options,
|
|
28
|
+
onPaymentMethod = _ref.onPaymentMethod;
|
|
29
|
+
var stripe = useStripe();
|
|
30
|
+
var _useState = useState(null),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
paymentRequest = _useState2[0],
|
|
33
|
+
setPaymentRequest = _useState2[1];
|
|
34
|
+
var _useState3 = useState(false),
|
|
35
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
+
canMakePayment = _useState4[0],
|
|
37
|
+
setCanMakePayment = _useState4[1];
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (stripe && paymentRequest === null) {
|
|
40
|
+
var pr = stripe.paymentRequest(options);
|
|
41
|
+
setPaymentRequest(pr);
|
|
42
|
+
}
|
|
43
|
+
}, [stripe, options, paymentRequest]);
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
var subscribed = true;
|
|
46
|
+
if (paymentRequest) {
|
|
47
|
+
paymentRequest.canMakePayment().then(function (res) {
|
|
48
|
+
if (res && subscribed) {
|
|
49
|
+
setCanMakePayment(true);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return function () {
|
|
54
|
+
subscribed = false;
|
|
55
|
+
};
|
|
56
|
+
}, [paymentRequest]);
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
if (paymentRequest) {
|
|
59
|
+
paymentRequest.on('paymentmethod', onPaymentMethod);
|
|
60
|
+
}
|
|
61
|
+
return function () {
|
|
62
|
+
if (paymentRequest) {
|
|
63
|
+
paymentRequest.off('paymentmethod', onPaymentMethod);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}, [paymentRequest, onPaymentMethod]);
|
|
67
|
+
return canMakePayment ? paymentRequest : null;
|
|
68
|
+
}
|
|
69
|
+
function StripePaymentButtons(_ref2) {
|
|
70
|
+
var doPaymentRequest = _ref2.doPaymentRequest,
|
|
71
|
+
cart = _ref2.cart;
|
|
72
|
+
var paymentRequest = usePaymentRequest({
|
|
73
|
+
options: {
|
|
74
|
+
country: cart.domain.company.country,
|
|
75
|
+
currency: String(cart.currency).toLowerCase(),
|
|
76
|
+
total: {
|
|
77
|
+
label: "Merchi Cart #".concat(cart.id),
|
|
78
|
+
amount: Math.round(cart.totalCost * 100)
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
onPaymentMethod: doPaymentRequest
|
|
82
|
+
});
|
|
83
|
+
var options = useOptions(paymentRequest);
|
|
84
|
+
if (!paymentRequest) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return /*#__PURE__*/_jsx("div", {
|
|
88
|
+
style: {
|
|
89
|
+
marginBottom: '2rem',
|
|
90
|
+
marginTop: '2rem'
|
|
91
|
+
},
|
|
92
|
+
children: /*#__PURE__*/_jsx(PaymentRequestButtonElement, {
|
|
93
|
+
className: "PaymentRequestButton",
|
|
94
|
+
options: options
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
export default StripePaymentButtons;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
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 }; })(); }
|
|
2
|
+
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); }
|
|
3
|
+
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); }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
export function stripeInitPromise(_x) {
|
|
6
|
+
return _stripeInitPromise.apply(this, arguments);
|
|
7
|
+
}
|
|
8
|
+
function _stripeInitPromise() {
|
|
9
|
+
_stripeInitPromise = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(apiUrl) {
|
|
10
|
+
return _regenerator().w(function (_context) {
|
|
11
|
+
while (1) switch (_context.n) {
|
|
12
|
+
case 0:
|
|
13
|
+
_context.n = 1;
|
|
14
|
+
return fetch("".concat(apiUrl, "stripe/master_publishable_key/"), {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
mode: 'cors'
|
|
17
|
+
}).then(function (response) {
|
|
18
|
+
return response.key;
|
|
19
|
+
});
|
|
20
|
+
case 1:
|
|
21
|
+
return _context.a(2, _context.v);
|
|
22
|
+
}
|
|
23
|
+
}, _callee);
|
|
24
|
+
}));
|
|
25
|
+
return _stripeInitPromise.apply(this, arguments);
|
|
26
|
+
}
|
|
27
|
+
function createPaymentIntent(_x2, _x3, _x4) {
|
|
28
|
+
return _createPaymentIntent.apply(this, arguments);
|
|
29
|
+
}
|
|
30
|
+
function _createPaymentIntent() {
|
|
31
|
+
_createPaymentIntent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(apiUrl, cart, paymentMethodType) {
|
|
32
|
+
var id, token, fetchOptions, queryParams, queryString, uri, url, response;
|
|
33
|
+
return _regenerator().w(function (_context2) {
|
|
34
|
+
while (1) switch (_context2.n) {
|
|
35
|
+
case 0:
|
|
36
|
+
id = cart.id, token = cart.token;
|
|
37
|
+
fetchOptions = {
|
|
38
|
+
method: 'GET',
|
|
39
|
+
mode: 'cors'
|
|
40
|
+
};
|
|
41
|
+
queryParams = [['cart_token', token]];
|
|
42
|
+
if (paymentMethodType) {
|
|
43
|
+
queryParams.push(['payment_method_types', paymentMethodType]);
|
|
44
|
+
}
|
|
45
|
+
queryString = new URLSearchParams(queryParams).toString();
|
|
46
|
+
uri = "stripe/payment_intent/cart/".concat(id, "/");
|
|
47
|
+
url = "".concat(apiUrl).concat(uri, "?").concat(queryString);
|
|
48
|
+
_context2.n = 1;
|
|
49
|
+
return fetch(url, fetchOptions);
|
|
50
|
+
case 1:
|
|
51
|
+
response = _context2.v;
|
|
52
|
+
if (response.ok) {
|
|
53
|
+
_context2.n = 2;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
throw new Error("Failed to create payment intent.");
|
|
57
|
+
case 2:
|
|
58
|
+
_context2.n = 3;
|
|
59
|
+
return response.json();
|
|
60
|
+
case 3:
|
|
61
|
+
return _context2.a(2, _context2.v);
|
|
62
|
+
}
|
|
63
|
+
}, _callee2);
|
|
64
|
+
}));
|
|
65
|
+
return _createPaymentIntent.apply(this, arguments);
|
|
66
|
+
}
|
|
67
|
+
function checkPaymentIntnetIsComplete(_x5, _x6) {
|
|
68
|
+
return _checkPaymentIntnetIsComplete.apply(this, arguments);
|
|
69
|
+
}
|
|
70
|
+
function _checkPaymentIntnetIsComplete() {
|
|
71
|
+
_checkPaymentIntnetIsComplete = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(apiUrl, cart) {
|
|
72
|
+
var url, fetchOptions, queryString, response, i;
|
|
73
|
+
return _regenerator().w(function (_context3) {
|
|
74
|
+
while (1) switch (_context3.n) {
|
|
75
|
+
case 0:
|
|
76
|
+
url = "stripe/payment_intent/cart/complete/".concat(cart.id, "/");
|
|
77
|
+
fetchOptions = {
|
|
78
|
+
method: 'GET',
|
|
79
|
+
mode: 'cors'
|
|
80
|
+
};
|
|
81
|
+
queryString = new URLSearchParams({
|
|
82
|
+
cart_token: cart.token
|
|
83
|
+
}).toString();
|
|
84
|
+
_context3.n = 1;
|
|
85
|
+
return fetch("".concat(apiUrl).concat(url, "?").concat(queryString), fetchOptions);
|
|
86
|
+
case 1:
|
|
87
|
+
response = _context3.v;
|
|
88
|
+
if (response.ok) {
|
|
89
|
+
_context3.n = 2;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
throw new Error("Failed to check if payment intent is complete.");
|
|
93
|
+
case 2:
|
|
94
|
+
_context3.n = 3;
|
|
95
|
+
return response.json();
|
|
96
|
+
case 3:
|
|
97
|
+
i = _context3.v;
|
|
98
|
+
return _context3.a(2, i.invoice);
|
|
99
|
+
}
|
|
100
|
+
}, _callee3);
|
|
101
|
+
}));
|
|
102
|
+
return _checkPaymentIntnetIsComplete.apply(this, arguments);
|
|
103
|
+
}
|
|
104
|
+
export function stripeCardFormSubmit(_x7, _x8, _x9, _x0) {
|
|
105
|
+
return _stripeCardFormSubmit.apply(this, arguments);
|
|
106
|
+
}
|
|
107
|
+
function _stripeCardFormSubmit() {
|
|
108
|
+
_stripeCardFormSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(apiUrl, stripe, card, cart) {
|
|
109
|
+
var intent, stripePayment, _t;
|
|
110
|
+
return _regenerator().w(function (_context4) {
|
|
111
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
112
|
+
case 0:
|
|
113
|
+
_context4.p = 0;
|
|
114
|
+
_context4.n = 1;
|
|
115
|
+
return createPaymentIntent(apiUrl, cart);
|
|
116
|
+
case 1:
|
|
117
|
+
intent = _context4.v;
|
|
118
|
+
_context4.n = 2;
|
|
119
|
+
return stripe.confirmCardPayment(intent.stripeClientSecret, {
|
|
120
|
+
payment_method: {
|
|
121
|
+
card: card
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
case 2:
|
|
125
|
+
stripePayment = _context4.v;
|
|
126
|
+
if (!stripePayment.error) {
|
|
127
|
+
_context4.n = 3;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
throw new Error(stripePayment.error.message || 'Stripe connect unknown error');
|
|
131
|
+
case 3:
|
|
132
|
+
_context4.n = 4;
|
|
133
|
+
return checkPaymentIntnetIsComplete(apiUrl, cart);
|
|
134
|
+
case 4:
|
|
135
|
+
return _context4.a(2, _context4.v);
|
|
136
|
+
case 5:
|
|
137
|
+
_context4.p = 5;
|
|
138
|
+
_t = _context4.v;
|
|
139
|
+
throw _t;
|
|
140
|
+
case 6:
|
|
141
|
+
return _context4.a(2);
|
|
142
|
+
}
|
|
143
|
+
}, _callee4, null, [[0, 5]]);
|
|
144
|
+
}));
|
|
145
|
+
return _stripeCardFormSubmit.apply(this, arguments);
|
|
146
|
+
}
|
|
147
|
+
export function stripePaymentButtonSubmit(_x1, _x10, _x11, _x12) {
|
|
148
|
+
return _stripePaymentButtonSubmit.apply(this, arguments);
|
|
149
|
+
}
|
|
150
|
+
function _stripePaymentButtonSubmit() {
|
|
151
|
+
_stripePaymentButtonSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(apiUrl, stripe, cart, paymentMethodEvent) {
|
|
152
|
+
var complete, paymentMethod, intent, stripePayment, _t2;
|
|
153
|
+
return _regenerator().w(function (_context5) {
|
|
154
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
155
|
+
case 0:
|
|
156
|
+
complete = paymentMethodEvent.complete, paymentMethod = paymentMethodEvent.paymentMethod;
|
|
157
|
+
_context5.p = 1;
|
|
158
|
+
_context5.n = 2;
|
|
159
|
+
return createPaymentIntent(apiUrl, cart);
|
|
160
|
+
case 2:
|
|
161
|
+
intent = _context5.v;
|
|
162
|
+
_context5.n = 3;
|
|
163
|
+
return stripe.confirmCardPayment(intent.stripeClientSecret, {
|
|
164
|
+
payment_method: paymentMethod.id
|
|
165
|
+
}, {
|
|
166
|
+
handleActions: false
|
|
167
|
+
});
|
|
168
|
+
case 3:
|
|
169
|
+
stripePayment = _context5.v;
|
|
170
|
+
if (!stripePayment.error) {
|
|
171
|
+
_context5.n = 4;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
throw new Error(stripePayment.error.message || 'Stripe unknown error');
|
|
175
|
+
case 4:
|
|
176
|
+
complete('success');
|
|
177
|
+
_context5.n = 5;
|
|
178
|
+
return checkPaymentIntnetIsComplete(apiUrl, cart);
|
|
179
|
+
case 5:
|
|
180
|
+
return _context5.a(2, _context5.v);
|
|
181
|
+
case 6:
|
|
182
|
+
_context5.p = 6;
|
|
183
|
+
_t2 = _context5.v;
|
|
184
|
+
complete('fail');
|
|
185
|
+
throw _t2;
|
|
186
|
+
case 7:
|
|
187
|
+
return _context5.a(2);
|
|
188
|
+
}
|
|
189
|
+
}, _callee5, null, [[1, 6]]);
|
|
190
|
+
}));
|
|
191
|
+
return _stripePaymentButtonSubmit.apply(this, arguments);
|
|
192
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function companyStripePubKeyOrTestPubKey(company) {
|
|
2
|
+
return company.isTesting ? company.stripePublishableTestKey : company.stripePublishableKey;
|
|
3
|
+
}
|
|
4
|
+
export var CARD_ELEMENT_OPTIONS = {
|
|
5
|
+
hidePostalCode: true,
|
|
6
|
+
style: {
|
|
7
|
+
base: {
|
|
8
|
+
'::placeholder': {
|
|
9
|
+
color: '#999',
|
|
10
|
+
fontSize: '16px'
|
|
11
|
+
},
|
|
12
|
+
fontSize: '16px',
|
|
13
|
+
lineHeight: '1.33',
|
|
14
|
+
paddingTop: '4px'
|
|
15
|
+
},
|
|
16
|
+
invalid: {
|
|
17
|
+
color: '#9e2146'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|