@rebilly/instruments 3.12.3-beta.0 → 3.13.2-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.
Files changed (84) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +43 -66
  3. package/dist/index.min.js +43 -66
  4. package/package.json +3 -6
  5. package/src/functions/destroy.js +8 -2
  6. package/src/functions/mount/fetch-data.js +9 -2
  7. package/src/functions/mount/index.js +15 -10
  8. package/src/functions/mount/mount.spec.js +10 -11
  9. package/src/functions/mount/setup-framepay-theme.js +30 -72
  10. package/src/functions/mount/setup-options.js +2 -2
  11. package/src/functions/mount/{setup-styles.js → setup-styles-vars.js} +9 -7
  12. package/src/functions/purchase.js +2 -5
  13. package/src/functions/setup.js +3 -6
  14. package/src/functions/show.js +2 -2
  15. package/src/functions/show.spec.js +4 -4
  16. package/src/functions/update.spec.js +4 -3
  17. package/src/instance.js +4 -1
  18. package/src/loader/index.js +57 -33
  19. package/src/storefront/index.js +2 -5
  20. package/src/storefront/payment-instruments.js +7 -0
  21. package/src/style/base/__snapshots__/theme.spec.js.snap +136 -220
  22. package/src/style/base/default-theme.js +187 -14
  23. package/src/style/base/index.js +487 -79
  24. package/src/style/base/theme.js +3 -4
  25. package/src/style/base/theme.spec.js +2 -3
  26. package/src/style/index.js +4 -24
  27. package/src/style/utils/color-values.js +1 -1
  28. package/src/style/utils/minifyCss.js +14 -0
  29. package/src/views/common/iframe/base-iframe.js +3 -2
  30. package/src/views/common/iframe/event-listeners.js +12 -9
  31. package/src/views/common/iframe/method-iframe.js +3 -1
  32. package/src/views/common/iframe/modal-iframe.js +4 -2
  33. package/src/views/common/iframe/view-iframe.js +3 -1
  34. package/src/views/confirmation.js +12 -7
  35. package/src/views/errors.js +95 -0
  36. package/src/views/method-selector/express-methods.js +51 -0
  37. package/src/views/method-selector/generate-framepay-config.js +54 -0
  38. package/src/views/method-selector/generate-framepay-config.spec.js +195 -0
  39. package/src/views/method-selector/get-payment-methods.js +0 -1
  40. package/src/views/method-selector/index.js +45 -58
  41. package/src/views/method-selector/method-selector.spec.js +1 -1
  42. package/src/views/method-selector/mount-express-methods.js +66 -26
  43. package/src/views/modal.js +1 -1
  44. package/src/views/result.js +3 -3
  45. package/src/views/summary.js +24 -190
  46. package/tests/mocks/storefront-api-mock.js +48 -27
  47. package/src/style/browserslist.js +0 -1
  48. package/src/style/components/accordion.js +0 -140
  49. package/src/style/components/address.js +0 -55
  50. package/src/style/components/button.js +0 -117
  51. package/src/style/components/divider.js +0 -39
  52. package/src/style/components/forms/checkbox.js +0 -75
  53. package/src/style/components/forms/field.js +0 -56
  54. package/src/style/components/forms/form.js +0 -18
  55. package/src/style/components/forms/input.js +0 -77
  56. package/src/style/components/forms/label.js +0 -55
  57. package/src/style/components/forms/radio.js +0 -80
  58. package/src/style/components/forms/select.js +0 -86
  59. package/src/style/components/forms/validation.js +0 -72
  60. package/src/style/components/icons.js +0 -13
  61. package/src/style/components/index.js +0 -39
  62. package/src/style/components/loader.js +0 -41
  63. package/src/style/components/methods.js +0 -97
  64. package/src/style/components/overlay.js +0 -24
  65. package/src/style/helpers/index.js +0 -54
  66. package/src/style/payment-instruments/content.js +0 -8
  67. package/src/style/payment-instruments/index.js +0 -14
  68. package/src/style/payment-instruments/payment-card.js +0 -27
  69. package/src/style/payment-instruments/payment-instrument-list.js +0 -44
  70. package/src/style/payment-instruments/payment-instrument.js +0 -55
  71. package/src/style/utils/remove-empty-null.js +0 -10
  72. package/src/style/vendor/framepay.js +0 -28
  73. package/src/style/vendor/postmate.js +0 -18
  74. package/src/style/views/confirmation.js +0 -26
  75. package/src/style/views/index.js +0 -16
  76. package/src/style/views/method-selector.js +0 -11
  77. package/src/style/views/modal.js +0 -91
  78. package/src/style/views/result.js +0 -52
  79. package/src/style/views/summary.js +0 -118
  80. package/src/views/__snapshots__/summary.spec.js.snap +0 -246
  81. package/src/views/method-selector/express-methods/apple-pay.js +0 -92
  82. package/src/views/method-selector/express-methods/index.js +0 -25
  83. package/src/views/method-selector/mount-methods.js +0 -178
  84. package/src/views/summary.spec.js +0 -145
