@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
|
@@ -5,20 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.mount = mount;
|
|
7
7
|
|
|
8
|
-
var _riskDataCollector = require("@rebilly/risk-data-collector");
|
|
9
|
-
|
|
10
8
|
var _summary = require("../../views/summary");
|
|
11
9
|
|
|
12
10
|
var _methodSelector = require("../../views/method-selector");
|
|
13
11
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var _fetchSummaryData = require("./fetch-summary-data");
|
|
12
|
+
var _fetchData = require("./fetch-data");
|
|
17
13
|
|
|
18
14
|
var _show = require("../show");
|
|
19
15
|
|
|
20
16
|
var _on = require("../on");
|
|
21
17
|
|
|
18
|
+
var _setupElement = _interopRequireDefault(require("./setup-element"));
|
|
19
|
+
|
|
22
20
|
var _setupStorefront = _interopRequireDefault(require("./setup-storefront"));
|
|
23
21
|
|
|
24
22
|
var _setupOptions = _interopRequireDefault(require("./setup-options"));
|
|
@@ -27,6 +25,10 @@ var _setupFramepay = _interopRequireDefault(require("./setup-framepay"));
|
|
|
27
25
|
|
|
28
26
|
var _setupStyles = _interopRequireDefault(require("./setup-styles"));
|
|
29
27
|
|
|
28
|
+
var _setupI18n = _interopRequireDefault(require("./setup-i18n"));
|
|
29
|
+
|
|
30
|
+
var _setupFramepayTheme = _interopRequireDefault(require("./setup-framepay-theme"));
|
|
31
|
+
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
33
|
|
|
32
34
|
/* eslint-disable max-len */
|
|
@@ -36,196 +38,152 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
36
38
|
* @property {string} planId - The Rebilly id of the plan.
|
|
37
39
|
* @property {number} quantity - The number of the plans to be purchased.
|
|
38
40
|
* @property {string} thumbnail - The source img for the product. Recommend 100px by 100px.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* @
|
|
43
|
-
* @property {
|
|
44
|
-
*
|
|
45
|
-
* @
|
|
46
|
-
* @property {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* @typedef {
|
|
51
|
-
* @
|
|
52
|
-
*
|
|
53
|
-
* @param {string} buttonHeight - The value and units of the button to match other payment buttons
|
|
54
|
-
* <br>example: "44px", "1rem" etc.
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
/**
|
|
41
|
+
*
|
|
42
|
+
* @typedef {object} GooglePayDisplayOptions
|
|
43
|
+
* @property {"back" | "white"} [buttonColor=black] - Color of google pay button
|
|
44
|
+
* @property {"short" | "long"} [buttonType=short] - The length of the button
|
|
45
|
+
* @property {string} [buttonHeight=44px] - The value and units of the button to match other payment buttons
|
|
46
|
+
*
|
|
47
|
+
* @typedef {object} ApplePayDisplayOptions
|
|
48
|
+
* @property {"back" | "white"} [buttonColor=black] - Color of apple pay button
|
|
49
|
+
* @property {"short" | "long"} [buttonType=short] - The length of the button
|
|
50
|
+
* @property {string} [buttonHeight=44px] - The value and units of the button to match other payment buttons
|
|
51
|
+
*
|
|
52
|
+
* @typedef {object} ApplePayMerchantOptions
|
|
53
|
+
* @property {string} merchantName - The name of the merchant store.
|
|
54
|
+
*
|
|
58
55
|
* @typedef {object} GooglePay
|
|
59
|
-
* @
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
* @property {GooglePayDisplayOptions} displayOptions - display options for google pay instrument
|
|
57
|
+
*
|
|
58
|
+
* @typedef {object} ApplePay
|
|
59
|
+
* @property {ApplePayDisplayOptions} displayOptions - display options for apple pay instrument
|
|
60
|
+
* @property {ApplePayMerchantOptions} merchantOptions - merchant options for apple pay instrument
|
|
61
|
+
*
|
|
63
62
|
* @typedef {object} PaymentCard
|
|
64
|
-
* @
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
/**
|
|
63
|
+
* @property {boolean} [popup=true] - Show method as a button with a form popup. Otherwise the form will be mounted inline.
|
|
64
|
+
*
|
|
69
65
|
* @typedef {object} Address
|
|
70
|
-
* @
|
|
71
|
-
* @
|
|
72
|
-
* @
|
|
73
|
-
* @
|
|
74
|
-
* @
|
|
75
|
-
*
|
|
76
|
-
* <br>First name and last name are always required. Country is always required if the products require shipping.
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
/**
|
|
66
|
+
* @property {string} [name=default] - One of default, combined, or stacked.
|
|
67
|
+
* @property {string} [region=default] - One of default, split, or stacked.
|
|
68
|
+
* @property {Array.<"organization" | "phoneNumber">} show - Show extra fields listed.
|
|
69
|
+
* @property {Array.<"address" | "address2" | "email | "country" | "region" | "postalCode"">} hide - Hide the listed fields.
|
|
70
|
+
* @property {Array.<"organization" | "address" | "address2" | "email" | "phoneNumber" | "country" | "region" | "postalCode">} require - Require the listed fields.
|
|
71
|
+
*
|
|
80
72
|
* @typedef {object} PaymentInstruments
|
|
81
|
-
* @
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
84
|
-
* @
|
|
85
|
-
* @
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
/**
|
|
73
|
+
* @property {boolean} [compactExpressInstruments=true] - Show express methods as inline pill buttons, or list of full width button.
|
|
74
|
+
* @property {PaymentCard} paymentCard - settings for payment card instruments
|
|
75
|
+
* @property {GooglePay} googlePay - settings for google pay instruments
|
|
76
|
+
* @property {ApplePay} applePay - settings for apple pay instruments
|
|
77
|
+
* @property {Address} address - customization for address components for all payment instruments.
|
|
78
|
+
*
|
|
89
79
|
* @typedef {object} Features
|
|
90
|
-
* @
|
|
91
|
-
*
|
|
92
|
-
* <br>Can use RebillyInstruments.show('confirmation', options) to mount defautl component
|
|
93
|
-
* @param {boolean} autoResult - default: true. Show results of transaction after `purchase-completed` event is triggered
|
|
94
|
-
* <br>Will need to handle purchase result manually if set to false.
|
|
95
|
-
* <br>Can use RebillyInstruments.show('result', options) to display default component
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @typedef {object} Options
|
|
100
|
-
* @property {Intent} intent - The information required for purchaseing or vaulting an instrument
|
|
101
|
-
* @property {PaymentInstruments} paymentInstruments - settings for various payment instruments
|
|
102
|
-
* @property {Features} features - flags to enable and disable different features
|
|
103
|
-
* @property {string} locale - default: auto. Language to render component text
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Mount library with configurations.
|
|
108
|
-
* @typedef {object} MountParams
|
|
109
|
-
* @property {Object} state - Global state
|
|
110
|
-
* @property {string | HTMLElement} form - The CSS class or HTML element were the form will be mounted.
|
|
111
|
-
* @property {string | HTMLElement} form - The CSS class or HTML element were the form will be mounted.
|
|
112
|
-
* @property {string | HTMLElement} summary - The CSS class or HTML element were the summary will be mounted.
|
|
113
|
-
* @property {Options} options - The configurations that are to be passed to the library for use.
|
|
80
|
+
* @property {boolean} [autoConfirmation=true] - Will mount the confirmation screen after `instrument-ready` event is triggered.
|
|
81
|
+
* @property {boolean} [autoResult=true] - Show results of transaction after `purchase-completed` event is triggered
|
|
114
82
|
*/
|
|
115
83
|
|
|
116
84
|
/**
|
|
117
85
|
* Mount library with configurations.
|
|
118
|
-
* @param {
|
|
86
|
+
* @param {object} options - The options object
|
|
87
|
+
* @param {object} options.state - Global state
|
|
88
|
+
* @param {string | HTMLElement} options.form - The CSS class or HTML element were the form will be mounted.
|
|
89
|
+
* @param {string | HTMLElement} options.summary - The CSS class or HTML element were the summary will be mounted.
|
|
90
|
+
* @param {Item[]} options.items - Which plans the customer is purchasing.
|
|
91
|
+
* @param {string} options.invoiceId - The Rebilly id of the invoice used for purchasing.
|
|
92
|
+
* @param {string} options.customerJwt - The customer token to access the invoice.
|
|
93
|
+
* @param {string} [options.countryCode=USD] - The country code for the transaction
|
|
94
|
+
* @param {PaymentInstruments} options.paymentInstruments - settings for various payment instruments
|
|
95
|
+
* @param {Features} options.features - flags to enable and disable different features
|
|
96
|
+
* @param {string} options.locale - default: auto. Language to render component text
|
|
119
97
|
*/
|
|
120
98
|
async function mount({
|
|
121
99
|
state,
|
|
122
|
-
form = '.rebilly-instruments',
|
|
123
|
-
summary = '.rebilly-instruments-summary',
|
|
124
100
|
...options
|
|
125
101
|
} = {}) {
|
|
126
|
-
state.form = form;
|
|
127
|
-
state.summary = summary;
|
|
128
|
-
state.storefront = (0, _setupStorefront.default)(options);
|
|
129
|
-
state.options = (0, _setupOptions.default)(options);
|
|
130
|
-
state.mainStyle = await (0, _setupStyles.default)(options);
|
|
131
|
-
state._dev = options._dev;
|
|
132
|
-
(0, _setupFramepay.default)(options);
|
|
133
|
-
state.form = (0, _utils.processPropertyAsDOMElement)({
|
|
134
|
-
prop: state.form,
|
|
135
|
-
propName: 'form'
|
|
136
|
-
});
|
|
137
|
-
state.summary = (0, _utils.processPropertyAsDOMElement)({
|
|
138
|
-
prop: state.summary,
|
|
139
|
-
propName: 'summary',
|
|
140
|
-
isRequired: false
|
|
141
|
-
}); // Setup loader
|
|
142
|
-
|
|
143
|
-
state.loader.addDOMElement({
|
|
144
|
-
el: state.form
|
|
145
|
-
});
|
|
146
|
-
state.loader.addDOMElement({
|
|
147
|
-
section: 'summary',
|
|
148
|
-
el: state.summary
|
|
149
|
-
});
|
|
150
|
-
|
|
151
102
|
try {
|
|
152
|
-
var
|
|
103
|
+
var _state$data$transacti;
|
|
104
|
+
|
|
105
|
+
state.data = {};
|
|
106
|
+
state.options = {}; // Setup DOM
|
|
153
107
|
|
|
108
|
+
state.form = (0, _setupElement.default)({
|
|
109
|
+
element: 'form',
|
|
110
|
+
options
|
|
111
|
+
});
|
|
112
|
+
state.summary = (0, _setupElement.default)({
|
|
113
|
+
element: 'summary',
|
|
114
|
+
options
|
|
115
|
+
}); // Setup loader
|
|
116
|
+
|
|
117
|
+
state.loader.addDOMElement({
|
|
118
|
+
el: state.form
|
|
119
|
+
});
|
|
120
|
+
state.loader.addDOMElement({
|
|
121
|
+
section: 'summary',
|
|
122
|
+
el: state.summary
|
|
123
|
+
});
|
|
154
124
|
state.loader.startLoading({
|
|
155
125
|
section: 'summary',
|
|
156
126
|
id: 'initSummary'
|
|
157
127
|
});
|
|
158
128
|
state.loader.startLoading({
|
|
159
129
|
id: 'initForm'
|
|
160
|
-
});
|
|
161
|
-
const {
|
|
162
|
-
riskMetadata
|
|
163
|
-
} = await (0, _riskDataCollector.collectData)();
|
|
164
|
-
|
|
165
|
-
if (state.options.locale === 'auto' && riskMetadata !== null && riskMetadata !== void 0 && (_riskMetadata$browser = riskMetadata.browserData) !== null && _riskMetadata$browser !== void 0 && _riskMetadata$browser.language) {
|
|
166
|
-
const {
|
|
167
|
-
browserData: {
|
|
168
|
-
language
|
|
169
|
-
}
|
|
170
|
-
} = riskMetadata;
|
|
171
|
-
state.options.locale = language;
|
|
172
|
-
}
|
|
130
|
+
}); // Setup state
|
|
173
131
|
|
|
174
|
-
state.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
132
|
+
state.storefront = (0, _setupStorefront.default)({
|
|
133
|
+
options
|
|
134
|
+
});
|
|
135
|
+
state.options = (0, _setupOptions.default)({
|
|
136
|
+
options
|
|
137
|
+
});
|
|
138
|
+
state.mainStyle = await (0, _setupStyles.default)({
|
|
139
|
+
options
|
|
140
|
+
});
|
|
141
|
+
state.data = await (0, _fetchData.fetchData)({
|
|
182
142
|
state
|
|
183
143
|
});
|
|
184
|
-
state.
|
|
144
|
+
state.options.themeFramepay = await (0, _setupFramepayTheme.default)({
|
|
145
|
+
state,
|
|
146
|
+
options
|
|
147
|
+
});
|
|
148
|
+
const i18n = (0, _setupI18n.default)({
|
|
149
|
+
state
|
|
150
|
+
});
|
|
151
|
+
(0, _setupFramepay.default)({
|
|
152
|
+
state
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
if (state.data.transaction && ((_state$data$transacti = state.data.transaction) === null || _state$data$transacti === void 0 ? void 0 : _state$data$transacti.type) === 'setup') {
|
|
156
|
+
state.options.transactionType = 'setup';
|
|
157
|
+
} // Mount content
|
|
158
|
+
|
|
185
159
|
|
|
186
160
|
if (state.form) {
|
|
187
|
-
const formOptions = {
|
|
188
|
-
summary: summaryData,
|
|
189
|
-
mainStyle: state.mainStyle,
|
|
190
|
-
readyToPay,
|
|
191
|
-
plans,
|
|
192
|
-
products
|
|
193
|
-
};
|
|
194
161
|
(0, _methodSelector.mountMethodSelector)({
|
|
195
|
-
state
|
|
196
|
-
formOptions
|
|
162
|
+
state
|
|
197
163
|
});
|
|
198
164
|
}
|
|
199
165
|
|
|
200
166
|
if (state.summary) {
|
|
201
|
-
const summaryOptions = {
|
|
202
|
-
summary: summaryData,
|
|
203
|
-
readyToPay,
|
|
204
|
-
plans,
|
|
205
|
-
products
|
|
206
|
-
};
|
|
207
167
|
(0, _summary.mountSummary)({
|
|
208
|
-
state
|
|
209
|
-
summaryOptions
|
|
168
|
+
state
|
|
210
169
|
});
|
|
211
170
|
}
|
|
171
|
+
|
|
172
|
+
i18n({
|
|
173
|
+
state
|
|
174
|
+
});
|
|
175
|
+
state.hasMounted = true;
|
|
212
176
|
} catch (error) {
|
|
213
177
|
throw error;
|
|
214
178
|
}
|
|
215
179
|
|
|
216
|
-
state.translate.init(state.options.locale, state.options.i18n);
|
|
217
|
-
state.translate.translateItems();
|
|
218
|
-
|
|
219
180
|
if (state.options.features.autoConfirmation) {
|
|
220
181
|
(0, _on.on)({
|
|
221
182
|
eventName: 'instrument-ready',
|
|
222
|
-
callback:
|
|
183
|
+
callback: payload => {
|
|
223
184
|
(0, _show.show)({
|
|
224
185
|
componentName: 'confirmation',
|
|
225
|
-
payload
|
|
226
|
-
instrument,
|
|
227
|
-
mainStyle: state.mainStyle
|
|
228
|
-
},
|
|
186
|
+
payload,
|
|
229
187
|
state
|
|
230
188
|
});
|
|
231
189
|
}
|
|
@@ -233,18 +191,28 @@ async function mount({
|
|
|
233
191
|
}
|
|
234
192
|
|
|
235
193
|
if (state.options.features.autoResult) {
|
|
236
|
-
(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
194
|
+
if (state.options.transactionType === 'setup') {
|
|
195
|
+
(0, _on.on)({
|
|
196
|
+
eventName: 'setup-completed',
|
|
197
|
+
callback: payload => {
|
|
198
|
+
(0, _show.show)({
|
|
199
|
+
componentName: 'result',
|
|
200
|
+
payload,
|
|
201
|
+
state
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
} else {
|
|
206
|
+
(0, _on.on)({
|
|
207
|
+
eventName: 'purchase-completed',
|
|
208
|
+
callback: payload => {
|
|
209
|
+
(0, _show.show)({
|
|
210
|
+
componentName: 'result',
|
|
211
|
+
payload,
|
|
212
|
+
state
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
249
217
|
}
|
|
250
218
|
}
|
|
@@ -31,9 +31,7 @@ describe('RebillyInstruments instance', () => {
|
|
|
31
31
|
quantity: 1
|
|
32
32
|
}],
|
|
33
33
|
theme: {
|
|
34
|
-
|
|
35
|
-
background: '#000'
|
|
36
|
-
}
|
|
34
|
+
colorBackground: '#000'
|
|
37
35
|
},
|
|
38
36
|
css: `
|
|
39
37
|
.rebilly-instruments-summary-line-item-synopsis-title {
|
|
@@ -50,7 +48,7 @@ describe('RebillyInstruments instance', () => {
|
|
|
50
48
|
expect(summarySelector.innerHTML).toMatch('My Product'); // Theme config overrides initial styles
|
|
51
49
|
|
|
52
50
|
const SUMMARY_CONTAINER = summarySelector.querySelector('.rebilly-instruments-content');
|
|
53
|
-
expect(getComputedStyle(SUMMARY_CONTAINER).
|
|
51
|
+
expect(getComputedStyle(SUMMARY_CONTAINER).getPropertyValue('--rebilly-colorBackground')).toEqual('#000'); // CSS config property overrides initial styles
|
|
54
52
|
|
|
55
53
|
const LINE_ITEM_TITLE = document.querySelector('.rebilly-instruments-summary-line-item-synopsis-title');
|
|
56
54
|
expect(getComputedStyle(LINE_ITEM_TITLE).color).toEqual('rgb(0, 68, 212)'); // Mounts default FramePay script
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _utils = require("../../utils");
|
|
9
|
+
|
|
10
|
+
var _default = ({
|
|
11
|
+
element = '',
|
|
12
|
+
options = {}
|
|
13
|
+
}) => {
|
|
14
|
+
if (element !== 'form' && element !== 'summary') {
|
|
15
|
+
throw new Error('element must be "form" or "summary"');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const getProp = () => {
|
|
19
|
+
if (options[element]) {
|
|
20
|
+
return options[element];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
switch (element) {
|
|
24
|
+
case 'summary':
|
|
25
|
+
return '.rebilly-instruments-summary';
|
|
26
|
+
|
|
27
|
+
case 'form':
|
|
28
|
+
default:
|
|
29
|
+
return '.rebilly-instruments';
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (0, _utils.processPropertyAsDOMElement)({
|
|
34
|
+
prop: getProp(),
|
|
35
|
+
propName: element,
|
|
36
|
+
isRequired: ['form'].includes(element)
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.default = _default;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _css = _interopRequireDefault(require("css"));
|
|
9
|
+
|
|
10
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
|
11
|
+
|
|
12
|
+
var _postcssCustomProperties = _interopRequireDefault(require("postcss-custom-properties"));
|
|
13
|
+
|
|
14
|
+
var _lodash = _interopRequireDefault(require("lodash.camelcase"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
const resolveCssVars = async rawCss => (0, _postcss.default)([(0, _postcssCustomProperties.default)({
|
|
19
|
+
preserve: false
|
|
20
|
+
})]).process(rawCss, {
|
|
21
|
+
from: undefined
|
|
22
|
+
}).then(output => output.css);
|
|
23
|
+
|
|
24
|
+
const getStyleProps = (ast, selector) => {
|
|
25
|
+
const {
|
|
26
|
+
rules
|
|
27
|
+
} = ast.stylesheet;
|
|
28
|
+
const output = {
|
|
29
|
+
color: null,
|
|
30
|
+
fontFamily: null,
|
|
31
|
+
fontSize: null,
|
|
32
|
+
lineHeight: null,
|
|
33
|
+
fontWeight: null,
|
|
34
|
+
background: null
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
for (let i = 0; i < rules.length; i += 1) {
|
|
38
|
+
const rule = rules[i];
|
|
39
|
+
|
|
40
|
+
if (rule.type === 'rule' && rule.selectors.includes(selector)) {
|
|
41
|
+
rule.declarations.forEach(decl => {
|
|
42
|
+
const propName = (0, _lodash.default)(decl.property);
|
|
43
|
+
|
|
44
|
+
if (typeof output[propName] !== 'undefined') {
|
|
45
|
+
output[propName] = decl.value;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return output;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var _default = async ({
|
|
55
|
+
state,
|
|
56
|
+
options = {}
|
|
57
|
+
}) => {
|
|
58
|
+
const fullCss = `
|
|
59
|
+
${state.mainStyle}
|
|
60
|
+
${options.css || ''}
|
|
61
|
+
`;
|
|
62
|
+
const resolvedCss = await resolveCssVars(fullCss);
|
|
63
|
+
|
|
64
|
+
const cssAst = _css.default.parse(resolvedCss);
|
|
65
|
+
|
|
66
|
+
const cssSelectors = {
|
|
67
|
+
base: '.rebilly-instruments-form-field-input',
|
|
68
|
+
baseHover: '.rebilly-instruments-form-field-input:hover',
|
|
69
|
+
baseFocus: '.rebilly-instruments-form-field-input:focus',
|
|
70
|
+
basePlaceholder: '.rebilly-instruments-form-field-input::placeholder',
|
|
71
|
+
baseSelection: '.rebilly-instruments-form-field-input::selection',
|
|
72
|
+
invalid: '.rebilly-instruments-form-field.is-error .rebilly-instruments-form-field-input',
|
|
73
|
+
invalidHover: '.rebilly-instruments-form-field.is-error .rebilly-instruments-form-field-input:hover',
|
|
74
|
+
invalidFocus: '.rebilly-instruments-form-field.is-error .rebilly-instruments-form-field-input:focus',
|
|
75
|
+
invalidPlaceholder: '.rebilly-instruments-form-field.is-error .rebilly-instruments-form-field-input::placeholder',
|
|
76
|
+
invalidSelection: '.rebilly-instruments-form-field.is-error .rebilly-instruments-form-field-input::selection'
|
|
77
|
+
};
|
|
78
|
+
const framepayStyle = {
|
|
79
|
+
base: { ...getStyleProps(cssAst, cssSelectors.base),
|
|
80
|
+
':hover': getStyleProps(cssAst, cssSelectors.baseHover),
|
|
81
|
+
':focus': getStyleProps(cssAst, cssSelectors.baseFocus),
|
|
82
|
+
'::placeholder': getStyleProps(cssAst, cssSelectors.basePlaceholder),
|
|
83
|
+
'::selection': getStyleProps(cssAst, cssSelectors.baseSelection)
|
|
84
|
+
},
|
|
85
|
+
invalid: { ...getStyleProps(cssAst, cssSelectors.invalid),
|
|
86
|
+
':hover': getStyleProps(cssAst, cssSelectors.invalidHover),
|
|
87
|
+
':focus': getStyleProps(cssAst, cssSelectors.invalidFocus),
|
|
88
|
+
'::placeholder': getStyleProps(cssAst, cssSelectors.invalidPlaceholder),
|
|
89
|
+
'::selection': getStyleProps(cssAst, cssSelectors.invalidSelection)
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return framepayStyle;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
exports.default = _default;
|
|
@@ -8,7 +8,11 @@ exports.default = void 0;
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
10
|
var _default = ({
|
|
11
|
-
|
|
11
|
+
state: {
|
|
12
|
+
options: {
|
|
13
|
+
_dev
|
|
14
|
+
}
|
|
15
|
+
}
|
|
12
16
|
} = {}) => {
|
|
13
17
|
const framePayUrls = {
|
|
14
18
|
script: _dev ? _dev.framePayScriptLink || 'https://framepay.rebilly.com/rebilly.js' : 'https://framepay.rebilly.com/rebilly.js',
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
const triggerTranslations = ({
|
|
9
|
+
state
|
|
10
|
+
}) => {
|
|
11
|
+
state.translate.init(state.options.locale, state.options.i18n);
|
|
12
|
+
state.translate.translateItems();
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
var _default = ({
|
|
16
|
+
state = {}
|
|
17
|
+
}) => {
|
|
18
|
+
var _state$data$riskMetad, _state$data$riskMetad2;
|
|
19
|
+
|
|
20
|
+
if (state.options.locale === 'auto' && (_state$data$riskMetad = state.data.riskMetadata) !== null && _state$data$riskMetad !== void 0 && (_state$data$riskMetad2 = _state$data$riskMetad.browserData) !== null && _state$data$riskMetad2 !== void 0 && _state$data$riskMetad2.language) {
|
|
21
|
+
const {
|
|
22
|
+
browserData: {
|
|
23
|
+
language
|
|
24
|
+
}
|
|
25
|
+
} = state.data.riskMetadata;
|
|
26
|
+
state.options.locale = language;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
state.translate.init(state.options.locale, state.options.i18n);
|
|
30
|
+
return triggerTranslations;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.default = _default;
|