@rebilly/instruments 1.0.2-beta.8 → 2.1.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +13 -4
- package/.eslintrc.js +3 -0
- package/.prettierrc.js +11 -0
- package/README.md +15 -314
- package/dist/events/base-event.js +6 -9
- package/dist/events/events.spec.js +4 -4
- package/dist/events/index.js +2 -1
- package/dist/functions/destroy.js +12 -14
- package/dist/functions/destroy.spec.js +3 -3
- package/dist/functions/mount/fetch-data.js +183 -0
- package/dist/functions/mount/fetch-data.spec.js +189 -0
- package/dist/functions/mount/index.js +158 -251
- package/dist/functions/mount/mount.spec.js +24 -121
- package/dist/functions/mount/setup-element.js +40 -0
- package/dist/functions/mount/setup-framepay.js +46 -0
- package/dist/functions/mount/setup-i18n.js +33 -0
- package/dist/functions/mount/setup-options.js +96 -0
- package/dist/functions/mount/setup-options.spec.js +66 -0
- package/dist/functions/mount/setup-storefront.js +34 -0
- package/dist/functions/mount/setup-styles.js +43 -0
- package/dist/functions/on.js +13 -4
- package/dist/functions/on.spec.js +19 -5
- package/dist/functions/purchase.js +139 -22
- package/dist/functions/purchase.spec.js +23 -19
- package/dist/functions/setup.js +85 -0
- package/dist/functions/setup.spec.js +87 -0
- package/dist/functions/show.js +31 -14
- package/dist/functions/show.spec.js +47 -18
- package/dist/functions/update.js +53 -27
- package/dist/functions/update.spec.js +40 -21
- package/dist/i18n/en.json +4 -1
- package/dist/i18n/es.json +4 -1
- package/dist/index.js +67 -56
- package/dist/index.spec.js +7 -27
- package/dist/loader/index.js +4 -3
- package/dist/storefront/index.js +33 -0
- package/dist/storefront/invoices.js +27 -0
- package/dist/storefront/models/base-model.js +18 -0
- package/dist/storefront/models/invoice-model.js +14 -0
- package/dist/storefront/models/plan-model.js +4 -35
- package/dist/storefront/models/product-model.js +4 -23
- package/dist/storefront/models/summary-model.js +12 -25
- package/dist/storefront/models/transaction-model.js +31 -0
- package/dist/storefront/payment-instruments.js +47 -0
- package/dist/storefront/payment-instruments.spec.js +55 -0
- package/dist/storefront/plans.js +15 -24
- package/dist/storefront/plans.spec.js +17 -44
- package/dist/storefront/products.js +16 -20
- package/dist/storefront/products.spec.js +25 -49
- package/dist/storefront/purchase.js +28 -16
- package/dist/storefront/purchase.spec.js +4 -22
- package/dist/storefront/ready-to-pay.js +26 -22
- package/dist/storefront/ready-to-pay.spec.js +25 -54
- package/dist/storefront/storefront.spec.js +1 -1
- package/dist/storefront/summary.js +27 -24
- package/dist/storefront/summary.spec.js +44 -86
- package/dist/storefront/transactions.js +27 -0
- package/dist/style/base/theme.js +3 -3
- package/dist/style/components/methods.js +43 -42
- package/dist/style/utils/color-values.js +1 -3
- package/dist/style/views/confirmation.js +0 -4
- package/dist/style/views/method-selector.js +1 -1
- package/dist/style/views/modal.js +3 -1
- package/dist/style/views/summary.js +5 -1
- package/dist/utils/format-currency.js +4 -2
- package/dist/utils/has-valid-css-selector.js +1 -1
- package/dist/utils/process-property-as-dom-element.js +0 -2
- package/dist/views/__snapshots__/summary.spec.js.snap +103 -113
- package/dist/views/common/iframe/base-iframe.js +10 -2
- package/dist/views/common/iframe/modal-iframe.js +44 -3
- package/dist/views/confirmation.js +44 -20
- package/dist/views/method-selector/express-methods/apple-pay.js +92 -0
- package/dist/views/method-selector/express-methods/google-pay.js +31 -0
- package/dist/views/method-selector/express-methods/paypal.js +19 -0
- package/dist/views/method-selector/generate-digital-wallet.js +68 -0
- package/dist/views/method-selector/generate-digital-wallet.spec.js +135 -0
- package/dist/views/method-selector/get-payment-methods.js +28 -8
- package/dist/views/method-selector/get-payment-methods.spec.js +25 -26
- package/dist/views/method-selector/index.js +55 -86
- package/dist/views/method-selector/method-selector.spec.js +80 -69
- package/dist/views/method-selector/mount-express-methods.js +38 -62
- package/dist/views/method-selector/mount-methods.js +18 -18
- package/dist/views/modal.js +21 -15
- package/dist/views/result.js +13 -16
- package/dist/views/summary.js +170 -114
- package/dist/views/summary.spec.js +72 -76
- package/package.json +5 -4
- package/src/events/base-event.js +15 -17
- package/src/events/events.spec.js +6 -4
- package/src/events/index.js +6 -3
- package/src/functions/destroy.js +12 -13
- package/src/functions/destroy.spec.js +30 -31
- package/src/functions/mount/fetch-data.js +148 -0
- package/src/functions/mount/fetch-data.spec.js +238 -0
- package/src/functions/mount/index.js +129 -244
- package/src/functions/mount/mount.spec.js +35 -139
- package/src/functions/mount/setup-element.js +26 -0
- package/src/functions/mount/setup-framepay.js +41 -0
- package/src/functions/mount/setup-i18n.js +19 -0
- package/src/functions/mount/setup-options.js +100 -0
- package/src/functions/mount/setup-options.spec.js +60 -0
- package/src/functions/mount/setup-storefront.js +24 -0
- package/src/functions/mount/setup-styles.js +30 -0
- package/src/functions/on.js +13 -8
- package/src/functions/on.spec.js +30 -17
- package/src/functions/purchase.js +101 -19
- package/src/functions/purchase.spec.js +18 -18
- package/src/functions/setup.js +48 -0
- package/src/functions/setup.spec.js +98 -0
- package/src/functions/show.js +20 -10
- package/src/functions/show.spec.js +43 -22
- package/src/functions/update.js +50 -27
- package/src/functions/update.spec.js +57 -22
- package/src/i18n/en.json +4 -1
- package/src/i18n/es.json +4 -1
- package/src/i18n/i18n.spec.js +6 -4
- package/src/i18n/index.js +14 -11
- package/src/index.js +41 -52
- package/src/index.spec.js +8 -37
- package/src/loader/index.js +51 -47
- package/src/loader/loader.spec.js +26 -19
- package/src/storefront/index.js +37 -7
- package/src/storefront/invoices.js +11 -0
- package/src/storefront/models/base-model.js +10 -0
- package/src/storefront/models/invoice-model.js +3 -0
- package/src/storefront/models/plan-model.js +3 -35
- package/src/storefront/models/product-model.js +3 -23
- package/src/storefront/models/ready-to-pay-model.js +3 -3
- package/src/storefront/models/summary-model.js +15 -29
- package/src/storefront/models/transaction-model.js +19 -0
- package/src/storefront/payment-instruments.js +30 -0
- package/src/storefront/payment-instruments.spec.js +69 -0
- package/src/storefront/plans.js +16 -23
- package/src/storefront/plans.spec.js +25 -54
- package/src/storefront/products.js +18 -22
- package/src/storefront/products.spec.js +23 -54
- package/src/storefront/purchase.js +14 -14
- package/src/storefront/purchase.spec.js +17 -29
- package/src/storefront/ready-to-pay.js +26 -23
- package/src/storefront/ready-to-pay.spec.js +41 -71
- package/src/storefront/storefront.spec.js +1 -1
- package/src/storefront/summary.js +26 -22
- package/src/storefront/summary.spec.js +60 -109
- package/src/storefront/transactions.js +11 -0
- package/src/style/base/theme.js +10 -8
- package/src/style/base/theme.spec.js +4 -2
- package/src/style/browserslist.js +1 -3
- package/src/style/components/button.js +3 -1
- package/src/style/components/forms/checkbox.js +3 -1
- package/src/style/components/index.js +1 -1
- package/src/style/components/loader.js +3 -1
- package/src/style/components/methods.js +43 -42
- package/src/style/helpers/index.js +1 -1
- package/src/style/index.js +2 -1
- package/src/style/utils/color-values.js +4 -4
- package/src/style/vendor/framepay.js +1 -1
- package/src/style/vendor/postmate.js +1 -1
- package/src/style/views/confirmation.js +0 -4
- package/src/style/views/index.js +1 -1
- package/src/style/views/method-selector.js +1 -1
- package/src/style/views/modal.js +4 -2
- package/src/style/views/summary.js +5 -1
- package/src/utils/add-dom-element.js +12 -13
- package/src/utils/format-currency.js +6 -2
- package/src/utils/has-valid-css-selector.js +2 -2
- package/src/utils/is-dom-element.js +1 -1
- package/src/utils/process-property-as-dom-element.js +27 -24
- package/src/utils/sleep.js +1 -1
- package/src/views/__snapshots__/summary.spec.js.snap +103 -113
- package/src/views/common/iframe/base-iframe.js +12 -4
- package/src/views/common/iframe/event-listeners.js +6 -6
- package/src/views/common/iframe/index.js +1 -1
- package/src/views/common/iframe/method-iframe.js +3 -6
- package/src/views/common/iframe/modal-iframe.js +42 -6
- package/src/views/common/iframe/view-iframe.js +3 -5
- package/src/views/common/render-utilities.js +3 -3
- package/src/views/confirmation.js +34 -25
- package/src/views/method-selector/express-methods/apple-pay.js +78 -0
- package/src/views/method-selector/express-methods/google-pay.js +24 -0
- package/src/views/method-selector/express-methods/paypal.js +7 -0
- package/src/views/method-selector/generate-digital-wallet.js +51 -0
- package/src/views/method-selector/generate-digital-wallet.spec.js +135 -0
- package/src/views/method-selector/get-method-data.js +7 -4
- package/src/views/method-selector/get-payment-methods.js +38 -29
- package/src/views/method-selector/get-payment-methods.spec.js +26 -33
- package/src/views/method-selector/index.js +70 -99
- package/src/views/method-selector/method-selector.spec.js +88 -78
- package/src/views/method-selector/mount-express-methods.js +36 -60
- package/src/views/method-selector/mount-methods.js +32 -21
- package/src/views/modal.js +37 -23
- package/src/views/result.js +12 -15
- package/src/views/summary.js +169 -101
- package/src/views/summary.spec.js +99 -74
- package/tests/async-utilities.js +22 -0
- package/tests/mocks/rebilly-instruments-mock.js +89 -77
- package/tests/mocks/storefront-api-mock.js +8 -0
- package/tests/mocks/storefront-mock.js +17 -0
- package/dist/events/purchase-completed.js +0 -24
- package/dist/functions/initialize.js +0 -82
- package/dist/functions/initialize.spec.js +0 -34
- package/dist/functions/mount/fetch-summary-data.js +0 -31
- package/dist/functions/mount/fetch-summary-data.spec.js +0 -45
- package/dist/views/method-selector/process-digital-wallet-options.js +0 -35
- package/dist/views/method-selector/process-digital-wallet-options.spec.js +0 -80
- package/src/events/purchase-completed.js +0 -11
- package/src/functions/initialize.js +0 -74
- package/src/functions/initialize.spec.js +0 -38
- package/src/functions/mount/fetch-summary-data.js +0 -26
- package/src/functions/mount/fetch-summary-data.spec.js +0 -46
- package/src/views/method-selector/process-digital-wallet-options.js +0 -16
- package/src/views/method-selector/process-digital-wallet-options.spec.js +0 -94
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _summaryModel = _interopRequireDefault(require("
|
|
3
|
+
var _summaryModel = _interopRequireDefault(require("../../storefront/models/summary-model"));
|
|
4
4
|
|
|
5
|
-
var _readyToPayModel = _interopRequireDefault(require("
|
|
5
|
+
var _readyToPayModel = _interopRequireDefault(require("../../storefront/models/ready-to-pay-model"));
|
|
6
6
|
|
|
7
7
|
var _loader = require("../../loader");
|
|
8
8
|
|
|
@@ -10,6 +10,14 @@ var _i18n = require("../../i18n");
|
|
|
10
10
|
|
|
11
11
|
var _index = require("./index");
|
|
12
12
|
|
|
13
|
+
var _asyncUtilities = require("../../../tests/async-utilities");
|
|
14
|
+
|
|
15
|
+
var _storefrontMock = require("../../../tests/mocks/storefront-mock");
|
|
16
|
+
|
|
17
|
+
var _fetchData = require("../../functions/mount/fetch-data");
|
|
18
|
+
|
|
19
|
+
var _setupOptions = _interopRequireDefault(require("../../functions/mount/setup-options"));
|
|
20
|
+
|
|
13
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
22
|
|
|
15
23
|
describe('Summary component', () => {
|
|
@@ -21,93 +29,96 @@ describe('Summary component', () => {
|
|
|
21
29
|
|
|
22
30
|
class TestMountMethodSelectorInstance {
|
|
23
31
|
constructor({
|
|
24
|
-
configs = {},
|
|
25
32
|
options = {},
|
|
26
33
|
form = formElement,
|
|
27
34
|
loader = new _loader.Loader(),
|
|
28
|
-
translate = new _i18n.Translate()
|
|
29
|
-
zoidComponents = {}
|
|
35
|
+
translate = new _i18n.Translate()
|
|
30
36
|
} = {}) {
|
|
31
|
-
this.
|
|
32
|
-
|
|
37
|
+
this.options = (0, _setupOptions.default)({
|
|
38
|
+
options
|
|
39
|
+
});
|
|
33
40
|
this.form = form;
|
|
34
41
|
this.loader = loader;
|
|
35
42
|
this.translate = translate;
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
this.storefront = (0, _storefrontMock.MockStorefront)();
|
|
44
|
+
this.data = new _fetchData.DataInstance({
|
|
45
|
+
state: {
|
|
46
|
+
options
|
|
47
|
+
},
|
|
48
|
+
previewPurchase: new _summaryModel.default({
|
|
49
|
+
currency: 'USD',
|
|
50
|
+
lineItems: [{
|
|
51
|
+
type: 'debit',
|
|
52
|
+
description: 'My Awesome Product',
|
|
53
|
+
unitPrice: 30,
|
|
54
|
+
quantity: 1,
|
|
55
|
+
price: 30,
|
|
56
|
+
productId: 'my-awesome-product',
|
|
57
|
+
planId: 'my-awesome-product'
|
|
58
|
+
}, {
|
|
59
|
+
type: 'debit',
|
|
60
|
+
description: 'Awesome T-Shirt',
|
|
61
|
+
unitPrice: 20,
|
|
62
|
+
quantity: 2,
|
|
63
|
+
price: 40,
|
|
64
|
+
productId: 'my-app',
|
|
65
|
+
planId: 'awesome-t-shirt'
|
|
66
|
+
}],
|
|
67
|
+
subtotalAmount: 70,
|
|
68
|
+
taxAmount: 0,
|
|
69
|
+
shippingAmount: 0,
|
|
70
|
+
discountsAmount: 0,
|
|
71
|
+
total: 70
|
|
72
|
+
}),
|
|
73
|
+
readyToPay: [new _readyToPayModel.default({
|
|
74
|
+
method: 'payment-card',
|
|
75
|
+
feature: {
|
|
76
|
+
name: 'Google Pay',
|
|
77
|
+
merchantName: 'google-pay-merchant-name',
|
|
78
|
+
merchantOrigin: 'google-pay-merchant-origin'
|
|
79
|
+
},
|
|
80
|
+
brands: ['Visa'],
|
|
81
|
+
filters: []
|
|
82
|
+
})]
|
|
83
|
+
});
|
|
42
84
|
}
|
|
43
85
|
|
|
44
86
|
}
|
|
45
87
|
|
|
46
88
|
const options = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
thumbnail: ''
|
|
53
|
-
}, {
|
|
54
|
-
planId: 'awesome-t-shirt',
|
|
55
|
-
quantity: 2,
|
|
56
|
-
thumbnail: ''
|
|
57
|
-
}]
|
|
58
|
-
},
|
|
59
|
-
paymentInstruments: {
|
|
60
|
-
compactExpressInstruments: true
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const summaryData = new _summaryModel.default({
|
|
64
|
-
currency: "USD",
|
|
65
|
-
lineItems: [{
|
|
66
|
-
type: "debit",
|
|
67
|
-
description: "My Awesome Product",
|
|
68
|
-
unitPrice: 30,
|
|
69
|
-
quantity: 1,
|
|
70
|
-
price: 30,
|
|
71
|
-
productId: "my-awesome-product",
|
|
72
|
-
planId: "my-awesome-product"
|
|
89
|
+
websiteId: 'test-website-id',
|
|
90
|
+
countryCode: 'US',
|
|
91
|
+
items: [{
|
|
92
|
+
planId: 'my-awesome-product',
|
|
93
|
+
quantity: 1
|
|
73
94
|
}, {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
unitPrice: 20,
|
|
77
|
-
quantity: 2,
|
|
78
|
-
price: 40,
|
|
79
|
-
productId: "my-app",
|
|
80
|
-
planId: "awesome-t-shirt"
|
|
95
|
+
planId: 'awesome-t-shirt',
|
|
96
|
+
quantity: 2
|
|
81
97
|
}],
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
discountsAmount: 0,
|
|
86
|
-
total: 70
|
|
87
|
-
});
|
|
88
|
-
const readyToPayData = [new _readyToPayModel.default({
|
|
89
|
-
method: 'payment-card',
|
|
90
|
-
feature: {
|
|
91
|
-
name: 'Google Pay',
|
|
92
|
-
merchantName: 'google-pay-merchant-name',
|
|
93
|
-
merchantOrigin: 'google-pay-merchant-origin'
|
|
94
|
-
},
|
|
95
|
-
brands: ['Visa'],
|
|
96
|
-
filters: []
|
|
97
|
-
})];
|
|
98
|
-
const configs = {
|
|
99
|
-
websiteId: 'test-website-id'
|
|
98
|
+
_computed: {
|
|
99
|
+
paymentMethodsUrl: ''
|
|
100
|
+
}
|
|
100
101
|
};
|
|
101
|
-
it('should inject the proper HTML for express methods', () => {
|
|
102
|
+
it('should inject the proper HTML for express methods', async () => {
|
|
102
103
|
const mountSummaryInstance = new TestMountMethodSelectorInstance({
|
|
103
|
-
configs,
|
|
104
104
|
options
|
|
105
105
|
});
|
|
106
|
-
mountSummaryInstance.
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
mountSummaryInstance.loader.DOM.form = mountSummaryInstance.form;
|
|
107
|
+
(0, _index.mountMethodSelector)({
|
|
108
|
+
state: mountSummaryInstance
|
|
109
109
|
});
|
|
110
110
|
const form = document.querySelector('.rebilly-instruments-form');
|
|
111
111
|
expect(form).toMatchSnapshot();
|
|
112
|
+
await (0, _asyncUtilities.avoidUnhandledPromises)();
|
|
113
|
+
});
|
|
114
|
+
it('should allow updating method selector', async () => {
|
|
115
|
+
const state = new TestMountMethodSelectorInstance({
|
|
116
|
+
options
|
|
117
|
+
});
|
|
118
|
+
state.loader.DOM.form = state.form;
|
|
119
|
+
await (0, _index.updateMethodSelector)({
|
|
120
|
+
state,
|
|
121
|
+
mainStyle: 'any main style'
|
|
122
|
+
});
|
|
112
123
|
});
|
|
113
124
|
});
|
|
@@ -5,88 +5,64 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.mountExpressMethods = mountExpressMethods;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _googlePay = _interopRequireDefault(require("./express-methods/google-pay"));
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
/* eslint-disable no-undef */
|
|
13
|
-
async function mountGooglePay({
|
|
14
|
-
methodId
|
|
15
|
-
}) {
|
|
16
|
-
const container = document.querySelector('.rebilly-instruments-express-methods');
|
|
17
|
-
const {
|
|
18
|
-
paymentMethodsUrl
|
|
19
|
-
} = this.options._computed;
|
|
20
|
-
const model = {
|
|
21
|
-
configs: this.configs,
|
|
22
|
-
options: this.options
|
|
23
|
-
};
|
|
24
|
-
const iframe = await new _iframe.MethodIframe({
|
|
25
|
-
name: methodId,
|
|
26
|
-
url: `${paymentMethodsUrl}/${methodId}`,
|
|
27
|
-
container,
|
|
28
|
-
model
|
|
29
|
-
});
|
|
30
|
-
iframe.bindEventListeners({
|
|
31
|
-
loader: this.loader
|
|
32
|
-
});
|
|
33
|
-
this.iframeComponents.push(iframe);
|
|
34
|
-
}
|
|
10
|
+
var _applePay = _interopRequireDefault(require("./express-methods/apple-pay"));
|
|
35
11
|
|
|
36
|
-
|
|
37
|
-
EXPRESS_METHODS_CONTAINER,
|
|
38
|
-
METHOD_ID,
|
|
39
|
-
METHOD_TYPE
|
|
40
|
-
}) {
|
|
41
|
-
EXPRESS_METHODS_CONTAINER.innerHTML += `
|
|
42
|
-
<div id="rebilly-instruments-${METHOD_ID}" data-rebilly-instruments-express-type="${METHOD_TYPE}"></div>
|
|
43
|
-
`;
|
|
44
|
-
Rebilly.applePay.mount(`#rebilly-instruments-${METHOD_ID}`);
|
|
45
|
-
Rebilly.on('token-ready', token => {
|
|
46
|
-
dispatch('instrument-ready', token);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
12
|
+
var _paypal = _interopRequireDefault(require("./express-methods/paypal"));
|
|
49
13
|
|
|
50
|
-
|
|
51
|
-
console.log('PayPal - work in progress');
|
|
52
|
-
this.loader.stopLoading({
|
|
53
|
-
id: 'paypal-express'
|
|
54
|
-
});
|
|
55
|
-
}
|
|
14
|
+
var _getMethodData = require("./get-method-data");
|
|
56
15
|
|
|
57
|
-
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
58
17
|
|
|
59
18
|
function mountExpressMethods({
|
|
19
|
+
state,
|
|
60
20
|
EXPRESS_METHODS,
|
|
61
21
|
EXPRESS_METHODS_CONTAINER
|
|
62
22
|
}) {
|
|
23
|
+
// A child div for each method must be created before mounting.
|
|
24
|
+
// Any DOM operation (innerHTML, append, etc) done on the parent div (EXPRESS_METHODS_CONTAINER) in between
|
|
25
|
+
// the two Postmate's instantiation (1 parent, 1 child) will cause the parent <-> child handshake to fail
|
|
26
|
+
EXPRESS_METHODS.forEach(expressMethod => {
|
|
27
|
+
const {
|
|
28
|
+
METHOD_ID
|
|
29
|
+
} = (0, _getMethodData.getMethodData)(expressMethod);
|
|
30
|
+
EXPRESS_METHODS_CONTAINER.innerHTML += `
|
|
31
|
+
<div class="rebilly-instruments-${METHOD_ID}-method"></div>
|
|
32
|
+
`;
|
|
33
|
+
});
|
|
63
34
|
EXPRESS_METHODS.forEach(expressMethod => {
|
|
64
35
|
const {
|
|
65
36
|
method,
|
|
66
37
|
feature
|
|
67
38
|
} = expressMethod;
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
;
|
|
39
|
+
const {
|
|
40
|
+
METHOD_ID,
|
|
41
|
+
METHOD_TYPE
|
|
42
|
+
} = (0, _getMethodData.getMethodData)(expressMethod);
|
|
75
43
|
|
|
76
44
|
if ((feature === null || feature === void 0 ? void 0 : feature.name) === 'Google Pay') {
|
|
77
|
-
|
|
78
|
-
|
|
45
|
+
(0, _googlePay.default)({
|
|
46
|
+
state,
|
|
47
|
+
METHOD_ID
|
|
79
48
|
});
|
|
80
49
|
}
|
|
81
50
|
|
|
82
|
-
if ((feature === null || feature === void 0 ? void 0 : feature.name) === 'Apple Pay'
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
51
|
+
if ((feature === null || feature === void 0 ? void 0 : feature.name) === 'Apple Pay') {
|
|
52
|
+
(0, _applePay.default)({
|
|
53
|
+
state,
|
|
54
|
+
METHOD_ID,
|
|
55
|
+
METHOD_TYPE,
|
|
56
|
+
EXPRESS_METHODS,
|
|
57
|
+
EXPRESS_METHODS_CONTAINER
|
|
86
58
|
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (method === 'paypal') {
|
|
62
|
+
(0, _paypal.default)({
|
|
63
|
+
state,
|
|
64
|
+
METHOD_ID,
|
|
65
|
+
METHOD_TYPE
|
|
90
66
|
});
|
|
91
67
|
}
|
|
92
68
|
});
|
|
@@ -7,6 +7,8 @@ exports.MountMethods = MountMethods;
|
|
|
7
7
|
|
|
8
8
|
var _lodash = _interopRequireDefault(require("lodash.camelcase"));
|
|
9
9
|
|
|
10
|
+
var _modal = require("../modal");
|
|
11
|
+
|
|
10
12
|
var _iframe = require("../common/iframe");
|
|
11
13
|
|
|
12
14
|
var _getMethodData = require("./get-method-data");
|
|
@@ -14,14 +16,12 @@ var _getMethodData = require("./get-method-data");
|
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
17
|
|
|
16
18
|
function MountMethods({
|
|
19
|
+
state,
|
|
17
20
|
METHODS_CONTAINER,
|
|
18
|
-
METHODS
|
|
19
|
-
mainStyle,
|
|
20
|
-
plans,
|
|
21
|
-
products
|
|
21
|
+
METHODS
|
|
22
22
|
}) {
|
|
23
23
|
METHODS.forEach(async method => {
|
|
24
|
-
var
|
|
24
|
+
var _state$options$paymen;
|
|
25
25
|
|
|
26
26
|
const {
|
|
27
27
|
METHOD_ID: methodId,
|
|
@@ -29,16 +29,15 @@ function MountMethods({
|
|
|
29
29
|
} = (0, _getMethodData.getMethodData)(method);
|
|
30
30
|
const {
|
|
31
31
|
paymentMethodsUrl
|
|
32
|
-
} =
|
|
32
|
+
} = state.options._computed || 'https://www.example.com';
|
|
33
33
|
const selector = `rebilly-instruments-${methodId}`;
|
|
34
|
-
const isiFrame = methodId === 'payment-card' && !((
|
|
34
|
+
const isiFrame = methodId === 'payment-card' && !((_state$options$paymen = state.options.paymentInstruments[methodType]) !== null && _state$options$paymen !== void 0 && _state$options$paymen.popup);
|
|
35
35
|
const model = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
products
|
|
36
|
+
options: state.options,
|
|
37
|
+
mainStyle: state.mainStyle,
|
|
38
|
+
plans: state.data.plans,
|
|
39
|
+
products: state.data.products,
|
|
40
|
+
method
|
|
42
41
|
};
|
|
43
42
|
METHODS_CONTAINER.insertAdjacentHTML('beforeend', `<div id="${selector}" data-rebilly-instruments-type="${methodId}"></div>`);
|
|
44
43
|
const container = document.querySelector(`#${selector}`);
|
|
@@ -51,22 +50,23 @@ function MountMethods({
|
|
|
51
50
|
model
|
|
52
51
|
});
|
|
53
52
|
iframe.bindEventListeners({
|
|
54
|
-
loader:
|
|
53
|
+
loader: state.loader,
|
|
55
54
|
id: method.method
|
|
56
55
|
});
|
|
57
|
-
|
|
56
|
+
state.iframeComponents.push(iframe);
|
|
58
57
|
} else {
|
|
59
58
|
container.insertAdjacentHTML('beforeend', `<button class="${selector} rebilly-instruments-button" data-rebilly-i18n="paymentMethods.${method.method}">${(0, _lodash.default)(method.method)}</button>`);
|
|
60
59
|
const paymentCardButton = document.querySelector(`.${selector}`);
|
|
61
60
|
paymentCardButton.addEventListener('click', async () => {
|
|
62
|
-
const iframe = await
|
|
61
|
+
const iframe = await (0, _modal.mountModal)({
|
|
62
|
+
state,
|
|
63
63
|
name: methodId,
|
|
64
64
|
url: `${paymentMethodsUrl}/${methodId}`,
|
|
65
65
|
model
|
|
66
66
|
});
|
|
67
|
-
|
|
67
|
+
state.iframeComponents.push(iframe);
|
|
68
68
|
});
|
|
69
|
-
|
|
69
|
+
state.loader.stopLoading({
|
|
70
70
|
id: method.method
|
|
71
71
|
});
|
|
72
72
|
}
|
package/dist/views/modal.js
CHANGED
|
@@ -3,33 +3,36 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.mountModal = mountModal;
|
|
7
7
|
|
|
8
8
|
var _iframe = require("./common/iframe");
|
|
9
9
|
|
|
10
10
|
const modalTemplate = (isRedirect, method) => `
|
|
11
11
|
<div class="rebilly-instruments-modal-overlay">
|
|
12
12
|
<div class="rebilly-instruments-modal-container ${method ? `rebilly-instruments-${method}` : ''} ${isRedirect ? 'is-redirect' : ''}">
|
|
13
|
+
${isRedirect ? '' : `
|
|
13
14
|
<svg class="rebilly-instruments-modal-close" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg">
|
|
14
15
|
<path d="m15 13.5858 7.2929-7.293c.3905-.3904 1.0237-.3904 1.4142 0 .3905.3906.3905 1.0238 0 1.4143L16.4142 15l7.293 7.2929c.3904.3905.3904 1.0237 0 1.4142-.3906.3905-1.0238.3905-1.4143 0L15 16.4142l-7.2929 7.293c-.3905.3904-1.0237.3904-1.4142 0-.3905-.3906-.3905-1.0238 0-1.4143L13.5858 15l-7.293-7.2929c-.3904-.3905-.3904-1.0237 0-1.4142.3906-.3905 1.0238-.3905 1.4143 0L15 13.5858Z" fill-rule="nonzero"/>
|
|
15
16
|
</svg>
|
|
17
|
+
`}
|
|
16
18
|
<div class="rebilly-instruments-modal-content"></div>
|
|
17
19
|
</div>
|
|
18
20
|
</div>
|
|
19
21
|
`;
|
|
20
22
|
|
|
21
|
-
async function
|
|
23
|
+
async function mountModal({
|
|
22
24
|
name = '',
|
|
23
25
|
url = '',
|
|
24
26
|
model = {},
|
|
25
27
|
classListArray = [],
|
|
26
|
-
close = () => {}
|
|
28
|
+
close = () => {},
|
|
29
|
+
state = null
|
|
27
30
|
} = {}) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
var _model$method;
|
|
32
|
+
|
|
33
|
+
const method = model === null || model === void 0 ? void 0 : (_model$method = model.method) === null || _model$method === void 0 ? void 0 : _model$method.method;
|
|
31
34
|
const isRedirect = name === 'rebilly-instruments-approval-url';
|
|
32
|
-
|
|
35
|
+
state.form.insertAdjacentHTML('beforeend', modalTemplate(isRedirect, method));
|
|
33
36
|
const modalOverlay = document.querySelector('.rebilly-instruments-modal-overlay');
|
|
34
37
|
const modalContainer = document.querySelector('.rebilly-instruments-modal-container');
|
|
35
38
|
const closeButton = document.querySelector('.rebilly-instruments-modal-close');
|
|
@@ -39,20 +42,20 @@ async function MountModal({
|
|
|
39
42
|
modalOverlay.classList.add('is-visible');
|
|
40
43
|
modalContainer.classList.add('is-visible');
|
|
41
44
|
}, 240);
|
|
42
|
-
|
|
45
|
+
state.loader.addDOMElement({
|
|
43
46
|
section: 'modal',
|
|
44
47
|
el: modalContent
|
|
45
48
|
});
|
|
46
|
-
|
|
49
|
+
state.loader.startLoading({
|
|
47
50
|
section: 'modal',
|
|
48
51
|
id: 'modal-content'
|
|
49
52
|
});
|
|
50
53
|
const injectedModel = {
|
|
51
|
-
|
|
52
|
-
options: this.options,
|
|
54
|
+
options: state.options,
|
|
53
55
|
...model
|
|
54
56
|
};
|
|
55
57
|
const iframe = await new _iframe.ModalIframe({
|
|
58
|
+
state,
|
|
56
59
|
name,
|
|
57
60
|
url,
|
|
58
61
|
model: injectedModel,
|
|
@@ -68,15 +71,18 @@ async function MountModal({
|
|
|
68
71
|
modalOverlay.children.forEach(child => child.remove());
|
|
69
72
|
modalOverlay.remove();
|
|
70
73
|
close(...args);
|
|
71
|
-
iframe.
|
|
74
|
+
iframe.destroy();
|
|
72
75
|
}, 300);
|
|
73
76
|
};
|
|
74
77
|
|
|
75
78
|
iframe.bindEventListeners({
|
|
76
79
|
close: closeModal,
|
|
77
|
-
loader:
|
|
80
|
+
loader: state.loader
|
|
78
81
|
});
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
|
|
83
|
+
if (!isRedirect) {
|
|
84
|
+
closeButton.addEventListener('click', closeModal);
|
|
85
|
+
}
|
|
86
|
+
|
|
81
87
|
return iframe;
|
|
82
88
|
}
|
package/dist/views/result.js
CHANGED
|
@@ -3,30 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.mountResult = mountResult;
|
|
7
7
|
|
|
8
8
|
var _iframe = require("./common/iframe");
|
|
9
9
|
|
|
10
10
|
var _renderUtilities = require("./common/render-utilities");
|
|
11
11
|
|
|
12
|
-
async function
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
async function mountResult({
|
|
13
|
+
payload,
|
|
14
|
+
state
|
|
15
15
|
}) {
|
|
16
16
|
const resultContainerClassName = 'rebilly-instruments-result';
|
|
17
|
-
(0, _renderUtilities.replaceContent)(
|
|
18
|
-
|
|
17
|
+
(0, _renderUtilities.replaceContent)(state.form, `<div class="${resultContainerClassName}"></div>`);
|
|
18
|
+
state.loader.startLoading({
|
|
19
19
|
id: 'result'
|
|
20
20
|
});
|
|
21
21
|
const container = document.querySelector(`.${resultContainerClassName}`);
|
|
22
22
|
const {
|
|
23
23
|
paymentMethodsUrl
|
|
24
|
-
} =
|
|
24
|
+
} = state.options._computed;
|
|
25
25
|
const model = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
purchase
|
|
26
|
+
options: state.options,
|
|
27
|
+
mainStyle: state.mainStyle,
|
|
28
|
+
[state.options.transactionType]: payload
|
|
30
29
|
};
|
|
31
30
|
const iframe = await new _iframe.ViewIframe({
|
|
32
31
|
name: 'rebilly-instruments-result',
|
|
@@ -35,9 +34,7 @@ async function MountResult({
|
|
|
35
34
|
model
|
|
36
35
|
});
|
|
37
36
|
iframe.bindEventListeners({
|
|
38
|
-
loader:
|
|
37
|
+
loader: state.loader
|
|
39
38
|
});
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
;
|
|
39
|
+
state.iframeComponents.push(iframe);
|
|
40
|
+
}
|