@rebilly/instruments 1.0.2-beta.8 → 2.1.1-beta.0
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/.babelrc +13 -4
- package/.eslintrc.js +3 -0
- package/.prettierrc.js +11 -0
- package/README.md +15 -314
- package/dist/events/base-event.js +6 -9
- package/dist/events/events.spec.js +4 -4
- package/dist/events/index.js +2 -1
- package/dist/functions/destroy.js +12 -14
- package/dist/functions/destroy.spec.js +3 -3
- package/dist/functions/mount/fetch-data.js +183 -0
- package/dist/functions/mount/fetch-data.spec.js +189 -0
- package/dist/functions/mount/index.js +158 -251
- package/dist/functions/mount/mount.spec.js +24 -121
- package/dist/functions/mount/setup-element.js +40 -0
- package/dist/functions/mount/setup-framepay.js +46 -0
- package/dist/functions/mount/setup-i18n.js +33 -0
- package/dist/functions/mount/setup-options.js +96 -0
- package/dist/functions/mount/setup-options.spec.js +66 -0
- package/dist/functions/mount/setup-storefront.js +34 -0
- package/dist/functions/mount/setup-styles.js +43 -0
- package/dist/functions/on.js +13 -4
- package/dist/functions/on.spec.js +19 -5
- package/dist/functions/purchase.js +139 -22
- package/dist/functions/purchase.spec.js +23 -19
- package/dist/functions/setup.js +85 -0
- package/dist/functions/setup.spec.js +87 -0
- package/dist/functions/show.js +31 -14
- package/dist/functions/show.spec.js +47 -18
- package/dist/functions/update.js +53 -27
- package/dist/functions/update.spec.js +40 -21
- package/dist/i18n/en.json +4 -1
- package/dist/i18n/es.json +4 -1
- package/dist/index.js +67 -56
- package/dist/index.spec.js +7 -27
- package/dist/loader/index.js +4 -3
- package/dist/storefront/index.js +33 -0
- package/dist/storefront/invoices.js +27 -0
- package/dist/storefront/models/base-model.js +18 -0
- package/dist/storefront/models/invoice-model.js +14 -0
- package/dist/storefront/models/plan-model.js +4 -35
- package/dist/storefront/models/product-model.js +4 -23
- package/dist/storefront/models/summary-model.js +12 -25
- package/dist/storefront/models/transaction-model.js +31 -0
- package/dist/storefront/payment-instruments.js +47 -0
- package/dist/storefront/payment-instruments.spec.js +55 -0
- package/dist/storefront/plans.js +15 -24
- package/dist/storefront/plans.spec.js +17 -44
- package/dist/storefront/products.js +16 -20
- package/dist/storefront/products.spec.js +25 -49
- package/dist/storefront/purchase.js +28 -16
- package/dist/storefront/purchase.spec.js +4 -22
- package/dist/storefront/ready-to-pay.js +26 -22
- package/dist/storefront/ready-to-pay.spec.js +25 -54
- package/dist/storefront/storefront.spec.js +1 -1
- package/dist/storefront/summary.js +27 -24
- package/dist/storefront/summary.spec.js +44 -86
- package/dist/storefront/transactions.js +27 -0
- package/dist/style/base/theme.js +3 -3
- package/dist/style/components/methods.js +43 -42
- package/dist/style/utils/color-values.js +1 -3
- package/dist/style/views/confirmation.js +0 -4
- package/dist/style/views/method-selector.js +1 -1
- package/dist/style/views/modal.js +3 -1
- package/dist/style/views/summary.js +5 -1
- package/dist/utils/format-currency.js +4 -2
- package/dist/utils/has-valid-css-selector.js +1 -1
- package/dist/utils/process-property-as-dom-element.js +0 -2
- package/dist/views/__snapshots__/summary.spec.js.snap +103 -113
- package/dist/views/common/iframe/base-iframe.js +10 -2
- package/dist/views/common/iframe/modal-iframe.js +44 -3
- package/dist/views/confirmation.js +44 -20
- package/dist/views/method-selector/express-methods/apple-pay.js +92 -0
- package/dist/views/method-selector/express-methods/google-pay.js +31 -0
- package/dist/views/method-selector/express-methods/paypal.js +19 -0
- package/dist/views/method-selector/generate-digital-wallet.js +68 -0
- package/dist/views/method-selector/generate-digital-wallet.spec.js +135 -0
- package/dist/views/method-selector/get-payment-methods.js +28 -8
- package/dist/views/method-selector/get-payment-methods.spec.js +25 -26
- package/dist/views/method-selector/index.js +55 -86
- package/dist/views/method-selector/method-selector.spec.js +80 -69
- package/dist/views/method-selector/mount-express-methods.js +38 -62
- package/dist/views/method-selector/mount-methods.js +18 -18
- package/dist/views/modal.js +21 -15
- package/dist/views/result.js +13 -16
- package/dist/views/summary.js +170 -114
- package/dist/views/summary.spec.js +72 -76
- package/package.json +5 -4
- package/src/events/base-event.js +15 -17
- package/src/events/events.spec.js +6 -4
- package/src/events/index.js +6 -3
- package/src/functions/destroy.js +12 -13
- package/src/functions/destroy.spec.js +30 -31
- package/src/functions/mount/fetch-data.js +148 -0
- package/src/functions/mount/fetch-data.spec.js +238 -0
- package/src/functions/mount/index.js +129 -244
- package/src/functions/mount/mount.spec.js +35 -139
- package/src/functions/mount/setup-element.js +26 -0
- package/src/functions/mount/setup-framepay.js +41 -0
- package/src/functions/mount/setup-i18n.js +19 -0
- package/src/functions/mount/setup-options.js +100 -0
- package/src/functions/mount/setup-options.spec.js +60 -0
- package/src/functions/mount/setup-storefront.js +24 -0
- package/src/functions/mount/setup-styles.js +30 -0
- package/src/functions/on.js +13 -8
- package/src/functions/on.spec.js +30 -17
- package/src/functions/purchase.js +101 -19
- package/src/functions/purchase.spec.js +18 -18
- package/src/functions/setup.js +48 -0
- package/src/functions/setup.spec.js +98 -0
- package/src/functions/show.js +20 -10
- package/src/functions/show.spec.js +43 -22
- package/src/functions/update.js +50 -27
- package/src/functions/update.spec.js +57 -22
- package/src/i18n/en.json +4 -1
- package/src/i18n/es.json +4 -1
- package/src/i18n/i18n.spec.js +6 -4
- package/src/i18n/index.js +14 -11
- package/src/index.js +41 -52
- package/src/index.spec.js +8 -37
- package/src/loader/index.js +51 -47
- package/src/loader/loader.spec.js +26 -19
- package/src/storefront/index.js +37 -7
- package/src/storefront/invoices.js +11 -0
- package/src/storefront/models/base-model.js +10 -0
- package/src/storefront/models/invoice-model.js +3 -0
- package/src/storefront/models/plan-model.js +3 -35
- package/src/storefront/models/product-model.js +3 -23
- package/src/storefront/models/ready-to-pay-model.js +3 -3
- package/src/storefront/models/summary-model.js +15 -29
- package/src/storefront/models/transaction-model.js +19 -0
- package/src/storefront/payment-instruments.js +30 -0
- package/src/storefront/payment-instruments.spec.js +69 -0
- package/src/storefront/plans.js +16 -23
- package/src/storefront/plans.spec.js +25 -54
- package/src/storefront/products.js +18 -22
- package/src/storefront/products.spec.js +23 -54
- package/src/storefront/purchase.js +14 -14
- package/src/storefront/purchase.spec.js +17 -29
- package/src/storefront/ready-to-pay.js +26 -23
- package/src/storefront/ready-to-pay.spec.js +41 -71
- package/src/storefront/storefront.spec.js +1 -1
- package/src/storefront/summary.js +26 -22
- package/src/storefront/summary.spec.js +60 -109
- package/src/storefront/transactions.js +11 -0
- package/src/style/base/theme.js +10 -8
- package/src/style/base/theme.spec.js +4 -2
- package/src/style/browserslist.js +1 -3
- package/src/style/components/button.js +3 -1
- package/src/style/components/forms/checkbox.js +3 -1
- package/src/style/components/index.js +1 -1
- package/src/style/components/loader.js +3 -1
- package/src/style/components/methods.js +43 -42
- package/src/style/helpers/index.js +1 -1
- package/src/style/index.js +2 -1
- package/src/style/utils/color-values.js +4 -4
- package/src/style/vendor/framepay.js +1 -1
- package/src/style/vendor/postmate.js +1 -1
- package/src/style/views/confirmation.js +0 -4
- package/src/style/views/index.js +1 -1
- package/src/style/views/method-selector.js +1 -1
- package/src/style/views/modal.js +4 -2
- package/src/style/views/summary.js +5 -1
- package/src/utils/add-dom-element.js +12 -13
- package/src/utils/format-currency.js +6 -2
- package/src/utils/has-valid-css-selector.js +2 -2
- package/src/utils/is-dom-element.js +1 -1
- package/src/utils/process-property-as-dom-element.js +27 -24
- package/src/utils/sleep.js +1 -1
- package/src/views/__snapshots__/summary.spec.js.snap +103 -113
- package/src/views/common/iframe/base-iframe.js +12 -4
- package/src/views/common/iframe/event-listeners.js +6 -6
- package/src/views/common/iframe/index.js +1 -1
- package/src/views/common/iframe/method-iframe.js +3 -6
- package/src/views/common/iframe/modal-iframe.js +42 -6
- package/src/views/common/iframe/view-iframe.js +3 -5
- package/src/views/common/render-utilities.js +3 -3
- package/src/views/confirmation.js +34 -25
- package/src/views/method-selector/express-methods/apple-pay.js +78 -0
- package/src/views/method-selector/express-methods/google-pay.js +24 -0
- package/src/views/method-selector/express-methods/paypal.js +7 -0
- package/src/views/method-selector/generate-digital-wallet.js +51 -0
- package/src/views/method-selector/generate-digital-wallet.spec.js +135 -0
- package/src/views/method-selector/get-method-data.js +7 -4
- package/src/views/method-selector/get-payment-methods.js +38 -29
- package/src/views/method-selector/get-payment-methods.spec.js +26 -33
- package/src/views/method-selector/index.js +70 -99
- package/src/views/method-selector/method-selector.spec.js +88 -78
- package/src/views/method-selector/mount-express-methods.js +36 -60
- package/src/views/method-selector/mount-methods.js +32 -21
- package/src/views/modal.js +37 -23
- package/src/views/result.js +12 -15
- package/src/views/summary.js +169 -101
- package/src/views/summary.spec.js +99 -74
- package/tests/async-utilities.js +22 -0
- package/tests/mocks/rebilly-instruments-mock.js +89 -77
- package/tests/mocks/storefront-api-mock.js +8 -0
- package/tests/mocks/storefront-mock.js +17 -0
- package/dist/events/purchase-completed.js +0 -24
- package/dist/functions/initialize.js +0 -82
- package/dist/functions/initialize.spec.js +0 -34
- package/dist/functions/mount/fetch-summary-data.js +0 -31
- package/dist/functions/mount/fetch-summary-data.spec.js +0 -45
- package/dist/views/method-selector/process-digital-wallet-options.js +0 -35
- package/dist/views/method-selector/process-digital-wallet-options.spec.js +0 -80
- package/src/events/purchase-completed.js +0 -11
- package/src/functions/initialize.js +0 -74
- package/src/functions/initialize.spec.js +0 -38
- package/src/functions/mount/fetch-summary-data.js +0 -26
- package/src/functions/mount/fetch-summary-data.spec.js +0 -46
- package/src/views/method-selector/process-digital-wallet-options.js +0 -16
- package/src/views/method-selector/process-digital-wallet-options.spec.js +0 -94
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
export default function addDOMElement(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
1
|
+
export default function addDOMElement({
|
|
2
|
+
element = 'div',
|
|
3
|
+
attributes = {},
|
|
4
|
+
content = null,
|
|
5
|
+
target = 'body',
|
|
6
|
+
insertMethod = 'append'
|
|
7
|
+
} = {}) {
|
|
8
|
+
const ELEMENT = document.createElement(element);
|
|
9
|
+
const ELEMENT_ATTRIBUTES = Object.entries(attributes);
|
|
10
|
+
ELEMENT_ATTRIBUTES.forEach(([attribute, value]) => {
|
|
11
|
+
ELEMENT.setAttribute(attribute, value);
|
|
12
|
+
});
|
|
14
13
|
if (content) {
|
|
15
14
|
ELEMENT.innerHTML = content;
|
|
16
15
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export default function formatCurrency(number, currency
|
|
2
|
-
|
|
1
|
+
export default function formatCurrency(number, currency) {
|
|
2
|
+
const converToNumber = Number(number);
|
|
3
|
+
if (Number.isNaN(converToNumber) || number === null) return '-';
|
|
4
|
+
return new Intl.NumberFormat('en-US', { style: 'currency', currency: currency || 'USD'}).format(
|
|
5
|
+
number
|
|
6
|
+
);
|
|
3
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export default function hasValidCSSSelector(selector) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const REGEX_CSS_SELECTOR = /([.#][_a-z]+[_a-z0-9-:\\]*)/gi;
|
|
3
|
+
return typeof selector === 'string' && selector.match(REGEX_CSS_SELECTOR);
|
|
4
4
|
}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import hasValidCSSSelector from './has-valid-css-selector';
|
|
2
2
|
import isDOMElement from './is-dom-element';
|
|
3
3
|
|
|
4
|
-
export default function processPropertyAsDOMElement(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
4
|
+
export default function processPropertyAsDOMElement({
|
|
5
|
+
prop,
|
|
6
|
+
propName = 'Mounting',
|
|
7
|
+
isRequired = true
|
|
8
|
+
} = {}) {
|
|
9
|
+
let DOMElement;
|
|
10
|
+
|
|
11
|
+
if (typeof prop === 'undefined') {
|
|
12
|
+
throw new Error('processPropertyDOMElement: Missing argument "prop"');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (hasValidCSSSelector(prop)) {
|
|
16
|
+
DOMElement = document.querySelector(prop);
|
|
17
|
+
} else if (isDOMElement(prop)) {
|
|
18
|
+
DOMElement = prop;
|
|
19
|
+
} else {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Please provide a valid CSS class, id or DOM element for "${propName}" property`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!DOMElement && isRequired) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Could not find DOM element with CSS class or id "${prop}" to mount ${propName}`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return DOMElement;
|
|
28
31
|
}
|
package/src/utils/sleep.js
CHANGED
|
@@ -5,150 +5,151 @@ exports[`Summary component should render the summary correctly 1`] = `
|
|
|
5
5
|
class="rebilly-instruments-summary-line-items"
|
|
6
6
|
>
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
<div
|
|
10
10
|
class="rebilly-instruments-summary-line-item"
|
|
11
11
|
>
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
|
|
15
15
|
<div
|
|
16
16
|
class="rebilly-instruments-summary-line-item-synopsis"
|
|
17
17
|
>
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
<p
|
|
21
21
|
class="rebilly-instruments-summary-line-item-synopsis-title"
|
|
22
22
|
>
|
|
23
23
|
My Awesome Product
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
|
+
|
|
26
27
|
|
|
27
|
-
|
|
28
28
|
<p
|
|
29
29
|
class="rebilly-instruments-summary-line-item-synopsis-description"
|
|
30
30
|
>
|
|
31
31
|
My Awesome Product
|
|
32
32
|
</p>
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
|
|
35
|
+
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
<div
|
|
40
40
|
class="rebilly-instruments-summary-line-item-price-breakdown"
|
|
41
41
|
>
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
<p
|
|
45
45
|
class="rebilly-instruments-summary-line-item-price-breakdown-quantity"
|
|
46
46
|
>
|
|
47
47
|
1
|
|
48
48
|
</p>
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
<svg
|
|
52
52
|
class="rebilly-instruments-icon"
|
|
53
53
|
viewBox="0 0 24 24"
|
|
54
54
|
xmlns="http://www.w3.org/2000/svg"
|
|
55
55
|
>
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
<path
|
|
59
59
|
d="M12 10.5858l2.8284-2.8284c.3906-.3906 1.0237-.3906 1.4142 0 .3906.3905.3906 1.0236 0 1.4142L13.4142 12l2.8284 2.8284c.3906.3906.3906 1.0237 0 1.4142-.3905.3906-1.0236.3906-1.4142 0L12 13.4142l-2.8284 2.8284c-.3906.3906-1.0237.3906-1.4142 0-.3906-.3905-.3906-1.0236 0-1.4142L10.5858 12 7.7574 9.1716c-.3906-.3906-.3906-1.0237 0-1.4142.3905-.3906 1.0236-.3906 1.4142 0L12 10.5858z"
|
|
60
60
|
fill-rule="nonzero"
|
|
61
61
|
/>
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
</svg>
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
<p
|
|
68
68
|
class="rebilly-instruments-summary-line-item-price-breakdown-unit-price"
|
|
69
69
|
>
|
|
70
70
|
$30.00
|
|
71
71
|
</p>
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
</div>
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
</div>
|
|
78
78
|
|
|
79
|
+
|
|
80
|
+
|
|
79
81
|
|
|
80
|
-
|
|
81
82
|
<div
|
|
82
83
|
class="rebilly-instruments-summary-line-item"
|
|
83
84
|
>
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
|
|
87
|
+
|
|
87
88
|
<div
|
|
88
89
|
class="rebilly-instruments-summary-line-item-synopsis"
|
|
89
90
|
>
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
|
|
92
93
|
<p
|
|
93
94
|
class="rebilly-instruments-summary-line-item-synopsis-title"
|
|
94
95
|
>
|
|
95
96
|
My Awesome T-Shirt
|
|
96
97
|
</p>
|
|
97
98
|
|
|
99
|
+
|
|
98
100
|
|
|
99
|
-
|
|
100
101
|
<p
|
|
101
102
|
class="rebilly-instruments-summary-line-item-synopsis-description"
|
|
102
103
|
>
|
|
103
|
-
|
|
104
|
+
Awesome T-Shirt
|
|
104
105
|
</p>
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
|
|
108
|
+
|
|
108
109
|
</div>
|
|
109
110
|
|
|
110
|
-
|
|
111
|
+
|
|
111
112
|
<div
|
|
112
113
|
class="rebilly-instruments-summary-line-item-price-breakdown"
|
|
113
114
|
>
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
|
|
116
117
|
<p
|
|
117
118
|
class="rebilly-instruments-summary-line-item-price-breakdown-quantity"
|
|
118
119
|
>
|
|
119
120
|
2
|
|
120
121
|
</p>
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
|
|
123
124
|
<svg
|
|
124
125
|
class="rebilly-instruments-icon"
|
|
125
126
|
viewBox="0 0 24 24"
|
|
126
127
|
xmlns="http://www.w3.org/2000/svg"
|
|
127
128
|
>
|
|
128
129
|
|
|
129
|
-
|
|
130
|
+
|
|
130
131
|
<path
|
|
131
132
|
d="M12 10.5858l2.8284-2.8284c.3906-.3906 1.0237-.3906 1.4142 0 .3906.3905.3906 1.0236 0 1.4142L13.4142 12l2.8284 2.8284c.3906.3906.3906 1.0237 0 1.4142-.3905.3906-1.0236.3906-1.4142 0L12 13.4142l-2.8284 2.8284c-.3906.3906-1.0237.3906-1.4142 0-.3906-.3905-.3906-1.0236 0-1.4142L10.5858 12 7.7574 9.1716c-.3906-.3906-.3906-1.0237 0-1.4142.3905-.3906 1.0236-.3906 1.4142 0L12 10.5858z"
|
|
132
133
|
fill-rule="nonzero"
|
|
133
134
|
/>
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
|
|
136
137
|
</svg>
|
|
137
138
|
|
|
138
|
-
|
|
139
|
+
|
|
139
140
|
<p
|
|
140
141
|
class="rebilly-instruments-summary-line-item-price-breakdown-unit-price"
|
|
141
142
|
>
|
|
142
143
|
$20.00
|
|
143
144
|
</p>
|
|
144
145
|
|
|
145
|
-
|
|
146
|
+
|
|
146
147
|
</div>
|
|
147
148
|
|
|
148
|
-
|
|
149
|
+
|
|
149
150
|
</div>
|
|
150
151
|
|
|
151
|
-
|
|
152
|
+
|
|
152
153
|
</div>
|
|
153
154
|
`;
|
|
154
155
|
|
|
@@ -156,137 +157,126 @@ exports[`Summary component should render the summary correctly 2`] = `
|
|
|
156
157
|
<div
|
|
157
158
|
class="rebilly-instruments-summary-breakdown"
|
|
158
159
|
>
|
|
159
|
-
|
|
160
|
-
|
|
161
160
|
<table>
|
|
162
161
|
|
|
163
|
-
|
|
162
|
+
|
|
164
163
|
<colgroup>
|
|
165
164
|
|
|
166
|
-
|
|
165
|
+
|
|
167
166
|
<col />
|
|
168
167
|
|
|
169
|
-
|
|
168
|
+
|
|
170
169
|
<col />
|
|
171
170
|
|
|
172
|
-
|
|
171
|
+
|
|
173
172
|
</colgroup>
|
|
174
173
|
|
|
175
174
|
|
|
176
|
-
<
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
<tr
|
|
176
|
+
class="rebilly-instruments-summary-breakdown-sub-total"
|
|
177
|
+
>
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
<td
|
|
181
|
+
data-rebilly-i18n="summary.subTotal"
|
|
179
182
|
>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
data-rebilly-i18n="summary.subTotal"
|
|
184
|
-
>
|
|
185
|
-
Sub Total
|
|
186
|
-
</td>
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
<td>
|
|
190
|
-
$70.00
|
|
191
|
-
</td>
|
|
192
|
-
|
|
183
|
+
Sub Total
|
|
184
|
+
</td>
|
|
185
|
+
|
|
193
186
|
|
|
194
|
-
|
|
187
|
+
<td>
|
|
188
|
+
$70.00
|
|
189
|
+
</td>
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
</tr>
|
|
193
|
+
<tr
|
|
194
|
+
class="rebilly-instruments-summary-breakdown-discounts"
|
|
195
|
+
>
|
|
195
196
|
|
|
196
197
|
|
|
197
|
-
<
|
|
198
|
-
|
|
198
|
+
<td
|
|
199
|
+
data-rebilly-i18n="summary.discounts"
|
|
199
200
|
>
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
<td>
|
|
210
|
-
$0.00
|
|
211
|
-
</td>
|
|
212
|
-
|
|
201
|
+
Discounts
|
|
202
|
+
</td>
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
<td>
|
|
206
|
+
$0.00
|
|
207
|
+
</td>
|
|
213
208
|
|
|
214
|
-
|
|
209
|
+
|
|
210
|
+
</tr>
|
|
211
|
+
<tr
|
|
212
|
+
class="rebilly-instruments-summary-breakdown-taxes"
|
|
213
|
+
>
|
|
215
214
|
|
|
216
215
|
|
|
217
|
-
<
|
|
218
|
-
|
|
216
|
+
<td
|
|
217
|
+
data-rebilly-i18n="summary.taxes"
|
|
219
218
|
>
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
data-rebilly-i18n="summary.taxes"
|
|
224
|
-
>
|
|
225
|
-
Taxes
|
|
226
|
-
</td>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
<td>
|
|
230
|
-
$0.00
|
|
231
|
-
</td>
|
|
232
|
-
|
|
219
|
+
Taxes
|
|
220
|
+
</td>
|
|
221
|
+
|
|
233
222
|
|
|
234
|
-
|
|
223
|
+
<td>
|
|
224
|
+
$0.00
|
|
225
|
+
</td>
|
|
235
226
|
|
|
227
|
+
|
|
228
|
+
</tr>
|
|
229
|
+
<tr
|
|
230
|
+
class="rebilly-instruments-summary-breakdown-shipping"
|
|
231
|
+
>
|
|
236
232
|
|
|
237
|
-
|
|
238
|
-
|
|
233
|
+
|
|
234
|
+
<td
|
|
235
|
+
data-rebilly-i18n="summary.shipping"
|
|
239
236
|
>
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
<td
|
|
243
|
-
data-rebilly-i18n="summary.shipping"
|
|
244
|
-
>
|
|
245
|
-
Shipping
|
|
246
|
-
</td>
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
<td>
|
|
250
|
-
$0.00
|
|
251
|
-
</td>
|
|
252
|
-
|
|
237
|
+
Shipping
|
|
238
|
+
</td>
|
|
253
239
|
|
|
254
|
-
|
|
240
|
+
|
|
241
|
+
<td>
|
|
242
|
+
$0.00
|
|
243
|
+
</td>
|
|
255
244
|
|
|
256
245
|
|
|
257
|
-
</
|
|
246
|
+
</tr>
|
|
258
247
|
</table>
|
|
259
|
-
|
|
260
|
-
|
|
261
248
|
<div
|
|
262
249
|
class="rebilly-instruments-summary-breakdown-total"
|
|
263
250
|
>
|
|
264
251
|
|
|
265
|
-
|
|
252
|
+
|
|
266
253
|
<p
|
|
267
254
|
data-rebilly-i18n="summary.total"
|
|
268
255
|
>
|
|
269
256
|
Total
|
|
270
257
|
</p>
|
|
271
258
|
|
|
272
|
-
|
|
259
|
+
|
|
273
260
|
<p
|
|
274
261
|
class="rebilly-instruments-summary-breakdown-total-amount"
|
|
275
262
|
>
|
|
276
263
|
|
|
277
|
-
|
|
264
|
+
|
|
278
265
|
<span
|
|
279
266
|
class="rebilly-instruments-summary-breakdown-total-amount-currency"
|
|
280
267
|
>
|
|
268
|
+
|
|
281
269
|
USD
|
|
270
|
+
|
|
282
271
|
</span>
|
|
272
|
+
|
|
283
273
|
$70.00
|
|
274
|
+
|
|
275
|
+
</p>
|
|
276
|
+
<p>
|
|
284
277
|
|
|
278
|
+
|
|
285
279
|
</p>
|
|
286
|
-
|
|
287
|
-
|
|
288
280
|
</div>
|
|
289
|
-
|
|
290
|
-
|
|
291
281
|
</div>
|
|
292
282
|
`;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import Postmate from '
|
|
1
|
+
import Postmate from 'popostmate';
|
|
2
2
|
|
|
3
3
|
export default class BaseIframe {
|
|
4
|
-
constructor
|
|
4
|
+
constructor({
|
|
5
|
+
state = {},
|
|
5
6
|
name = '',
|
|
6
7
|
url = '',
|
|
7
8
|
model = {},
|
|
@@ -9,10 +10,11 @@ export default class BaseIframe {
|
|
|
9
10
|
classListArray = []
|
|
10
11
|
} = {}) {
|
|
11
12
|
classListArray = Array.isArray(classListArray) ? classListArray : [];
|
|
12
|
-
if(!classListArray.includes('rebilly-instruments-iframe')) {
|
|
13
|
+
if (!classListArray.includes('rebilly-instruments-iframe')) {
|
|
13
14
|
classListArray.push('rebilly-instruments-iframe');
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
this.state = state;
|
|
16
18
|
this.container = container;
|
|
17
19
|
this.classListArray = classListArray;
|
|
18
20
|
this.name = name;
|
|
@@ -26,6 +28,12 @@ export default class BaseIframe {
|
|
|
26
28
|
})();
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
async destroy() {
|
|
32
|
+
if (this.component.frame.parentNode) {
|
|
33
|
+
await this.component.destroy();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
async createComponent() {
|
|
30
38
|
const component = await new Postmate({
|
|
31
39
|
name: this.name,
|
|
@@ -37,4 +45,4 @@ export default class BaseIframe {
|
|
|
37
45
|
|
|
38
46
|
return component;
|
|
39
47
|
}
|
|
40
|
-
}
|
|
48
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import camelCase from 'lodash.camelcase';
|
|
2
|
-
import Events from '../../../events'
|
|
2
|
+
import Events from '../../../events';
|
|
3
3
|
|
|
4
4
|
export function dispatchRebillyInsturmentEventHandler(iframe) {
|
|
5
|
-
iframe.component.on(`${iframe.name}-dispatch`, ({event, detail}) => {
|
|
5
|
+
iframe.component.on(`${iframe.name}-dispatch`, ({ event, detail }) => {
|
|
6
6
|
Events[camelCase(event).replace(/-/, '')].dispatch(detail);
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function resizeComponentHandler(iframe) {
|
|
11
|
-
iframe.component.on(`${iframe.name}-resize-frame`, height => {
|
|
11
|
+
iframe.component.on(`${iframe.name}-resize-frame`, (height) => {
|
|
12
12
|
iframe.component.frame.style.height = height;
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function stopLoaderHandler(iframe, data = {section: 'form'}) {
|
|
16
|
+
export function stopLoaderHandler(iframe, data = { section: 'form' }) {
|
|
17
17
|
iframe.component.on(`${iframe.name}-stop-loading`, (id = null) => {
|
|
18
|
-
data.loader?.stopLoading({section: data.section, id: id || data.id});
|
|
18
|
+
data.loader?.stopLoading({ section: data.section, id: id || data.id });
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -24,4 +24,4 @@ export function changeIframeSrcHandler(iframe) {
|
|
|
24
24
|
iframe.component.frame.src = url;
|
|
25
25
|
iframe.component.frame.style.height = '75vh';
|
|
26
26
|
});
|
|
27
|
-
}
|
|
27
|
+
}
|
|
@@ -10,15 +10,12 @@ export class MethodIframe extends BaseIframe {
|
|
|
10
10
|
super(args);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
bindEventListeners({
|
|
14
|
-
loader,
|
|
15
|
-
id,
|
|
16
|
-
} = {}) {
|
|
13
|
+
bindEventListeners({ loader, id } = {}) {
|
|
17
14
|
dispatchRebillyInsturmentEventHandler(this);
|
|
18
15
|
resizeComponentHandler(this);
|
|
19
16
|
stopLoaderHandler(this, {
|
|
20
17
|
loader,
|
|
21
18
|
id
|
|
22
|
-
})
|
|
19
|
+
});
|
|
23
20
|
}
|
|
24
|
-
}
|
|
21
|
+
}
|
|
@@ -11,17 +11,53 @@ export class ModalIframe extends BaseIframe {
|
|
|
11
11
|
super(args);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
bindEventListeners({close = () => {}, loader} = {}) {
|
|
14
|
+
bindEventListeners({ close = () => {}, loader } = {}) {
|
|
15
15
|
dispatchRebillyInsturmentEventHandler(this);
|
|
16
16
|
resizeComponentHandler(this);
|
|
17
17
|
changeIframeSrcHandler(this);
|
|
18
|
-
this.component.on(`${this.name}-close`, (...args) => {
|
|
19
|
-
close(...args)
|
|
20
|
-
});
|
|
21
18
|
stopLoaderHandler(this, {
|
|
22
19
|
loader,
|
|
23
20
|
section: 'modal',
|
|
24
21
|
id: 'modal-content'
|
|
25
|
-
})
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
window.addEventListener('message', async (event) => {
|
|
25
|
+
if(event.data === 'rebilly-instruments-approval-url-close') {
|
|
26
|
+
if (this.state.options.transactionType === 'purchase') {
|
|
27
|
+
this.state.storefront.setSessionToken(this.state.data.token);
|
|
28
|
+
|
|
29
|
+
const [
|
|
30
|
+
{fields: transaction},
|
|
31
|
+
{fields: invoice}
|
|
32
|
+
] = await Promise.all([
|
|
33
|
+
this.state.storefront.transactions.get({id: this.state.data.transaction.id}),
|
|
34
|
+
this.state.data.invoice?.id
|
|
35
|
+
? this.state.storefront.invoices.get({id: this.state.data.invoice.id})
|
|
36
|
+
: {fields: null}
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const updatedPurchase = {
|
|
40
|
+
orderId: this.state.data.orderId,
|
|
41
|
+
token: this.state.data.token,
|
|
42
|
+
transaction,
|
|
43
|
+
};
|
|
44
|
+
if (invoice) {
|
|
45
|
+
updatedPurchase.invoice = invoice;
|
|
46
|
+
}
|
|
47
|
+
close(updatedPurchase);
|
|
48
|
+
} else if (this.state.options.transactionType === 'setup') {
|
|
49
|
+
this.state.storefront.setSessionToken(this.state.data.instrument.token);
|
|
50
|
+
const {
|
|
51
|
+
fields: transaction
|
|
52
|
+
} = await this.state.storefront.transactions.get({id: this.state.data.transaction.id});
|
|
53
|
+
close({
|
|
54
|
+
transaction,
|
|
55
|
+
instrument: this.state.data.instrument
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
close();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, false);
|
|
26
62
|
}
|
|
27
|
-
}
|
|
63
|
+
}
|
|
@@ -10,11 +10,9 @@ export class ViewIframe extends BaseIframe {
|
|
|
10
10
|
super(args);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
bindEventListeners({
|
|
14
|
-
loader,
|
|
15
|
-
} = {}) {
|
|
13
|
+
bindEventListeners({ loader } = {}) {
|
|
16
14
|
dispatchRebillyInsturmentEventHandler(this);
|
|
17
15
|
resizeComponentHandler(this);
|
|
18
|
-
stopLoaderHandler(this, {loader});
|
|
16
|
+
stopLoaderHandler(this, { loader });
|
|
19
17
|
}
|
|
20
|
-
}
|
|
18
|
+
}
|