@@ -1,52 +0,0 @@
1
- // -----------------------------------------------------------------------------
2
- // This file contains all styles related to the result view.
3
- // -----------------------------------------------------------------------------
4
- export const result = () => `
5
- /**
6
- * Result
7
- */
8
- .rebilly-instruments-results .rebilly-instruments-h1 {
9
- text-align: center;
10
- margin: 0;
11
- }
12
-
13
- .rebilly-instruments-results-icon {
14
- width: 160px;
15
- margin: 0 auto var(--rebilly-spacings-base) auto;
16
- display: block;
17
- }
18
-
19
- .rebilly-instruments-results-icon g {
20
- stroke: var(--rebilly-colorPrimary);
21
- }
22
-
23
- .rebilly-instruments-results-icon.is-error g {
24
- stroke: var(--rebilly-colorDanger);
25
- }
26
-
27
- .rebilly-instruments-results-icon path {
28
- stroke-linecap: round;
29
- stroke-linejoin: round;
30
- }
31
-
32
- .rebilly-instruments-results-icon path.circle {
33
- stroke-dasharray: 350;
34
- stroke-dashoffset: 0;
35
- animation: 0.6s cubic-bezier(1.0, 0.5, 0.8, 1.0) 1 rebillyDashResultIcon;
36
- }
37
-
38
- .rebilly-instruments-results-icon path.mark {
39
- stroke-dasharray: 350;
40
- stroke-dashoffset: 0;
41
- animation: 1s cubic-bezier(1.0, 0.5, 0.8, 1.0) 1 rebillyDashResultIcon;
42
- }
43
-
44
- @keyframes rebillyDashResultIcon {
45
- from {
46
- stroke-dashoffset: 350;
47
- }
48
- to {
49
- stroke-dashoffset: 0;
50
- }
51
- }
52
- `;
@@ -1,118 +0,0 @@
1
- // -----------------------------------------------------------------------------
2
- // This file contains all styles related to the summary view.
3
- // -----------------------------------------------------------------------------
4
- export const summary = () => `
5
- /**
6
- * Summary
7
- */
8
- .rebilly-instruments-summary-line-item {
9
- border-bottom: 1px solid var(--rebilly-colorMutedBorder);
10
- padding: var(--rebilly-spacings-s) 0;
11
- display: flex;
12
- align-items: center;
13
- position: relative;
14
- }
15
-
16
- .rebilly-instruments-summary-line-item:first-child {
17
- padding-top: 0;
18
- }
19
-
20
- .rebilly-instruments-summary-line-item-figure {
21
- margin: 0 var(--rebilly-spacings-s) 0 0;
22
- flex: 0 0 auto;
23
- width: 48px;
24
- height: 48px;
25
- border-radius: var(--rebilly-borderRadius);
26
- border: 1px solid var(--rebilly-colorMutedBorder);
27
- overflow: hidden;
28
- }
29
-
30
- .rebilly-instruments-summary-line-item-figure img {
31
- width: 100%;
32
- }
33
-
34
- .rebilly-instruments-summary-line-item-synopsis {
35
- flex: 1 2 auto;
36
- }
37
-
38
- .rebilly-instruments-summary-line-item-synopsis-title {
39
- margin: 0;
40
- font-weight: 500;
41
- }
42
-
43
- .rebilly-instruments-summary-line-item-synopsis-description {
44
- color: var(--rebilly-colorMutedText);
45
- margin: 0;
46
- font-size: calc(var(--rebilly-fontSizeBase) * 0.875);
47
- line-height: 1;
48
- }
49
-
50
- .rebilly-instruments-summary-line-item-price-breakdown {
51
- display: flex;
52
- justify-content: center;
53
- align-items: center;
54
- color: var(--rebilly-colorMutedText);
55
- margin: 0 0 0 var(--rebilly-spacings-s);
56
- }
57
-
58
- .rebilly-instruments-summary-line-item-price-breakdown .rebilly-instruments-icon {
59
- fill: var(--rebilly-colorMutedText);
60
- }
61
-
62
- .rebilly-instruments-summary-line-item-price-breakdown-unit-price {
63
- color: var(--rebilly-colorText);
64
- }
65
-
66
- .rebilly-instruments-summary-breakdown table {
67
- width: 100%;
68
- margin: var(--rebilly-spacings-xs) 0;
69
- color: inherit;
70
- }
71
-
72
- .rebilly-instruments-summary-breakdown table colgroup col:first-child {
73
- width: 85%;
74
- }
75
-
76
- .rebilly-instruments-summary-breakdown table colgroup col {
77
- width: 15%;
78
- }
79
-
80
- .rebilly-instruments-summary-breakdown table tr td {
81
- text-align: right;
82
- }
83
-
84
- .rebilly-instruments-summary-breakdown table tr td:first-child {
85
- padding-right: var(--rebilly-spacings-s);
86
- font-weight: 500;
87
- }
88
-
89
- .rebilly-instruments-summary-breakdown table {
90
- border-bottom: 1px solid var(--rebilly-colorMutedBorder);
91
- padding-bottom: var(--rebilly-spacings-xs);
92
- }
93
-
94
- .rebilly-instruments-summary-breakdown-total {
95
- padding-top: var(--rebilly-spacings-xs);
96
- display: flex;
97
- align-items: center;
98
- }
99
-
100
- .rebilly-instruments-summary-breakdown-total p {
101
- margin: var(--rebilly-spacings-s) 0;
102
- }
103
-
104
- .rebilly-instruments-summary-breakdown-total-amount {
105
- flex: 1 2 80%;
106
- font-size: calc(var(--rebilly-fontSizeBase) * 1.5);
107
- font-weight: 500;
108
- text-align: right;
109
- font-weight: bold;
110
- }
111
-
112
- .rebilly-instruments-summary-breakdown-total-amount-currency {
113
- font-size: var(--rebilly-fontSizeBase);
114
- font-weight: normal;
115
- color: var(--rebilly-colorMutedText);
116
- margin-right: var(--rebilly-spacings-s);
117
- }
118
- `;
@@ -1,246 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Summary component should render the summary correctly 1`] = `
4
- <div
5
- class="rebilly-instruments-summary-line-items"
6
- >
7
-
8
-
9
- <div
10
- class="rebilly-instruments-summary-line-item"
11
- >
12
-
13
-
14
-
15
- <div
16
- class="rebilly-instruments-summary-line-item-synopsis"
17
- >
18
-
19
-
20
- <p
21
- class="rebilly-instruments-summary-line-item-synopsis-title"
22
- >
23
- My Awesome Product
24
- </p>
25
-
26
-
27
-
28
- <p
29
- class="rebilly-instruments-summary-line-item-synopsis-description"
30
- >
31
- My Awesome Product
32
- </p>
33
-
34
-
35
-
36
- </div>
37
-
38
-
39
- <div
40
- class="rebilly-instruments-summary-line-item-price-breakdown"
41
- >
42
-
43
-
44
- <p
45
- class="rebilly-instruments-summary-line-item-price-breakdown-quantity"
46
- >
47
- 1
48
- </p>
49
-
50
-
51
- <svg
52
- class="rebilly-instruments-icon"
53
- viewBox="0 0 24 24"
54
- xmlns="http://www.w3.org/2000/svg"
55
- >
56
-
57
-
58
- <path
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
- fill-rule="nonzero"
61
- />
62
-
63
-
64
- </svg>
65
-
66
-
67
- <p
68
- class="rebilly-instruments-summary-line-item-price-breakdown-unit-price"
69
- >
70
- $30.00
71
- </p>
72
-
73
-
74
- </div>
75
-
76
-
77
- </div>
78
-
79
-
80
-
81
-
82
- <div
83
- class="rebilly-instruments-summary-line-item"
84
- >
85
-
86
-
87
-
88
- <div
89
- class="rebilly-instruments-summary-line-item-synopsis"
90
- >
91
-
92
-
93
- <p
94
- class="rebilly-instruments-summary-line-item-synopsis-title"
95
- >
96
- My Awesome T-Shirt
97
- </p>
98
-
99
-
100
-
101
- <p
102
- class="rebilly-instruments-summary-line-item-synopsis-description"
103
- >
104
- Awesome T-Shirt
105
- </p>
106
-
107
-
108
-
109
- </div>
110
-
111
-
112
- <div
113
- class="rebilly-instruments-summary-line-item-price-breakdown"
114
- >
115
-
116
-
117
- <p
118
- class="rebilly-instruments-summary-line-item-price-breakdown-quantity"
119
- >
120
- 2
121
- </p>
122
-
123
-
124
- <svg
125
- class="rebilly-instruments-icon"
126
- viewBox="0 0 24 24"
127
- xmlns="http://www.w3.org/2000/svg"
128
- >
129
-
130
-
131
- <path
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"
133
- fill-rule="nonzero"
134
- />
135
-
136
-
137
- </svg>
138
-
139
-
140
- <p
141
- class="rebilly-instruments-summary-line-item-price-breakdown-unit-price"
142
- >
143
- $20.00
144
- </p>
145
-
146
-
147
- </div>
148
-
149
-
150
- </div>
151
-
152
-
153
- </div>
154
- `;
155
-
156
- exports[`Summary component should render the summary correctly 2`] = `
157
- <div
158
- class="rebilly-instruments-summary-breakdown"
159
- >
160
- <table>
161
-
162
-
163
- <colgroup>
164
-
165
-
166
- <col />
167
-
168
-
169
- <col />
170
-
171
-
172
- </colgroup>
173
-
174
-
175
- <tr
176
- class="rebilly-instruments-summary-breakdown-sub-total"
177
- >
178
-
179
-
180
- <td
181
- data-rebilly-i18n="summary.subTotal"
182
- >
183
- Sub Total
184
- </td>
185
-
186
-
187
- <td>
188
- $70.00
189
- </td>
190
-
191
-
192
- </tr>
193
- <tr
194
- class="rebilly-instruments-summary-breakdown-taxes"
195
- >
196
-
197
-
198
- <td
199
- data-rebilly-i18n="summary.taxes"
200
- >
201
- Taxes
202
- </td>
203
-
204
-
205
- <td>
206
- $0.00
207
- </td>
208
-
209
-
210
- </tr>
211
- </table>
212
- <div
213
- class="rebilly-instruments-summary-breakdown-total"
214
- >
215
-
216
-
217
- <p
218
- data-rebilly-i18n="summary.total"
219
- >
220
- Total
221
- </p>
222
-
223
-
224
- <p
225
- class="rebilly-instruments-summary-breakdown-total-amount"
226
- >
227
-
228
-
229
- <span
230
- class="rebilly-instruments-summary-breakdown-total-amount-currency"
231
- >
232
-
233
- USD
234
-
235
- </span>
236
-
237
- $70.00
238
-
239
- </p>
240
- <p>
241
-
242
-
243
- </p>
244
- </div>
245
- </div>
246
- `;
@@ -1,92 +0,0 @@
1
- import Events from '../../../events';
2
-
3
- const browserIsSafari = () => window.ApplePaySession;
4
-
5
- export default function mountApplePay({
6
- state,
7
- METHOD_ID,
8
- METHOD_TYPE,
9
- EXPRESS_METHODS,
10
- EXPRESS_METHODS_CONTAINER
11
- }) {
12
- const container = document.querySelector(`.rebilly-instruments-${METHOD_ID}-method`);
13
- const digitalWallet = state.options.digitalWallet.applePay;
14
-
15
- function mountApplePayButton() {
16
- if(!container.children.length) {
17
- Rebilly.applePay.mount(`.rebilly-instruments-${METHOD_ID}-method`);
18
- }
19
- state.loader.stopLoading({ id: `${METHOD_TYPE}-express` });
20
- }
21
-
22
- // Hack: The correct way to do this is to accept the options via the framepay package
23
- // Will remove once these options are added to framepay
24
- function updateBtnStyling() {
25
- const applePayButton = document.querySelector('#rebilly-apple-pay-button');
26
- applePayButton.style.margin = '0px';
27
- applePayButton.style.width = '100%';
28
- applePayButton.style.height = digitalWallet.applePayDisplayOptions.buttonHeight;
29
- }
30
-
31
- if(!browserIsSafari()) {
32
- if(EXPRESS_METHODS.length === 1) {
33
- EXPRESS_METHODS_CONTAINER.parentNode.style.display = 'none';
34
- }
35
- state.loader.stopLoading({ id: `${METHOD_TYPE}-express` });
36
- container.style.display = 'none';
37
- return;
38
- }
39
-
40
- container.style.height = digitalWallet.applePayDisplayOptions.buttonHeight;
41
-
42
- if (!Rebilly.initialized) {
43
- const options = {
44
- transactionData: digitalWallet.transactionData,
45
- methods: state.data.readyToPay,
46
- applePay: digitalWallet.applePayDisplayOptions,
47
- organizationId: state.options.organizationId
48
- }
49
- if (state.options.jwt && !state.options.publishableKey) {
50
- options.jwt = state.options.jwt;
51
- options.sandbox = state.options.apiMode === 'sandbox';
52
- } else {
53
- options.publishableKey = state.options.publishableKey;
54
- }
55
- Rebilly.initialize(options);
56
- } else {
57
- mountApplePayButton();
58
- updateBtnStyling();
59
- }
60
-
61
- Rebilly.on('ready', () => {
62
- mountApplePayButton();
63
- updateBtnStyling();
64
- });
65
-
66
- // HOTFIX: Hardcoded, use env variables in the future
67
- const redirectUrl = state.options.apiMode === 'sandbox'
68
- ? 'https://forms-sandbox.secure-payments.app/approval-url?close=true'
69
- : 'https://forms.secure-payments.app/approval-url?close=true';
70
-
71
- Rebilly.on('token-ready', (token) => {
72
- const instrumentReadyPayload = {
73
- websiteId: state.options.websiteId,
74
- items: state.options.items,
75
- paymentInstruction: {
76
- token: token.id,
77
- },
78
- billingAddress: token.billingAddress,
79
- redirectUrl,
80
- _raw: token
81
- }
82
- if (!token.shippingAddress) {
83
- instrumentReadyPayload.deliveryAddress = token.shippingAddress;
84
- }
85
-
86
- Events.instrumentReady.dispatch(instrumentReadyPayload);
87
- });
88
-
89
- Rebilly.on('error', error => {
90
- console.error(error)
91
- });
92
- }
@@ -1,25 +0,0 @@
1
- import { MethodIframe } from '../../common/iframe';
2
-
3
- export default async function mountExpressMethod({ state, METHOD_ID }) {
4
- const container = document.querySelector(`.rebilly-instruments-${METHOD_ID}-method`);
5
-
6
- const { paymentMethodsUrl } = state.options._computed;
7
-
8
- const model = {
9
- options: state.options,
10
- data: state.data.toPostmatesModel()
11
- };
12
-
13
- const iframe = await new MethodIframe({
14
- name: METHOD_ID,
15
- url: `${paymentMethodsUrl}/${METHOD_ID}`,
16
- container,
17
- model
18
- });
19
-
20
- iframe.bindEventListeners({
21
- loader: state.loader
22
- });
23
-
24
- state.iframeComponents.push(iframe);
25
- }
@@ -1,178 +0,0 @@
1
- import camelCase from 'lodash.camelcase';
2
- import { mountModal } from '../modal';
3
- import { MethodIframe } from '../common/iframe';
4
- import { getMethodData } from './get-method-data';
5
-
6
- async function mountInline(state, {
7
- methodId,
8
- paymentMethodsUrl,
9
- container,
10
- model,
11
- method
12
- }) {
13
- const iframe = await new MethodIframe({
14
- name: methodId,
15
- url: `${paymentMethodsUrl}/${methodId}`,
16
- container,
17
- model
18
- });
19
- iframe.bindEventListeners({
20
- loader: state.loader,
21
- id: method.method
22
- });
23
- state.iframeComponents.push(iframe);
24
- }
25
-
26
- function displayBrands({summary, method}) {
27
- function renderBrand(brand) {
28
- return `
29
- <figure>
30
- <img alt="${brand}" src="https://forms.secure-payments.app/payment-instruments/brand/${brand.replace(/\s/, '')}.svg" />
31
- </figure>
32
- `;
33
- }
34
-
35
- const {brands} = method;
36
- summary.querySelector('.rebilly-instruments-accordion-title').insertAdjacentHTML(
37
- 'afterend',
38
- `<div class="rebilly-instruments-accordion-brands">${(() => {
39
- if (brands.length >= 4) {
40
- const truncatedBrands = brands.slice(0, 3);
41
- return `${truncatedBrands.map(brand => renderBrand(brand)).join('')}
42
- <span data-rebilly-i18n="forms.andMore">and more</span>
43
- `
44
- }
45
- return brands.map(brand => renderBrand(brand)).join('');
46
- })()}</div>`
47
- );
48
- }
49
-
50
- export function MountMethods({
51
- state,
52
- METHODS_CONTAINER,
53
- METHODS
54
- }) {
55
- const isAccordion = METHODS.length > 1;
56
-
57
- METHODS.forEach(async (method) => {
58
- const { METHOD_ID: methodId, METHOD_TYPE: methodType } =
59
- getMethodData(method);
60
- const { paymentMethodsUrl } =
61
- state.options._computed || 'https://www.example.com';
62
-
63
- const selector = `rebilly-instruments-${methodId}`;
64
- const isPopup = [
65
- 'payment-card'
66
- ].includes(methodId) && state.options.paymentInstruments[methodType]?.popup;
67
- const model = {
68
- account: state.data?.account,
69
- options: state.options,
70
- mainStyle: state.mainStyle,
71
- plans: state.data.plans,
72
- products: state.data.products,
73
- method,
74
- readyToPay: state.data.readyToPay,
75
- };
76
-
77
- if (isAccordion) {
78
- METHODS_CONTAINER.insertAdjacentHTML(
79
- 'beforeend',
80
- `<details class="rebilly-instruments-accordion for-${methodId}">
81
- <summary class="rebilly-instruments-accordion-summary">
82
- <img class="rebilly-instruments-accordion-${method.method}-img" src="${method.metadata.logo}" alt="${method.method}"/>
83
- <span class="rebilly-instruments-accordion-title" data-rebilly-i18n="paymentMethods.${method.method}">${method.metadata.name}</span>
84
- <span class="rebilly-instruments-accordion-summary-checkmark"></span>
85
- </summary>
86
- <div id="${selector}" data-rebilly-instruments-type="${methodId}" style="position: relative"></div>
87
- </details>`
88
- );
89
-
90
- if ([
91
- 'payment-card'
92
- ].includes(method.method)) {
93
- const summary = document.querySelector(`.for-${methodId} > .rebilly-instruments-accordion-summary`);
94
- displayBrands({summary, method});
95
- }
96
- state.loader.stopLoading({ id: method.method });
97
-
98
- METHODS_CONTAINER.insertAdjacentHTML(
99
- 'beforeend',
100
- `<div id="${selector}" data-rebilly-instruments-type="${methodId}"></div>`
101
- );
102
- const container = document.querySelector(`#${selector}`);
103
-
104
- state.loader.stopLoading({ id: method.method });
105
- mountInline(state, {
106
- methodId,
107
- paymentMethodsUrl,
108
- container,
109
- model,
110
- method
111
- });
112
- } else if (isPopup) {
113
- METHODS_CONTAINER.insertAdjacentHTML(
114
- 'beforeend',
115
- `<div id="${selector}" data-rebilly-instruments-type="${methodId}"></div>`
116
- );
117
- const container = document.querySelector(`#${selector}`);
118
-
119
- container.insertAdjacentHTML(
120
- 'beforeend',
121
- `<button class="${selector} rebilly-instruments-button" data-rebilly-i18n="paymentMethods.${
122
- method.method
123
- }">${camelCase(method.method)}</button>`
124
- );
125
- const button = document.querySelector(`.${selector}`);
126
- button.addEventListener('click', async () => {
127
- const iframe = await mountModal({
128
- state,
129
- name: methodId,
130
- url: `${paymentMethodsUrl}/${methodId}`,
131
- model
132
- });
133
- state.iframeComponents.push(iframe);
134
- });
135
- } else {
136
- METHODS_CONTAINER.insertAdjacentHTML(
137
- 'beforeend',
138
- `<div id="${selector}" data-rebilly-instruments-type="${methodId}"></div>`
139
- );
140
- const container = document.querySelector(`#${selector}`);
141
-
142
- mountInline(state, {
143
- methodId,
144
- paymentMethodsUrl,
145
- container,
146
- model,
147
- method
148
- });
149
- }
150
- state.loader.stopLoading({ id: method.method });
151
- });
152
-
153
- if (isAccordion) {
154
- // Fetch all the accordion elements.
155
- const details = document.querySelectorAll('.rebilly-instruments-accordion');
156
- // Add the onclick listeners.
157
- details.forEach((targetDetail) => {
158
- // set to open by default, will be closed by timeout below
159
- targetDetail.open = true;
160
- targetDetail.querySelector('summary').addEventListener('click', () => {
161
- // Close all the accordion that are not targetDetail.
162
- details.forEach((detail) => {
163
- detail.removeAttribute('open');
164
- });
165
- });
166
- });
167
-
168
- // All details must be open to connect to Postmate than closed
169
- setTimeout(() => {
170
- details.forEach((detail) => {
171
- detail.removeAttribute('open');
172
- });
173
- details[0].open = true;
174
- }, 100);
175
- }
176
-
177
- state.translate.translateItems();
178
- }