@rebilly/instruments 3.1.0-beta.0 → 3.1.4-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +88 -107
- package/dist/index.min.js +88 -0
- package/package.json +17 -6
- package/rollup.config.js +84 -0
- package/src/functions/mount/fetch-data.js +13 -1
- package/src/functions/mount/index.js +6 -42
- package/src/functions/mount/setup-framepay-theme.js +2 -2
- package/src/functions/mount/setup-options.js +3 -0
- package/src/functions/mount/setup-user-flow.js +49 -0
- package/src/functions/purchase.js +1 -1
- package/src/functions/setup.js +1 -1
- package/src/functions/show.spec.js +1 -1
- package/src/i18n/en.json +3 -0
- package/src/index.js +1 -61
- package/src/instance.js +65 -0
- package/src/{index.spec.js → instance.spec.js} +2 -1
- package/src/loader/index.js +21 -1
- package/src/storefront/models/ready-to-pay-model.js +13 -2
- package/src/storefront/plans.js +8 -4
- package/src/storefront/plans.spec.js +8 -2
- package/src/storefront/products.js +8 -4
- package/src/storefront/products.spec.js +8 -2
- package/src/storefront/ready-to-pay.js +5 -4
- package/src/style/components/button.js +1 -0
- package/src/style/components/loader.js +2 -1
- package/src/style/payment-instruments/payment-card.js +2 -1
- package/src/style/utils/remove-empty-null.js +9 -9
- package/src/style/vendor/postmate.js +13 -0
- package/src/style/views/confirmation.js +2 -1
- package/src/views/common/iframe/base-iframe.js +2 -0
- package/src/views/common/iframe/event-listeners.js +10 -0
- package/src/views/common/iframe/method-iframe.js +3 -1
- package/src/views/confirmation.js +1 -0
- package/src/views/method-selector/express-methods/{google-pay.js → index.js} +3 -2
- package/src/views/method-selector/mount-express-methods.js +6 -18
- package/src/views/result.js +1 -0
- package/tests/mocks/rebilly-instruments-mock.js +2 -2
- package/dist/events/base-event.js +0 -66
- package/dist/events/events.spec.js +0 -18
- package/dist/events/index.js +0 -22
- package/dist/functions/destroy.js +0 -34
- package/dist/functions/destroy.spec.js +0 -69
- package/dist/functions/mount/fetch-data.js +0 -187
- package/dist/functions/mount/fetch-data.spec.js +0 -189
- package/dist/functions/mount/index.js +0 -218
- package/dist/functions/mount/mount.spec.js +0 -64
- package/dist/functions/mount/setup-element.js +0 -40
- package/dist/functions/mount/setup-framepay-theme.js +0 -95
- package/dist/functions/mount/setup-framepay.js +0 -46
- package/dist/functions/mount/setup-i18n.js +0 -33
- package/dist/functions/mount/setup-options.js +0 -99
- package/dist/functions/mount/setup-options.spec.js +0 -66
- package/dist/functions/mount/setup-storefront.js +0 -34
- package/dist/functions/mount/setup-styles.js +0 -43
- package/dist/functions/on.js +0 -40
- package/dist/functions/on.spec.js +0 -55
- package/dist/functions/purchase.js +0 -158
- package/dist/functions/purchase.spec.js +0 -74
- package/dist/functions/setup.js +0 -85
- package/dist/functions/setup.spec.js +0 -87
- package/dist/functions/show.js +0 -55
- package/dist/functions/show.spec.js +0 -61
- package/dist/functions/update.js +0 -74
- package/dist/functions/update.spec.js +0 -86
- package/dist/i18n/en.json +0 -22
- package/dist/i18n/es.json +0 -22
- package/dist/i18n/i18n.spec.js +0 -22
- package/dist/i18n/index.js +0 -72
- package/dist/index.spec.js +0 -35
- package/dist/loader/index.js +0 -94
- package/dist/loader/loader.spec.js +0 -69
- package/dist/storefront/index.js +0 -73
- package/dist/storefront/invoices.js +0 -27
- package/dist/storefront/models/base-model.js +0 -18
- package/dist/storefront/models/invoice-model.js +0 -14
- package/dist/storefront/models/plan-model.js +0 -14
- package/dist/storefront/models/product-model.js +0 -14
- package/dist/storefront/models/ready-to-pay-model.js +0 -46
- package/dist/storefront/models/summary-model.js +0 -79
- package/dist/storefront/models/transaction-model.js +0 -31
- package/dist/storefront/payment-instruments.js +0 -47
- package/dist/storefront/payment-instruments.spec.js +0 -55
- package/dist/storefront/plans.js +0 -37
- package/dist/storefront/plans.spec.js +0 -64
- package/dist/storefront/products.js +0 -40
- package/dist/storefront/products.spec.js +0 -65
- package/dist/storefront/purchase.js +0 -43
- package/dist/storefront/purchase.spec.js +0 -48
- package/dist/storefront/ready-to-pay.js +0 -58
- package/dist/storefront/ready-to-pay.spec.js +0 -69
- package/dist/storefront/storefront.spec.js +0 -15
- package/dist/storefront/summary.js +0 -55
- package/dist/storefront/summary.spec.js +0 -124
- package/dist/storefront/transactions.js +0 -27
- package/dist/style/base/__snapshots__/theme.spec.js.snap +0 -227
- package/dist/style/base/default-theme.js +0 -804
- package/dist/style/base/index.js +0 -104
- package/dist/style/base/theme.js +0 -41
- package/dist/style/base/theme.spec.js +0 -19
- package/dist/style/browserslist.js +0 -8
- package/dist/style/components/address.js +0 -64
- package/dist/style/components/button.js +0 -87
- package/dist/style/components/divider.js +0 -48
- package/dist/style/components/forms/checkbox.js +0 -86
- package/dist/style/components/forms/field.js +0 -65
- package/dist/style/components/forms/form.js +0 -28
- package/dist/style/components/forms/input.js +0 -86
- package/dist/style/components/forms/label.js +0 -64
- package/dist/style/components/forms/select.js +0 -95
- package/dist/style/components/forms/validation.js +0 -81
- package/dist/style/components/icons.js +0 -22
- package/dist/style/components/index.js +0 -57
- package/dist/style/components/loader.js +0 -50
- package/dist/style/components/methods.js +0 -108
- package/dist/style/components/overlay.js +0 -33
- package/dist/style/helpers/index.js +0 -59
- package/dist/style/index.js +0 -50
- package/dist/style/payment-instruments/content.js +0 -17
- package/dist/style/payment-instruments/index.js +0 -20
- package/dist/style/payment-instruments/payment-card.js +0 -35
- package/dist/style/utils/border.js +0 -47
- package/dist/style/utils/color-values.js +0 -58
- package/dist/style/utils/remove-empty-null.js +0 -20
- package/dist/style/vendor/framepay.js +0 -37
- package/dist/style/vendor/postmate.js +0 -17
- package/dist/style/views/confirmation.js +0 -85
- package/dist/style/views/index.js +0 -29
- package/dist/style/views/method-selector.js +0 -20
- package/dist/style/views/modal.js +0 -93
- package/dist/style/views/result.js +0 -61
- package/dist/style/views/summary.js +0 -127
- package/dist/utils/add-dom-element.js +0 -26
- package/dist/utils/format-currency.js +0 -15
- package/dist/utils/has-valid-css-selector.js +0 -11
- package/dist/utils/index.js +0 -55
- package/dist/utils/is-dom-element.js +0 -10
- package/dist/utils/process-property-as-dom-element.js +0 -38
- package/dist/utils/sleep.js +0 -10
- package/dist/views/__snapshots__/summary.spec.js.snap +0 -246
- package/dist/views/common/iframe/base-iframe.js +0 -59
- package/dist/views/common/iframe/event-listeners.js +0 -50
- package/dist/views/common/iframe/index.js +0 -19
- package/dist/views/common/iframe/method-iframe.js +0 -33
- package/dist/views/common/iframe/modal-iframe.js +0 -84
- package/dist/views/common/iframe/view-iframe.js +0 -31
- package/dist/views/common/render-utilities.js +0 -11
- package/dist/views/confirmation.js +0 -92
- package/dist/views/method-selector/__snapshots__/method-selector.spec.js.snap +0 -3
- package/dist/views/method-selector/express-methods/apple-pay.js +0 -92
- package/dist/views/method-selector/express-methods/google-pay.js +0 -31
- package/dist/views/method-selector/express-methods/paypal.js +0 -19
- package/dist/views/method-selector/generate-digital-wallet.js +0 -68
- package/dist/views/method-selector/generate-digital-wallet.spec.js +0 -135
- package/dist/views/method-selector/get-method-data.js +0 -25
- package/dist/views/method-selector/get-payment-methods.js +0 -66
- package/dist/views/method-selector/get-payment-methods.spec.js +0 -46
- package/dist/views/method-selector/index.js +0 -122
- package/dist/views/method-selector/method-selector.spec.js +0 -124
- package/dist/views/method-selector/mount-express-methods.js +0 -69
- package/dist/views/method-selector/mount-methods.js +0 -74
- package/dist/views/modal.js +0 -88
- package/dist/views/result.js +0 -40
- package/dist/views/summary.js +0 -215
- package/dist/views/summary.spec.js +0 -134
- package/src/views/method-selector/express-methods/paypal.js +0 -7
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mountMethodSelector = mountMethodSelector;
|
|
7
|
-
exports.updateMethodSelector = updateMethodSelector;
|
|
8
|
-
exports.baseMethodSelectorHTML = void 0;
|
|
9
|
-
|
|
10
|
-
var _riskDataCollector = require("@rebilly/risk-data-collector");
|
|
11
|
-
|
|
12
|
-
var _getPaymentMethods = require("./get-payment-methods");
|
|
13
|
-
|
|
14
|
-
var _mountExpressMethods = require("./mount-express-methods");
|
|
15
|
-
|
|
16
|
-
var _generateDigitalWallet = require("./generate-digital-wallet");
|
|
17
|
-
|
|
18
|
-
var _mountMethods = require("./mount-methods");
|
|
19
|
-
|
|
20
|
-
var _fetchData = require("../../functions/mount/fetch-data");
|
|
21
|
-
|
|
22
|
-
/* eslint-disable no-undef */
|
|
23
|
-
const baseMethodSelectorHTML = compactExpressInstruments => `
|
|
24
|
-
<div class="rebilly-instruments-content">
|
|
25
|
-
<div class="rebilly-instruments-method-selector ${compactExpressInstruments ? 'has-express-compact' : ''}">
|
|
26
|
-
<div class="rebilly-instruments-express-methods ${compactExpressInstruments ? 'is-compact' : ''}">
|
|
27
|
-
<span data-rebilly-i18n="form.expressCheckout" class="rebilly-instruments-express-methods-label">Express checkout</span>
|
|
28
|
-
<div class="rebilly-instruments-express-methods-container"></div>
|
|
29
|
-
</div>
|
|
30
|
-
<div class="rebilly-instruments-divider">
|
|
31
|
-
<span class="rebilly-instruments-divider-label" data-rebilly-i18n="form.or">Or</span>
|
|
32
|
-
</div>
|
|
33
|
-
<div class="rebilly-instruments-methods"></div>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
exports.baseMethodSelectorHTML = baseMethodSelectorHTML;
|
|
39
|
-
|
|
40
|
-
function mountMethodSelector({
|
|
41
|
-
state
|
|
42
|
-
}) {
|
|
43
|
-
const {
|
|
44
|
-
EXPRESS_METHODS,
|
|
45
|
-
METHODS
|
|
46
|
-
} = (0, _getPaymentMethods.getPaymentMethods)({
|
|
47
|
-
state
|
|
48
|
-
});
|
|
49
|
-
state.form.innerHTML += baseMethodSelectorHTML(state.options.paymentInstruments.compactExpressInstruments && EXPRESS_METHODS.length);
|
|
50
|
-
const EXPRESS_METHODS_CONTAINER = document.querySelector('.rebilly-instruments-express-methods-container');
|
|
51
|
-
const METHODS_DIVIDER = document.querySelector('.rebilly-instruments-divider');
|
|
52
|
-
METHODS_DIVIDER.style.display = METHODS.length && EXPRESS_METHODS.length ? 'block' : 'none';
|
|
53
|
-
const METHODS_CONTAINER = document.querySelector('.rebilly-instruments-methods');
|
|
54
|
-
state.options.digitalWallet = (0, _generateDigitalWallet.generateDigitalWallet)({
|
|
55
|
-
state,
|
|
56
|
-
EXPRESS_METHODS
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
if (METHODS.length) {
|
|
60
|
-
(0, _mountMethods.MountMethods)({
|
|
61
|
-
state,
|
|
62
|
-
METHODS_CONTAINER,
|
|
63
|
-
METHODS
|
|
64
|
-
});
|
|
65
|
-
} else {
|
|
66
|
-
METHODS_CONTAINER.style.display = 'none';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (EXPRESS_METHODS.length) {
|
|
70
|
-
(0, _mountExpressMethods.mountExpressMethods)({
|
|
71
|
-
state,
|
|
72
|
-
EXPRESS_METHODS,
|
|
73
|
-
EXPRESS_METHODS_CONTAINER
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
EXPRESS_METHODS_CONTAINER.parentNode.style.display = 'none';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (!METHODS.length && !EXPRESS_METHODS.length) {
|
|
80
|
-
state.form.innerHTML = `
|
|
81
|
-
<p data-rebilly-i18n="form.error.noPaymentMethods">
|
|
82
|
-
No payment methods available for this transaction, please contact support.
|
|
83
|
-
<p>
|
|
84
|
-
`;
|
|
85
|
-
state.form.style.minHeight = 'auto';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
state.translate.translateItems();
|
|
89
|
-
state.loader.stopLoading({
|
|
90
|
-
id: 'initForm'
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function updateMethodSelector({
|
|
95
|
-
state
|
|
96
|
-
}) {
|
|
97
|
-
var _state$data$transacti;
|
|
98
|
-
|
|
99
|
-
state.loader.startLoading({
|
|
100
|
-
id: 'initForm'
|
|
101
|
-
});
|
|
102
|
-
const {
|
|
103
|
-
riskMetadata
|
|
104
|
-
} = await (0, _riskDataCollector.collectData)();
|
|
105
|
-
state.data = await (0, _fetchData.fetchData)({
|
|
106
|
-
state,
|
|
107
|
-
riskMetadata
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
if (state.data.transaction && ((_state$data$transacti = state.data.transaction) === null || _state$data$transacti === void 0 ? void 0 : _state$data$transacti.type) === 'setup') {
|
|
111
|
-
state.options.transactionType = 'setup';
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
state.form.querySelectorAll(':not(.rebilly-instruments-confirmation)').forEach(element => {
|
|
115
|
-
if (!element.classList.contains('rebilly-instruments-loader') && !element.classList.contains('rebilly-instruments-loader-spinner')) {
|
|
116
|
-
element.remove();
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
mountMethodSelector({
|
|
120
|
-
state
|
|
121
|
-
});
|
|
122
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _summaryModel = _interopRequireDefault(require("../../storefront/models/summary-model"));
|
|
4
|
-
|
|
5
|
-
var _readyToPayModel = _interopRequireDefault(require("../../storefront/models/ready-to-pay-model"));
|
|
6
|
-
|
|
7
|
-
var _loader = require("../../loader");
|
|
8
|
-
|
|
9
|
-
var _i18n = require("../../i18n");
|
|
10
|
-
|
|
11
|
-
var _index = require("./index");
|
|
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
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
|
-
describe('Summary component', () => {
|
|
24
|
-
let formElement;
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
formElement = document.createElement('div');
|
|
27
|
-
document.body.append(formElement);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
class TestMountMethodSelectorInstance {
|
|
31
|
-
constructor({
|
|
32
|
-
options = {},
|
|
33
|
-
form = formElement,
|
|
34
|
-
loader = new _loader.Loader(),
|
|
35
|
-
translate = new _i18n.Translate()
|
|
36
|
-
} = {}) {
|
|
37
|
-
this.options = (0, _setupOptions.default)({
|
|
38
|
-
options
|
|
39
|
-
});
|
|
40
|
-
this.form = form;
|
|
41
|
-
this.loader = loader;
|
|
42
|
-
this.translate = translate;
|
|
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
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const options = {
|
|
89
|
-
websiteId: 'test-website-id',
|
|
90
|
-
countryCode: 'US',
|
|
91
|
-
items: [{
|
|
92
|
-
planId: 'my-awesome-product',
|
|
93
|
-
quantity: 1
|
|
94
|
-
}, {
|
|
95
|
-
planId: 'awesome-t-shirt',
|
|
96
|
-
quantity: 2
|
|
97
|
-
}],
|
|
98
|
-
_computed: {
|
|
99
|
-
paymentMethodsUrl: ''
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
it('should inject the proper HTML for express methods', async () => {
|
|
103
|
-
const mountSummaryInstance = new TestMountMethodSelectorInstance({
|
|
104
|
-
options
|
|
105
|
-
});
|
|
106
|
-
mountSummaryInstance.loader.DOM.form = mountSummaryInstance.form;
|
|
107
|
-
(0, _index.mountMethodSelector)({
|
|
108
|
-
state: mountSummaryInstance
|
|
109
|
-
});
|
|
110
|
-
const form = document.querySelector('.rebilly-instruments-form');
|
|
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
|
-
});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mountExpressMethods = mountExpressMethods;
|
|
7
|
-
|
|
8
|
-
var _googlePay = _interopRequireDefault(require("./express-methods/google-pay"));
|
|
9
|
-
|
|
10
|
-
var _applePay = _interopRequireDefault(require("./express-methods/apple-pay"));
|
|
11
|
-
|
|
12
|
-
var _paypal = _interopRequireDefault(require("./express-methods/paypal"));
|
|
13
|
-
|
|
14
|
-
var _getMethodData = require("./get-method-data");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function mountExpressMethods({
|
|
19
|
-
state,
|
|
20
|
-
EXPRESS_METHODS,
|
|
21
|
-
EXPRESS_METHODS_CONTAINER
|
|
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
|
-
});
|
|
34
|
-
EXPRESS_METHODS.forEach(expressMethod => {
|
|
35
|
-
const {
|
|
36
|
-
method,
|
|
37
|
-
feature
|
|
38
|
-
} = expressMethod;
|
|
39
|
-
const {
|
|
40
|
-
METHOD_ID,
|
|
41
|
-
METHOD_TYPE
|
|
42
|
-
} = (0, _getMethodData.getMethodData)(expressMethod);
|
|
43
|
-
|
|
44
|
-
if ((feature === null || feature === void 0 ? void 0 : feature.name) === 'Google Pay') {
|
|
45
|
-
(0, _googlePay.default)({
|
|
46
|
-
state,
|
|
47
|
-
METHOD_ID
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
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
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (method === 'paypal') {
|
|
62
|
-
(0, _paypal.default)({
|
|
63
|
-
state,
|
|
64
|
-
METHOD_ID,
|
|
65
|
-
METHOD_TYPE
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MountMethods = MountMethods;
|
|
7
|
-
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash.camelcase"));
|
|
9
|
-
|
|
10
|
-
var _modal = require("../modal");
|
|
11
|
-
|
|
12
|
-
var _iframe = require("../common/iframe");
|
|
13
|
-
|
|
14
|
-
var _getMethodData = require("./get-method-data");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function MountMethods({
|
|
19
|
-
state,
|
|
20
|
-
METHODS_CONTAINER,
|
|
21
|
-
METHODS
|
|
22
|
-
}) {
|
|
23
|
-
METHODS.forEach(async method => {
|
|
24
|
-
var _state$options$paymen;
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
METHOD_ID: methodId,
|
|
28
|
-
METHOD_TYPE: methodType
|
|
29
|
-
} = (0, _getMethodData.getMethodData)(method);
|
|
30
|
-
const {
|
|
31
|
-
paymentMethodsUrl
|
|
32
|
-
} = state.options._computed || 'https://www.example.com';
|
|
33
|
-
const selector = `rebilly-instruments-${methodId}`;
|
|
34
|
-
const isiFrame = methodId === 'payment-card' && !((_state$options$paymen = state.options.paymentInstruments[methodType]) !== null && _state$options$paymen !== void 0 && _state$options$paymen.popup);
|
|
35
|
-
const model = {
|
|
36
|
-
options: state.options,
|
|
37
|
-
mainStyle: state.mainStyle,
|
|
38
|
-
plans: state.data.plans,
|
|
39
|
-
products: state.data.products,
|
|
40
|
-
method
|
|
41
|
-
};
|
|
42
|
-
METHODS_CONTAINER.insertAdjacentHTML('beforeend', `<div id="${selector}" data-rebilly-instruments-type="${methodId}"></div>`);
|
|
43
|
-
const container = document.querySelector(`#${selector}`);
|
|
44
|
-
|
|
45
|
-
if (isiFrame) {
|
|
46
|
-
const iframe = await new _iframe.MethodIframe({
|
|
47
|
-
name: methodId,
|
|
48
|
-
url: `${paymentMethodsUrl}/${methodId}`,
|
|
49
|
-
container,
|
|
50
|
-
model
|
|
51
|
-
});
|
|
52
|
-
iframe.bindEventListeners({
|
|
53
|
-
loader: state.loader,
|
|
54
|
-
id: method.method
|
|
55
|
-
});
|
|
56
|
-
state.iframeComponents.push(iframe);
|
|
57
|
-
} else {
|
|
58
|
-
container.insertAdjacentHTML('beforeend', `<button class="${selector} rebilly-instruments-button" data-rebilly-i18n="paymentMethods.${method.method}">${(0, _lodash.default)(method.method)}</button>`);
|
|
59
|
-
const paymentCardButton = document.querySelector(`.${selector}`);
|
|
60
|
-
paymentCardButton.addEventListener('click', async () => {
|
|
61
|
-
const iframe = await (0, _modal.mountModal)({
|
|
62
|
-
state,
|
|
63
|
-
name: methodId,
|
|
64
|
-
url: `${paymentMethodsUrl}/${methodId}`,
|
|
65
|
-
model
|
|
66
|
-
});
|
|
67
|
-
state.iframeComponents.push(iframe);
|
|
68
|
-
});
|
|
69
|
-
state.loader.stopLoading({
|
|
70
|
-
id: method.method
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
package/dist/views/modal.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mountModal = mountModal;
|
|
7
|
-
|
|
8
|
-
var _iframe = require("./common/iframe");
|
|
9
|
-
|
|
10
|
-
const modalTemplate = (isRedirect, method) => `
|
|
11
|
-
<div class="rebilly-instruments-modal-overlay">
|
|
12
|
-
<div class="rebilly-instruments-modal-container ${method ? `rebilly-instruments-${method}` : ''} ${isRedirect ? 'is-redirect' : ''}">
|
|
13
|
-
${isRedirect ? '' : `
|
|
14
|
-
<svg class="rebilly-instruments-modal-close" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg">
|
|
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"/>
|
|
16
|
-
</svg>
|
|
17
|
-
`}
|
|
18
|
-
<div class="rebilly-instruments-modal-content"></div>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
async function mountModal({
|
|
24
|
-
name = '',
|
|
25
|
-
url = '',
|
|
26
|
-
model = {},
|
|
27
|
-
classListArray = [],
|
|
28
|
-
close = () => {},
|
|
29
|
-
state = null
|
|
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;
|
|
34
|
-
const isRedirect = name === 'rebilly-instruments-approval-url';
|
|
35
|
-
state.form.insertAdjacentHTML('beforeend', modalTemplate(isRedirect, method));
|
|
36
|
-
const modalOverlay = document.querySelector('.rebilly-instruments-modal-overlay');
|
|
37
|
-
const modalContainer = document.querySelector('.rebilly-instruments-modal-container');
|
|
38
|
-
const closeButton = document.querySelector('.rebilly-instruments-modal-close');
|
|
39
|
-
const modalContent = document.querySelector('.rebilly-instruments-modal-content');
|
|
40
|
-
document.body.style.overflow = 'hidden';
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
modalOverlay.classList.add('is-visible');
|
|
43
|
-
modalContainer.classList.add('is-visible');
|
|
44
|
-
}, 240);
|
|
45
|
-
state.loader.addDOMElement({
|
|
46
|
-
section: 'modal',
|
|
47
|
-
el: modalContent
|
|
48
|
-
});
|
|
49
|
-
state.loader.startLoading({
|
|
50
|
-
section: 'modal',
|
|
51
|
-
id: 'modal-content'
|
|
52
|
-
});
|
|
53
|
-
const injectedModel = {
|
|
54
|
-
options: state.options,
|
|
55
|
-
...model
|
|
56
|
-
};
|
|
57
|
-
const iframe = await new _iframe.ModalIframe({
|
|
58
|
-
state,
|
|
59
|
-
name,
|
|
60
|
-
url,
|
|
61
|
-
model: injectedModel,
|
|
62
|
-
classListArray,
|
|
63
|
-
container: modalContent
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const closeModal = (...args) => {
|
|
67
|
-
modalContainer.classList.remove('is-visible');
|
|
68
|
-
modalOverlay.classList.remove('is-visible');
|
|
69
|
-
setTimeout(() => {
|
|
70
|
-
document.body.style.overflow = 'auto';
|
|
71
|
-
modalOverlay.children.forEach(child => child.remove());
|
|
72
|
-
modalOverlay.remove();
|
|
73
|
-
close(...args);
|
|
74
|
-
iframe.destroy();
|
|
75
|
-
}, 300);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
iframe.bindEventListeners({
|
|
79
|
-
close: closeModal,
|
|
80
|
-
loader: state.loader
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
if (!isRedirect) {
|
|
84
|
-
closeButton.addEventListener('click', closeModal);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return iframe;
|
|
88
|
-
}
|
package/dist/views/result.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mountResult = mountResult;
|
|
7
|
-
|
|
8
|
-
var _iframe = require("./common/iframe");
|
|
9
|
-
|
|
10
|
-
var _renderUtilities = require("./common/render-utilities");
|
|
11
|
-
|
|
12
|
-
async function mountResult({
|
|
13
|
-
payload,
|
|
14
|
-
state
|
|
15
|
-
}) {
|
|
16
|
-
const resultContainerClassName = 'rebilly-instruments-result';
|
|
17
|
-
(0, _renderUtilities.replaceContent)(state.form, `<div class="${resultContainerClassName}"></div>`);
|
|
18
|
-
state.loader.startLoading({
|
|
19
|
-
id: 'result'
|
|
20
|
-
});
|
|
21
|
-
const container = document.querySelector(`.${resultContainerClassName}`);
|
|
22
|
-
const {
|
|
23
|
-
paymentMethodsUrl
|
|
24
|
-
} = state.options._computed;
|
|
25
|
-
const model = {
|
|
26
|
-
options: state.options,
|
|
27
|
-
mainStyle: state.mainStyle,
|
|
28
|
-
[state.options.transactionType]: payload
|
|
29
|
-
};
|
|
30
|
-
const iframe = await new _iframe.ViewIframe({
|
|
31
|
-
name: 'rebilly-instruments-result',
|
|
32
|
-
url: `${paymentMethodsUrl}/result`,
|
|
33
|
-
container,
|
|
34
|
-
model
|
|
35
|
-
});
|
|
36
|
-
iframe.bindEventListeners({
|
|
37
|
-
loader: state.loader
|
|
38
|
-
});
|
|
39
|
-
state.iframeComponents.push(iframe);
|
|
40
|
-
}
|