merchi_cart 1.3.11 → 1.4.2
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 -21
- package/README.md +134 -134
- package/esm/components/CustomCartProductForm.js +3 -3
- package/esm/components/product-form-sdk-externals.js +3 -3
- package/esm/square/SquareCard.js +9 -9
- package/esm/stripe/LegacyStripeCardForm.js +161 -0
- package/esm/stripe/StripeCardForm.js +26 -154
- package/esm/utilities/area.js +15 -15
- package/esm/utilities/currency.js +7 -7
- package/esm/utilities/customForm.js +4 -4
- package/lib/components/CustomCartProductForm.js +3 -3
- package/lib/components/product-form-sdk-externals.js +3 -3
- package/lib/square/SquareCard.js +9 -9
- package/lib/stripe/LegacyStripeCardForm.js +168 -0
- package/lib/stripe/StripeCardForm.js +28 -153
- package/lib/utilities/area.js +15 -15
- package/lib/utilities/currency.js +7 -7
- package/lib/utilities/customForm.js +4 -4
- package/package.json +105 -104
- package/src/Cart.tsx +96 -96
- package/src/CartAlert.tsx +35 -35
- package/src/CartHeader.tsx +28 -28
- package/src/CartProvider.tsx +998 -998
- package/src/CartTotals.tsx +102 -102
- package/src/buttons/Button.tsx +35 -35
- package/src/buttons/ButtonBack.tsx +42 -42
- package/src/buttons/ButtonClearCart.tsx +17 -17
- package/src/buttons/ButtonInvoiceDownload.tsx +60 -60
- package/src/buttons/ButtonNext.tsx +35 -35
- package/src/buttons/ButtonNextDynamic.tsx +31 -31
- package/src/buttons/ButtonOpenCartMerchiCartModal.tsx +61 -61
- package/src/buttons/ButtonPay.tsx +32 -32
- package/src/buttons/ButtonShipmentTabNext.tsx +24 -24
- package/src/buttons/index.ts +15 -15
- package/src/components/Alert.tsx +31 -31
- package/src/components/CartBody.tsx +16 -16
- package/src/components/CartClient.tsx +52 -52
- package/src/components/CartFooter.tsx +15 -15
- package/src/components/CartItemRow.tsx +212 -212
- package/src/components/CartPaymentSettingsInvalid.tsx +12 -12
- package/src/components/CartShipment.tsx +56 -56
- package/src/components/CartTabContent.tsx +15 -15
- package/src/components/CartTabPanel.tsx +25 -25
- package/src/components/CartTableContainer.tsx +15 -15
- package/src/components/CartTitle.tsx +22 -22
- package/src/components/CartTotalsListGroup.tsx +58 -58
- package/src/components/Collapse.tsx +23 -23
- package/src/components/CustomCartProductForm.tsx +123 -123
- package/src/components/CustomerCheckoutMethodTabs.tsx +106 -106
- package/src/components/DiscountInputGroup.tsx +160 -160
- package/src/components/LoadingTemplate.tsx +22 -22
- package/src/components/NoCartItems.tsx +20 -20
- package/src/components/ShipmentGroupCard.tsx +170 -170
- package/src/components/Table.tsx +15 -15
- package/src/components/containers.tsx +40 -40
- package/src/components/index.ts +38 -38
- package/src/components/product-form-sdk-externals.ts +67 -67
- package/src/forms/FormNewCustomer.tsx +170 -170
- package/src/forms/FormReturningCustomer.tsx +117 -117
- package/src/forms/FormShipmentAddressAndNotes.tsx +165 -165
- package/src/forms/FormSquarePayment.tsx +19 -19
- package/src/forms/FormStripePayment.tsx +19 -19
- package/src/forms/FormWhatsappCustomer.tsx +179 -179
- package/src/forms/InputAcceptUserTermsAndConditions.tsx +43 -43
- package/src/forms/InputError.tsx +23 -23
- package/src/forms/InputSelect.tsx +58 -58
- package/src/forms/InputText.tsx +56 -56
- package/src/forms/InputsAddress.tsx +205 -205
- package/src/forms/index.ts +18 -18
- package/src/index.ts +31 -31
- package/src/modals.tsx +65 -65
- package/src/panels/PanelCartItems.tsx +56 -56
- package/src/panels/PanelCartShipment.tsx +86 -86
- package/src/panels/PanelClearCart.tsx +50 -50
- package/src/panels/PanelClientCheckout.tsx +102 -102
- package/src/panels/PanelEditCartItem.tsx +172 -172
- package/src/panels/PanelPaymentSuccess.tsx +66 -66
- package/src/panels/index.ts +15 -15
- package/src/square/SquareCard.tsx +84 -84
- package/src/stripe/LegacyStripeCardForm.tsx +91 -0
- package/src/stripe/StripeCardFields.tsx +173 -173
- package/src/stripe/StripeCardForm.tsx +18 -91
- package/src/stripe/StripePaymentButtons.tsx +117 -117
- package/src/stripe/actions.ts +94 -94
- package/src/stripe/utils.ts +22 -22
- package/src/styles/globals.scss +433 -433
- package/src/tabs/CartNav.tsx +18 -18
- package/src/tabs/NavTab.tsx +36 -36
- package/src/types/assets.d.ts +4 -4
- package/src/types/index.ts +15 -15
- package/src/types/merchi_product_form/index.d.ts +1 -1
- package/src/types/merchi_sdk_ts/index.d.ts +1 -1
- package/src/types/react-geosuggest/index.d.ts +1 -1
- package/src/utilities/address.ts +364 -364
- package/src/utilities/area.ts +359 -359
- package/src/utilities/cart.ts +80 -80
- package/src/utilities/company.ts +8 -8
- package/src/utilities/cookie.ts +58 -58
- package/src/utilities/currency.ts +216 -216
- package/src/utilities/customForm.ts +71 -71
- package/src/utilities/helpers.ts +213 -213
- package/src/utilities/index.ts +14 -14
- package/src/utilities/invoice.ts +60 -60
- package/src/utilities/job.ts +13 -13
- package/src/utilities/local_storage.ts +130 -130
- package/src/utilities/product.ts +14 -14
- package/src/utilities/shipment.ts +11 -11
- package/src/utilities/tabs.ts +38 -38
- package/src/utilities/user.ts +33 -33
- package/src/utilities/variations.ts +80 -80
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Merchi
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Merchi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
# merchi_cart
|
|
2
|
-
Merchi's cart
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Installation](#installation)
|
|
8
|
-
- [Usage](#usage)
|
|
9
|
-
- [Props](#props)
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install merchi_cart
|
|
15
|
-
|
|
16
|
-
or
|
|
17
|
-
|
|
18
|
-
yarn add merchi_cart
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Usage
|
|
22
|
-
context functions:
|
|
23
|
-
|
|
24
|
-
components:
|
|
25
|
-
ButtonOpenCart
|
|
26
|
-
ButtonListWrappedOpenCart
|
|
27
|
-
MerchiCart
|
|
28
|
-
MerchiCartModal
|
|
29
|
-
MerchiShoppingCartModal
|
|
30
|
-
|
|
31
|
-
context functions:
|
|
32
|
-
setCartComplete - Resets the cart
|
|
33
|
-
refetchCart - refetches the cart
|
|
34
|
-
createCartAndCookie - clears and resets the cart with a new cookie
|
|
35
|
-
getCartShipmentOptions - refetches the cart shipment options
|
|
36
|
-
|
|
37
|
-
window functions:
|
|
38
|
-
addCartItem - takes job json and creates a cart item
|
|
39
|
-
getCart - fetches the cart
|
|
40
|
-
getMerchiCartValues - retruns the following:
|
|
41
|
-
cart
|
|
42
|
-
cartItemsCount
|
|
43
|
-
currency
|
|
44
|
-
subtotalCost
|
|
45
|
-
taxAmount
|
|
46
|
-
totalCost
|
|
47
|
-
isMerchiCartFetching - checks the fetching state of the cart
|
|
48
|
-
setCartComplete - Resets the cart
|
|
49
|
-
toggleCartOpen - open close cart modal
|
|
50
|
-
refetchCart - refetches the cart
|
|
51
|
-
createCartAndCookie = clears and resets the cart with a new cookie
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
### Props
|
|
55
|
-
|
|
56
|
-
| Name | Type | Default | Description |
|
|
57
|
-
|-----------------------------------------------|------------|-----------------------------------------------------------------------------|---------------------------------------|
|
|
58
|
-
| `cart` | `cartJson Object || undefined`| `"{}"` | `Pass in a cart to init the cart state in the provider`|
|
|
59
|
-
| `classNameAlertError` | `string?` | `"alert alert-danger"` | `Class for alert error` |
|
|
60
|
-
| `classNameAlertInfo` | `string?` | `"alert alert-info"` | `Class for alert info` |
|
|
61
|
-
| `classNameAlertSuccess` | `string?` | `"alert alert-success"` | `Class for alert success` |
|
|
62
|
-
| `classNameAlertWarning` | `string?` | `"alert alert-warning"` | `Class for alert warning` |
|
|
63
|
-
| `classNameBtn` | `string?` | `"btn"` | `Base class for button elements` |
|
|
64
|
-
| `classNameBtnBack` | `string?` | `"btn-lg btn-default pull-left"` | `Class for back button` |
|
|
65
|
-
| `classNameBtnCartClear` | `string?` | `"btn-lg btn-danger mr-auto"` | `Class for clear cart button` |
|
|
66
|
-
| `classNameBtnClose` | `string?` | `"btn-close"` | `Class for close button element` |
|
|
67
|
-
| `classNameBtnDanger` | `string?` | `"btn btn-md btn-danger"` | `Class for button danger element` |
|
|
68
|
-
| `classNameBtnDownloadInvoice` | `string?` | `"btn btn-lg btn-primary"` | `Class for button download element` |
|
|
69
|
-
| `classNameBtnLink` | `string?` | `"btn-md btn-link"` | `Class for link button elements` |
|
|
70
|
-
| `classNameBtnNext` | `string?` | `"btn-lg btn-primary"` | `Class for next button` |
|
|
71
|
-
| `classNameBtnNextComplete` | `string?` | `"btn-lg btn-success"` | `Class for next button completed` |
|
|
72
|
-
| `classNameBtnPay` | `string?` | `"btn-lg btn-primary width-full"` | `Class for pay button completed` |
|
|
73
|
-
| `classNameBtnPrimary` | `string?` | `"btn btn-md btn-primary"` | `Class for edit cart item button` |
|
|
74
|
-
| `classNameBtnEditCartItem` | `string?` | `"btn btn-md btn-primary ml-auto"` | `Class for primary button completed` |
|
|
75
|
-
| `classNameCartBody` | `string?` | `"merchi-cart-body"` | `Class for cart body container` |
|
|
76
|
-
| `classNameCartFooter` | `string?` | `"merchi-cart-footer"` | `Class for cart footer container` |
|
|
77
|
-
| `classNameCartFormGroup` | `string?` | `"form-group merchi-form-group"` | `Class for form group element` |
|
|
78
|
-
| `classNameCartFormGroupButton` | `string?` | `"merchi-form-group-button"` | `Class for form group button` |
|
|
79
|
-
| `classNameCartFormGroupCheckbox` | `string?` | `"form-check"` | `Class for form group checkbox` |
|
|
80
|
-
| `classNameCartFormInput` | `string?` | `"form-control"` | `Class for form input` |
|
|
81
|
-
| `classNameCartFormLabelCheckbox` | `string?` | `""` | `Class for form input checkbpx label` |
|
|
82
|
-
| `classNameCartFormCheckbox` | `string?` | `"form-check-input"` | `Class for form input checkbpx` |
|
|
83
|
-
| `classNameCartHeader` | `string?` | `"merchi-cart-header"` | `Class for cart header container` |
|
|
84
|
-
| `classNameCartInputError` | `string?` | `"text-danger"` | `Class for form error` |
|
|
85
|
-
| `classNameCartNav` | `string?` | `"nav merchi-nav-tabs merchi-nav merchi-nav-fill merchi-nav-pills"` | `Class for cart nav` |
|
|
86
|
-
| `classNameNoItems` | `string?` | `"merchi-no-cart-items"` | `Class for no items in cart` |
|
|
87
|
-
| `classNameCartGoogleSuggestList` | `string?` | `"list-group m-b-0"` | `Class for google suggest list` |
|
|
88
|
-
| `classNameCartGoogleSuggestListItem` | `string?` | `"list-group-item cursor-pointer"` | `Class for google suggest list item` |
|
|
89
|
-
| `classNameCartItemFeatureImage` | `string?` | `"img-rounded m-10"` | `Class for cart item feature image` |
|
|
90
|
-
| `classNameCartItemInfo` | `string?` | `"text-muted font-weight-normal font-italic"` | `Class for cart item info element` |
|
|
91
|
-
| `classNameCartItemInfoCell` | `string?` | `"border-0 align-middle"` | `Class for cart item cell` |
|
|
92
|
-
| `classNameCartItemInfoCellRight` | `string?` | `"border-0 align-middle text-right"` | `Class for cart item cell right align`|
|
|
93
|
-
| `classNameCartItemInfoContainer` | `string?` | `"ml-3 d-inline-block align-middle"` | `Class for cart item info container` |
|
|
94
|
-
| `classNameCartRow` | `string?` | `"merchi-row"` | `Class for row element` |
|
|
95
|
-
| `classNameCartRowColumn` | `string?` | `"merchi-column"` | `Class for row column element` |
|
|
96
|
-
| `classNameTableContainer` | `string?` | `"table-responsive"` | `Class for cart table container` |
|
|
97
|
-
| `classNameCartTab` | `string?` | `"merchi-tab-content"` | `Class for cart tab container` |
|
|
98
|
-
| `classNameCartTabItem` | `string?` | `"nav-item merchi-nav-item"` | `Class for cart tab item` |
|
|
99
|
-
| `classNameCartTabItemLink` | `string?` | `"merchi-nav-link"` | `Class for cart tab item link |`
|
|
100
|
-
| `classNameCartTitle` | `string?` | `"merchi-cart-title"` | `Class for cart Title container` |
|
|
101
|
-
| `classNameCartTotalContainer` | `string?` | `"merchi-cart-total-container"` | `Class for totals container elements` |
|
|
102
|
-
| `classNameCartToggleIconButton` | `string?` | `"cart-icon-button-class"` | `Class for toggle modal button` |
|
|
103
|
-
| `classNameCartTotalItem` | `string?` | `"merchi-cart-total-item"` | `Class for totals item elements` |
|
|
104
|
-
| `classNameCartTotalItemPrice` | `string?` | `"merchi-cart-total-item-price"` | `Class for totals item price elements`|
|
|
105
|
-
| `classNameClearCartContainer` | `string?` | `"merchi-cart-clear-container"` | `Class cart clear container` |
|
|
106
|
-
| `classNameClearCartText` | `string?` | `"merchi-cart-clear-text"` | `Class cart clear text container` |
|
|
107
|
-
| `classNameListClientInfo` | `string?` | `"merchi-cart-client-info-list"` | `Class for client info list` |
|
|
108
|
-
| `classNameListContainer` | `string?` | `"pb-2"` | `Class for list conatiner element` |
|
|
109
|
-
| `classNameCartTotaListContainer` | `string?` | `"merchi-cart-total-list-container"` | `Class for list conatiner for cart totlas element`|
|
|
110
|
-
| `classNameListItem` | `string?` | `"list-group-item"` | `Class for list item elements` |
|
|
111
|
-
| `classNameListItemCartTotals` | `string?` | `"list-group-item d-flex justify-content-between align-items-center"` | `Class for list item cart totals elements`|
|
|
112
|
-
| `classNameList` | `string?` | `"list-group"` | `Class for list elements` |
|
|
113
|
-
| `classNameListInline` | `string?` | `"list-inline"` | `Class for list inline elements` |
|
|
114
|
-
| `classNameListUnstyles` | `string?` | `"list-unstyled"` | `Class for list unstyled elements` |
|
|
115
|
-
| `classNameLoadingTemplate` | `string?` | `"merchi-loading-template"` | `Class for loading elements` |
|
|
116
|
-
| `classNameLoadingTemplateContainer` | `string?` | `"merchi-loading-template-container"` | `Class for loading container elements`|
|
|
117
|
-
| `classNameShipmentOption` | `string?` | `"merchi-shipment-option"` | `Class for shipment option element` |
|
|
118
|
-
| `classNameTable` | `string?` | `"table"` | `Class for table elements` |
|
|
119
|
-
| `classNameVariationsList` | `string?` | `"list-unstyled list-inline"` | `Class for variation info` |
|
|
120
|
-
| `customSuccessMessage` | `string?` | `undefined` | `A message to display on payment success` |
|
|
121
|
-
| `domainId` | `number` | `undefined` | `The merchi domain/store id for the cart` |
|
|
122
|
-
| `footer` | `ReactElement`| `undefined` | `A customer footer component` |
|
|
123
|
-
| `hideHead` | `boolean` | `false` | `hides the cart head title and close` |
|
|
124
|
-
| `includeTheme` | `boolean?` | `false` | `If true will fetch and apply the store theme to the page` |
|
|
125
|
-
| `initialiseCart` | `boolean?` | `true` | `If true will initial fetch cart and set cart function on window`|
|
|
126
|
-
| `onClickClose` | `() => void?`| `() => console.log('close merchi cart!')` | `a function to close the cart` |
|
|
127
|
-
| `setIsCartModalOpen` | `(isOpen: boolean) => void?`| `() => console.log('close merchi cart!')` | `a function to open/close cart modal wrapper`|
|
|
128
|
-
| `isCartModalOpen` | `boolean` | `false` | `a boolean value to control the cart modal open/closed`|
|
|
129
|
-
| `productFormClassNames` | `obj` | `{}` | `An object to be passsed to the merchi_product_form `|
|
|
130
|
-
| `showUserTermsAndConditions` | `boolean?` | `true` | `Display the user t&cs for Merchi` |
|
|
131
|
-
| `showCartItemInfo` | `boolean?` | `true` | `Will display the cart item info in the cart items table`|
|
|
132
|
-
| `apiUrl` | `string?` | `'https://api.merchi.co/v6/'` | `URL to connect to the Merchi API` |
|
|
133
|
-
| `urlFrontend` | `string?` | `'https://merchi.co/'` | `URL to redirect users to a frontend` |
|
|
134
|
-
| `urlTrackingPage` | `string?` | `undefined` | `URL used on the thankyou page for tracking`|
|
|
1
|
+
# merchi_cart
|
|
2
|
+
Merchi's cart
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Props](#props)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install merchi_cart
|
|
15
|
+
|
|
16
|
+
or
|
|
17
|
+
|
|
18
|
+
yarn add merchi_cart
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Usage
|
|
22
|
+
context functions:
|
|
23
|
+
|
|
24
|
+
components:
|
|
25
|
+
ButtonOpenCart
|
|
26
|
+
ButtonListWrappedOpenCart
|
|
27
|
+
MerchiCart
|
|
28
|
+
MerchiCartModal
|
|
29
|
+
MerchiShoppingCartModal
|
|
30
|
+
|
|
31
|
+
context functions:
|
|
32
|
+
setCartComplete - Resets the cart
|
|
33
|
+
refetchCart - refetches the cart
|
|
34
|
+
createCartAndCookie - clears and resets the cart with a new cookie
|
|
35
|
+
getCartShipmentOptions - refetches the cart shipment options
|
|
36
|
+
|
|
37
|
+
window functions:
|
|
38
|
+
addCartItem - takes job json and creates a cart item
|
|
39
|
+
getCart - fetches the cart
|
|
40
|
+
getMerchiCartValues - retruns the following:
|
|
41
|
+
cart
|
|
42
|
+
cartItemsCount
|
|
43
|
+
currency
|
|
44
|
+
subtotalCost
|
|
45
|
+
taxAmount
|
|
46
|
+
totalCost
|
|
47
|
+
isMerchiCartFetching - checks the fetching state of the cart
|
|
48
|
+
setCartComplete - Resets the cart
|
|
49
|
+
toggleCartOpen - open close cart modal
|
|
50
|
+
refetchCart - refetches the cart
|
|
51
|
+
createCartAndCookie = clears and resets the cart with a new cookie
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Props
|
|
55
|
+
|
|
56
|
+
| Name | Type | Default | Description |
|
|
57
|
+
|-----------------------------------------------|------------|-----------------------------------------------------------------------------|---------------------------------------|
|
|
58
|
+
| `cart` | `cartJson Object || undefined`| `"{}"` | `Pass in a cart to init the cart state in the provider`|
|
|
59
|
+
| `classNameAlertError` | `string?` | `"alert alert-danger"` | `Class for alert error` |
|
|
60
|
+
| `classNameAlertInfo` | `string?` | `"alert alert-info"` | `Class for alert info` |
|
|
61
|
+
| `classNameAlertSuccess` | `string?` | `"alert alert-success"` | `Class for alert success` |
|
|
62
|
+
| `classNameAlertWarning` | `string?` | `"alert alert-warning"` | `Class for alert warning` |
|
|
63
|
+
| `classNameBtn` | `string?` | `"btn"` | `Base class for button elements` |
|
|
64
|
+
| `classNameBtnBack` | `string?` | `"btn-lg btn-default pull-left"` | `Class for back button` |
|
|
65
|
+
| `classNameBtnCartClear` | `string?` | `"btn-lg btn-danger mr-auto"` | `Class for clear cart button` |
|
|
66
|
+
| `classNameBtnClose` | `string?` | `"btn-close"` | `Class for close button element` |
|
|
67
|
+
| `classNameBtnDanger` | `string?` | `"btn btn-md btn-danger"` | `Class for button danger element` |
|
|
68
|
+
| `classNameBtnDownloadInvoice` | `string?` | `"btn btn-lg btn-primary"` | `Class for button download element` |
|
|
69
|
+
| `classNameBtnLink` | `string?` | `"btn-md btn-link"` | `Class for link button elements` |
|
|
70
|
+
| `classNameBtnNext` | `string?` | `"btn-lg btn-primary"` | `Class for next button` |
|
|
71
|
+
| `classNameBtnNextComplete` | `string?` | `"btn-lg btn-success"` | `Class for next button completed` |
|
|
72
|
+
| `classNameBtnPay` | `string?` | `"btn-lg btn-primary width-full"` | `Class for pay button completed` |
|
|
73
|
+
| `classNameBtnPrimary` | `string?` | `"btn btn-md btn-primary"` | `Class for edit cart item button` |
|
|
74
|
+
| `classNameBtnEditCartItem` | `string?` | `"btn btn-md btn-primary ml-auto"` | `Class for primary button completed` |
|
|
75
|
+
| `classNameCartBody` | `string?` | `"merchi-cart-body"` | `Class for cart body container` |
|
|
76
|
+
| `classNameCartFooter` | `string?` | `"merchi-cart-footer"` | `Class for cart footer container` |
|
|
77
|
+
| `classNameCartFormGroup` | `string?` | `"form-group merchi-form-group"` | `Class for form group element` |
|
|
78
|
+
| `classNameCartFormGroupButton` | `string?` | `"merchi-form-group-button"` | `Class for form group button` |
|
|
79
|
+
| `classNameCartFormGroupCheckbox` | `string?` | `"form-check"` | `Class for form group checkbox` |
|
|
80
|
+
| `classNameCartFormInput` | `string?` | `"form-control"` | `Class for form input` |
|
|
81
|
+
| `classNameCartFormLabelCheckbox` | `string?` | `""` | `Class for form input checkbpx label` |
|
|
82
|
+
| `classNameCartFormCheckbox` | `string?` | `"form-check-input"` | `Class for form input checkbpx` |
|
|
83
|
+
| `classNameCartHeader` | `string?` | `"merchi-cart-header"` | `Class for cart header container` |
|
|
84
|
+
| `classNameCartInputError` | `string?` | `"text-danger"` | `Class for form error` |
|
|
85
|
+
| `classNameCartNav` | `string?` | `"nav merchi-nav-tabs merchi-nav merchi-nav-fill merchi-nav-pills"` | `Class for cart nav` |
|
|
86
|
+
| `classNameNoItems` | `string?` | `"merchi-no-cart-items"` | `Class for no items in cart` |
|
|
87
|
+
| `classNameCartGoogleSuggestList` | `string?` | `"list-group m-b-0"` | `Class for google suggest list` |
|
|
88
|
+
| `classNameCartGoogleSuggestListItem` | `string?` | `"list-group-item cursor-pointer"` | `Class for google suggest list item` |
|
|
89
|
+
| `classNameCartItemFeatureImage` | `string?` | `"img-rounded m-10"` | `Class for cart item feature image` |
|
|
90
|
+
| `classNameCartItemInfo` | `string?` | `"text-muted font-weight-normal font-italic"` | `Class for cart item info element` |
|
|
91
|
+
| `classNameCartItemInfoCell` | `string?` | `"border-0 align-middle"` | `Class for cart item cell` |
|
|
92
|
+
| `classNameCartItemInfoCellRight` | `string?` | `"border-0 align-middle text-right"` | `Class for cart item cell right align`|
|
|
93
|
+
| `classNameCartItemInfoContainer` | `string?` | `"ml-3 d-inline-block align-middle"` | `Class for cart item info container` |
|
|
94
|
+
| `classNameCartRow` | `string?` | `"merchi-row"` | `Class for row element` |
|
|
95
|
+
| `classNameCartRowColumn` | `string?` | `"merchi-column"` | `Class for row column element` |
|
|
96
|
+
| `classNameTableContainer` | `string?` | `"table-responsive"` | `Class for cart table container` |
|
|
97
|
+
| `classNameCartTab` | `string?` | `"merchi-tab-content"` | `Class for cart tab container` |
|
|
98
|
+
| `classNameCartTabItem` | `string?` | `"nav-item merchi-nav-item"` | `Class for cart tab item` |
|
|
99
|
+
| `classNameCartTabItemLink` | `string?` | `"merchi-nav-link"` | `Class for cart tab item link |`
|
|
100
|
+
| `classNameCartTitle` | `string?` | `"merchi-cart-title"` | `Class for cart Title container` |
|
|
101
|
+
| `classNameCartTotalContainer` | `string?` | `"merchi-cart-total-container"` | `Class for totals container elements` |
|
|
102
|
+
| `classNameCartToggleIconButton` | `string?` | `"cart-icon-button-class"` | `Class for toggle modal button` |
|
|
103
|
+
| `classNameCartTotalItem` | `string?` | `"merchi-cart-total-item"` | `Class for totals item elements` |
|
|
104
|
+
| `classNameCartTotalItemPrice` | `string?` | `"merchi-cart-total-item-price"` | `Class for totals item price elements`|
|
|
105
|
+
| `classNameClearCartContainer` | `string?` | `"merchi-cart-clear-container"` | `Class cart clear container` |
|
|
106
|
+
| `classNameClearCartText` | `string?` | `"merchi-cart-clear-text"` | `Class cart clear text container` |
|
|
107
|
+
| `classNameListClientInfo` | `string?` | `"merchi-cart-client-info-list"` | `Class for client info list` |
|
|
108
|
+
| `classNameListContainer` | `string?` | `"pb-2"` | `Class for list conatiner element` |
|
|
109
|
+
| `classNameCartTotaListContainer` | `string?` | `"merchi-cart-total-list-container"` | `Class for list conatiner for cart totlas element`|
|
|
110
|
+
| `classNameListItem` | `string?` | `"list-group-item"` | `Class for list item elements` |
|
|
111
|
+
| `classNameListItemCartTotals` | `string?` | `"list-group-item d-flex justify-content-between align-items-center"` | `Class for list item cart totals elements`|
|
|
112
|
+
| `classNameList` | `string?` | `"list-group"` | `Class for list elements` |
|
|
113
|
+
| `classNameListInline` | `string?` | `"list-inline"` | `Class for list inline elements` |
|
|
114
|
+
| `classNameListUnstyles` | `string?` | `"list-unstyled"` | `Class for list unstyled elements` |
|
|
115
|
+
| `classNameLoadingTemplate` | `string?` | `"merchi-loading-template"` | `Class for loading elements` |
|
|
116
|
+
| `classNameLoadingTemplateContainer` | `string?` | `"merchi-loading-template-container"` | `Class for loading container elements`|
|
|
117
|
+
| `classNameShipmentOption` | `string?` | `"merchi-shipment-option"` | `Class for shipment option element` |
|
|
118
|
+
| `classNameTable` | `string?` | `"table"` | `Class for table elements` |
|
|
119
|
+
| `classNameVariationsList` | `string?` | `"list-unstyled list-inline"` | `Class for variation info` |
|
|
120
|
+
| `customSuccessMessage` | `string?` | `undefined` | `A message to display on payment success` |
|
|
121
|
+
| `domainId` | `number` | `undefined` | `The merchi domain/store id for the cart` |
|
|
122
|
+
| `footer` | `ReactElement`| `undefined` | `A customer footer component` |
|
|
123
|
+
| `hideHead` | `boolean` | `false` | `hides the cart head title and close` |
|
|
124
|
+
| `includeTheme` | `boolean?` | `false` | `If true will fetch and apply the store theme to the page` |
|
|
125
|
+
| `initialiseCart` | `boolean?` | `true` | `If true will initial fetch cart and set cart function on window`|
|
|
126
|
+
| `onClickClose` | `() => void?`| `() => console.log('close merchi cart!')` | `a function to close the cart` |
|
|
127
|
+
| `setIsCartModalOpen` | `(isOpen: boolean) => void?`| `() => console.log('close merchi cart!')` | `a function to open/close cart modal wrapper`|
|
|
128
|
+
| `isCartModalOpen` | `boolean` | `false` | `a boolean value to control the cart modal open/closed`|
|
|
129
|
+
| `productFormClassNames` | `obj` | `{}` | `An object to be passsed to the merchi_product_form `|
|
|
130
|
+
| `showUserTermsAndConditions` | `boolean?` | `true` | `Display the user t&cs for Merchi` |
|
|
131
|
+
| `showCartItemInfo` | `boolean?` | `true` | `Will display the cart item info in the cart items table`|
|
|
132
|
+
| `apiUrl` | `string?` | `'https://api.merchi.co/v6/'` | `URL to connect to the Merchi API` |
|
|
133
|
+
| `urlFrontend` | `string?` | `'https://merchi.co/'` | `URL to redirect users to a frontend` |
|
|
134
|
+
| `urlTrackingPage` | `string?` | `undefined` | `URL used on the thankyou page for tracking`|
|
|
@@ -16,9 +16,9 @@ import { loadFormBundle, publishedFormBundle } from '../utilities/customForm';
|
|
|
16
16
|
import { LoadingTemplateSm } from './LoadingTemplate';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
-
/**
|
|
20
|
-
* Loads a product's published custom form for cart-item edit. On any failure
|
|
21
|
-
* renders `fallback` (the default merchi_product_form) so the cart stays usable.
|
|
19
|
+
/**
|
|
20
|
+
* Loads a product's published custom form for cart-item edit. On any failure
|
|
21
|
+
* renders `fallback` (the default merchi_product_form) so the cart stays usable.
|
|
22
22
|
*/
|
|
23
23
|
export function CustomCartProductForm(_ref) {
|
|
24
24
|
var _publishedFormBundle$, _publishedFormBundle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Full merchi_sdk_product_form runtime for window.MerchiProductFormSdk.
|
|
3
|
-
* Keep in sync with merchi_api/common/js/product_form_gate.cjs SDK_EXPORTS.
|
|
1
|
+
/**
|
|
2
|
+
* Full merchi_sdk_product_form runtime for window.MerchiProductFormSdk.
|
|
3
|
+
* Keep in sync with merchi_api/common/js/product_form_gate.cjs SDK_EXPORTS.
|
|
4
4
|
*/
|
|
5
5
|
import { SDK_VERSION, serializeJob, nonEmptyGroups, formatCurrency, urlFor, createPricing, createProductFormRuntime, productHasGroups, groupFieldsOf, independentFieldsOf, isOptionQuantityGridProduct, buildProductFormJob, jobToFormState, selectionsToVariations, Section, Stack, Card, Heading, Text, Divider, Field, GroupRows, OptionQuantityGrid, ProductFormProvider, ProductFormShell, ProductFormActions, useProductForm, OPTION_FIELD_TYPES, theme } from 'merchi_sdk_product_form';
|
|
6
6
|
export var MerchiProductFormSdkExternals = {
|
package/esm/square/SquareCard.js
CHANGED
|
@@ -84,21 +84,21 @@ function SquareCard() {
|
|
|
84
84
|
return _actionSquarePaymentProcess.apply(this, arguments);
|
|
85
85
|
}
|
|
86
86
|
return squareWebLocationId ? /*#__PURE__*/_jsx(PaymentForm
|
|
87
|
-
/**
|
|
88
|
-
* Identifies the calling form with a verified application ID generated from
|
|
89
|
-
* the Square Application Dashboard.
|
|
87
|
+
/**
|
|
88
|
+
* Identifies the calling form with a verified application ID generated from
|
|
89
|
+
* the Square Application Dashboard.
|
|
90
90
|
*/, {
|
|
91
91
|
applicationId: SQUARE_APPLICATION_ID
|
|
92
|
-
/**
|
|
93
|
-
* Invoked when payment form receives the result of a tokenize generation
|
|
94
|
-
* request. The result will be a valid credit card or wallet token, or an error.
|
|
92
|
+
/**
|
|
93
|
+
* Invoked when payment form receives the result of a tokenize generation
|
|
94
|
+
* request. The result will be a valid credit card or wallet token, or an error.
|
|
95
95
|
*/,
|
|
96
96
|
cardTokenizeResponseReceived: function cardTokenizeResponseReceived(token, buyer) {
|
|
97
97
|
return actionSquarePaymentProcess(token.token, callbackCreditCardPaymentSuccess);
|
|
98
98
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Identifies the location of the merchant that is taking the payment.
|
|
101
|
-
* Obtained from the Square Application Dashboard - Locations tab.
|
|
99
|
+
/**
|
|
100
|
+
* Identifies the location of the merchant that is taking the payment.
|
|
101
|
+
* Obtained from the Square Application Dashboard - Locations tab.
|
|
102
102
|
*/,
|
|
103
103
|
locationId: squareWebLocationId,
|
|
104
104
|
children: /*#__PURE__*/_jsx(CreditCard, {
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _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(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
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(arr) { if (Array.isArray(arr)) return arr; }
|
|
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 } from "react/jsx-runtime";
|
|
20
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
function PaymentButton(_ref) {
|
|
23
|
+
var loading = _ref.loading;
|
|
24
|
+
var _useCartContext = useCartContext(),
|
|
25
|
+
cart = _useCartContext.cart;
|
|
26
|
+
return /*#__PURE__*/_jsx("div", {
|
|
27
|
+
children: /*#__PURE__*/_jsx(ButtonPay, {
|
|
28
|
+
cart: cart,
|
|
29
|
+
loading: loading
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
var badgeTestMode = /*#__PURE__*/_jsx("div", {
|
|
34
|
+
style: {
|
|
35
|
+
color: 'red'
|
|
36
|
+
},
|
|
37
|
+
children: "Test mode"
|
|
38
|
+
});
|
|
39
|
+
function StripeCardForm() {
|
|
40
|
+
var _useCartContext2 = useCartContext(),
|
|
41
|
+
alertError = _useCartContext2.alertError,
|
|
42
|
+
apiUrl = _useCartContext2.apiUrl,
|
|
43
|
+
cart = _useCartContext2.cart,
|
|
44
|
+
setActiveTabIndex = _useCartContext2.setActiveTabIndex,
|
|
45
|
+
setInvoiceJson = _useCartContext2.setInvoiceJson;
|
|
46
|
+
var domain = cart.domain;
|
|
47
|
+
var _useState = useState({}),
|
|
48
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
49
|
+
error = _useState2[0],
|
|
50
|
+
setError = _useState2[1];
|
|
51
|
+
var company = domain.company;
|
|
52
|
+
var hasCompanyPubKey = Boolean(company.isStripeValid && companyStripePubKeyOrTestPubKey(company));
|
|
53
|
+
var companyPubKey = hasCompanyPubKey ? companyStripePubKeyOrTestPubKey(company) : '';
|
|
54
|
+
var canUseConnect = !!company.stripeAccountId;
|
|
55
|
+
var _useState3 = useState(false),
|
|
56
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
57
|
+
loadingStripePayment = _useState4[0],
|
|
58
|
+
setLoadingStripePayment = _useState4[1];
|
|
59
|
+
var _useState5 = useState(false),
|
|
60
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
61
|
+
loadingStripePaymentButtons = _useState6[0],
|
|
62
|
+
setLoadingStripePaymentButtons = _useState6[1];
|
|
63
|
+
var url = apiUrl || '';
|
|
64
|
+
function callbackCreditCardPaymentSuccess(invoiceJson) {
|
|
65
|
+
setInvoiceJson(invoiceJson);
|
|
66
|
+
setActiveTabIndex(tabIdPaymentSuccess);
|
|
67
|
+
}
|
|
68
|
+
function doStripePayment(_x) {
|
|
69
|
+
return _doStripePayment.apply(this, arguments);
|
|
70
|
+
}
|
|
71
|
+
function _doStripePayment() {
|
|
72
|
+
_doStripePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(r) {
|
|
73
|
+
var response;
|
|
74
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
75
|
+
while (1) switch (_context.prev = _context.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
setLoadingStripePayment(true);
|
|
78
|
+
setError({});
|
|
79
|
+
_context.prev = 2;
|
|
80
|
+
_context.next = 5;
|
|
81
|
+
return stripeCardFormSubmit(url, r.stripe, r.card, cart);
|
|
82
|
+
case 5:
|
|
83
|
+
response = _context.sent;
|
|
84
|
+
callbackCreditCardPaymentSuccess(response);
|
|
85
|
+
setLoadingStripePayment(false);
|
|
86
|
+
_context.next = 15;
|
|
87
|
+
break;
|
|
88
|
+
case 10:
|
|
89
|
+
_context.prev = 10;
|
|
90
|
+
_context.t0 = _context["catch"](2);
|
|
91
|
+
setLoadingStripePayment(false);
|
|
92
|
+
alertError(_context.t0.message);
|
|
93
|
+
setError({
|
|
94
|
+
message: _context.t0.errorMessage || _context.t0.message || 'Unable to process card.'
|
|
95
|
+
});
|
|
96
|
+
case 15:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context.stop();
|
|
99
|
+
}
|
|
100
|
+
}, _callee, null, [[2, 10]]);
|
|
101
|
+
}));
|
|
102
|
+
return _doStripePayment.apply(this, arguments);
|
|
103
|
+
}
|
|
104
|
+
function doStripePaymentRequestForButton(_x2, _x3) {
|
|
105
|
+
return _doStripePaymentRequestForButton.apply(this, arguments);
|
|
106
|
+
}
|
|
107
|
+
function _doStripePaymentRequestForButton() {
|
|
108
|
+
_doStripePaymentRequestForButton = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(stripe, event) {
|
|
109
|
+
var response;
|
|
110
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
111
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
112
|
+
case 0:
|
|
113
|
+
setLoadingStripePaymentButtons(true);
|
|
114
|
+
setError({});
|
|
115
|
+
_context2.prev = 2;
|
|
116
|
+
_context2.next = 5;
|
|
117
|
+
return stripePaymentButtonSubmit(url, stripe, cart, event);
|
|
118
|
+
case 5:
|
|
119
|
+
response = _context2.sent;
|
|
120
|
+
callbackCreditCardPaymentSuccess(response);
|
|
121
|
+
setLoadingStripePaymentButtons(false);
|
|
122
|
+
_context2.next = 15;
|
|
123
|
+
break;
|
|
124
|
+
case 10:
|
|
125
|
+
_context2.prev = 10;
|
|
126
|
+
_context2.t0 = _context2["catch"](2);
|
|
127
|
+
setLoadingStripePaymentButtons(false);
|
|
128
|
+
alertError(_context2.t0.message);
|
|
129
|
+
setError({
|
|
130
|
+
message: _context2.t0.errorMessage || _context2.t0.message || 'Unable to process card.'
|
|
131
|
+
});
|
|
132
|
+
case 15:
|
|
133
|
+
case "end":
|
|
134
|
+
return _context2.stop();
|
|
135
|
+
}
|
|
136
|
+
}, _callee2, null, [[2, 10]]);
|
|
137
|
+
}));
|
|
138
|
+
return _doStripePaymentRequestForButton.apply(this, arguments);
|
|
139
|
+
}
|
|
140
|
+
var _useState7 = useState(companyPubKey),
|
|
141
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
142
|
+
stripePublicKey = _useState8[0],
|
|
143
|
+
setStripePublicKey = _useState8[1];
|
|
144
|
+
useEffect(function () {
|
|
145
|
+
if (!stripePublicKey && canUseConnect) stripeInitPromise(url).then(setStripePublicKey);
|
|
146
|
+
}, [stripePublicKey, canUseConnect]);
|
|
147
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
148
|
+
children: [company.isTesting && badgeTestMode, /*#__PURE__*/_jsx(FormStripeCardFields, {
|
|
149
|
+
doStripePayment: doStripePayment,
|
|
150
|
+
doStripePaymentRequestForButton: doStripePaymentRequestForButton,
|
|
151
|
+
cart: cart,
|
|
152
|
+
error: error,
|
|
153
|
+
loadingStripePayment: loadingStripePayment,
|
|
154
|
+
loadingStripePaymentButtons: loadingStripePaymentButtons,
|
|
155
|
+
PaymentButton: PaymentButton,
|
|
156
|
+
setLoadingStripePayment: setLoadingStripePayment,
|
|
157
|
+
stripePubKey: stripePublicKey
|
|
158
|
+
})]
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
export default StripeCardForm;
|