@rebilly/instruments 1.0.2-beta.9 → 3.0.0-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 +187 -0
- package/dist/functions/mount/fetch-data.spec.js +189 -0
- package/dist/functions/mount/index.js +164 -251
- package/dist/functions/mount/mount.spec.js +25 -124
- 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 +46 -0
- package/dist/functions/mount/setup-i18n.js +33 -0
- package/dist/functions/mount/setup-options.js +99 -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 +5 -2
- 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/__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 +15 -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 +44 -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 +52 -48
- 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 +37 -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 +3 -3
- package/dist/style/views/modal.js +8 -6
- package/dist/style/views/result.js +4 -4
- package/dist/style/views/summary.js +26 -22
- 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 +72 -118
- package/dist/views/common/iframe/base-iframe.js +10 -2
- package/dist/views/common/iframe/modal-iframe.js +50 -4
- 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 +27 -7
- 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 +18 -12
- package/dist/views/result.js +13 -16
- package/dist/views/summary.js +176 -114
- package/dist/views/summary.spec.js +72 -76
- package/package.json +7 -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 +152 -0
- package/src/functions/mount/fetch-data.spec.js +238 -0
- package/src/functions/mount/index.js +131 -244
- package/src/functions/mount/mount.spec.js +35 -141
- 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 +41 -0
- package/src/functions/mount/setup-i18n.js +19 -0
- package/src/functions/mount/setup-options.js +103 -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 +5 -2
- 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/__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 +20 -48
- package/src/style/base/theme.spec.js +5 -15
- package/src/style/browserslist.js +1 -3
- package/src/style/components/address.js +3 -3
- package/src/style/components/button.js +32 -22
- package/src/style/components/divider.js +9 -9
- package/src/style/components/forms/checkbox.js +11 -9
- 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 +44 -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/index.js +1 -1
- package/src/style/components/loader.js +4 -3
- package/src/style/components/methods.js +52 -48
- package/src/style/components/overlay.js +5 -5
- package/src/style/helpers/index.js +46 -46
- package/src/style/index.js +4 -2
- 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 +30 -4
- package/src/style/utils/remove-empty-null.js +10 -0
- package/src/style/vendor/framepay.js +12 -9
- package/src/style/vendor/postmate.js +3 -3
- package/src/style/views/confirmation.js +13 -13
- package/src/style/views/index.js +1 -1
- package/src/style/views/method-selector.js +3 -3
- package/src/style/views/modal.js +9 -7
- package/src/style/views/result.js +4 -4
- package/src/style/views/summary.js +26 -22
- 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 +72 -118
- 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 +48 -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 -31
- 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 +36 -22
- package/src/views/result.js +12 -15
- package/src/views/summary.js +175 -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
|
@@ -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,90 @@ 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
|
-
|
|
179
|
-
>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
<td
|
|
183
|
-
data-rebilly-i18n="summary.subTotal"
|
|
184
|
-
>
|
|
185
|
-
Sub Total
|
|
186
|
-
</td>
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
<td>
|
|
190
|
-
$70.00
|
|
191
|
-
</td>
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
</tr>
|
|
195
|
-
|
|
175
|
+
<tr
|
|
176
|
+
class="rebilly-instruments-summary-breakdown-sub-total"
|
|
177
|
+
>
|
|
196
178
|
|
|
197
|
-
<tr
|
|
198
|
-
class="rebilly-instruments-summary-breakdown-discounts"
|
|
199
|
-
>
|
|
200
|
-
|
|
201
179
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
>
|
|
205
|
-
Discounts
|
|
206
|
-
</td>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
<td>
|
|
210
|
-
$0.00
|
|
211
|
-
</td>
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
</tr>
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
<tr
|
|
218
|
-
class="rebilly-instruments-summary-breakdown-taxes"
|
|
180
|
+
<td
|
|
181
|
+
data-rebilly-i18n="summary.subTotal"
|
|
219
182
|
>
|
|
183
|
+
Sub Total
|
|
184
|
+
</td>
|
|
185
|
+
|
|
220
186
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
>
|
|
225
|
-
Taxes
|
|
226
|
-
</td>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
<td>
|
|
230
|
-
$0.00
|
|
231
|
-
</td>
|
|
232
|
-
|
|
187
|
+
<td>
|
|
188
|
+
$70.00
|
|
189
|
+
</td>
|
|
233
190
|
|
|
234
|
-
</tr>
|
|
235
191
|
|
|
192
|
+
</tr>
|
|
193
|
+
<tr
|
|
194
|
+
class="rebilly-instruments-summary-breakdown-taxes"
|
|
195
|
+
>
|
|
236
196
|
|
|
237
|
-
<tr
|
|
238
|
-
class="rebilly-instruments-summary-breakdown-taxes"
|
|
239
|
-
>
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
<td
|
|
243
|
-
data-rebilly-i18n="summary.shipping"
|
|
244
|
-
>
|
|
245
|
-
Shipping
|
|
246
|
-
</td>
|
|
247
197
|
|
|
198
|
+
<td
|
|
199
|
+
data-rebilly-i18n="summary.taxes"
|
|
200
|
+
>
|
|
201
|
+
Taxes
|
|
202
|
+
</td>
|
|
203
|
+
|
|
248
204
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
205
|
+
<td>
|
|
206
|
+
$0.00
|
|
207
|
+
</td>
|
|
253
208
|
|
|
254
|
-
</tr>
|
|
255
209
|
|
|
256
|
-
|
|
257
|
-
</tbody>
|
|
210
|
+
</tr>
|
|
258
211
|
</table>
|
|
259
|
-
|
|
260
|
-
|
|
261
212
|
<div
|
|
262
213
|
class="rebilly-instruments-summary-breakdown-total"
|
|
263
214
|
>
|
|
264
215
|
|
|
265
|
-
|
|
216
|
+
|
|
266
217
|
<p
|
|
267
218
|
data-rebilly-i18n="summary.total"
|
|
268
219
|
>
|
|
269
220
|
Total
|
|
270
221
|
</p>
|
|
271
222
|
|
|
272
|
-
|
|
223
|
+
|
|
273
224
|
<p
|
|
274
225
|
class="rebilly-instruments-summary-breakdown-total-amount"
|
|
275
226
|
>
|
|
276
227
|
|
|
277
|
-
|
|
228
|
+
|
|
278
229
|
<span
|
|
279
230
|
class="rebilly-instruments-summary-breakdown-total-amount-currency"
|
|
280
231
|
>
|
|
232
|
+
|
|
281
233
|
USD
|
|
234
|
+
|
|
282
235
|
</span>
|
|
236
|
+
|
|
283
237
|
$70.00
|
|
238
|
+
|
|
239
|
+
</p>
|
|
240
|
+
<p>
|
|
284
241
|
|
|
242
|
+
|
|
285
243
|
</p>
|
|
286
|
-
|
|
287
|
-
|
|
288
244
|
</div>
|
|
289
|
-
|
|
290
|
-
|
|
291
245
|
</div>
|
|
292
246
|
`;
|
|
@@ -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,59 @@ 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
|
+
// Close modal via postmate
|
|
25
|
+
this.component.on(`${this.name}-close`, (...args) => {
|
|
26
|
+
close(...args);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Close modal via postMessage (specifically during approal url flow)
|
|
30
|
+
window.addEventListener('message', async (event) => {
|
|
31
|
+
if(event.data === 'rebilly-instruments-approval-url-close') {
|
|
32
|
+
if (this.state.options.transactionType === 'purchase') {
|
|
33
|
+
this.state.storefront.setSessionToken(this.state.data.token);
|
|
34
|
+
|
|
35
|
+
const [
|
|
36
|
+
{fields: transaction},
|
|
37
|
+
{fields: invoice}
|
|
38
|
+
] = await Promise.all([
|
|
39
|
+
this.state.storefront.transactions.get({id: this.state.data.transaction.id}),
|
|
40
|
+
this.state.data.invoice?.id
|
|
41
|
+
? this.state.storefront.invoices.get({id: this.state.data.invoice.id})
|
|
42
|
+
: {fields: null}
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
const updatedPurchase = {
|
|
46
|
+
orderId: this.state.data.orderId,
|
|
47
|
+
token: this.state.data.token,
|
|
48
|
+
transaction,
|
|
49
|
+
};
|
|
50
|
+
if (invoice) {
|
|
51
|
+
updatedPurchase.invoice = invoice;
|
|
52
|
+
}
|
|
53
|
+
close(updatedPurchase);
|
|
54
|
+
} else if (this.state.options.transactionType === 'setup') {
|
|
55
|
+
this.state.storefront.setSessionToken(this.state.data.instrument.token);
|
|
56
|
+
const {
|
|
57
|
+
fields: transaction
|
|
58
|
+
} = await this.state.storefront.transactions.get({id: this.state.data.transaction.id});
|
|
59
|
+
close({
|
|
60
|
+
transaction,
|
|
61
|
+
instrument: this.state.data.instrument
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
close();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}, false);
|
|
26
68
|
}
|
|
27
|
-
}
|
|
69
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export function replaceContent(form, newContent) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
const contentElement = form.querySelector('.rebilly-instruments-content');
|
|
3
|
+
contentElement.innerHTML = newContent;
|
|
4
|
+
}
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
+
import { purchase } from '../functions/purchase';
|
|
2
|
+
import { setup } from '../functions/setup';
|
|
1
3
|
import { ViewIframe } from './common/iframe';
|
|
2
4
|
import { replaceContent } from './common/render-utilities';
|
|
5
|
+
import { updateMethodSelector } from './method-selector';
|
|
6
|
+
import { updateSummary } from './summary';
|
|
3
7
|
|
|
4
|
-
export const baseConfirmationHTML =
|
|
8
|
+
export const baseConfirmationHTML =
|
|
9
|
+
'<div class="rebilly-instruments-confirmation"></div>';
|
|
5
10
|
|
|
6
|
-
export async function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
export async function mountConfirmation({ payload: instrument, state }) {
|
|
12
|
+
if (
|
|
13
|
+
(instrument.billingAddress && state.summary) &&
|
|
14
|
+
state.data.isPurchase
|
|
15
|
+
) {
|
|
16
|
+
updateSummary({ state, instrument });
|
|
12
17
|
}
|
|
13
18
|
|
|
14
|
-
replaceContent(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
replaceContent(state.form, baseConfirmationHTML);
|
|
20
|
+
|
|
21
|
+
state.loader.startLoading({ id: 'confirmation' });
|
|
18
22
|
|
|
19
23
|
const container = document.querySelector('.rebilly-instruments-confirmation');
|
|
20
|
-
|
|
21
|
-
const {paymentMethodsUrl} =
|
|
24
|
+
|
|
25
|
+
const { paymentMethodsUrl } = state.options._computed;
|
|
22
26
|
|
|
23
27
|
const model = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
mainStyle,
|
|
28
|
+
options: state.options,
|
|
29
|
+
mainStyle: state.mainStyle,
|
|
27
30
|
instrument
|
|
28
31
|
};
|
|
29
32
|
const name = 'rebilly-instruments-confirmation';
|
|
@@ -34,24 +37,30 @@ export async function MountConfirmation({
|
|
|
34
37
|
model
|
|
35
38
|
});
|
|
36
39
|
iframe.bindEventListeners({
|
|
37
|
-
loader:
|
|
40
|
+
loader: state.loader
|
|
38
41
|
});
|
|
39
42
|
|
|
40
43
|
iframe.component.on(`${name}-confirm-purchase`, (confirmedInstrument) => {
|
|
41
|
-
|
|
44
|
+
purchase({ state, payload: confirmedInstrument });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
iframe.component.on(`${name}-confirm-setup`, (confirmedInstrument) => {
|
|
48
|
+
setup({ state, payload: confirmedInstrument });
|
|
42
49
|
});
|
|
43
50
|
|
|
44
51
|
iframe.component.on('choose-another-method', () => {
|
|
45
|
-
|
|
46
|
-
if(item.name === iframe.name) {
|
|
47
|
-
item.
|
|
52
|
+
state.iframeComponents = state.iframeComponents.filter((item) => {
|
|
53
|
+
if (item.name === iframe.name) {
|
|
54
|
+
item.destroy();
|
|
48
55
|
return false;
|
|
49
56
|
}
|
|
50
57
|
return true;
|
|
51
58
|
});
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
if (state.data.isPurchase) {
|
|
60
|
+
updateSummary({ state });
|
|
61
|
+
}
|
|
62
|
+
updateMethodSelector({ state, mainStyle: state.mainStyle });
|
|
54
63
|
});
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
}
|
|
65
|
+
state.iframeComponents.push(iframe);
|
|
66
|
+
}
|