@rebilly/instruments 2.0.0-beta → 3.0.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/dist/events/index.js +2 -1
- package/dist/functions/mount/fetch-data.js +187 -0
- package/dist/functions/mount/fetch-data.spec.js +189 -0
- package/dist/functions/mount/index.js +132 -164
- package/dist/functions/mount/mount.spec.js +2 -4
- package/dist/functions/mount/setup-element.js +40 -0
- package/dist/functions/mount/setup-framepay-theme.js +95 -0
- package/dist/functions/mount/setup-framepay.js +5 -1
- package/dist/functions/mount/setup-i18n.js +33 -0
- package/dist/functions/mount/setup-options.js +68 -47
- package/dist/functions/mount/setup-options.spec.js +66 -0
- package/dist/functions/mount/setup-storefront.js +6 -4
- package/dist/functions/mount/setup-styles.js +4 -2
- package/dist/functions/purchase.js +129 -24
- package/dist/functions/purchase.spec.js +13 -10
- package/dist/functions/setup.js +85 -0
- package/dist/functions/setup.spec.js +87 -0
- package/dist/functions/show.js +8 -4
- package/dist/functions/show.spec.js +9 -5
- package/dist/functions/update.js +39 -24
- package/dist/functions/update.spec.js +0 -4
- package/dist/i18n/en.json +5 -2
- package/dist/i18n/es.json +4 -1
- package/dist/index.js +17 -3
- package/dist/index.spec.js +3 -16
- 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 +10 -18
- package/dist/storefront/plans.spec.js +3 -13
- package/dist/storefront/products.js +10 -13
- package/dist/storefront/products.spec.js +12 -19
- package/dist/storefront/purchase.js +23 -12
- package/dist/storefront/purchase.spec.js +1 -20
- package/dist/storefront/ready-to-pay.js +18 -15
- package/dist/storefront/ready-to-pay.spec.js +2 -12
- package/dist/storefront/summary.js +21 -17
- package/dist/storefront/summary.spec.js +4 -15
- package/dist/storefront/transactions.js +27 -0
- package/dist/style/base/__snapshots__/theme.spec.js.snap +188 -45
- package/dist/style/base/default-theme.js +699 -0
- package/dist/style/base/index.js +48 -16
- package/dist/style/base/theme.js +16 -48
- package/dist/style/base/theme.spec.js +4 -15
- package/dist/style/components/address.js +3 -3
- package/dist/style/components/button.js +32 -22
- package/dist/style/components/divider.js +9 -9
- package/dist/style/components/forms/checkbox.js +12 -9
- package/dist/style/components/forms/field.js +18 -6
- package/dist/style/components/forms/form.js +2 -2
- package/dist/style/components/forms/input.js +54 -13
- package/dist/style/components/forms/label.js +39 -18
- package/dist/style/components/forms/select.js +54 -22
- package/dist/style/components/forms/validation.js +53 -6
- package/dist/style/components/icons.js +4 -4
- package/dist/style/components/loader.js +5 -3
- package/dist/style/components/methods.js +18 -15
- package/dist/style/components/overlay.js +5 -5
- package/dist/style/helpers/index.js +46 -46
- package/dist/style/index.js +3 -1
- package/dist/style/payment-instruments/payment-card.js +4 -4
- package/dist/style/utils/border.js +47 -0
- package/dist/style/utils/color-values.js +39 -3
- package/dist/style/utils/remove-empty-null.js +20 -0
- package/dist/style/vendor/framepay.js +11 -8
- package/dist/style/vendor/postmate.js +2 -2
- package/dist/style/views/confirmation.js +13 -13
- package/dist/style/views/method-selector.js +2 -2
- package/dist/style/views/modal.js +6 -6
- package/dist/style/views/result.js +4 -4
- package/dist/style/views/summary.js +26 -22
- package/dist/views/__snapshots__/summary.spec.js.snap +77 -119
- package/dist/views/common/iframe/base-iframe.js +2 -0
- package/dist/views/common/iframe/modal-iframe.js +50 -4
- package/dist/views/confirmation.js +19 -8
- package/dist/views/method-selector/generate-digital-wallet.js +12 -3
- package/dist/views/method-selector/generate-digital-wallet.spec.js +11 -0
- package/dist/views/method-selector/get-payment-methods.js +13 -2
- package/dist/views/method-selector/get-payment-methods.spec.js +21 -19
- package/dist/views/method-selector/index.js +23 -34
- package/dist/views/method-selector/method-selector.spec.js +50 -55
- package/dist/views/method-selector/mount-methods.js +5 -8
- package/dist/views/modal.js +8 -2
- package/dist/views/result.js +3 -4
- package/dist/views/summary.js +156 -97
- package/dist/views/summary.spec.js +53 -58
- package/package.json +4 -2
- package/src/events/index.js +2 -1
- package/src/functions/mount/fetch-data.js +152 -0
- package/src/functions/mount/fetch-data.spec.js +238 -0
- package/src/functions/mount/index.js +101 -158
- package/src/functions/mount/mount.spec.js +3 -5
- package/src/functions/mount/setup-element.js +26 -0
- package/src/functions/mount/setup-framepay-theme.js +82 -0
- package/src/functions/mount/setup-framepay.js +5 -1
- package/src/functions/mount/setup-i18n.js +19 -0
- package/src/functions/mount/setup-options.js +78 -48
- package/src/functions/mount/setup-options.spec.js +60 -0
- package/src/functions/mount/setup-storefront.js +6 -4
- package/src/functions/mount/setup-styles.js +4 -2
- package/src/functions/on.spec.js +1 -1
- package/src/functions/purchase.js +99 -23
- package/src/functions/purchase.spec.js +10 -10
- package/src/functions/setup.js +48 -0
- package/src/functions/setup.spec.js +98 -0
- package/src/functions/show.js +2 -4
- package/src/functions/show.spec.js +3 -4
- package/src/functions/update.js +40 -25
- package/src/functions/update.spec.js +0 -4
- package/src/i18n/en.json +5 -2
- package/src/i18n/es.json +4 -1
- package/src/index.js +9 -3
- package/src/index.spec.js +3 -21
- package/src/loader/index.js +3 -3
- package/src/storefront/index.js +28 -0
- 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/summary-model.js +12 -19
- 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 +6 -17
- package/src/storefront/plans.spec.js +4 -11
- package/src/storefront/products.js +8 -16
- package/src/storefront/products.spec.js +16 -22
- package/src/storefront/purchase.js +14 -16
- package/src/storefront/purchase.spec.js +2 -14
- package/src/storefront/ready-to-pay.js +13 -16
- package/src/storefront/ready-to-pay.spec.js +3 -10
- package/src/storefront/summary.js +19 -17
- package/src/storefront/summary.spec.js +5 -12
- package/src/storefront/transactions.js +11 -0
- package/src/style/base/__snapshots__/theme.spec.js.snap +188 -45
- package/src/style/base/default-theme.js +674 -0
- package/src/style/base/index.js +48 -16
- package/src/style/base/theme.js +17 -47
- package/src/style/base/theme.spec.js +4 -16
- package/src/style/components/address.js +3 -3
- package/src/style/components/button.js +32 -24
- package/src/style/components/divider.js +9 -9
- package/src/style/components/forms/checkbox.js +11 -11
- package/src/style/components/forms/field.js +18 -6
- package/src/style/components/forms/form.js +2 -2
- package/src/style/components/forms/input.js +54 -13
- package/src/style/components/forms/label.js +39 -18
- package/src/style/components/forms/select.js +54 -22
- package/src/style/components/forms/validation.js +53 -6
- package/src/style/components/icons.js +4 -4
- package/src/style/components/loader.js +4 -5
- package/src/style/components/methods.js +18 -15
- package/src/style/components/overlay.js +5 -5
- package/src/style/helpers/index.js +46 -46
- package/src/style/index.js +2 -1
- package/src/style/payment-instruments/payment-card.js +4 -4
- package/src/style/utils/border.js +34 -0
- package/src/style/utils/color-values.js +27 -1
- package/src/style/utils/remove-empty-null.js +10 -0
- package/src/style/vendor/framepay.js +11 -8
- package/src/style/vendor/postmate.js +2 -2
- package/src/style/views/confirmation.js +13 -13
- package/src/style/views/method-selector.js +2 -2
- package/src/style/views/modal.js +6 -6
- package/src/style/views/result.js +4 -4
- package/src/style/views/summary.js +26 -22
- package/src/views/__snapshots__/summary.spec.js.snap +77 -119
- package/src/views/common/iframe/base-iframe.js +2 -0
- package/src/views/common/iframe/modal-iframe.js +45 -3
- package/src/views/confirmation.js +15 -5
- package/src/views/method-selector/generate-digital-wallet.js +10 -3
- package/src/views/method-selector/generate-digital-wallet.spec.js +10 -0
- package/src/views/method-selector/get-payment-methods.js +7 -2
- package/src/views/method-selector/get-payment-methods.spec.js +26 -23
- package/src/views/method-selector/index.js +21 -28
- package/src/views/method-selector/method-selector.spec.js +49 -64
- package/src/views/method-selector/mount-methods.js +5 -8
- package/src/views/modal.js +6 -2
- package/src/views/result.js +4 -3
- package/src/views/summary.js +161 -117
- package/src/views/summary.spec.js +60 -75
- package/tests/mocks/rebilly-instruments-mock.js +37 -7
- package/tests/mocks/storefront-api-mock.js +8 -0
- package/tests/mocks/storefront-mock.js +17 -0
- package/dist/functions/mount/fetch-summary-data.js +0 -46
- package/dist/functions/mount/fetch-summary-data.spec.js +0 -43
- package/src/functions/mount/fetch-summary-data.js +0 -29
- package/src/functions/mount/fetch-summary-data.spec.js +0 -40
|
@@ -5,146 +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
|
+
My Awesome Product
|
|
24
|
+
</p>
|
|
23
25
|
|
|
26
|
+
|
|
24
27
|
|
|
25
|
-
|
|
26
28
|
<p
|
|
27
29
|
class="rebilly-instruments-summary-line-item-synopsis-description"
|
|
28
30
|
>
|
|
29
31
|
My Awesome Product
|
|
30
32
|
</p>
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
|
|
34
36
|
</div>
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
|
|
37
39
|
<div
|
|
38
40
|
class="rebilly-instruments-summary-line-item-price-breakdown"
|
|
39
41
|
>
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
|
|
42
44
|
<p
|
|
43
45
|
class="rebilly-instruments-summary-line-item-price-breakdown-quantity"
|
|
44
46
|
>
|
|
45
47
|
1
|
|
46
48
|
</p>
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
|
|
49
51
|
<svg
|
|
50
52
|
class="rebilly-instruments-icon"
|
|
51
53
|
viewBox="0 0 24 24"
|
|
52
54
|
xmlns="http://www.w3.org/2000/svg"
|
|
53
55
|
>
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
|
|
56
58
|
<path
|
|
57
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"
|
|
58
60
|
fill-rule="nonzero"
|
|
59
61
|
/>
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
|
|
62
64
|
</svg>
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
|
|
65
67
|
<p
|
|
66
68
|
class="rebilly-instruments-summary-line-item-price-breakdown-unit-price"
|
|
67
69
|
>
|
|
68
70
|
$30.00
|
|
69
71
|
</p>
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
|
|
72
74
|
</div>
|
|
73
75
|
|
|
74
|
-
|
|
76
|
+
|
|
75
77
|
</div>
|
|
76
78
|
|
|
79
|
+
|
|
80
|
+
|
|
77
81
|
|
|
78
|
-
|
|
79
82
|
<div
|
|
80
83
|
class="rebilly-instruments-summary-line-item"
|
|
81
84
|
>
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
|
|
87
|
+
|
|
85
88
|
<div
|
|
86
89
|
class="rebilly-instruments-summary-line-item-synopsis"
|
|
87
90
|
>
|
|
88
91
|
|
|
89
|
-
|
|
92
|
+
|
|
90
93
|
<p
|
|
91
94
|
class="rebilly-instruments-summary-line-item-synopsis-title"
|
|
92
|
-
|
|
95
|
+
>
|
|
96
|
+
My Awesome T-Shirt
|
|
97
|
+
</p>
|
|
93
98
|
|
|
99
|
+
|
|
94
100
|
|
|
95
|
-
|
|
96
101
|
<p
|
|
97
102
|
class="rebilly-instruments-summary-line-item-synopsis-description"
|
|
98
103
|
>
|
|
99
104
|
Awesome T-Shirt
|
|
100
105
|
</p>
|
|
101
106
|
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
|
|
108
|
+
|
|
104
109
|
</div>
|
|
105
110
|
|
|
106
|
-
|
|
111
|
+
|
|
107
112
|
<div
|
|
108
113
|
class="rebilly-instruments-summary-line-item-price-breakdown"
|
|
109
114
|
>
|
|
110
115
|
|
|
111
|
-
|
|
116
|
+
|
|
112
117
|
<p
|
|
113
118
|
class="rebilly-instruments-summary-line-item-price-breakdown-quantity"
|
|
114
119
|
>
|
|
115
120
|
2
|
|
116
121
|
</p>
|
|
117
122
|
|
|
118
|
-
|
|
123
|
+
|
|
119
124
|
<svg
|
|
120
125
|
class="rebilly-instruments-icon"
|
|
121
126
|
viewBox="0 0 24 24"
|
|
122
127
|
xmlns="http://www.w3.org/2000/svg"
|
|
123
128
|
>
|
|
124
129
|
|
|
125
|
-
|
|
130
|
+
|
|
126
131
|
<path
|
|
127
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"
|
|
128
133
|
fill-rule="nonzero"
|
|
129
134
|
/>
|
|
130
135
|
|
|
131
|
-
|
|
136
|
+
|
|
132
137
|
</svg>
|
|
133
138
|
|
|
134
|
-
|
|
139
|
+
|
|
135
140
|
<p
|
|
136
141
|
class="rebilly-instruments-summary-line-item-price-breakdown-unit-price"
|
|
137
142
|
>
|
|
138
143
|
$20.00
|
|
139
144
|
</p>
|
|
140
145
|
|
|
141
|
-
|
|
146
|
+
|
|
142
147
|
</div>
|
|
143
148
|
|
|
144
|
-
|
|
149
|
+
|
|
145
150
|
</div>
|
|
146
151
|
|
|
147
|
-
|
|
152
|
+
|
|
148
153
|
</div>
|
|
149
154
|
`;
|
|
150
155
|
|
|
@@ -152,137 +157,90 @@ exports[`Summary component should render the summary correctly 2`] = `
|
|
|
152
157
|
<div
|
|
153
158
|
class="rebilly-instruments-summary-breakdown"
|
|
154
159
|
>
|
|
155
|
-
|
|
156
|
-
|
|
157
160
|
<table>
|
|
158
161
|
|
|
159
|
-
|
|
162
|
+
|
|
160
163
|
<colgroup>
|
|
161
164
|
|
|
162
|
-
|
|
165
|
+
|
|
163
166
|
<col />
|
|
164
167
|
|
|
165
|
-
|
|
168
|
+
|
|
166
169
|
<col />
|
|
167
170
|
|
|
168
|
-
|
|
171
|
+
|
|
169
172
|
</colgroup>
|
|
170
173
|
|
|
171
174
|
|
|
172
|
-
<
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
>
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
<td
|
|
179
|
-
data-rebilly-i18n="summary.subTotal"
|
|
180
|
-
>
|
|
181
|
-
Sub Total
|
|
182
|
-
</td>
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
<td>
|
|
186
|
-
$70.00
|
|
187
|
-
</td>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
</tr>
|
|
191
|
-
|
|
175
|
+
<tr
|
|
176
|
+
class="rebilly-instruments-summary-breakdown-sub-total"
|
|
177
|
+
>
|
|
192
178
|
|
|
193
|
-
<tr
|
|
194
|
-
class="rebilly-instruments-summary-breakdown-discounts"
|
|
195
|
-
>
|
|
196
179
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
data-rebilly-i18n="summary.discounts"
|
|
200
|
-
>
|
|
201
|
-
Discounts
|
|
202
|
-
</td>
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
<td>
|
|
206
|
-
$0.00
|
|
207
|
-
</td>
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
</tr>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
<tr
|
|
214
|
-
class="rebilly-instruments-summary-breakdown-taxes"
|
|
180
|
+
<td
|
|
181
|
+
data-rebilly-i18n="summary.subTotal"
|
|
215
182
|
>
|
|
183
|
+
Sub Total
|
|
184
|
+
</td>
|
|
185
|
+
|
|
216
186
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
>
|
|
221
|
-
Taxes
|
|
222
|
-
</td>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
<td>
|
|
226
|
-
$0.00
|
|
227
|
-
</td>
|
|
228
|
-
|
|
187
|
+
<td>
|
|
188
|
+
$70.00
|
|
189
|
+
</td>
|
|
229
190
|
|
|
230
|
-
</tr>
|
|
231
191
|
|
|
192
|
+
</tr>
|
|
193
|
+
<tr
|
|
194
|
+
class="rebilly-instruments-summary-breakdown-taxes"
|
|
195
|
+
>
|
|
232
196
|
|
|
233
|
-
<tr
|
|
234
|
-
class="rebilly-instruments-summary-breakdown-taxes"
|
|
235
|
-
>
|
|
236
|
-
|
|
237
197
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
<td>
|
|
246
|
-
$0.00
|
|
247
|
-
</td>
|
|
198
|
+
<td
|
|
199
|
+
data-rebilly-i18n="summary.taxes"
|
|
200
|
+
>
|
|
201
|
+
Taxes
|
|
202
|
+
</td>
|
|
203
|
+
|
|
248
204
|
|
|
205
|
+
<td>
|
|
206
|
+
$0.00
|
|
207
|
+
</td>
|
|
249
208
|
|
|
250
|
-
</tr>
|
|
251
209
|
|
|
252
|
-
|
|
253
|
-
</tbody>
|
|
210
|
+
</tr>
|
|
254
211
|
</table>
|
|
255
|
-
|
|
256
|
-
|
|
257
212
|
<div
|
|
258
213
|
class="rebilly-instruments-summary-breakdown-total"
|
|
259
214
|
>
|
|
260
215
|
|
|
261
|
-
|
|
216
|
+
|
|
262
217
|
<p
|
|
263
218
|
data-rebilly-i18n="summary.total"
|
|
264
219
|
>
|
|
265
220
|
Total
|
|
266
221
|
</p>
|
|
267
222
|
|
|
268
|
-
|
|
223
|
+
|
|
269
224
|
<p
|
|
270
225
|
class="rebilly-instruments-summary-breakdown-total-amount"
|
|
271
226
|
>
|
|
272
227
|
|
|
273
|
-
|
|
228
|
+
|
|
274
229
|
<span
|
|
275
230
|
class="rebilly-instruments-summary-breakdown-total-amount-currency"
|
|
276
231
|
>
|
|
232
|
+
|
|
277
233
|
USD
|
|
234
|
+
|
|
278
235
|
</span>
|
|
236
|
+
|
|
279
237
|
$70.00
|
|
238
|
+
|
|
239
|
+
</p>
|
|
240
|
+
<p>
|
|
280
241
|
|
|
242
|
+
|
|
281
243
|
</p>
|
|
282
|
-
|
|
283
|
-
|
|
284
244
|
</div>
|
|
285
|
-
|
|
286
|
-
|
|
287
245
|
</div>
|
|
288
246
|
`;
|
|
@@ -11,6 +11,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
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;
|
|
@@ -23,14 +23,60 @@ 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
|
+
}); // Close modal via postmate
|
|
31
|
+
|
|
32
|
+
this.component.on(`${this.name}-close`, (...args) => {
|
|
33
|
+
close(...args);
|
|
34
|
+
}); // Close modal via postMessage (specifically during approal url flow)
|
|
35
|
+
|
|
36
|
+
window.addEventListener('message', async event => {
|
|
37
|
+
if (event.data === 'rebilly-instruments-approval-url-close') {
|
|
38
|
+
if (this.state.options.transactionType === 'purchase') {
|
|
39
|
+
var _this$state$data$invo;
|
|
40
|
+
|
|
41
|
+
this.state.storefront.setSessionToken(this.state.data.token);
|
|
42
|
+
const [{
|
|
43
|
+
fields: transaction
|
|
44
|
+
}, {
|
|
45
|
+
fields: invoice
|
|
46
|
+
}] = await Promise.all([this.state.storefront.transactions.get({
|
|
47
|
+
id: this.state.data.transaction.id
|
|
48
|
+
}), (_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({
|
|
49
|
+
id: this.state.data.invoice.id
|
|
50
|
+
}) : {
|
|
51
|
+
fields: null
|
|
52
|
+
}]);
|
|
53
|
+
const updatedPurchase = {
|
|
54
|
+
orderId: this.state.data.orderId,
|
|
55
|
+
token: this.state.data.token,
|
|
56
|
+
transaction
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
if (invoice) {
|
|
60
|
+
updatedPurchase.invoice = invoice;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
close(updatedPurchase);
|
|
64
|
+
} else if (this.state.options.transactionType === 'setup') {
|
|
65
|
+
this.state.storefront.setSessionToken(this.state.data.instrument.token);
|
|
66
|
+
const {
|
|
67
|
+
fields: transaction
|
|
68
|
+
} = await this.state.storefront.transactions.get({
|
|
69
|
+
id: this.state.data.transaction.id
|
|
70
|
+
});
|
|
71
|
+
close({
|
|
72
|
+
transaction,
|
|
73
|
+
instrument: this.state.data.instrument
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
close();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, false);
|
|
34
80
|
}
|
|
35
81
|
|
|
36
82
|
}
|
|
@@ -8,6 +8,8 @@ exports.baseConfirmationHTML = void 0;
|
|
|
8
8
|
|
|
9
9
|
var _purchase = require("../functions/purchase");
|
|
10
10
|
|
|
11
|
+
var _setup = require("../functions/setup");
|
|
12
|
+
|
|
11
13
|
var _iframe = require("./common/iframe");
|
|
12
14
|
|
|
13
15
|
var _renderUtilities = require("./common/render-utilities");
|
|
@@ -20,11 +22,10 @@ const baseConfirmationHTML = '<div class="rebilly-instruments-confirmation"></di
|
|
|
20
22
|
exports.baseConfirmationHTML = baseConfirmationHTML;
|
|
21
23
|
|
|
22
24
|
async function mountConfirmation({
|
|
23
|
-
instrument,
|
|
24
|
-
mainStyle,
|
|
25
|
+
payload: instrument,
|
|
25
26
|
state
|
|
26
27
|
}) {
|
|
27
|
-
if (instrument.billingAddress && state.summary) {
|
|
28
|
+
if (instrument.billingAddress && state.summary && state.data.isPurchase) {
|
|
28
29
|
(0, _summary.updateSummary)({
|
|
29
30
|
state,
|
|
30
31
|
instrument
|
|
@@ -41,7 +42,7 @@ async function mountConfirmation({
|
|
|
41
42
|
} = state.options._computed;
|
|
42
43
|
const model = {
|
|
43
44
|
options: state.options,
|
|
44
|
-
mainStyle,
|
|
45
|
+
mainStyle: state.mainStyle,
|
|
45
46
|
instrument
|
|
46
47
|
};
|
|
47
48
|
const name = 'rebilly-instruments-confirmation';
|
|
@@ -60,6 +61,12 @@ async function mountConfirmation({
|
|
|
60
61
|
payload: confirmedInstrument
|
|
61
62
|
});
|
|
62
63
|
});
|
|
64
|
+
iframe.component.on(`${name}-confirm-setup`, confirmedInstrument => {
|
|
65
|
+
(0, _setup.setup)({
|
|
66
|
+
state,
|
|
67
|
+
payload: confirmedInstrument
|
|
68
|
+
});
|
|
69
|
+
});
|
|
63
70
|
iframe.component.on('choose-another-method', () => {
|
|
64
71
|
state.iframeComponents = state.iframeComponents.filter(item => {
|
|
65
72
|
if (item.name === iframe.name) {
|
|
@@ -69,12 +76,16 @@ async function mountConfirmation({
|
|
|
69
76
|
|
|
70
77
|
return true;
|
|
71
78
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
|
|
80
|
+
if (state.data.isPurchase) {
|
|
81
|
+
(0, _summary.updateSummary)({
|
|
82
|
+
state
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
75
86
|
(0, _methodSelector.updateMethodSelector)({
|
|
76
87
|
state,
|
|
77
|
-
mainStyle
|
|
88
|
+
mainStyle: state.mainStyle
|
|
78
89
|
});
|
|
79
90
|
});
|
|
80
91
|
state.iframeComponents.push(iframe);
|
|
@@ -9,19 +9,28 @@ var _getMethodData = require("./get-method-data");
|
|
|
9
9
|
|
|
10
10
|
function generateDigitalWallet({
|
|
11
11
|
state,
|
|
12
|
-
summary,
|
|
13
12
|
EXPRESS_METHODS
|
|
14
13
|
}) {
|
|
14
|
+
var _state$data;
|
|
15
|
+
|
|
15
16
|
const output = {};
|
|
16
17
|
const {
|
|
17
18
|
paymentInstruments
|
|
18
19
|
} = state.options;
|
|
19
20
|
const transactionData = {
|
|
20
|
-
amount: summary.total,
|
|
21
|
-
currency: summary.currency,
|
|
22
21
|
countryCode: state.options.countryCode,
|
|
23
22
|
label: state.options.websiteId
|
|
24
23
|
};
|
|
24
|
+
|
|
25
|
+
if ((_state$data = state.data) !== null && _state$data !== void 0 && _state$data.amountAndCurrency) {
|
|
26
|
+
const {
|
|
27
|
+
amount,
|
|
28
|
+
currency
|
|
29
|
+
} = state.data.amountAndCurrency;
|
|
30
|
+
transactionData.amount = amount;
|
|
31
|
+
transactionData.currency = currency;
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
EXPRESS_METHODS.forEach(method => {
|
|
26
35
|
var _method$feature, _method$feature2;
|
|
27
36
|
|
|
@@ -6,6 +6,8 @@ var _readyToPayModel = _interopRequireDefault(require("../../storefront/models/r
|
|
|
6
6
|
|
|
7
7
|
var _summaryModel = _interopRequireDefault(require("../../storefront/models/summary-model"));
|
|
8
8
|
|
|
9
|
+
var _fetchData = require("../../functions/mount/fetch-data");
|
|
10
|
+
|
|
9
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
12
|
|
|
11
13
|
describe('generateDigitalWallet', () => {
|
|
@@ -14,6 +16,15 @@ describe('generateDigitalWallet', () => {
|
|
|
14
16
|
options = {}
|
|
15
17
|
} = {}) {
|
|
16
18
|
this.options = options;
|
|
19
|
+
this.data = new _fetchData.DataInstance({
|
|
20
|
+
state: {
|
|
21
|
+
options
|
|
22
|
+
},
|
|
23
|
+
previewPurchase: {
|
|
24
|
+
total: 1,
|
|
25
|
+
currency: 'USD'
|
|
26
|
+
}
|
|
27
|
+
});
|
|
17
28
|
}
|
|
18
29
|
|
|
19
30
|
}
|
|
@@ -26,14 +26,13 @@ const isSupportedMethod = ({
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
function getPaymentMethods({
|
|
29
|
-
methods,
|
|
30
29
|
state
|
|
31
30
|
}) {
|
|
32
31
|
const result = {
|
|
33
32
|
EXPRESS_METHODS: [],
|
|
34
33
|
METHODS: []
|
|
35
34
|
};
|
|
36
|
-
|
|
35
|
+
state.data.readyToPay.forEach(method => {
|
|
37
36
|
if (isExpressMethod(method)) {
|
|
38
37
|
const {
|
|
39
38
|
METHOD_TYPE
|
|
@@ -51,5 +50,17 @@ function getPaymentMethods({
|
|
|
51
50
|
result.METHODS.push(method);
|
|
52
51
|
}
|
|
53
52
|
});
|
|
53
|
+
|
|
54
|
+
if (!window.ApplePaySession) {
|
|
55
|
+
result.EXPRESS_METHODS = result.EXPRESS_METHODS.filter(method => {
|
|
56
|
+
var _method$feature;
|
|
57
|
+
|
|
58
|
+
return (method === null || method === void 0 ? void 0 : (_method$feature = method.feature) === null || _method$feature === void 0 ? void 0 : _method$feature.name) !== 'Apple Pay';
|
|
59
|
+
});
|
|
60
|
+
state.loader.stopLoading({
|
|
61
|
+
id: 'applePay-express'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
54
65
|
return result;
|
|
55
66
|
}
|
|
@@ -9,7 +9,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
9
9
|
class TestInstance {
|
|
10
10
|
constructor() {
|
|
11
11
|
this.loader = {
|
|
12
|
-
startLoading: jest.fn()
|
|
12
|
+
startLoading: jest.fn(),
|
|
13
|
+
stopLoading: jest.fn()
|
|
14
|
+
};
|
|
15
|
+
this.data = {
|
|
16
|
+
readyToPay: [new _readyToPayModel.default({
|
|
17
|
+
method: 'payment-card',
|
|
18
|
+
feature: {
|
|
19
|
+
name: 'Google Pay',
|
|
20
|
+
merchantName: 'google-pay-merchant-name',
|
|
21
|
+
merchantOrigin: 'google-pay-merchant-origin'
|
|
22
|
+
},
|
|
23
|
+
brands: ['Visa'],
|
|
24
|
+
filters: []
|
|
25
|
+
}), new _readyToPayModel.default({
|
|
26
|
+
method: 'bitcoin',
|
|
27
|
+
filters: []
|
|
28
|
+
}), new _readyToPayModel.default({
|
|
29
|
+
method: 'payment-card',
|
|
30
|
+
brands: ['Visa'],
|
|
31
|
+
filters: []
|
|
32
|
+
})]
|
|
13
33
|
};
|
|
14
34
|
}
|
|
15
35
|
|
|
@@ -17,25 +37,7 @@ class TestInstance {
|
|
|
17
37
|
|
|
18
38
|
it('should only return the allowed methods', () => {
|
|
19
39
|
const instance = new TestInstance();
|
|
20
|
-
const methods = [new _readyToPayModel.default({
|
|
21
|
-
method: 'payment-card',
|
|
22
|
-
feature: {
|
|
23
|
-
name: 'Google Pay',
|
|
24
|
-
merchantName: 'google-pay-merchant-name',
|
|
25
|
-
merchantOrigin: 'google-pay-merchant-origin'
|
|
26
|
-
},
|
|
27
|
-
brands: ['Visa'],
|
|
28
|
-
filters: []
|
|
29
|
-
}), new _readyToPayModel.default({
|
|
30
|
-
method: 'bitcoin',
|
|
31
|
-
filters: []
|
|
32
|
-
}), new _readyToPayModel.default({
|
|
33
|
-
method: 'payment-card',
|
|
34
|
-
brands: ['Visa'],
|
|
35
|
-
filters: []
|
|
36
|
-
})];
|
|
37
40
|
const results = (0, _getPaymentMethods.getPaymentMethods)({
|
|
38
|
-
methods,
|
|
39
41
|
state: instance
|
|
40
42
|
});
|
|
41
43
|
expect(results.hasOwnProperty('EXPRESS_METHODS')).toEqual(true);
|