@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
|
@@ -22,8 +22,6 @@ function processPropertyAsDOMElement({
|
|
|
22
22
|
throw new Error('processPropertyDOMElement: Missing argument "prop"');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
;
|
|
26
|
-
|
|
27
25
|
if ((0, _hasValidCssSelector.default)(prop)) {
|
|
28
26
|
DOMElement = document.querySelector(prop);
|
|
29
27
|
} else if ((0, _isDomElement.default)(prop)) {
|
|
@@ -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
|
`;
|
|
@@ -5,12 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _popostmate = _interopRequireDefault(require("popostmate"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
12
|
class BaseIframe {
|
|
13
13
|
constructor({
|
|
14
|
+
state = {},
|
|
14
15
|
name = '',
|
|
15
16
|
url = '',
|
|
16
17
|
model = {},
|
|
@@ -23,6 +24,7 @@ class BaseIframe {
|
|
|
23
24
|
classListArray.push('rebilly-instruments-iframe');
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
this.state = state;
|
|
26
28
|
this.container = container;
|
|
27
29
|
this.classListArray = classListArray;
|
|
28
30
|
this.name = name;
|
|
@@ -35,8 +37,14 @@ class BaseIframe {
|
|
|
35
37
|
})();
|
|
36
38
|
}
|
|
37
39
|
|
|
40
|
+
async destroy() {
|
|
41
|
+
if (this.component.frame.parentNode) {
|
|
42
|
+
await this.component.destroy();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
async createComponent() {
|
|
39
|
-
const component = await new
|
|
47
|
+
const component = await new _popostmate.default({
|
|
40
48
|
name: this.name,
|
|
41
49
|
url: this.url,
|
|
42
50
|
container: this.container,
|
|
@@ -23,14 +23,55 @@ class ModalIframe extends _baseIframe.default {
|
|
|
23
23
|
(0, _eventListeners.dispatchRebillyInsturmentEventHandler)(this);
|
|
24
24
|
(0, _eventListeners.resizeComponentHandler)(this);
|
|
25
25
|
(0, _eventListeners.changeIframeSrcHandler)(this);
|
|
26
|
-
this.component.on(`${this.name}-close`, (...args) => {
|
|
27
|
-
close(...args);
|
|
28
|
-
});
|
|
29
26
|
(0, _eventListeners.stopLoaderHandler)(this, {
|
|
30
27
|
loader,
|
|
31
28
|
section: 'modal',
|
|
32
29
|
id: 'modal-content'
|
|
33
30
|
});
|
|
31
|
+
window.addEventListener('message', async event => {
|
|
32
|
+
if (event.data === 'rebilly-instruments-approval-url-close') {
|
|
33
|
+
if (this.state.options.transactionType === 'purchase') {
|
|
34
|
+
var _this$state$data$invo;
|
|
35
|
+
|
|
36
|
+
this.state.storefront.setSessionToken(this.state.data.token);
|
|
37
|
+
const [{
|
|
38
|
+
fields: transaction
|
|
39
|
+
}, {
|
|
40
|
+
fields: invoice
|
|
41
|
+
}] = await Promise.all([this.state.storefront.transactions.get({
|
|
42
|
+
id: this.state.data.transaction.id
|
|
43
|
+
}), (_this$state$data$invo = this.state.data.invoice) !== null && _this$state$data$invo !== void 0 && _this$state$data$invo.id ? this.state.storefront.invoices.get({
|
|
44
|
+
id: this.state.data.invoice.id
|
|
45
|
+
}) : {
|
|
46
|
+
fields: null
|
|
47
|
+
}]);
|
|
48
|
+
const updatedPurchase = {
|
|
49
|
+
orderId: this.state.data.orderId,
|
|
50
|
+
token: this.state.data.token,
|
|
51
|
+
transaction
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (invoice) {
|
|
55
|
+
updatedPurchase.invoice = invoice;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
close(updatedPurchase);
|
|
59
|
+
} else if (this.state.options.transactionType === 'setup') {
|
|
60
|
+
this.state.storefront.setSessionToken(this.state.data.instrument.token);
|
|
61
|
+
const {
|
|
62
|
+
fields: transaction
|
|
63
|
+
} = await this.state.storefront.transactions.get({
|
|
64
|
+
id: this.state.data.transaction.id
|
|
65
|
+
});
|
|
66
|
+
close({
|
|
67
|
+
transaction,
|
|
68
|
+
instrument: this.state.data.instrument
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
close();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, false);
|
|
34
75
|
}
|
|
35
76
|
|
|
36
77
|
}
|
|
@@ -3,36 +3,46 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.mountConfirmation = mountConfirmation;
|
|
7
7
|
exports.baseConfirmationHTML = void 0;
|
|
8
8
|
|
|
9
|
+
var _purchase = require("../functions/purchase");
|
|
10
|
+
|
|
11
|
+
var _setup = require("../functions/setup");
|
|
12
|
+
|
|
9
13
|
var _iframe = require("./common/iframe");
|
|
10
14
|
|
|
11
15
|
var _renderUtilities = require("./common/render-utilities");
|
|
12
16
|
|
|
17
|
+
var _methodSelector = require("./method-selector");
|
|
18
|
+
|
|
19
|
+
var _summary = require("./summary");
|
|
20
|
+
|
|
13
21
|
const baseConfirmationHTML = '<div class="rebilly-instruments-confirmation"></div>';
|
|
14
22
|
exports.baseConfirmationHTML = baseConfirmationHTML;
|
|
15
23
|
|
|
16
|
-
async function
|
|
17
|
-
instrument,
|
|
18
|
-
|
|
24
|
+
async function mountConfirmation({
|
|
25
|
+
payload: instrument,
|
|
26
|
+
state
|
|
19
27
|
}) {
|
|
20
|
-
if (instrument.billingAddress &&
|
|
21
|
-
|
|
28
|
+
if (instrument.billingAddress && state.summary && state.data.isPurchase) {
|
|
29
|
+
(0, _summary.updateSummary)({
|
|
30
|
+
state,
|
|
31
|
+
instrument
|
|
32
|
+
});
|
|
22
33
|
}
|
|
23
34
|
|
|
24
|
-
(0, _renderUtilities.replaceContent)(
|
|
25
|
-
|
|
35
|
+
(0, _renderUtilities.replaceContent)(state.form, baseConfirmationHTML);
|
|
36
|
+
state.loader.startLoading({
|
|
26
37
|
id: 'confirmation'
|
|
27
38
|
});
|
|
28
39
|
const container = document.querySelector('.rebilly-instruments-confirmation');
|
|
29
40
|
const {
|
|
30
41
|
paymentMethodsUrl
|
|
31
|
-
} =
|
|
42
|
+
} = state.options._computed;
|
|
32
43
|
const model = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
mainStyle,
|
|
44
|
+
options: state.options,
|
|
45
|
+
mainStyle: state.mainStyle,
|
|
36
46
|
instrument
|
|
37
47
|
};
|
|
38
48
|
const name = 'rebilly-instruments-confirmation';
|
|
@@ -43,26 +53,40 @@ async function MountConfirmation({
|
|
|
43
53
|
model
|
|
44
54
|
});
|
|
45
55
|
iframe.bindEventListeners({
|
|
46
|
-
loader:
|
|
56
|
+
loader: state.loader
|
|
47
57
|
});
|
|
48
58
|
iframe.component.on(`${name}-confirm-purchase`, confirmedInstrument => {
|
|
49
|
-
|
|
59
|
+
(0, _purchase.purchase)({
|
|
60
|
+
state,
|
|
61
|
+
payload: confirmedInstrument
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
iframe.component.on(`${name}-confirm-setup`, confirmedInstrument => {
|
|
65
|
+
(0, _setup.setup)({
|
|
66
|
+
state,
|
|
67
|
+
payload: confirmedInstrument
|
|
68
|
+
});
|
|
50
69
|
});
|
|
51
70
|
iframe.component.on('choose-another-method', () => {
|
|
52
|
-
|
|
71
|
+
state.iframeComponents = state.iframeComponents.filter(item => {
|
|
53
72
|
if (item.name === iframe.name) {
|
|
54
|
-
item.
|
|
73
|
+
item.destroy();
|
|
55
74
|
return false;
|
|
56
75
|
}
|
|
57
76
|
|
|
58
77
|
return true;
|
|
59
78
|
});
|
|
60
79
|
|
|
61
|
-
|
|
80
|
+
if (state.data.isPurchase) {
|
|
81
|
+
(0, _summary.updateSummary)({
|
|
82
|
+
state
|
|
83
|
+
});
|
|
84
|
+
}
|
|
62
85
|
|
|
63
|
-
|
|
64
|
-
|
|
86
|
+
(0, _methodSelector.updateMethodSelector)({
|
|
87
|
+
state,
|
|
88
|
+
mainStyle: state.mainStyle
|
|
65
89
|
});
|
|
66
90
|
});
|
|
67
|
-
|
|
91
|
+
state.iframeComponents.push(iframe);
|
|
68
92
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = mountApplePay;
|
|
7
|
+
|
|
8
|
+
var _events = _interopRequireDefault(require("../../../events"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const browserIsSafari = () => window.ApplePaySession;
|
|
13
|
+
|
|
14
|
+
function mountApplePay({
|
|
15
|
+
state,
|
|
16
|
+
METHOD_ID,
|
|
17
|
+
METHOD_TYPE,
|
|
18
|
+
EXPRESS_METHODS,
|
|
19
|
+
EXPRESS_METHODS_CONTAINER
|
|
20
|
+
}) {
|
|
21
|
+
const container = document.querySelector(`.rebilly-instruments-${METHOD_ID}-method`);
|
|
22
|
+
const digitalWallet = state.options.digitalWallet.applePay;
|
|
23
|
+
|
|
24
|
+
function mountApplePayButton() {
|
|
25
|
+
if (!container.children.length) {
|
|
26
|
+
Rebilly.applePay.mount(`.rebilly-instruments-${METHOD_ID}-method`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
state.loader.stopLoading({
|
|
30
|
+
id: `${METHOD_TYPE}-express`
|
|
31
|
+
});
|
|
32
|
+
} // Hack: The correct way to do this is to accept the options via the framepay package
|
|
33
|
+
// Will remove once these options are added to framepay
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function updateBtnStyling() {
|
|
37
|
+
const applePayButton = document.querySelector('#rebilly-apple-pay-button');
|
|
38
|
+
applePayButton.style.margin = '0px';
|
|
39
|
+
applePayButton.style.width = '100%';
|
|
40
|
+
applePayButton.style.height = digitalWallet.applePayDisplayOptions.buttonHeight;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!browserIsSafari()) {
|
|
44
|
+
if (EXPRESS_METHODS.length === 1) {
|
|
45
|
+
EXPRESS_METHODS_CONTAINER.parentNode.style.display = 'none';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
state.loader.stopLoading({
|
|
49
|
+
id: `${METHOD_TYPE}-express`
|
|
50
|
+
});
|
|
51
|
+
container.style.display = 'none';
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
container.style.height = digitalWallet.applePayDisplayOptions.buttonHeight;
|
|
56
|
+
|
|
57
|
+
if (!Rebilly.initialized) {
|
|
58
|
+
Rebilly.initialize({
|
|
59
|
+
publishableKey: state.options.publishableKey,
|
|
60
|
+
organizationId: state.options.organizationId,
|
|
61
|
+
digitalWallet
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
mountApplePayButton();
|
|
65
|
+
updateBtnStyling();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Rebilly.on('ready', () => {
|
|
69
|
+
mountApplePayButton();
|
|
70
|
+
updateBtnStyling();
|
|
71
|
+
});
|
|
72
|
+
Rebilly.on('token-ready', token => {
|
|
73
|
+
const instrumentReadyPayload = {
|
|
74
|
+
websiteId: state.options.websiteId,
|
|
75
|
+
items: state.options.items,
|
|
76
|
+
paymentInstruction: {
|
|
77
|
+
token: token.id
|
|
78
|
+
},
|
|
79
|
+
billingAddress: token.billingAddress,
|
|
80
|
+
_raw: token
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (!token.shippingAddress) {
|
|
84
|
+
instrumentReadyPayload.deliveryAddress = token.shippingAddress;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_events.default.instrumentReady.dispatch(instrumentReadyPayload);
|
|
88
|
+
});
|
|
89
|
+
Rebilly.on('error', error => {
|
|
90
|
+
console.error(error);
|
|
91
|
+
});
|
|
92
|
+
}
|