merchi_cart 0.0.4-c → 0.0.4-e
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/lib/Cart.js +20 -25
- package/lib/CartAlert.js +14 -12
- package/lib/CartHeader.js +9 -9
- package/lib/CartProvider.js +157 -226
- package/lib/CartTotals.js +44 -44
- package/lib/MerchiSDK/constants/auto_assign_production_on_actions.js +1 -1
- package/lib/MerchiSDK/constants/call_to_actions.js +1 -1
- package/lib/MerchiSDK/constants/discount_types.js +1 -1
- package/lib/MerchiSDK/constants/domain_types.js +1 -1
- package/lib/MerchiSDK/constants/errors.js +1 -1
- package/lib/MerchiSDK/constants/event_types.js +1 -1
- package/lib/MerchiSDK/constants/field_types.js +1 -1
- package/lib/MerchiSDK/constants/input_types.js +1 -1
- package/lib/MerchiSDK/constants/inventory_statuses.js +1 -1
- package/lib/MerchiSDK/constants/invoice_types.js +1 -1
- package/lib/MerchiSDK/constants/item_types.js +1 -1
- package/lib/MerchiSDK/constants/job/drafting_status.js +1 -1
- package/lib/MerchiSDK/constants/job/payment_status.js +1 -1
- package/lib/MerchiSDK/constants/job/production_status.js +1 -1
- package/lib/MerchiSDK/constants/job/shipment_status.js +1 -1
- package/lib/MerchiSDK/constants/job/supply_chain_request_status.js +1 -1
- package/lib/MerchiSDK/constants/job_priorities.js +1 -1
- package/lib/MerchiSDK/constants/job_status.js +5 -5
- package/lib/MerchiSDK/constants/job_types.js +1 -1
- package/lib/MerchiSDK/constants/notification_sections.js +1 -1
- package/lib/MerchiSDK/constants/notification_types.js +1 -1
- package/lib/MerchiSDK/constants/notification_urgencies.js +1 -1
- package/lib/MerchiSDK/constants/payment_types.js +1 -1
- package/lib/MerchiSDK/constants/platform.js +5 -5
- package/lib/MerchiSDK/constants/product_types.js +1 -1
- package/lib/MerchiSDK/constants/rights.js +1 -1
- package/lib/MerchiSDK/constants/robots_meta_directives.js +1 -1
- package/lib/MerchiSDK/constants/roles.js +8 -14
- package/lib/MerchiSDK/constants/shipment_companies.js +1 -1
- package/lib/MerchiSDK/constants/shipment_services.js +1 -1
- package/lib/MerchiSDK/constants/system_roles.js +1 -1
- package/lib/MerchiSDK/constants/theme_foundations.js +1 -1
- package/lib/MerchiSDK/constants/theme_status.js +1 -1
- package/lib/MerchiSDK/constants/user_types.js +1 -1
- package/lib/MerchiSDK/constants/white_label_accessibilities.js +1 -1
- package/lib/MerchiSDK/cookie.js +3 -3
- package/lib/MerchiSDK/entities/address.js +22 -43
- package/lib/MerchiSDK/entities/assignment.js +28 -49
- package/lib/MerchiSDK/entities/automatic_payment_relationship.js +11 -32
- package/lib/MerchiSDK/entities/backup.js +6 -27
- package/lib/MerchiSDK/entities/bank.js +17 -38
- package/lib/MerchiSDK/entities/cart.js +31 -64
- package/lib/MerchiSDK/entities/cart_item.js +30 -51
- package/lib/MerchiSDK/entities/cart_shipment_group.js +9 -30
- package/lib/MerchiSDK/entities/cart_shipment_quote.js +13 -34
- package/lib/MerchiSDK/entities/category.js +14 -35
- package/lib/MerchiSDK/entities/company.js +88 -109
- package/lib/MerchiSDK/entities/company_invitation.js +13 -34
- package/lib/MerchiSDK/entities/component.js +33 -54
- package/lib/MerchiSDK/entities/component_tag.js +7 -28
- package/lib/MerchiSDK/entities/component_version.js +12 -33
- package/lib/MerchiSDK/entities/country_tax.js +21 -45
- package/lib/MerchiSDK/entities/discount.js +13 -34
- package/lib/MerchiSDK/entities/discount_group.js +11 -32
- package/lib/MerchiSDK/entities/domain.js +80 -101
- package/lib/MerchiSDK/entities/domain_invitation.js +14 -35
- package/lib/MerchiSDK/entities/domain_tag.js +15 -36
- package/lib/MerchiSDK/entities/draft.js +32 -65
- package/lib/MerchiSDK/entities/draft_comment.js +19 -40
- package/lib/MerchiSDK/entities/draft_template.js +15 -36
- package/lib/MerchiSDK/entities/email_address.js +10 -31
- package/lib/MerchiSDK/entities/email_counter.js +8 -29
- package/lib/MerchiSDK/entities/enrolled_domain.js +20 -44
- package/lib/MerchiSDK/entities/exchange_rate.js +9 -30
- package/lib/MerchiSDK/entities/file.js +59 -80
- package/lib/MerchiSDK/entities/internal_tag.js +17 -38
- package/lib/MerchiSDK/entities/inventory.js +19 -42
- package/lib/MerchiSDK/entities/inventory_unit_variation.js +12 -33
- package/lib/MerchiSDK/entities/invoice.js +57 -78
- package/lib/MerchiSDK/entities/item.js +18 -39
- package/lib/MerchiSDK/entities/job.js +117 -140
- package/lib/MerchiSDK/entities/job_comment.js +18 -39
- package/lib/MerchiSDK/entities/matching_inventory.js +11 -32
- package/lib/MerchiSDK/entities/menu.js +12 -33
- package/lib/MerchiSDK/entities/menu_item.js +12 -33
- package/lib/MerchiSDK/entities/notification.js +32 -53
- package/lib/MerchiSDK/entities/page.js +13 -34
- package/lib/MerchiSDK/entities/payment.js +25 -46
- package/lib/MerchiSDK/entities/payment_device.js +12 -33
- package/lib/MerchiSDK/entities/phone_number.js +14 -35
- package/lib/MerchiSDK/entities/product.js +153 -188
- package/lib/MerchiSDK/entities/production_comment.js +18 -39
- package/lib/MerchiSDK/entities/quote.js +70 -106
- package/lib/MerchiSDK/entities/quote_item.js +28 -49
- package/lib/MerchiSDK/entities/seo_domain_page.js +13 -34
- package/lib/MerchiSDK/entities/session.js +11 -32
- package/lib/MerchiSDK/entities/shipment.js +62 -83
- package/lib/MerchiSDK/entities/shipment_item.js +7 -28
- package/lib/MerchiSDK/entities/shipment_item_fulfillment.js +7 -28
- package/lib/MerchiSDK/entities/shipment_method.js +21 -42
- package/lib/MerchiSDK/entities/shipment_method_variation.js +15 -36
- package/lib/MerchiSDK/entities/short_url.js +14 -35
- package/lib/MerchiSDK/entities/subscription_plan.js +26 -47
- package/lib/MerchiSDK/entities/supply_domain.js +11 -32
- package/lib/MerchiSDK/entities/system_role.js +7 -28
- package/lib/MerchiSDK/entities/theme.js +89 -110
- package/lib/MerchiSDK/entities/theme_css_setting.js +10 -31
- package/lib/MerchiSDK/entities/user.js +151 -213
- package/lib/MerchiSDK/entities/user_company.js +11 -32
- package/lib/MerchiSDK/entities/variation.js +21 -42
- package/lib/MerchiSDK/entities/variation_field.js +61 -94
- package/lib/MerchiSDK/entities/variation_fields_option.js +40 -61
- package/lib/MerchiSDK/entities/variation_option.js +20 -41
- package/lib/MerchiSDK/entities/variations_group.js +15 -36
- package/lib/MerchiSDK/entity.js +534 -624
- package/lib/MerchiSDK/merchi.js +42 -53
- package/lib/MerchiSDK/request.js +47 -75
- package/lib/MerchiSDK/test_util.js +6 -10
- package/lib/MerchiSDK/toasts.js +12 -13
- package/lib/MerchiSDK/util/float.js +7 -19
- package/lib/MerchiSDK/util/query_string.js +4 -4
- package/lib/MerchiSDK/util/validation.js +2 -3
- package/lib/MerchiSDK/uuid.js +2 -2
- package/lib/buttons/Button.js +15 -15
- package/lib/buttons/ButtonBack.js +22 -25
- package/lib/buttons/ButtonClearCart.js +8 -9
- package/lib/buttons/ButtonInvoiceDownload.js +26 -61
- package/lib/buttons/ButtonNext.js +20 -25
- package/lib/buttons/ButtonNextDynamic.js +16 -18
- package/lib/buttons/ButtonPay.js +17 -13
- package/lib/buttons/ButtonShipmentTabNext.js +12 -13
- package/lib/buttons/index.js +13 -13
- package/lib/components/Alert.js +14 -12
- package/lib/components/CartBody.js +10 -8
- package/lib/components/CartClient.js +22 -17
- package/lib/components/CartFooter.js +9 -7
- package/lib/components/CartItemRow.js +58 -48
- package/lib/components/CartPaymentSettingsInvalid.js +3 -4
- package/lib/components/CartShipment.js +18 -13
- package/lib/components/CartTabContent.js +9 -7
- package/lib/components/CartTabPanel.js +15 -13
- package/lib/components/CartTableContainer.js +9 -7
- package/lib/components/Collapse.js +14 -22
- package/lib/components/LoadingTemplate.js +10 -7
- package/lib/components/NoCartItems.js +9 -9
- package/lib/components/ShipmentGroupCard.js +69 -52
- package/lib/components/Table.js +7 -4
- package/lib/components/Title.js +11 -9
- package/lib/components/containers.js +12 -11
- package/lib/components/index.js +30 -31
- package/lib/forms/FormNewCustomer.js +48 -76
- package/lib/forms/FormReturningCustomer.js +38 -58
- package/lib/forms/FormShipmentAddressAndNotes.js +42 -47
- package/lib/forms/FormSquarePayment.js +8 -9
- package/lib/forms/FormStripePayment.js +8 -9
- package/lib/forms/InputAcceptUserTermsAndConditions.js +12 -11
- package/lib/forms/InputError.js +11 -9
- package/lib/forms/InputSelect.js +34 -36
- package/lib/forms/InputText.js +38 -42
- package/lib/forms/InputsAddress.js +59 -69
- package/lib/index.js +6 -6
- package/lib/panels/PanelCartItems.js +14 -17
- package/lib/panels/PanelCartShipment.js +10 -13
- package/lib/panels/PanelClearCart.js +8 -7
- package/lib/panels/PanelClientCheckout.js +18 -17
- package/lib/panels/PanelEditCartItem.js +17 -22
- package/lib/panels/PanelPaymentSuccess.js +18 -16
- package/lib/panels/index.js +13 -13
- package/lib/slices/sliceCart.js +53 -56
- package/lib/slices/sliceCartAlert.js +11 -15
- package/lib/slices/sliceCartItem.js +11 -10
- package/lib/slices/sliceCartPayment.js +15 -16
- package/lib/slices/sliceCartShipment.js +23 -26
- package/lib/slices/sliceFormReturningCustomer.js +7 -7
- package/lib/slices/sliceNewCustomerForm.js +6 -6
- package/lib/square/SquareCard.js +16 -18
- package/lib/square/actions.js +24 -46
- package/lib/square/slices/reducersSquare.js +6 -6
- package/lib/square/slices/sliceSquareAlerts.js +10 -16
- package/lib/square/slices/sliceSquareForm.js +10 -9
- package/lib/store.js +359 -565
- package/lib/stripe/StripeCardFields.js +43 -44
- package/lib/stripe/StripeCardForm.js +51 -109
- package/lib/stripe/StripePaymentButtons.js +35 -46
- package/lib/stripe/actions.js +75 -196
- package/lib/stripe/slices/sliceStripeAlerts.js +10 -16
- package/lib/stripe/slices/sliceStripeCardForm.js +6 -6
- package/lib/stripe/slices/sliceStripeForm.js +18 -17
- package/lib/stripe/utils.js +1 -1
- package/lib/tabs/CartNav.js +15 -24
- package/lib/tabs/NavTab.js +20 -19
- package/lib/utilities/address.js +32 -30
- package/lib/utilities/cart.js +33 -50
- package/lib/utilities/cookie.js +46 -129
- package/lib/utilities/currency.js +29 -25
- package/lib/utilities/helpers.js +41 -60
- package/lib/utilities/invoice.js +45 -114
- package/lib/utilities/product.js +5 -3
- package/lib/utilities/user.js +24 -62
- package/lib/utilities/variations.js +16 -14
- package/package.json +1 -1
package/lib/stripe/actions.js
CHANGED
|
@@ -6,205 +6,84 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.stripeCardFormSubmit = stripeCardFormSubmit;
|
|
7
7
|
exports.stripeInitPromise = stripeInitPromise;
|
|
8
8
|
exports.stripePaymentButtonSubmit = stripePaymentButtonSubmit;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return _stripeInitPromise.apply(this, arguments);
|
|
9
|
+
async function stripeInitPromise(urlApi) {
|
|
10
|
+
return await fetch(`${urlApi}stripe/master_publishable_key/`, {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
mode: 'cors'
|
|
13
|
+
}).then(response => response.key);
|
|
15
14
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
return
|
|
15
|
+
async function createPaymentIntent(urlApi, cart, paymentMethodType) {
|
|
16
|
+
const {
|
|
17
|
+
id,
|
|
18
|
+
token
|
|
19
|
+
} = cart;
|
|
20
|
+
const fetchOptions = {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
mode: 'cors'
|
|
23
|
+
};
|
|
24
|
+
const queryParams = [['cart_token', token]];
|
|
25
|
+
if (paymentMethodType) {
|
|
26
|
+
queryParams.push(['payment_method_types', paymentMethodType]);
|
|
27
|
+
}
|
|
28
|
+
const queryString = new URLSearchParams(queryParams).toString();
|
|
29
|
+
const uri = `stripe/payment_intent/cart/${id}/`;
|
|
30
|
+
const url = `${urlApi}${uri}?${queryString}`;
|
|
31
|
+
const response = await fetch(url, fetchOptions);
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
throw new Error("Failed to create payment intent.");
|
|
34
|
+
}
|
|
35
|
+
return await response.json();
|
|
37
36
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
37
|
+
async function checkPaymentIntnetIsComplete(urlApi, cart) {
|
|
38
|
+
const url = `stripe/payment_intent/cart/complete/${cart.id}/`;
|
|
39
|
+
const fetchOptions = {
|
|
40
|
+
method: 'GET',
|
|
41
|
+
mode: 'cors'
|
|
42
|
+
};
|
|
43
|
+
const queryString = new URLSearchParams({
|
|
44
|
+
cart_token: cart.token
|
|
45
|
+
}).toString();
|
|
46
|
+
const response = await fetch(`${urlApi}${url}?${queryString}`, fetchOptions);
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
throw new Error("Failed to check if payment intent is complete.");
|
|
49
|
+
}
|
|
50
|
+
return await response.json();
|
|
40
51
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
id = cart.id, token = cart.token;
|
|
48
|
-
fetchOptions = {
|
|
49
|
-
method: 'GET',
|
|
50
|
-
mode: 'cors'
|
|
51
|
-
};
|
|
52
|
-
queryParams = [['cart_token', token]];
|
|
53
|
-
if (paymentMethodType) {
|
|
54
|
-
queryParams.push(['payment_method_types', paymentMethodType]);
|
|
55
|
-
}
|
|
56
|
-
queryString = new URLSearchParams(queryParams).toString();
|
|
57
|
-
uri = "stripe/payment_intent/cart/".concat(id, "/");
|
|
58
|
-
url = "".concat(urlApi).concat(uri, "?").concat(queryString);
|
|
59
|
-
_context2.next = 9;
|
|
60
|
-
return fetch(url, fetchOptions);
|
|
61
|
-
case 9:
|
|
62
|
-
response = _context2.sent;
|
|
63
|
-
if (response.ok) {
|
|
64
|
-
_context2.next = 12;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
throw new Error("Failed to create payment intent.");
|
|
68
|
-
case 12:
|
|
69
|
-
_context2.next = 14;
|
|
70
|
-
return response.json();
|
|
71
|
-
case 14:
|
|
72
|
-
return _context2.abrupt("return", _context2.sent);
|
|
73
|
-
case 15:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context2.stop();
|
|
52
|
+
async function stripeCardFormSubmit(urlApi, stripe, card, cart) {
|
|
53
|
+
try {
|
|
54
|
+
const intent = await createPaymentIntent(urlApi, cart);
|
|
55
|
+
const stripePayment = await stripe.confirmCardPayment(intent.stripeClientSecret, {
|
|
56
|
+
payment_method: {
|
|
57
|
+
card
|
|
76
58
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
_checkPaymentIntnetIsComplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(urlApi, cart) {
|
|
86
|
-
var url, fetchOptions, queryString, response;
|
|
87
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
88
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
89
|
-
case 0:
|
|
90
|
-
url = "stripe/payment_intent/cart/complete/".concat(cart.id, "/");
|
|
91
|
-
fetchOptions = {
|
|
92
|
-
method: 'GET',
|
|
93
|
-
mode: 'cors'
|
|
94
|
-
};
|
|
95
|
-
queryString = new URLSearchParams({
|
|
96
|
-
cart_token: cart.token
|
|
97
|
-
}).toString();
|
|
98
|
-
_context3.next = 5;
|
|
99
|
-
return fetch("".concat(urlApi).concat(url, "?").concat(queryString), fetchOptions);
|
|
100
|
-
case 5:
|
|
101
|
-
response = _context3.sent;
|
|
102
|
-
if (response.ok) {
|
|
103
|
-
_context3.next = 8;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
throw new Error("Failed to check if payment intent is complete.");
|
|
107
|
-
case 8:
|
|
108
|
-
_context3.next = 10;
|
|
109
|
-
return response.json();
|
|
110
|
-
case 10:
|
|
111
|
-
return _context3.abrupt("return", _context3.sent);
|
|
112
|
-
case 11:
|
|
113
|
-
case "end":
|
|
114
|
-
return _context3.stop();
|
|
115
|
-
}
|
|
116
|
-
}, _callee3);
|
|
117
|
-
}));
|
|
118
|
-
return _checkPaymentIntnetIsComplete.apply(this, arguments);
|
|
119
|
-
}
|
|
120
|
-
function stripeCardFormSubmit(_x7, _x8, _x9, _x10) {
|
|
121
|
-
return _stripeCardFormSubmit.apply(this, arguments);
|
|
59
|
+
});
|
|
60
|
+
if (stripePayment.error) {
|
|
61
|
+
throw new Error(stripePayment.error.message || 'Stripe connect unknown error');
|
|
62
|
+
}
|
|
63
|
+
return await checkPaymentIntnetIsComplete(urlApi, cart);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
122
67
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
throw new Error(stripePayment.error.message || 'Stripe connect unknown error');
|
|
147
|
-
case 9:
|
|
148
|
-
_context4.next = 11;
|
|
149
|
-
return checkPaymentIntnetIsComplete(urlApi, cart);
|
|
150
|
-
case 11:
|
|
151
|
-
return _context4.abrupt("return", _context4.sent);
|
|
152
|
-
case 14:
|
|
153
|
-
_context4.prev = 14;
|
|
154
|
-
_context4.t0 = _context4["catch"](0);
|
|
155
|
-
throw _context4.t0;
|
|
156
|
-
case 17:
|
|
157
|
-
case "end":
|
|
158
|
-
return _context4.stop();
|
|
159
|
-
}
|
|
160
|
-
}, _callee4, null, [[0, 14]]);
|
|
161
|
-
}));
|
|
162
|
-
return _stripeCardFormSubmit.apply(this, arguments);
|
|
163
|
-
}
|
|
164
|
-
function stripePaymentButtonSubmit(_x11, _x12, _x13, _x14) {
|
|
165
|
-
return _stripePaymentButtonSubmit.apply(this, arguments);
|
|
166
|
-
}
|
|
167
|
-
function _stripePaymentButtonSubmit() {
|
|
168
|
-
_stripePaymentButtonSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(urlApi, stripe, cart, paymentMethodEvent) {
|
|
169
|
-
var complete, paymentMethod, intent, stripePayment;
|
|
170
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
171
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
172
|
-
case 0:
|
|
173
|
-
complete = paymentMethodEvent.complete, paymentMethod = paymentMethodEvent.paymentMethod;
|
|
174
|
-
_context5.prev = 1;
|
|
175
|
-
_context5.next = 4;
|
|
176
|
-
return createPaymentIntent(urlApi, cart);
|
|
177
|
-
case 4:
|
|
178
|
-
intent = _context5.sent;
|
|
179
|
-
_context5.next = 7;
|
|
180
|
-
return stripe.confirmCardPayment(intent.stripeClientSecret, {
|
|
181
|
-
payment_method: paymentMethod.id
|
|
182
|
-
}, {
|
|
183
|
-
handleActions: false
|
|
184
|
-
});
|
|
185
|
-
case 7:
|
|
186
|
-
stripePayment = _context5.sent;
|
|
187
|
-
if (!stripePayment.error) {
|
|
188
|
-
_context5.next = 10;
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
throw new Error(stripePayment.error.message || 'Stripe unknown error');
|
|
192
|
-
case 10:
|
|
193
|
-
complete('success');
|
|
194
|
-
_context5.next = 13;
|
|
195
|
-
return checkPaymentIntnetIsComplete(urlApi, cart);
|
|
196
|
-
case 13:
|
|
197
|
-
return _context5.abrupt("return", _context5.sent);
|
|
198
|
-
case 16:
|
|
199
|
-
_context5.prev = 16;
|
|
200
|
-
_context5.t0 = _context5["catch"](1);
|
|
201
|
-
complete('fail');
|
|
202
|
-
throw _context5.t0;
|
|
203
|
-
case 20:
|
|
204
|
-
case "end":
|
|
205
|
-
return _context5.stop();
|
|
206
|
-
}
|
|
207
|
-
}, _callee5, null, [[1, 16]]);
|
|
208
|
-
}));
|
|
209
|
-
return _stripePaymentButtonSubmit.apply(this, arguments);
|
|
68
|
+
async function stripePaymentButtonSubmit(urlApi, stripe, cart, paymentMethodEvent) {
|
|
69
|
+
const {
|
|
70
|
+
complete,
|
|
71
|
+
paymentMethod
|
|
72
|
+
} = paymentMethodEvent;
|
|
73
|
+
try {
|
|
74
|
+
const intent = await createPaymentIntent(urlApi, cart);
|
|
75
|
+
const stripePayment = await stripe.confirmCardPayment(intent.stripeClientSecret, {
|
|
76
|
+
payment_method: paymentMethod.id
|
|
77
|
+
}, {
|
|
78
|
+
handleActions: false
|
|
79
|
+
});
|
|
80
|
+
if (stripePayment.error) {
|
|
81
|
+
throw new Error(stripePayment.error.message || 'Stripe unknown error');
|
|
82
|
+
}
|
|
83
|
+
complete('success');
|
|
84
|
+
return await checkPaymentIntnetIsComplete(urlApi, cart);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
complete('fail');
|
|
87
|
+
throw e;
|
|
88
|
+
}
|
|
210
89
|
}
|
|
@@ -3,37 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
var _toolkit = require("@reduxjs/toolkit");
|
|
8
|
-
|
|
9
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
-
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); }
|
|
11
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
|
-
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; }
|
|
14
|
-
var sliceStripeAlerts = (0, _toolkit.createSlice)({
|
|
8
|
+
const sliceStripeAlerts = (0, _toolkit.createSlice)({
|
|
15
9
|
initialState: {
|
|
16
10
|
alerts: []
|
|
17
11
|
},
|
|
18
12
|
name: 'stateStripeAlerts',
|
|
19
13
|
reducers: {
|
|
20
|
-
alertError:
|
|
21
|
-
state.alerts = [
|
|
14
|
+
alertError: (state, action) => {
|
|
15
|
+
state.alerts = [...state.alerts, {
|
|
22
16
|
alertType: 'danger',
|
|
23
17
|
message: action.payload,
|
|
24
18
|
title: 'Error!'
|
|
25
|
-
}]
|
|
19
|
+
}];
|
|
26
20
|
},
|
|
27
|
-
alertRemove:
|
|
21
|
+
alertRemove: (state, action) => {
|
|
28
22
|
state.alerts.splice(action.payload, 1);
|
|
29
23
|
},
|
|
30
|
-
alertSuccess:
|
|
31
|
-
state.alerts = [
|
|
24
|
+
alertSuccess: (state, action) => {
|
|
25
|
+
state.alerts = [...state.alerts, {
|
|
32
26
|
alertType: 'success',
|
|
33
27
|
message: action.payload,
|
|
34
28
|
title: 'Success!'
|
|
35
|
-
}]
|
|
29
|
+
}];
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
32
|
});
|
|
39
|
-
var _default = exports
|
|
33
|
+
var _default = exports.default = sliceStripeAlerts;
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
var _sliceStripeAlerts = _interopRequireDefault(require("./sliceStripeAlerts"));
|
|
8
8
|
var _sliceStripeForm = _interopRequireDefault(require("./sliceStripeForm"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {
|
|
10
|
-
|
|
11
|
-
stateStripeAlerts: _sliceStripeAlerts
|
|
12
|
-
stateStripeForm: _sliceStripeForm
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
const sliceStripeCardForm = {
|
|
11
|
+
stateStripeAlerts: _sliceStripeAlerts.default.reducer,
|
|
12
|
+
stateStripeForm: _sliceStripeForm.default.reducer
|
|
13
13
|
};
|
|
14
|
-
var _default = exports
|
|
14
|
+
var _default = exports.default = sliceStripeCardForm;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
var _toolkit = require("@reduxjs/toolkit");
|
|
8
|
-
|
|
8
|
+
const sliceStripeForm = (0, _toolkit.createSlice)({
|
|
9
9
|
initialState: {
|
|
10
10
|
acceptedPaymentMethods: {},
|
|
11
11
|
invoice: {},
|
|
@@ -17,46 +17,47 @@ var sliceStripeForm = (0, _toolkit.createSlice)({
|
|
|
17
17
|
},
|
|
18
18
|
name: 'stateStripeForm',
|
|
19
19
|
reducers: {
|
|
20
|
-
actionFetchAcceptedPaymentMethods:
|
|
20
|
+
actionFetchAcceptedPaymentMethods: state => {
|
|
21
21
|
state.loadingAcceptedPaymentMethods = true;
|
|
22
22
|
},
|
|
23
|
-
actionFetchAcceptedPaymentMethodsDone:
|
|
23
|
+
actionFetchAcceptedPaymentMethodsDone: (state, action) => {
|
|
24
24
|
state.loadingAcceptedPaymentMethods = false;
|
|
25
25
|
state.acceptedPaymentMethods = action.payload;
|
|
26
26
|
},
|
|
27
|
-
actionStripePaymentEnd:
|
|
27
|
+
actionStripePaymentEnd: state => {
|
|
28
28
|
state.loading = false;
|
|
29
29
|
},
|
|
30
|
-
actionStripePaymentStart:
|
|
30
|
+
actionStripePaymentStart: state => {
|
|
31
31
|
state.loading = true;
|
|
32
32
|
},
|
|
33
|
-
actionStripePaymentRequestButtonEnd:
|
|
33
|
+
actionStripePaymentRequestButtonEnd: state => {
|
|
34
34
|
state.loadingPaymentRequestButton = false;
|
|
35
35
|
},
|
|
36
|
-
actionStripePaymentRequestButtonStart:
|
|
36
|
+
actionStripePaymentRequestButtonStart: state => {
|
|
37
37
|
state.loadingPaymentRequestButton = true;
|
|
38
38
|
},
|
|
39
|
-
actionStripeWeChatPaymentEnd:
|
|
39
|
+
actionStripeWeChatPaymentEnd: state => {
|
|
40
40
|
state.loadingWeChatPayment = false;
|
|
41
41
|
},
|
|
42
|
-
actionStripeWeChatPaymentStart:
|
|
42
|
+
actionStripeWeChatPaymentStart: state => {
|
|
43
43
|
state.loadingWeChatPayment = true;
|
|
44
44
|
},
|
|
45
|
-
setInvoiceOrCart:
|
|
46
|
-
|
|
47
|
-
invoice
|
|
48
|
-
isCart
|
|
45
|
+
setInvoiceOrCart: (state, action) => {
|
|
46
|
+
const {
|
|
47
|
+
invoice,
|
|
48
|
+
isCart
|
|
49
|
+
} = action.payload;
|
|
49
50
|
state.invoice = invoice;
|
|
50
51
|
if (isCart) {
|
|
51
52
|
state.isCart = isCart;
|
|
52
53
|
}
|
|
53
54
|
},
|
|
54
|
-
stripePaymentEnd:
|
|
55
|
+
stripePaymentEnd: state => {
|
|
55
56
|
state.loading = false;
|
|
56
57
|
},
|
|
57
|
-
stripePaymentStart:
|
|
58
|
+
stripePaymentStart: (state, action) => {
|
|
58
59
|
state.loading = true;
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
});
|
|
62
|
-
var _default = exports
|
|
63
|
+
var _default = exports.default = sliceStripeForm;
|
package/lib/stripe/utils.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.companyStripePubKeyOrTestPubKey = companyStripePubKeyOrTestPubKey;
|
|
|
8
8
|
function companyStripePubKeyOrTestPubKey(company) {
|
|
9
9
|
return company.isTesting ? company.stripePublishableTestKey : company.stripePublishableKey;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
const CARD_ELEMENT_OPTIONS = exports.CARD_ELEMENT_OPTIONS = {
|
|
12
12
|
style: {
|
|
13
13
|
base: {
|
|
14
14
|
'::placeholder': {
|
package/lib/tabs/CartNav.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var React = _react;
|
|
9
9
|
var _reactRedux = require("react-redux");
|
|
@@ -11,31 +11,22 @@ var _CartProvider = require("../CartProvider");
|
|
|
11
11
|
var _sliceCart = require("../slices/sliceCart");
|
|
12
12
|
var _NavTab = _interopRequireDefault(require("./NavTab"));
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {
|
|
15
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
16
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
17
|
-
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); }
|
|
18
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
22
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
17
|
function CartNav() {
|
|
24
|
-
|
|
25
|
-
classNameCartNav
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
const {
|
|
19
|
+
classNameCartNav
|
|
20
|
+
} = (0, _CartProvider.useCartContext)();
|
|
21
|
+
const {
|
|
22
|
+
tabs
|
|
23
|
+
} = (0, _reactRedux.useSelector)(s => s.stateCart);
|
|
30
24
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
31
25
|
className: classNameCartNav,
|
|
32
|
-
children: tabs.filter(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
key: "".concat(index, "-tab")
|
|
37
|
-
}));
|
|
38
|
-
})
|
|
26
|
+
children: tabs.filter(tab => tab.tabId !== _sliceCart.tabIdPaymentSuccess).map((tab, index) => /*#__PURE__*/(0, _react.createElement)(_NavTab.default, {
|
|
27
|
+
...tab,
|
|
28
|
+
key: `${index}-tab`
|
|
29
|
+
}))
|
|
39
30
|
});
|
|
40
31
|
}
|
|
41
|
-
var _default = exports
|
|
32
|
+
var _default = exports.default = CartNav;
|
package/lib/tabs/NavTab.js
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
8
7
|
var React = _interopRequireWildcard(require("react"));
|
|
9
8
|
var _reactRedux = require("react-redux");
|
|
10
9
|
var _sliceCart = require("../slices/sliceCart");
|
|
11
10
|
var _CartProvider = require("../CartProvider");
|
|
12
11
|
var _reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
13
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
15
|
function NavTab(_ref) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
let {
|
|
17
|
+
disabled,
|
|
18
|
+
icon,
|
|
19
|
+
name,
|
|
20
|
+
tabId
|
|
21
|
+
} = _ref;
|
|
22
|
+
const dispatch = (0, _reactRedux.useDispatch)();
|
|
23
|
+
const {
|
|
24
|
+
classNameCartTabItem,
|
|
25
|
+
classNameCartTabItemLink
|
|
26
|
+
} = (0, _CartProvider.useCartContext)();
|
|
27
|
+
const {
|
|
28
|
+
activeTab
|
|
29
|
+
} = (0, _reactRedux.useSelector)(s => s.stateCart);
|
|
29
30
|
function toggle() {
|
|
30
31
|
dispatch(_sliceCart.sliceCart.actions.setActiveTab(tabId));
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
const active = activeTab === tabId;
|
|
33
34
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
34
35
|
className: classNameCartTabItem,
|
|
35
36
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|
|
36
|
-
className:
|
|
37
|
+
className: `${classNameCartTabItemLink} ${active ? 'active' : ''}`,
|
|
37
38
|
onClick: toggle,
|
|
38
39
|
disabled: disabled,
|
|
39
40
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
@@ -42,4 +43,4 @@ function NavTab(_ref) {
|
|
|
42
43
|
})
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
|
-
var _default = exports
|
|
46
|
+
var _default = exports.default = NavTab;
|