@rebilly/instruments 2.0.0-beta → 3.0.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/dist/events/index.js +2 -1
- package/dist/functions/mount/fetch-data.js +187 -0
- package/dist/functions/mount/fetch-data.spec.js +189 -0
- package/dist/functions/mount/index.js +132 -164
- package/dist/functions/mount/mount.spec.js +2 -4
- package/dist/functions/mount/setup-element.js +40 -0
- package/dist/functions/mount/setup-framepay-theme.js +95 -0
- package/dist/functions/mount/setup-framepay.js +5 -1
- package/dist/functions/mount/setup-i18n.js +33 -0
- package/dist/functions/mount/setup-options.js +68 -47
- package/dist/functions/mount/setup-options.spec.js +66 -0
- package/dist/functions/mount/setup-storefront.js +6 -4
- package/dist/functions/mount/setup-styles.js +4 -2
- package/dist/functions/purchase.js +129 -24
- package/dist/functions/purchase.spec.js +13 -10
- package/dist/functions/setup.js +85 -0
- package/dist/functions/setup.spec.js +87 -0
- package/dist/functions/show.js +8 -4
- package/dist/functions/show.spec.js +9 -5
- package/dist/functions/update.js +39 -24
- package/dist/functions/update.spec.js +0 -4
- package/dist/i18n/en.json +5 -2
- package/dist/i18n/es.json +4 -1
- package/dist/index.js +17 -3
- package/dist/index.spec.js +3 -16
- 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 +10 -18
- package/dist/storefront/plans.spec.js +3 -13
- package/dist/storefront/products.js +10 -13
- package/dist/storefront/products.spec.js +12 -19
- package/dist/storefront/purchase.js +23 -12
- package/dist/storefront/purchase.spec.js +1 -20
- package/dist/storefront/ready-to-pay.js +18 -15
- package/dist/storefront/ready-to-pay.spec.js +2 -12
- package/dist/storefront/summary.js +21 -17
- package/dist/storefront/summary.spec.js +4 -15
- package/dist/storefront/transactions.js +27 -0
- package/dist/style/base/__snapshots__/theme.spec.js.snap +188 -45
- package/dist/style/base/default-theme.js +699 -0
- package/dist/style/base/index.js +48 -16
- package/dist/style/base/theme.js +16 -48
- package/dist/style/base/theme.spec.js +4 -15
- package/dist/style/components/address.js +3 -3
- package/dist/style/components/button.js +32 -22
- package/dist/style/components/divider.js +9 -9
- package/dist/style/components/forms/checkbox.js +12 -9
- package/dist/style/components/forms/field.js +18 -6
- package/dist/style/components/forms/form.js +2 -2
- package/dist/style/components/forms/input.js +54 -13
- package/dist/style/components/forms/label.js +39 -18
- package/dist/style/components/forms/select.js +54 -22
- package/dist/style/components/forms/validation.js +53 -6
- package/dist/style/components/icons.js +4 -4
- package/dist/style/components/loader.js +5 -3
- package/dist/style/components/methods.js +18 -15
- package/dist/style/components/overlay.js +5 -5
- package/dist/style/helpers/index.js +46 -46
- package/dist/style/index.js +3 -1
- package/dist/style/payment-instruments/payment-card.js +4 -4
- package/dist/style/utils/border.js +47 -0
- package/dist/style/utils/color-values.js +39 -3
- package/dist/style/utils/remove-empty-null.js +20 -0
- package/dist/style/vendor/framepay.js +11 -8
- package/dist/style/vendor/postmate.js +2 -2
- package/dist/style/views/confirmation.js +13 -13
- package/dist/style/views/method-selector.js +2 -2
- package/dist/style/views/modal.js +6 -6
- package/dist/style/views/result.js +4 -4
- package/dist/style/views/summary.js +26 -22
- package/dist/views/__snapshots__/summary.spec.js.snap +77 -119
- package/dist/views/common/iframe/base-iframe.js +2 -0
- package/dist/views/common/iframe/modal-iframe.js +50 -4
- package/dist/views/confirmation.js +19 -8
- package/dist/views/method-selector/generate-digital-wallet.js +12 -3
- package/dist/views/method-selector/generate-digital-wallet.spec.js +11 -0
- package/dist/views/method-selector/get-payment-methods.js +13 -2
- package/dist/views/method-selector/get-payment-methods.spec.js +21 -19
- package/dist/views/method-selector/index.js +23 -34
- package/dist/views/method-selector/method-selector.spec.js +50 -55
- package/dist/views/method-selector/mount-methods.js +5 -8
- package/dist/views/modal.js +8 -2
- package/dist/views/result.js +3 -4
- package/dist/views/summary.js +156 -97
- package/dist/views/summary.spec.js +53 -58
- package/package.json +4 -2
- package/src/events/index.js +2 -1
- package/src/functions/mount/fetch-data.js +152 -0
- package/src/functions/mount/fetch-data.spec.js +238 -0
- package/src/functions/mount/index.js +101 -158
- package/src/functions/mount/mount.spec.js +3 -5
- package/src/functions/mount/setup-element.js +26 -0
- package/src/functions/mount/setup-framepay-theme.js +82 -0
- package/src/functions/mount/setup-framepay.js +5 -1
- package/src/functions/mount/setup-i18n.js +19 -0
- package/src/functions/mount/setup-options.js +78 -48
- package/src/functions/mount/setup-options.spec.js +60 -0
- package/src/functions/mount/setup-storefront.js +6 -4
- package/src/functions/mount/setup-styles.js +4 -2
- package/src/functions/on.spec.js +1 -1
- package/src/functions/purchase.js +99 -23
- package/src/functions/purchase.spec.js +10 -10
- package/src/functions/setup.js +48 -0
- package/src/functions/setup.spec.js +98 -0
- package/src/functions/show.js +2 -4
- package/src/functions/show.spec.js +3 -4
- package/src/functions/update.js +40 -25
- package/src/functions/update.spec.js +0 -4
- package/src/i18n/en.json +5 -2
- package/src/i18n/es.json +4 -1
- package/src/index.js +9 -3
- package/src/index.spec.js +3 -21
- package/src/loader/index.js +3 -3
- package/src/storefront/index.js +28 -0
- 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/summary-model.js +12 -19
- 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 +6 -17
- package/src/storefront/plans.spec.js +4 -11
- package/src/storefront/products.js +8 -16
- package/src/storefront/products.spec.js +16 -22
- package/src/storefront/purchase.js +14 -16
- package/src/storefront/purchase.spec.js +2 -14
- package/src/storefront/ready-to-pay.js +13 -16
- package/src/storefront/ready-to-pay.spec.js +3 -10
- package/src/storefront/summary.js +19 -17
- package/src/storefront/summary.spec.js +5 -12
- package/src/storefront/transactions.js +11 -0
- package/src/style/base/__snapshots__/theme.spec.js.snap +188 -45
- package/src/style/base/default-theme.js +674 -0
- package/src/style/base/index.js +48 -16
- package/src/style/base/theme.js +17 -47
- package/src/style/base/theme.spec.js +4 -16
- package/src/style/components/address.js +3 -3
- package/src/style/components/button.js +32 -24
- package/src/style/components/divider.js +9 -9
- package/src/style/components/forms/checkbox.js +11 -11
- package/src/style/components/forms/field.js +18 -6
- package/src/style/components/forms/form.js +2 -2
- package/src/style/components/forms/input.js +54 -13
- package/src/style/components/forms/label.js +39 -18
- package/src/style/components/forms/select.js +54 -22
- package/src/style/components/forms/validation.js +53 -6
- package/src/style/components/icons.js +4 -4
- package/src/style/components/loader.js +4 -5
- package/src/style/components/methods.js +18 -15
- package/src/style/components/overlay.js +5 -5
- package/src/style/helpers/index.js +46 -46
- package/src/style/index.js +2 -1
- package/src/style/payment-instruments/payment-card.js +4 -4
- package/src/style/utils/border.js +34 -0
- package/src/style/utils/color-values.js +27 -1
- package/src/style/utils/remove-empty-null.js +10 -0
- package/src/style/vendor/framepay.js +11 -8
- package/src/style/vendor/postmate.js +2 -2
- package/src/style/views/confirmation.js +13 -13
- package/src/style/views/method-selector.js +2 -2
- package/src/style/views/modal.js +6 -6
- package/src/style/views/result.js +4 -4
- package/src/style/views/summary.js +26 -22
- package/src/views/__snapshots__/summary.spec.js.snap +77 -119
- package/src/views/common/iframe/base-iframe.js +2 -0
- package/src/views/common/iframe/modal-iframe.js +45 -3
- package/src/views/confirmation.js +15 -5
- package/src/views/method-selector/generate-digital-wallet.js +10 -3
- package/src/views/method-selector/generate-digital-wallet.spec.js +10 -0
- package/src/views/method-selector/get-payment-methods.js +7 -2
- package/src/views/method-selector/get-payment-methods.spec.js +26 -23
- package/src/views/method-selector/index.js +21 -28
- package/src/views/method-selector/method-selector.spec.js +49 -64
- package/src/views/method-selector/mount-methods.js +5 -8
- package/src/views/modal.js +6 -2
- package/src/views/result.js +4 -3
- package/src/views/summary.js +161 -117
- package/src/views/summary.spec.js +60 -75
- package/tests/mocks/rebilly-instruments-mock.js +37 -7
- package/tests/mocks/storefront-api-mock.js +8 -0
- package/tests/mocks/storefront-mock.js +17 -0
- package/dist/functions/mount/fetch-summary-data.js +0 -46
- package/dist/functions/mount/fetch-summary-data.spec.js +0 -43
- package/src/functions/mount/fetch-summary-data.js +0 -29
- package/src/functions/mount/fetch-summary-data.spec.js +0 -40
|
@@ -17,7 +17,7 @@ var _generateDigitalWallet = require("./generate-digital-wallet");
|
|
|
17
17
|
|
|
18
18
|
var _mountMethods = require("./mount-methods");
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _fetchData = require("../../functions/mount/fetch-data");
|
|
21
21
|
|
|
22
22
|
/* eslint-disable no-undef */
|
|
23
23
|
const baseMethodSelectorHTML = compactExpressInstruments => `
|
|
@@ -38,31 +38,21 @@ const baseMethodSelectorHTML = compactExpressInstruments => `
|
|
|
38
38
|
exports.baseMethodSelectorHTML = baseMethodSelectorHTML;
|
|
39
39
|
|
|
40
40
|
function mountMethodSelector({
|
|
41
|
-
state
|
|
42
|
-
formOptions
|
|
41
|
+
state
|
|
43
42
|
}) {
|
|
44
|
-
const {
|
|
45
|
-
readyToPay,
|
|
46
|
-
summary,
|
|
47
|
-
plans,
|
|
48
|
-
products,
|
|
49
|
-
mainStyle
|
|
50
|
-
} = formOptions;
|
|
51
43
|
const {
|
|
52
44
|
EXPRESS_METHODS,
|
|
53
45
|
METHODS
|
|
54
46
|
} = (0, _getPaymentMethods.getPaymentMethods)({
|
|
55
|
-
methods: readyToPay,
|
|
56
47
|
state
|
|
57
48
|
});
|
|
58
|
-
state.form.innerHTML += baseMethodSelectorHTML(state.options.paymentInstruments.compactExpressInstruments);
|
|
49
|
+
state.form.innerHTML += baseMethodSelectorHTML(state.options.paymentInstruments.compactExpressInstruments && EXPRESS_METHODS.length);
|
|
59
50
|
const EXPRESS_METHODS_CONTAINER = document.querySelector('.rebilly-instruments-express-methods-container');
|
|
60
51
|
const METHODS_DIVIDER = document.querySelector('.rebilly-instruments-divider');
|
|
61
52
|
METHODS_DIVIDER.style.display = METHODS.length && EXPRESS_METHODS.length ? 'block' : 'none';
|
|
62
53
|
const METHODS_CONTAINER = document.querySelector('.rebilly-instruments-methods');
|
|
63
54
|
state.options.digitalWallet = (0, _generateDigitalWallet.generateDigitalWallet)({
|
|
64
55
|
state,
|
|
65
|
-
summary,
|
|
66
56
|
EXPRESS_METHODS
|
|
67
57
|
});
|
|
68
58
|
|
|
@@ -70,10 +60,7 @@ function mountMethodSelector({
|
|
|
70
60
|
(0, _mountMethods.MountMethods)({
|
|
71
61
|
state,
|
|
72
62
|
METHODS_CONTAINER,
|
|
73
|
-
METHODS
|
|
74
|
-
mainStyle,
|
|
75
|
-
plans,
|
|
76
|
-
products
|
|
63
|
+
METHODS
|
|
77
64
|
});
|
|
78
65
|
} else {
|
|
79
66
|
METHODS_CONTAINER.style.display = 'none';
|
|
@@ -89,6 +76,15 @@ function mountMethodSelector({
|
|
|
89
76
|
EXPRESS_METHODS_CONTAINER.parentNode.style.display = 'none';
|
|
90
77
|
}
|
|
91
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
|
+
|
|
92
88
|
state.translate.translateItems();
|
|
93
89
|
state.loader.stopLoading({
|
|
94
90
|
id: 'initForm'
|
|
@@ -96,38 +92,31 @@ function mountMethodSelector({
|
|
|
96
92
|
}
|
|
97
93
|
|
|
98
94
|
async function updateMethodSelector({
|
|
99
|
-
state
|
|
100
|
-
mainStyle
|
|
95
|
+
state
|
|
101
96
|
}) {
|
|
97
|
+
var _state$data$transacti;
|
|
98
|
+
|
|
102
99
|
state.loader.startLoading({
|
|
103
100
|
id: 'initForm'
|
|
104
101
|
});
|
|
105
102
|
const {
|
|
106
103
|
riskMetadata
|
|
107
104
|
} = await (0, _riskDataCollector.collectData)();
|
|
108
|
-
|
|
109
|
-
readyToPay,
|
|
110
|
-
summary: summaryData,
|
|
111
|
-
plans,
|
|
112
|
-
products
|
|
113
|
-
} = await (0, _fetchSummaryData.fetchSummaryData)({
|
|
105
|
+
state.data = await (0, _fetchData.fetchData)({
|
|
114
106
|
state,
|
|
115
107
|
riskMetadata
|
|
116
108
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
mainStyle
|
|
123
|
-
};
|
|
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
|
+
|
|
124
114
|
state.form.querySelectorAll(':not(.rebilly-instruments-confirmation)').forEach(element => {
|
|
125
115
|
if (!element.classList.contains('rebilly-instruments-loader') && !element.classList.contains('rebilly-instruments-loader-spinner')) {
|
|
126
116
|
element.remove();
|
|
127
117
|
}
|
|
128
118
|
});
|
|
129
119
|
mountMethodSelector({
|
|
130
|
-
state
|
|
131
|
-
formOptions
|
|
120
|
+
state
|
|
132
121
|
});
|
|
133
122
|
}
|
|
@@ -14,6 +14,10 @@ var _asyncUtilities = require("../../../tests/async-utilities");
|
|
|
14
14
|
|
|
15
15
|
var _storefrontMock = require("../../../tests/mocks/storefront-mock");
|
|
16
16
|
|
|
17
|
+
var _fetchData = require("../../functions/mount/fetch-data");
|
|
18
|
+
|
|
19
|
+
var _setupOptions = _interopRequireDefault(require("../../functions/mount/setup-options"));
|
|
20
|
+
|
|
17
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
22
|
|
|
19
23
|
describe('Summary component', () => {
|
|
@@ -30,11 +34,53 @@ describe('Summary component', () => {
|
|
|
30
34
|
loader = new _loader.Loader(),
|
|
31
35
|
translate = new _i18n.Translate()
|
|
32
36
|
} = {}) {
|
|
33
|
-
this.options =
|
|
37
|
+
this.options = (0, _setupOptions.default)({
|
|
38
|
+
options
|
|
39
|
+
});
|
|
34
40
|
this.form = form;
|
|
35
41
|
this.loader = loader;
|
|
36
42
|
this.translate = translate;
|
|
37
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
|
+
});
|
|
38
84
|
}
|
|
39
85
|
|
|
40
86
|
}
|
|
@@ -44,73 +90,22 @@ describe('Summary component', () => {
|
|
|
44
90
|
countryCode: 'US',
|
|
45
91
|
items: [{
|
|
46
92
|
planId: 'my-awesome-product',
|
|
47
|
-
quantity: 1
|
|
48
|
-
thumbnail: ''
|
|
93
|
+
quantity: 1
|
|
49
94
|
}, {
|
|
50
95
|
planId: 'awesome-t-shirt',
|
|
51
|
-
quantity: 2
|
|
52
|
-
thumbnail: ''
|
|
96
|
+
quantity: 2
|
|
53
97
|
}],
|
|
54
|
-
paymentInstruments: {
|
|
55
|
-
googlePay: {
|
|
56
|
-
displayOptions: {
|
|
57
|
-
buttonColor: 'black',
|
|
58
|
-
buttonHeight: '44px',
|
|
59
|
-
buttonType: 'short'
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
compactExpressInstruments: true
|
|
63
|
-
},
|
|
64
98
|
_computed: {
|
|
65
99
|
paymentMethodsUrl: ''
|
|
66
100
|
}
|
|
67
101
|
};
|
|
68
|
-
const summaryData = new _summaryModel.default({
|
|
69
|
-
currency: 'USD',
|
|
70
|
-
lineItems: [{
|
|
71
|
-
type: 'debit',
|
|
72
|
-
description: 'My Awesome Product',
|
|
73
|
-
unitPrice: 30,
|
|
74
|
-
quantity: 1,
|
|
75
|
-
price: 30,
|
|
76
|
-
productId: 'my-awesome-product',
|
|
77
|
-
planId: 'my-awesome-product'
|
|
78
|
-
}, {
|
|
79
|
-
type: 'debit',
|
|
80
|
-
description: 'Awesome T-Shirt',
|
|
81
|
-
unitPrice: 20,
|
|
82
|
-
quantity: 2,
|
|
83
|
-
price: 40,
|
|
84
|
-
productId: 'my-app',
|
|
85
|
-
planId: 'awesome-t-shirt'
|
|
86
|
-
}],
|
|
87
|
-
subtotalAmount: 70,
|
|
88
|
-
taxAmount: 0,
|
|
89
|
-
shippingAmount: 0,
|
|
90
|
-
discountsAmount: 0,
|
|
91
|
-
total: 70
|
|
92
|
-
});
|
|
93
|
-
const readyToPayData = [new _readyToPayModel.default({
|
|
94
|
-
method: 'payment-card',
|
|
95
|
-
feature: {
|
|
96
|
-
name: 'Google Pay',
|
|
97
|
-
merchantName: 'google-pay-merchant-name',
|
|
98
|
-
merchantOrigin: 'google-pay-merchant-origin'
|
|
99
|
-
},
|
|
100
|
-
brands: ['Visa'],
|
|
101
|
-
filters: []
|
|
102
|
-
})];
|
|
103
102
|
it('should inject the proper HTML for express methods', async () => {
|
|
104
103
|
const mountSummaryInstance = new TestMountMethodSelectorInstance({
|
|
105
104
|
options
|
|
106
105
|
});
|
|
107
106
|
mountSummaryInstance.loader.DOM.form = mountSummaryInstance.form;
|
|
108
107
|
(0, _index.mountMethodSelector)({
|
|
109
|
-
state: mountSummaryInstance
|
|
110
|
-
formOptions: {
|
|
111
|
-
summary: summaryData,
|
|
112
|
-
readyToPay: readyToPayData
|
|
113
|
-
}
|
|
108
|
+
state: mountSummaryInstance
|
|
114
109
|
});
|
|
115
110
|
const form = document.querySelector('.rebilly-instruments-form');
|
|
116
111
|
expect(form).toMatchSnapshot();
|
|
@@ -18,10 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
function MountMethods({
|
|
19
19
|
state,
|
|
20
20
|
METHODS_CONTAINER,
|
|
21
|
-
METHODS
|
|
22
|
-
mainStyle,
|
|
23
|
-
plans,
|
|
24
|
-
products
|
|
21
|
+
METHODS
|
|
25
22
|
}) {
|
|
26
23
|
METHODS.forEach(async method => {
|
|
27
24
|
var _state$options$paymen;
|
|
@@ -37,10 +34,10 @@ function MountMethods({
|
|
|
37
34
|
const isiFrame = methodId === 'payment-card' && !((_state$options$paymen = state.options.paymentInstruments[methodType]) !== null && _state$options$paymen !== void 0 && _state$options$paymen.popup);
|
|
38
35
|
const model = {
|
|
39
36
|
options: state.options,
|
|
40
|
-
mainStyle,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
mainStyle: state.mainStyle,
|
|
38
|
+
plans: state.data.plans,
|
|
39
|
+
products: state.data.products,
|
|
40
|
+
method
|
|
44
41
|
};
|
|
45
42
|
METHODS_CONTAINER.insertAdjacentHTML('beforeend', `<div id="${selector}" data-rebilly-instruments-type="${methodId}"></div>`);
|
|
46
43
|
const container = document.querySelector(`#${selector}`);
|
package/dist/views/modal.js
CHANGED
|
@@ -10,9 +10,11 @@ var _iframe = require("./common/iframe");
|
|
|
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>
|
|
@@ -53,6 +55,7 @@ async function mountModal({
|
|
|
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,
|
|
@@ -76,7 +79,10 @@ async function mountModal({
|
|
|
76
79
|
close: closeModal,
|
|
77
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
|
@@ -10,8 +10,7 @@ var _iframe = require("./common/iframe");
|
|
|
10
10
|
var _renderUtilities = require("./common/render-utilities");
|
|
11
11
|
|
|
12
12
|
async function mountResult({
|
|
13
|
-
|
|
14
|
-
mainStyle,
|
|
13
|
+
payload,
|
|
15
14
|
state
|
|
16
15
|
}) {
|
|
17
16
|
const resultContainerClassName = 'rebilly-instruments-result';
|
|
@@ -25,8 +24,8 @@ async function mountResult({
|
|
|
25
24
|
} = state.options._computed;
|
|
26
25
|
const model = {
|
|
27
26
|
options: state.options,
|
|
28
|
-
mainStyle,
|
|
29
|
-
|
|
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',
|
package/dist/views/summary.js
CHANGED
|
@@ -3,108 +3,172 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.lineItemHTML = lineItemHTML;
|
|
7
|
+
exports.summaryBreakdownHTML = summaryBreakdownHTML;
|
|
6
8
|
exports.mountSummary = mountSummary;
|
|
7
9
|
exports.updateSummary = updateSummary;
|
|
8
|
-
exports.baseSummaryHTML = void 0;
|
|
9
10
|
|
|
10
11
|
var _riskDataCollector = require("@rebilly/risk-data-collector");
|
|
11
12
|
|
|
12
13
|
var _utils = require("../utils");
|
|
13
14
|
|
|
14
|
-
var
|
|
15
|
+
var _fetchData = require("../functions/mount/fetch-data");
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
<div class="rebilly-instruments-content">
|
|
18
|
-
<div class="rebilly-instruments-summary-line-items"></div>
|
|
19
|
-
<div class="rebilly-instruments-summary-breakdown"></div>
|
|
20
|
-
</div>
|
|
21
|
-
`;
|
|
22
|
-
exports.baseSummaryHTML = baseSummaryHTML;
|
|
23
|
-
|
|
24
|
-
function mountSummary({
|
|
17
|
+
function lineItemHTML({
|
|
25
18
|
state,
|
|
26
|
-
|
|
19
|
+
lineItem
|
|
27
20
|
}) {
|
|
21
|
+
var _state$data;
|
|
22
|
+
|
|
28
23
|
const {
|
|
29
|
-
summary,
|
|
30
24
|
products
|
|
31
|
-
} =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
} = state.data;
|
|
26
|
+
const {
|
|
27
|
+
currency = null
|
|
28
|
+
} = (_state$data = state.data) === null || _state$data === void 0 ? void 0 : _state$data.amountAndCurrency;
|
|
35
29
|
const {
|
|
36
|
-
items: optionItems
|
|
30
|
+
items: optionItems = []
|
|
37
31
|
} = state.options;
|
|
38
32
|
const hasThumbnails = optionItems === null || optionItems === void 0 ? void 0 : optionItems.some(optionItem => optionItem.thumbnail);
|
|
39
33
|
const {
|
|
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
|
-
${lineItem.description ? `
|
|
65
|
-
<p class="rebilly-instruments-summary-line-item-synopsis-description">${lineItem.description}</p>
|
|
66
|
-
` : ''}
|
|
67
|
-
</div>
|
|
68
|
-
<div class="rebilly-instruments-summary-line-item-price-breakdown">
|
|
69
|
-
<p class="rebilly-instruments-summary-line-item-price-breakdown-quantity">${lineItem.quantity}</p>
|
|
70
|
-
<svg class="rebilly-instruments-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
71
|
-
<path 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" fill-rule="nonzero"/>
|
|
72
|
-
</svg>
|
|
73
|
-
<p class="rebilly-instruments-summary-line-item-price-breakdown-unit-price">${(0, _utils.formatCurrency)(lineItem.unitPrice, currency)}</p>
|
|
74
|
-
</div>
|
|
34
|
+
thumbnail = null
|
|
35
|
+
} = optionItems.find(optionItem => optionItem.planId === lineItem.planId) || {};
|
|
36
|
+
const {
|
|
37
|
+
name
|
|
38
|
+
} = products.find(product => product.id === lineItem.productId);
|
|
39
|
+
return `
|
|
40
|
+
<div class="rebilly-instruments-summary-line-item">
|
|
41
|
+
${hasThumbnails ? `
|
|
42
|
+
<figure class="rebilly-instruments-summary-line-item-figure">
|
|
43
|
+
${thumbnail ? `<img src="${thumbnail}" alt="${name}">` : ''}
|
|
44
|
+
</figure>
|
|
45
|
+
` : ''}
|
|
46
|
+
<div class="rebilly-instruments-summary-line-item-synopsis">
|
|
47
|
+
<p class="rebilly-instruments-summary-line-item-synopsis-title">${name}</p>
|
|
48
|
+
${lineItem.description ? `
|
|
49
|
+
<p class="rebilly-instruments-summary-line-item-synopsis-description">${lineItem.description}</p>
|
|
50
|
+
` : ''}
|
|
51
|
+
</div>
|
|
52
|
+
<div class="rebilly-instruments-summary-line-item-price-breakdown">
|
|
53
|
+
<p class="rebilly-instruments-summary-line-item-price-breakdown-quantity">${lineItem.quantity}</p>
|
|
54
|
+
<svg class="rebilly-instruments-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
55
|
+
<path 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" fill-rule="nonzero"/>
|
|
56
|
+
</svg>
|
|
57
|
+
<p class="rebilly-instruments-summary-line-item-price-breakdown-unit-price">${(0, _utils.formatCurrency)(lineItem.unitPrice, currency)}</p>
|
|
75
58
|
</div>
|
|
76
|
-
`;
|
|
77
|
-
});
|
|
78
|
-
summaryBreakdown.innerHTML = `
|
|
79
|
-
<table>
|
|
80
|
-
<colgroup>
|
|
81
|
-
<col>
|
|
82
|
-
<col>
|
|
83
|
-
</colgroup>
|
|
84
|
-
<tr class="rebilly-instruments-summary-breakdown-sub-total">
|
|
85
|
-
<td data-rebilly-i18n="summary.subTotal">Sub Total</td>
|
|
86
|
-
<td>${(0, _utils.formatCurrency)(subtotalAmount, currency)}</td>
|
|
87
|
-
</tr>
|
|
88
|
-
<tr class="rebilly-instruments-summary-breakdown-discounts">
|
|
89
|
-
<td data-rebilly-i18n="summary.discounts">Discounts</td>
|
|
90
|
-
<td>${(0, _utils.formatCurrency)(discountsAmount, currency)}</td>
|
|
91
|
-
</tr>
|
|
92
|
-
<tr class="rebilly-instruments-summary-breakdown-taxes">
|
|
93
|
-
<td data-rebilly-i18n="summary.taxes">Taxes</td>
|
|
94
|
-
<td>${(0, _utils.formatCurrency)(taxAmount, currency)}</td>
|
|
95
|
-
</tr>
|
|
96
|
-
<tr class="rebilly-instruments-summary-breakdown-taxes">
|
|
97
|
-
<td data-rebilly-i18n="summary.shipping">Shipping</td>
|
|
98
|
-
<td>${(0, _utils.formatCurrency)(shippingAmount, currency)}</td>
|
|
99
|
-
</tr>
|
|
100
|
-
</table>
|
|
101
|
-
<div class="rebilly-instruments-summary-breakdown-total">
|
|
102
|
-
<p data-rebilly-i18n="summary.total">Total</p>
|
|
103
|
-
<p class="rebilly-instruments-summary-breakdown-total-amount">
|
|
104
|
-
<span class="rebilly-instruments-summary-breakdown-total-amount-currency">${currency}</span>${(0, _utils.formatCurrency)(total, currency)}
|
|
105
|
-
</p>
|
|
106
59
|
</div>
|
|
107
60
|
`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function summaryBreakdownHTML({
|
|
64
|
+
state,
|
|
65
|
+
element
|
|
66
|
+
}) {
|
|
67
|
+
const {
|
|
68
|
+
amount = null,
|
|
69
|
+
currency = null,
|
|
70
|
+
discountsAmount = null,
|
|
71
|
+
shippingAmount = null,
|
|
72
|
+
subtotalAmount = null,
|
|
73
|
+
taxAmount = null
|
|
74
|
+
} = { ...state.data.amountAndCurrency,
|
|
75
|
+
...state.data.summaryItems
|
|
76
|
+
};
|
|
77
|
+
let table = null;
|
|
78
|
+
[{
|
|
79
|
+
label: 'Sub Total',
|
|
80
|
+
class: 'sub-total',
|
|
81
|
+
i18n: 'summary.subTotal',
|
|
82
|
+
value: subtotalAmount,
|
|
83
|
+
show: true
|
|
84
|
+
}, {
|
|
85
|
+
label: 'Discounts',
|
|
86
|
+
class: 'discounts',
|
|
87
|
+
i18n: 'summary.discounts',
|
|
88
|
+
value: discountsAmount,
|
|
89
|
+
show: discountsAmount > 0
|
|
90
|
+
}, {
|
|
91
|
+
label: 'Taxes',
|
|
92
|
+
class: 'taxes',
|
|
93
|
+
i18n: 'summary.taxes',
|
|
94
|
+
value: taxAmount,
|
|
95
|
+
show: true
|
|
96
|
+
}, {
|
|
97
|
+
label: 'Shipping',
|
|
98
|
+
class: 'shipping',
|
|
99
|
+
i18n: 'summary.shipping',
|
|
100
|
+
value: shippingAmount,
|
|
101
|
+
show: state.data.isShippingRequired
|
|
102
|
+
}].filter(({
|
|
103
|
+
value
|
|
104
|
+
}) => value !== null).forEach(item => {
|
|
105
|
+
if (!table) {
|
|
106
|
+
table = document.createElement('table');
|
|
107
|
+
table.insertAdjacentHTML('beforeend', `
|
|
108
|
+
<colgroup>
|
|
109
|
+
<col>
|
|
110
|
+
<col>
|
|
111
|
+
</colgroup>
|
|
112
|
+
`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (item.show) {
|
|
116
|
+
const row = document.createElement('tr');
|
|
117
|
+
row.setAttribute('class', `rebilly-instruments-summary-breakdown-${item.class}`);
|
|
118
|
+
row.insertAdjacentHTML('beforeend', `
|
|
119
|
+
<td data-rebilly-i18n="${item.i18n}">${item.label}</td>
|
|
120
|
+
<td>${(0, _utils.formatCurrency)(item.value, currency)}</td>
|
|
121
|
+
`);
|
|
122
|
+
table.appendChild(row);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (table) {
|
|
127
|
+
element.appendChild(table);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const totalElement = document.createElement('div');
|
|
131
|
+
totalElement.setAttribute('class', 'rebilly-instruments-summary-breakdown-total');
|
|
132
|
+
totalElement.insertAdjacentHTML('beforeend', `
|
|
133
|
+
<p data-rebilly-i18n="summary.total">Total</p>
|
|
134
|
+
<p class="rebilly-instruments-summary-breakdown-total-amount">
|
|
135
|
+
<span class="rebilly-instruments-summary-breakdown-total-amount-currency">
|
|
136
|
+
${currency}
|
|
137
|
+
</span>
|
|
138
|
+
${(0, _utils.formatCurrency)(amount, currency)}
|
|
139
|
+
<p>
|
|
140
|
+
`);
|
|
141
|
+
element.appendChild(totalElement);
|
|
142
|
+
return element;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function mountSummary({
|
|
146
|
+
state
|
|
147
|
+
}) {
|
|
148
|
+
const contentContainer = document.createElement('div');
|
|
149
|
+
contentContainer.setAttribute('class', 'rebilly-instruments-content');
|
|
150
|
+
const lineItems = state.data.summaryLineItems;
|
|
151
|
+
|
|
152
|
+
if (lineItems) {
|
|
153
|
+
const lineItemsElement = document.createElement('div');
|
|
154
|
+
lineItemsElement.setAttribute('class', 'rebilly-instruments-summary-line-items');
|
|
155
|
+
lineItems.forEach(lineItem => {
|
|
156
|
+
lineItemsElement.insertAdjacentHTML('beforeend', lineItemHTML({
|
|
157
|
+
state,
|
|
158
|
+
lineItem
|
|
159
|
+
}));
|
|
160
|
+
});
|
|
161
|
+
contentContainer.appendChild(lineItemsElement);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const summaryBreakdownElement = document.createElement('div');
|
|
165
|
+
summaryBreakdownElement.setAttribute('class', 'rebilly-instruments-summary-breakdown');
|
|
166
|
+
contentContainer.appendChild(summaryBreakdownHTML({
|
|
167
|
+
state,
|
|
168
|
+
element: summaryBreakdownElement
|
|
169
|
+
}));
|
|
170
|
+
state.summary.appendChild(contentContainer);
|
|
171
|
+
state.summary.style.minHeight = '';
|
|
108
172
|
state.translate.translateItems();
|
|
109
173
|
state.loader.stopLoading({
|
|
110
174
|
section: 'summary',
|
|
@@ -116,6 +180,8 @@ async function updateSummary({
|
|
|
116
180
|
state,
|
|
117
181
|
instrument = null
|
|
118
182
|
}) {
|
|
183
|
+
var _state$data$transacti;
|
|
184
|
+
|
|
119
185
|
state.loader.startLoading({
|
|
120
186
|
section: 'summary',
|
|
121
187
|
id: 'initSummary'
|
|
@@ -131,26 +197,19 @@ async function updateSummary({
|
|
|
131
197
|
};
|
|
132
198
|
}
|
|
133
199
|
|
|
134
|
-
|
|
135
|
-
readyToPay,
|
|
136
|
-
summary: summaryData,
|
|
137
|
-
plans,
|
|
138
|
-
products
|
|
139
|
-
} = await (0, _fetchSummaryData.fetchSummaryData)({
|
|
200
|
+
state.data = await (0, _fetchData.fetchData)({
|
|
140
201
|
riskMetadata,
|
|
141
202
|
summaryPayload,
|
|
142
203
|
state
|
|
143
204
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
};
|
|
205
|
+
|
|
206
|
+
if (state.data.transaction && ((_state$data$transacti = state.data.transaction) === null || _state$data$transacti === void 0 ? void 0 : _state$data$transacti.type) === 'setup') {
|
|
207
|
+
state.options.transactionType = 'setup';
|
|
208
|
+
}
|
|
209
|
+
|
|
150
210
|
const itemsContainer = state.summary.querySelector('.rebilly-instruments-content');
|
|
151
211
|
itemsContainer === null || itemsContainer === void 0 ? void 0 : itemsContainer.remove();
|
|
152
212
|
mountSummary({
|
|
153
|
-
state
|
|
154
|
-
summaryOptions
|
|
213
|
+
state
|
|
155
214
|
});
|
|
156
215
|
}
|