@rebilly/instruments 4.5.0 → 4.7.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 +24 -26
- package/CHANGELOG.md +14 -0
- package/dist/index.js +8 -8
- package/dist/index.min.js +8 -8
- package/package.json +14 -3
- package/project.json +9 -0
- package/rollup.config.mjs +21 -26
- package/src/data/options-schema/index.js +94 -78
- package/src/data/options-schema/schemas/options-schema.js +419 -411
- package/src/events/base-event.js +34 -34
- package/src/events/events.spec.js +6 -6
- package/src/events/index.js +5 -5
- package/src/functions/destroy.js +19 -19
- package/src/functions/destroy.spec.js +41 -41
- package/src/functions/mount/fetch-data.js +200 -193
- package/src/functions/mount/fetch-data.spec.js +287 -285
- package/src/functions/mount/get-lead-source-data.js +31 -31
- package/src/functions/mount/get-lead-source-data.spec.js +19 -19
- package/src/functions/mount/index.js +73 -65
- package/src/functions/mount/mount.spec.js +77 -66
- package/src/functions/mount/setup-element.js +23 -23
- package/src/functions/mount/setup-framepay-theme.js +86 -68
- package/src/functions/mount/setup-framepay.js +9 -5
- package/src/functions/mount/setup-i18n.js +15 -15
- package/src/functions/mount/setup-options.js +74 -74
- package/src/functions/mount/setup-options.spec.js +323 -287
- package/src/functions/mount/setup-storefront.js +15 -20
- package/src/functions/mount/setup-styles-vars.js +19 -22
- package/src/functions/mount/setup-user-flow.js +51 -47
- package/src/functions/on.js +5 -5
- package/src/functions/on.spec.js +60 -51
- package/src/functions/purchase.js +151 -146
- package/src/functions/purchase.spec.js +59 -56
- package/src/functions/setup.js +53 -53
- package/src/functions/setup.spec.js +88 -75
- package/src/functions/show.js +13 -14
- package/src/functions/show.spec.js +53 -53
- package/src/functions/update.js +30 -28
- package/src/functions/update.spec.js +94 -93
- package/src/i18n/en.json +32 -32
- package/src/i18n/es.json +29 -29
- package/src/i18n/i18n.spec.js +18 -18
- package/src/i18n/index.js +48 -48
- package/src/instance.js +36 -36
- package/src/instance.spec.js +29 -27
- package/src/loader/index.js +95 -70
- package/src/loader/loader.spec.js +63 -63
- package/src/state/iframes.js +21 -21
- package/src/state/index.js +56 -54
- package/src/storefront/account-and-website.js +10 -8
- package/src/storefront/account-and-website.spec.js +55 -55
- package/src/storefront/deposit-requests.js +6 -6
- package/src/storefront/fetch-plans-from-addons-bumpOffer.js +21 -19
- package/src/storefront/fetch-products-from-plans.js +52 -51
- package/src/storefront/fetch-products-from-plans.spec.js +90 -87
- package/src/storefront/index.js +56 -49
- package/src/storefront/invoices.js +15 -15
- package/src/storefront/invoices.spec.js +69 -65
- package/src/storefront/models/account-model.js +29 -32
- package/src/storefront/models/base-model.js +6 -9
- package/src/storefront/models/deposit-request-model.js +22 -13
- package/src/storefront/models/invoice-model.js +16 -16
- package/src/storefront/models/payment-metadata.js +4 -4
- package/src/storefront/models/plan-model.js +73 -64
- package/src/storefront/models/ready-to-pay-model.js +59 -59
- package/src/storefront/models/summary-model.js +43 -46
- package/src/storefront/models/transaction-model.js +11 -14
- package/src/storefront/payment-instruments.js +38 -35
- package/src/storefront/payment-instruments.spec.js +81 -62
- package/src/storefront/purchase.js +50 -44
- package/src/storefront/purchase.spec.js +40 -40
- package/src/storefront/ready-to-pay.js +75 -77
- package/src/storefront/ready-to-pay.spec.js +59 -54
- package/src/storefront/storefront.spec.js +9 -9
- package/src/storefront/summary.js +93 -67
- package/src/storefront/summary.spec.js +108 -106
- package/src/storefront/transactions.js +6 -6
- package/src/style/base/default-theme.js +928 -923
- package/src/style/base/theme.js +21 -21
- package/src/style/base/theme.spec.js +13 -13
- package/src/style/index.js +3 -3
- package/src/style/utils/border.js +40 -27
- package/src/style/utils/color-values.js +18 -18
- package/src/style/utils/minifyCss.js +6 -6
- package/src/utils/add-dom-element.js +14 -14
- package/src/utils/format-currency.js +6 -5
- package/src/utils/has-valid-css-selector.js +2 -2
- package/src/utils/index.js +6 -6
- package/src/utils/is-dom-element.js +1 -1
- package/src/utils/process-property-as-dom-element.js +22 -22
- package/src/utils/quantity.js +26 -28
- package/src/utils/sleep.js +3 -1
- package/src/views/amount-selector.js +37 -36
- package/src/views/common/iframe/base-iframe.js +53 -52
- package/src/views/common/iframe/events/change-iframe-src-handler.js +5 -5
- package/src/views/common/iframe/events/dispatch-event-handler.js +4 -4
- package/src/views/common/iframe/events/resize-component-handler.js +8 -8
- package/src/views/common/iframe/events/show-error-handler.js +2 -2
- package/src/views/common/iframe/events/stop-loader-handler.js +8 -8
- package/src/views/common/iframe/events/update-addons-handler.js +20 -13
- package/src/views/common/iframe/events/update-coupons-handler.js +9 -9
- package/src/views/common/iframe/events/update-items-handler.js +26 -22
- package/src/views/common/iframe/modal-iframe.js +67 -56
- package/src/views/common/iframe/view-iframe.js +11 -11
- package/src/views/common/render-utilities.js +2 -2
- package/src/views/confirmation.js +33 -30
- package/src/views/errors.js +89 -79
- package/src/views/form.js +41 -37
- package/src/views/method-selector/express-methods.js +46 -46
- package/src/views/method-selector/generate-digital-wallet.js +46 -45
- package/src/views/method-selector/generate-digital-wallet.spec.js +104 -102
- package/src/views/method-selector/generate-framepay-config.js +53 -51
- package/src/views/method-selector/generate-framepay-config.spec.js +197 -173
- package/src/views/method-selector/get-method-data.js +5 -6
- package/src/views/method-selector/get-payment-methods.js +18 -16
- package/src/views/method-selector/get-payment-methods.spec.js +29 -27
- package/src/views/method-selector/index.js +154 -139
- package/src/views/method-selector/method-selector.spec.js +13 -13
- package/src/views/method-selector/mount-bump-offer.js +65 -49
- package/src/views/method-selector/mount-express-methods.js +89 -85
- package/src/views/modal.js +74 -67
- package/src/views/result.js +14 -14
- package/src/views/summary.js +25 -26
- package/tests/async-utilities.js +13 -13
- package/tests/mocks/framepay-mock.js +9 -8
- package/tests/mocks/rebilly-api-mock.js +5 -3
- package/tests/mocks/rebilly-instruments-mock.js +121 -117
- package/tests/mocks/storefront-api-mock.js +55 -48
- package/tests/mocks/storefront-mock.js +10 -14
- package/tests/msw/server.js +6 -6
- package/tests/setup-test.js +14 -16
- package/vitest.config.js +14 -14
- package/.eslintrc.js +0 -34
- package/.prettierrc.js +0 -11
|
@@ -1,65 +1,66 @@
|
|
|
1
1
|
import Postmate from 'popostmate';
|
|
2
2
|
|
|
3
3
|
export default class BaseIframe {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
constructor({
|
|
5
|
+
name = '',
|
|
6
|
+
url = '',
|
|
7
|
+
model = {},
|
|
8
|
+
container = null,
|
|
9
|
+
classListArray = [],
|
|
10
|
+
route = null,
|
|
11
|
+
} = {}) {
|
|
12
|
+
classListArray = Array.isArray(classListArray) ? classListArray : [];
|
|
13
|
+
if (!classListArray.includes('rebilly-instruments-iframe')) {
|
|
14
|
+
classListArray.push('rebilly-instruments-iframe');
|
|
15
|
+
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
this.container = container;
|
|
18
|
+
this.classListArray = classListArray;
|
|
19
|
+
this.name = name;
|
|
20
|
+
this.url = url;
|
|
21
|
+
this.model = model;
|
|
22
|
+
this.component = null;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// eslint-disable-next-line no-constructor-return
|
|
25
|
+
return (async () => {
|
|
26
|
+
this.component = await this.createComponent();
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if (route) {
|
|
29
|
+
this.component.call('route', route);
|
|
30
|
+
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
return this;
|
|
33
|
+
})();
|
|
34
|
+
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
async destroy() {
|
|
37
|
+
if (this.component.frame.parentNode) {
|
|
38
|
+
await this.component.destroy();
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
|
-
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
async createComponent() {
|
|
43
|
+
// Use a fake container so we can capture the appendChild call
|
|
44
|
+
// and immediately apply the feature-policy flags to the iframe
|
|
45
|
+
// before Postmate tries to load the iframe. The feature policy
|
|
46
|
+
// would otherwise not apply until the frame was reloaded.
|
|
47
|
+
const container = {
|
|
48
|
+
appendChild: (iframe) => {
|
|
49
|
+
iframe.setAttribute('loading', 'lazy');
|
|
50
|
+
iframe.setAttribute('allow', 'payment');
|
|
51
|
+
iframe.allowPaymentRequest = true;
|
|
52
|
+
this.container.appendChild(iframe);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const component = await new Postmate({
|
|
57
|
+
name: this.name,
|
|
58
|
+
url: this.url,
|
|
59
|
+
container,
|
|
60
|
+
classListArray: this.classListArray,
|
|
61
|
+
model: this.model,
|
|
62
|
+
});
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
return component;
|
|
65
|
+
}
|
|
65
66
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function changeIframeSrcHandler(iframe) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
2
|
+
iframe.component.on(`${iframe.name}-change-iframe-src`, (url = null) => {
|
|
3
|
+
iframe.component.frame.src = url;
|
|
4
|
+
iframe.component.frame.style.height = '75vh';
|
|
5
|
+
});
|
|
6
|
+
}
|
|
@@ -2,7 +2,7 @@ import camelCase from 'lodash.camelcase';
|
|
|
2
2
|
import Events from '../../../../events';
|
|
3
3
|
|
|
4
4
|
export function dispatchEventHandler(iframe) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
5
|
+
iframe.component.on(`${iframe.name}-dispatch`, ({ event, detail }) => {
|
|
6
|
+
Events[camelCase(event).replace(/-/, '')].dispatch(detail);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export function resizeComponentHandler(iframe) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
2
|
+
let prevHeight = '';
|
|
3
|
+
iframe.component.on(`${iframe.name}-resize-frame`, (height) => {
|
|
4
|
+
if (height !== prevHeight) {
|
|
5
|
+
prevHeight = height;
|
|
6
|
+
iframe.component.frame.style.height = height;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export function stopLoaderHandler(iframe, data) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
2
|
+
iframe.component.on(`${iframe.name}-stop-loading`, (id) => {
|
|
3
|
+
let { section } = data;
|
|
4
|
+
if (!section) {
|
|
5
|
+
section = id.includes('summary') ? 'summary' : 'form';
|
|
6
|
+
}
|
|
7
|
+
data.loader?.stopLoading({ section, id });
|
|
8
|
+
});
|
|
9
|
+
}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import state from '../../../../state';
|
|
2
2
|
|
|
3
3
|
export function updateAddonsHandler(iframe) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
iframe.component.on(
|
|
5
|
+
`${iframe.name}-update-addons`,
|
|
6
|
+
async ({ addons, previewPurchase }) => {
|
|
7
|
+
const addonPlanIds = addons.map((addon) => addon.planId);
|
|
8
|
+
state.data.addons = addonPlanIds;
|
|
9
|
+
state.data.previewPurchase = previewPurchase;
|
|
10
|
+
|
|
11
|
+
state.data.previewPurchase.addonLineItems =
|
|
12
|
+
state.data.previewPurchase.lineItems.filter((item) =>
|
|
13
|
+
addonPlanIds.includes(item.planId),
|
|
14
|
+
);
|
|
15
|
+
state.data.previewPurchase.lineItems =
|
|
16
|
+
state.data.previewPurchase.lineItems.filter(
|
|
17
|
+
(item) => !addonPlanIds.includes(item.planId),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
state.updateModel();
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import state from '../../../../state';
|
|
2
2
|
|
|
3
3
|
export function updateCouponsHandler(iframe) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
4
|
+
iframe.component.on(
|
|
5
|
+
`${iframe.name}-update-coupon`,
|
|
6
|
+
async ({ couponIds, previewPurchase } = {}) => {
|
|
7
|
+
state.data.couponIds = couponIds;
|
|
8
|
+
state.data.previewPurchase = previewPurchase;
|
|
9
|
+
state.updateModel();
|
|
10
|
+
},
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import state from '../../../../state';
|
|
2
2
|
import { fetchSummary } from '../../../../storefront/summary';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createQuantitiesMap,
|
|
5
|
+
getQuantityValue,
|
|
6
|
+
isObject,
|
|
7
|
+
} from '../../../../utils/quantity';
|
|
4
8
|
|
|
5
9
|
let loading = false;
|
|
6
10
|
export async function itemsUpdatedHandler(iframe) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
iframe.component.on(`${iframe.name}-update-items`, async (lineItems) => {
|
|
12
|
+
try {
|
|
13
|
+
if (loading) return;
|
|
14
|
+
loading = true;
|
|
15
|
+
const mappedItems = createQuantitiesMap(lineItems);
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
state.data.summaryLineItems.forEach((item) => {
|
|
18
|
+
const quantity = getQuantityValue(mappedItems.get(item.planId));
|
|
19
|
+
if (isObject(item.quantity)) {
|
|
20
|
+
item.quantity.default = quantity;
|
|
21
|
+
} else {
|
|
22
|
+
item.quantity = quantity;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
await fetchSummary();
|
|
27
|
+
state.updateModel();
|
|
28
|
+
loading = false;
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.error(err);
|
|
31
|
+
loading = false;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
30
34
|
}
|
|
@@ -8,64 +8,75 @@ import { showErrorHandler } from './events/show-error-handler';
|
|
|
8
8
|
import { stopLoaderHandler } from './events/stop-loader-handler';
|
|
9
9
|
|
|
10
10
|
export class ModalIframe extends BaseIframe {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
constructor(args = {}) {
|
|
12
|
+
super(args);
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
bindEventListeners({ close = () => {}, loader } = {}) {
|
|
16
|
+
dispatchEventHandler(this);
|
|
17
|
+
resizeComponentHandler(this);
|
|
18
|
+
changeIframeSrcHandler(this);
|
|
19
|
+
stopLoaderHandler(this, {
|
|
20
|
+
loader,
|
|
21
|
+
section: 'modal',
|
|
22
|
+
id: this.name,
|
|
23
|
+
});
|
|
24
|
+
showErrorHandler(this);
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
// Close modal via postmate
|
|
27
|
+
this.component.on(`${this.name}-close`, (...args) => {
|
|
28
|
+
close(...args);
|
|
29
|
+
});
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
// Close modal via postMessage (specifically during approval url flow)
|
|
32
|
+
window.addEventListener(
|
|
33
|
+
'message',
|
|
34
|
+
async (event) => {
|
|
35
|
+
if (event.data === 'rebilly-instruments-approval-url-close') {
|
|
36
|
+
if (state.options.transactionType === 'purchase') {
|
|
37
|
+
state.storefront.setSessionToken(
|
|
38
|
+
state.data.token || state.options.jwt,
|
|
39
|
+
);
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
41
|
+
const [{ fields: transaction }, { fields: invoice }] =
|
|
42
|
+
await Promise.all([
|
|
43
|
+
state.storefront.transactions.get({
|
|
44
|
+
id: state.data.transaction.id,
|
|
45
|
+
}),
|
|
46
|
+
state.data.invoice?.id
|
|
47
|
+
? state.storefront.invoices.get({
|
|
48
|
+
id: state.data.invoice.id,
|
|
49
|
+
})
|
|
50
|
+
: { fields: null },
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
const updatedPurchase = {
|
|
54
|
+
orderId: state.data.orderId,
|
|
55
|
+
token: state.data.token,
|
|
56
|
+
transaction,
|
|
57
|
+
};
|
|
58
|
+
if (invoice) {
|
|
59
|
+
updatedPurchase.invoice = invoice;
|
|
60
|
+
}
|
|
61
|
+
close(updatedPurchase);
|
|
62
|
+
} else if (state.options.transactionType === 'setup') {
|
|
63
|
+
state.storefront.setSessionToken(
|
|
64
|
+
state.data.instrument.token || state.options.jwt,
|
|
65
|
+
);
|
|
66
|
+
const { fields: transaction } =
|
|
67
|
+
await state.storefront.transactions.get({
|
|
68
|
+
id: state.data.transaction.id,
|
|
69
|
+
});
|
|
70
|
+
close({
|
|
71
|
+
transaction,
|
|
72
|
+
instrument: state.data.instrument,
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
close();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
false,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
71
82
|
}
|
|
@@ -8,16 +8,16 @@ import { showErrorHandler } from './events/show-error-handler';
|
|
|
8
8
|
import { stopLoaderHandler } from './events/stop-loader-handler';
|
|
9
9
|
|
|
10
10
|
export class ViewIframe extends BaseIframe {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
constructor(args = {}) {
|
|
12
|
+
super(args);
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
bindEventListeners({ loader } = {}) {
|
|
16
|
+
dispatchEventHandler(this);
|
|
17
|
+
resizeComponentHandler(this);
|
|
18
|
+
stopLoaderHandler(this, { loader });
|
|
19
|
+
showErrorHandler(this);
|
|
20
|
+
updateCouponsHandler(this);
|
|
21
|
+
updateAddonsHandler(this);
|
|
22
|
+
}
|
|
23
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export function replaceContent(form, newContent) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const contentElement = form.querySelector('.rebilly-instruments-content');
|
|
3
|
+
contentElement.innerHTML = newContent;
|
|
4
4
|
}
|
|
@@ -2,41 +2,44 @@ import state from '../state';
|
|
|
2
2
|
import iframes from '../state/iframes';
|
|
3
3
|
import { mountForm } from './form';
|
|
4
4
|
import { updateSummary } from './summary';
|
|
5
|
-
import { purchase} from '../functions/purchase';
|
|
5
|
+
import { purchase } from '../functions/purchase';
|
|
6
6
|
import { setup } from '../functions/setup';
|
|
7
7
|
|
|
8
8
|
export async function mountConfirmation({ payload: instrument }) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
) {
|
|
13
|
-
updateSummary({ instrument });
|
|
14
|
-
}
|
|
9
|
+
if (instrument.billingAddress && state.summary && state.data.isPurchase) {
|
|
10
|
+
updateSummary({ instrument });
|
|
11
|
+
}
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const modelSafeState = state.toModel();
|
|
22
|
-
const model = {
|
|
23
|
-
options: modelSafeState.options,
|
|
24
|
-
data: modelSafeState.data,
|
|
25
|
-
mainStyleVars: modelSafeState.mainStyleVars,
|
|
26
|
-
instrument
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
iframe?.component?.call('update', model);
|
|
13
|
+
const iframe = iframes.form;
|
|
14
|
+
if (!iframe) {
|
|
15
|
+
await mountForm();
|
|
16
|
+
}
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
const modelSafeState = state.toModel();
|
|
19
|
+
const model = {
|
|
20
|
+
options: modelSafeState.options,
|
|
21
|
+
data: modelSafeState.data,
|
|
22
|
+
mainStyleVars: modelSafeState.mainStyleVars,
|
|
23
|
+
instrument,
|
|
24
|
+
};
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
purchase({ payload: confirmedInstrument });
|
|
37
|
-
});
|
|
26
|
+
iframe?.component?.call('update', model);
|
|
38
27
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
iframe?.component?.call('route', {
|
|
29
|
+
name: 'confirmation',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
iframe?.component?.on(
|
|
33
|
+
`${iframe.name}-confirm-purchase`,
|
|
34
|
+
(confirmedInstrument) => {
|
|
35
|
+
purchase({ payload: confirmedInstrument });
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
iframe?.component?.on(
|
|
40
|
+
`${iframe.name}-confirm-setup`,
|
|
41
|
+
(confirmedInstrument) => {
|
|
42
|
+
setup({ payload: confirmedInstrument });
|
|
43
|
+
},
|
|
44
|
+
);
|
|
42
45
|
}
|