@merchi/cart 1.4.83 → 1.4.85
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/esm/panels/PanelPaymentSuccess.js +22 -15
- package/esm/panels/PanelPaymentSuccess.test.js +68 -0
- package/esm/utilities/test_checkout.js +2 -18
- package/lib/panels/PanelPaymentSuccess.js +22 -14
- package/lib/utilities/test_checkout.d.ts +1 -4
- package/lib/utilities/test_checkout.js +25 -20
- package/package.json +3 -3
- package/src/panels/PanelPaymentSuccess.test.tsx +36 -0
- package/src/panels/PanelPaymentSuccess.tsx +20 -12
- package/src/utilities/test_checkout.ts +2 -19
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import TestOrderNotice from '@merchi/invoice/lib/TestOrderNotice';
|
|
1
2
|
import { CheckoutContainer, InnerContainer } from '../components/containers';
|
|
2
3
|
import { tabIdPaymentSuccess } from '../utilities/tabs';
|
|
3
4
|
import { companyPrimaryAddress } from '../utilities/company';
|
|
@@ -6,9 +7,10 @@ import { faCheckCircle } from '@fortawesome/free-solid-svg-icons';
|
|
|
6
7
|
import { Button, ButtonInvoiceDownload } from '../buttons';
|
|
7
8
|
import { CartBody, CartTabPanel } from '../components';
|
|
8
9
|
import { useCartContext } from '../CartProvider';
|
|
9
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
11
|
function PanelPaymentSuccess() {
|
|
11
12
|
var _useCartContext = useCartContext(),
|
|
13
|
+
cart = _useCartContext.cart,
|
|
12
14
|
classNameBtnPrimary = _useCartContext.classNameBtnPrimary,
|
|
13
15
|
customSuccessMessage = _useCartContext.customSuccessMessage,
|
|
14
16
|
fetchingCart = _useCartContext.fetchingCart,
|
|
@@ -24,20 +26,25 @@ function PanelPaymentSuccess() {
|
|
|
24
26
|
children: /*#__PURE__*/_jsxs(CartBody, {
|
|
25
27
|
children: [/*#__PURE__*/_jsx(CheckoutContainer, {
|
|
26
28
|
children: /*#__PURE__*/_jsxs(InnerContainer, {
|
|
27
|
-
children: [/*#__PURE__*/_jsx(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
children: [invoiceJson.isTest || cart !== null && cart !== void 0 && cart.isTest ? /*#__PURE__*/_jsx(TestOrderNotice, {
|
|
30
|
+
title: "Test order #".concat(id),
|
|
31
|
+
paymentReceived: unpaid === false
|
|
32
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
33
|
+
children: [/*#__PURE__*/_jsx("h2", {
|
|
34
|
+
children: /*#__PURE__*/_jsx(FontAwesomeIcon, {
|
|
35
|
+
icon: faCheckCircle
|
|
36
|
+
})
|
|
37
|
+
}), /*#__PURE__*/_jsxs("h3", {
|
|
38
|
+
children: ["Order #", id]
|
|
39
|
+
}), /*#__PURE__*/_jsx("h4", {
|
|
40
|
+
children: "Payment Received!"
|
|
41
|
+
}), customSuccessMessage ? /*#__PURE__*/_jsx("p", {
|
|
42
|
+
className: "merchi-cart-success-message ",
|
|
43
|
+
children: customSuccessMessage
|
|
44
|
+
}) : /*#__PURE__*/_jsxs("p", {
|
|
45
|
+
className: "merchi-cart-success-message ",
|
|
46
|
+
children: ["Your order #", id, " is being processed and you should receive an email from us shortly. If you haven't heard from us within 24 hours please feel free to contact us", email ? " at ".concat(email.emailAddress, ".") : '.']
|
|
47
|
+
})]
|
|
41
48
|
}), !unpaid && /*#__PURE__*/_jsx("p", {
|
|
42
49
|
children: /*#__PURE__*/_jsx(ButtonInvoiceDownload, {})
|
|
43
50
|
}), /*#__PURE__*/_jsx("p", {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server.node';
|
|
3
|
+
import { useCartContext } from '../CartProvider';
|
|
4
|
+
import PanelPaymentSuccess from './PanelPaymentSuccess';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
jest.mock('../CartProvider', function () {
|
|
7
|
+
return {
|
|
8
|
+
useCartContext: jest.fn()
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
jest.mock('../components/containers', function () {
|
|
12
|
+
return {
|
|
13
|
+
CheckoutContainer: function CheckoutContainer(_ref) {
|
|
14
|
+
var children = _ref.children;
|
|
15
|
+
return children;
|
|
16
|
+
},
|
|
17
|
+
InnerContainer: function InnerContainer(_ref2) {
|
|
18
|
+
var children = _ref2.children;
|
|
19
|
+
return children;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
jest.mock('../components', function () {
|
|
24
|
+
return {
|
|
25
|
+
CartBody: function CartBody(_ref3) {
|
|
26
|
+
var children = _ref3.children;
|
|
27
|
+
return children;
|
|
28
|
+
},
|
|
29
|
+
CartTabPanel: function CartTabPanel(_ref4) {
|
|
30
|
+
var children = _ref4.children;
|
|
31
|
+
return children;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
jest.mock('../buttons', function () {
|
|
36
|
+
return {
|
|
37
|
+
Button: function Button(_ref5) {
|
|
38
|
+
var children = _ref5.children;
|
|
39
|
+
return /*#__PURE__*/_jsx("button", {
|
|
40
|
+
children: children
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
ButtonInvoiceDownload: function ButtonInvoiceDownload() {
|
|
44
|
+
return /*#__PURE__*/_jsx("button", {
|
|
45
|
+
children: "Download receipt"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
it.each([[true, false, true], [undefined, true, true], [false, false, false]])('labels the confirmation for invoice %s and cart %s', function (invoiceTest, cartTest, expectedTest) {
|
|
51
|
+
useCartContext.mockReturnValue({
|
|
52
|
+
cart: {
|
|
53
|
+
isTest: cartTest
|
|
54
|
+
},
|
|
55
|
+
invoiceJson: {
|
|
56
|
+
id: 42,
|
|
57
|
+
isTest: invoiceTest,
|
|
58
|
+
unpaid: false
|
|
59
|
+
},
|
|
60
|
+
customSuccessMessage: 'Our team is preparing your goods.'
|
|
61
|
+
});
|
|
62
|
+
var page = renderToStaticMarkup(/*#__PURE__*/_jsx(PanelPaymentSuccess, {}));
|
|
63
|
+
expect(page.includes('Test order #42')).toBe(expectedTest);
|
|
64
|
+
expect(page.includes('Simulated payment received.')).toBe(expectedTest);
|
|
65
|
+
expect(page.includes('Payment Received!')).toBe(!expectedTest);
|
|
66
|
+
expect(page.includes('Our team is preparing your goods.')).toBe(!expectedTest);
|
|
67
|
+
expect(page).toContain('Download receipt');
|
|
68
|
+
});
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export var TEST_CARD_NUMBER = '4242 4242 4242 4242';
|
|
4
|
-
export function readTestCheckoutFlag() {
|
|
5
|
-
if (typeof window === 'undefined') {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
try {
|
|
9
|
-
var params = new URLSearchParams(window.location.search);
|
|
10
|
-
if (params.get(TEST_CHECKOUT_QUERY) === '1') {
|
|
11
|
-
window.localStorage.setItem(TEST_CHECKOUT_STORAGE_KEY, '1');
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return window.localStorage.getItem(TEST_CHECKOUT_STORAGE_KEY) === '1';
|
|
15
|
-
} catch (_unused) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
import { readTestCheckoutFlag } from '@merchi/invoice/lib/testCheckout';
|
|
2
|
+
export { readTestCheckoutFlag, TEST_CARD_NUMBER, TEST_CHECKOUT_QUERY, TEST_CHECKOUT_STORAGE_KEY } from '@merchi/invoice/lib/testCheckout';
|
|
19
3
|
export function persistTestCheckoutFlag() {
|
|
20
4
|
return readTestCheckoutFlag();
|
|
21
5
|
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
+
var _TestOrderNotice = _interopRequireDefault(require("@merchi/invoice/lib/TestOrderNotice"));
|
|
7
8
|
var _containers = require("../components/containers");
|
|
8
9
|
var _tabs = require("../utilities/tabs");
|
|
9
10
|
var _company = require("../utilities/company");
|
|
@@ -13,8 +14,10 @@ var _buttons = require("../buttons");
|
|
|
13
14
|
var _components = require("../components");
|
|
14
15
|
var _CartProvider = require("../CartProvider");
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
16
18
|
function PanelPaymentSuccess() {
|
|
17
19
|
var _useCartContext = (0, _CartProvider.useCartContext)(),
|
|
20
|
+
cart = _useCartContext.cart,
|
|
18
21
|
classNameBtnPrimary = _useCartContext.classNameBtnPrimary,
|
|
19
22
|
customSuccessMessage = _useCartContext.customSuccessMessage,
|
|
20
23
|
fetchingCart = _useCartContext.fetchingCart,
|
|
@@ -30,20 +33,25 @@ function PanelPaymentSuccess() {
|
|
|
30
33
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.CartBody, {
|
|
31
34
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_containers.CheckoutContainer, {
|
|
32
35
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_containers.InnerContainer, {
|
|
33
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
children: [invoiceJson.isTest || cart !== null && cart !== void 0 && cart.isTest ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_TestOrderNotice["default"], {
|
|
37
|
+
title: "Test order #".concat(id),
|
|
38
|
+
paymentReceived: unpaid === false
|
|
39
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
40
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
|
|
41
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
|
|
42
|
+
icon: _freeSolidSvgIcons.faCheckCircle
|
|
43
|
+
})
|
|
44
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
|
|
45
|
+
children: ["Order #", id]
|
|
46
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("h4", {
|
|
47
|
+
children: "Payment Received!"
|
|
48
|
+
}), customSuccessMessage ? /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
49
|
+
className: "merchi-cart-success-message ",
|
|
50
|
+
children: customSuccessMessage
|
|
51
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
|
|
52
|
+
className: "merchi-cart-success-message ",
|
|
53
|
+
children: ["Your order #", id, " is being processed and you should receive an email from us shortly. If you haven't heard from us within 24 hours please feel free to contact us", email ? " at ".concat(email.emailAddress, ".") : '.']
|
|
54
|
+
})]
|
|
47
55
|
}), !unpaid && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
48
56
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_buttons.ButtonInvoiceDownload, {})
|
|
49
57
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare const TEST_CHECKOUT_STORAGE_KEY = "merchi_test_checkout";
|
|
3
|
-
export declare const TEST_CARD_NUMBER = "4242 4242 4242 4242";
|
|
4
|
-
export declare function readTestCheckoutFlag(): boolean;
|
|
1
|
+
export { readTestCheckoutFlag, TEST_CARD_NUMBER, TEST_CHECKOUT_QUERY, TEST_CHECKOUT_STORAGE_KEY } from '@merchi/invoice/lib/testCheckout';
|
|
5
2
|
export declare function persistTestCheckoutFlag(): boolean;
|
|
6
3
|
export declare function cartCookieName(domainId: number | string, isTest?: boolean): string;
|
|
@@ -3,30 +3,35 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
Object.defineProperty(exports, "TEST_CARD_NUMBER", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _testCheckout.TEST_CARD_NUMBER;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "TEST_CHECKOUT_QUERY", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _testCheckout.TEST_CHECKOUT_QUERY;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "TEST_CHECKOUT_STORAGE_KEY", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _testCheckout.TEST_CHECKOUT_STORAGE_KEY;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
7
24
|
exports.cartCookieName = cartCookieName;
|
|
8
25
|
exports.persistTestCheckoutFlag = persistTestCheckoutFlag;
|
|
9
|
-
exports
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function readTestCheckoutFlag() {
|
|
14
|
-
if (typeof window === 'undefined') {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
var params = new URLSearchParams(window.location.search);
|
|
19
|
-
if (params.get(TEST_CHECKOUT_QUERY) === '1') {
|
|
20
|
-
window.localStorage.setItem(TEST_CHECKOUT_STORAGE_KEY, '1');
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
return window.localStorage.getItem(TEST_CHECKOUT_STORAGE_KEY) === '1';
|
|
24
|
-
} catch (_unused) {
|
|
25
|
-
return false;
|
|
26
|
+
Object.defineProperty(exports, "readTestCheckoutFlag", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _testCheckout.readTestCheckoutFlag;
|
|
26
30
|
}
|
|
27
|
-
}
|
|
31
|
+
});
|
|
32
|
+
var _testCheckout = require("@merchi/invoice/lib/testCheckout");
|
|
28
33
|
function persistTestCheckoutFlag() {
|
|
29
|
-
return readTestCheckoutFlag();
|
|
34
|
+
return (0, _testCheckout.readTestCheckoutFlag)();
|
|
30
35
|
}
|
|
31
36
|
function cartCookieName(domainId) {
|
|
32
37
|
var isTest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merchi/cart",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.85",
|
|
4
4
|
"description": "Merchi's cart",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
"@fortawesome/free-solid-svg-icons": "6.4.2",
|
|
95
95
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
96
96
|
"@merchi/error-catch": "^0.1.13",
|
|
97
|
-
"@merchi/invoice": "^1.3.
|
|
98
|
-
"@merchi/product-form": "^1.19.
|
|
97
|
+
"@merchi/invoice": "^1.3.21",
|
|
98
|
+
"@merchi/product-form": "^1.19.66",
|
|
99
99
|
"@merchi/product-form-sdk": "^1.0.43",
|
|
100
100
|
"@merchi/sdk": "^1.42.32",
|
|
101
101
|
"@stripe/react-stripe-js": "^2.3.0",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server.node';
|
|
3
|
+
import { useCartContext } from '../CartProvider';
|
|
4
|
+
import PanelPaymentSuccess from './PanelPaymentSuccess';
|
|
5
|
+
|
|
6
|
+
jest.mock('../CartProvider', () => ({ useCartContext: jest.fn() }));
|
|
7
|
+
jest.mock('../components/containers', () => ({
|
|
8
|
+
CheckoutContainer: ({ children }: any) => children,
|
|
9
|
+
InnerContainer: ({ children }: any) => children,
|
|
10
|
+
}));
|
|
11
|
+
jest.mock('../components', () => ({
|
|
12
|
+
CartBody: ({ children }: any) => children,
|
|
13
|
+
CartTabPanel: ({ children }: any) => children,
|
|
14
|
+
}));
|
|
15
|
+
jest.mock('../buttons', () => ({
|
|
16
|
+
Button: ({ children }: any) => <button>{children}</button>,
|
|
17
|
+
ButtonInvoiceDownload: () => <button>Download receipt</button>,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
it.each([
|
|
21
|
+
[true, false, true],
|
|
22
|
+
[undefined, true, true],
|
|
23
|
+
[false, false, false],
|
|
24
|
+
])('labels the confirmation for invoice %s and cart %s', (invoiceTest, cartTest, expectedTest) => {
|
|
25
|
+
(useCartContext as jest.Mock).mockReturnValue({
|
|
26
|
+
cart: { isTest: cartTest },
|
|
27
|
+
invoiceJson: { id: 42, isTest: invoiceTest, unpaid: false },
|
|
28
|
+
customSuccessMessage: 'Our team is preparing your goods.',
|
|
29
|
+
});
|
|
30
|
+
const page = renderToStaticMarkup(<PanelPaymentSuccess />);
|
|
31
|
+
expect(page.includes('Test order #42')).toBe(expectedTest);
|
|
32
|
+
expect(page.includes('Simulated payment received.')).toBe(expectedTest);
|
|
33
|
+
expect(page.includes('Payment Received!')).toBe(!expectedTest);
|
|
34
|
+
expect(page.includes('Our team is preparing your goods.')).toBe(!expectedTest);
|
|
35
|
+
expect(page).toContain('Download receipt');
|
|
36
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import TestOrderNotice from '@merchi/invoice/lib/TestOrderNotice';
|
|
1
2
|
import {
|
|
2
3
|
CheckoutContainer,
|
|
3
4
|
InnerContainer,
|
|
@@ -12,6 +13,7 @@ import { useCartContext } from '../CartProvider';
|
|
|
12
13
|
|
|
13
14
|
function PanelPaymentSuccess() {
|
|
14
15
|
const {
|
|
16
|
+
cart,
|
|
15
17
|
classNameBtnPrimary,
|
|
16
18
|
customSuccessMessage,
|
|
17
19
|
fetchingCart,
|
|
@@ -26,19 +28,25 @@ function PanelPaymentSuccess() {
|
|
|
26
28
|
<CartBody>
|
|
27
29
|
<CheckoutContainer>
|
|
28
30
|
<InnerContainer>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<h4>Payment Received!</h4>
|
|
32
|
-
{customSuccessMessage ? (
|
|
33
|
-
<p className='merchi-cart-success-message '>
|
|
34
|
-
{customSuccessMessage}
|
|
35
|
-
</p>
|
|
31
|
+
{invoiceJson.isTest || cart?.isTest ? (
|
|
32
|
+
<TestOrderNotice title={`Test order #${id}`} paymentReceived={unpaid === false} />
|
|
36
33
|
) : (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
<>
|
|
35
|
+
<h2><FontAwesomeIcon icon={faCheckCircle} /></h2>
|
|
36
|
+
<h3>Order #{id}</h3>
|
|
37
|
+
<h4>Payment Received!</h4>
|
|
38
|
+
{customSuccessMessage ? (
|
|
39
|
+
<p className='merchi-cart-success-message '>
|
|
40
|
+
{customSuccessMessage}
|
|
41
|
+
</p>
|
|
42
|
+
) : (
|
|
43
|
+
<p className='merchi-cart-success-message '>
|
|
44
|
+
Your order #{id} is being processed and you should
|
|
45
|
+
receive an email from us shortly. If you haven't heard from us within 24
|
|
46
|
+
hours please feel free to contact us{email ? ` at ${email.emailAddress}.` : '.'}
|
|
47
|
+
</p>
|
|
48
|
+
)}
|
|
49
|
+
</>
|
|
42
50
|
)}
|
|
43
51
|
{!unpaid && <p><ButtonInvoiceDownload /></p>}
|
|
44
52
|
<p>
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export const TEST_CARD_NUMBER = '4242 4242 4242 4242';
|
|
4
|
-
|
|
5
|
-
export function readTestCheckoutFlag(): boolean {
|
|
6
|
-
if (typeof window === 'undefined') {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
try {
|
|
10
|
-
const params = new URLSearchParams(window.location.search);
|
|
11
|
-
if (params.get(TEST_CHECKOUT_QUERY) === '1') {
|
|
12
|
-
window.localStorage.setItem(TEST_CHECKOUT_STORAGE_KEY, '1');
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
return window.localStorage.getItem(TEST_CHECKOUT_STORAGE_KEY) === '1';
|
|
16
|
-
} catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
import { readTestCheckoutFlag } from '@merchi/invoice/lib/testCheckout';
|
|
2
|
+
export { readTestCheckoutFlag, TEST_CARD_NUMBER, TEST_CHECKOUT_QUERY, TEST_CHECKOUT_STORAGE_KEY } from '@merchi/invoice/lib/testCheckout';
|
|
20
3
|
|
|
21
4
|
export function persistTestCheckoutFlag(): boolean {
|
|
22
5
|
return readTestCheckoutFlag();
|