@rebilly/instruments 3.0.0-beta.0 → 3.1.2-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/i18n/index.js +1 -1
- 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/base/__snapshots__/theme.spec.js.snap +34 -2
- package/src/style/base/default-theme.js +106 -3
- package/src/style/components/button.js +17 -1
- package/src/style/components/forms/label.js +0 -5
- 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 -195
- package/dist/style/base/default-theme.js +0 -699
- 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 -71
- 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 -69
- 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,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _rebillyInstrumentsMock = require("../../../tests/mocks/rebilly-instruments-mock");
|
|
4
|
-
|
|
5
|
-
var _instruments = require("@rebilly/instruments");
|
|
6
|
-
|
|
7
|
-
var _mswWhenThen = require("msw-when-then");
|
|
8
|
-
|
|
9
|
-
var _server = require("../../../tests/msw/server");
|
|
10
|
-
|
|
11
|
-
var _storefrontApiMock = require("../../../tests/mocks/storefront-api-mock");
|
|
12
|
-
|
|
13
|
-
var _planModel = _interopRequireDefault(require("../../storefront/models/plan-model"));
|
|
14
|
-
|
|
15
|
-
var _productModel = _interopRequireDefault(require("../../storefront/models/product-model"));
|
|
16
|
-
|
|
17
|
-
var _summaryModel = _interopRequireDefault(require("../../storefront/models/summary-model"));
|
|
18
|
-
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
|
-
describe('RebillyInstruments instance', () => {
|
|
22
|
-
it("should inject HTML to the merchant's website", async () => {
|
|
23
|
-
const framePayScriptUrl = 'https://framepay.rebilly.com/rebilly.js';
|
|
24
|
-
const framePayStyleUrl = 'https://dev.framepay.rebilly.com/rebilly.css';
|
|
25
|
-
const options = {
|
|
26
|
-
form: '.form-selector',
|
|
27
|
-
summary: '.summary-selector',
|
|
28
|
-
locale: 'auto',
|
|
29
|
-
items: [{
|
|
30
|
-
planId: 'test-plan-id-1',
|
|
31
|
-
quantity: 1
|
|
32
|
-
}],
|
|
33
|
-
theme: {
|
|
34
|
-
colorBackground: '#000'
|
|
35
|
-
},
|
|
36
|
-
css: `
|
|
37
|
-
.rebilly-instruments-summary-line-item-synopsis-title {
|
|
38
|
-
color: rgb(0, 68, 212);
|
|
39
|
-
}
|
|
40
|
-
`,
|
|
41
|
-
_dev: {
|
|
42
|
-
framePayStyleLink: framePayStyleUrl
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
await (0, _rebillyInstrumentsMock.RenderMockRebillyInstruments)(options); // Mounts form and summary
|
|
46
|
-
|
|
47
|
-
const summarySelector = document.querySelector('.summary-selector');
|
|
48
|
-
expect(summarySelector.innerHTML).toMatch('My Product'); // Theme config overrides initial styles
|
|
49
|
-
|
|
50
|
-
const SUMMARY_CONTAINER = summarySelector.querySelector('.rebilly-instruments-content');
|
|
51
|
-
expect(getComputedStyle(SUMMARY_CONTAINER).getPropertyValue('--rebilly-colorBackground')).toEqual('#000'); // CSS config property overrides initial styles
|
|
52
|
-
|
|
53
|
-
const LINE_ITEM_TITLE = document.querySelector('.rebilly-instruments-summary-line-item-synopsis-title');
|
|
54
|
-
expect(getComputedStyle(LINE_ITEM_TITLE).color).toEqual('rgb(0, 68, 212)'); // Mounts default FramePay script
|
|
55
|
-
|
|
56
|
-
const SCRIPTS = [...document.querySelectorAll('head script')];
|
|
57
|
-
const FRAMEPAY_SCRIPT = SCRIPTS.find(script => script.src === framePayScriptUrl);
|
|
58
|
-
expect(FRAMEPAY_SCRIPT.src).toEqual(framePayScriptUrl); // Mounts _dev FramePay style
|
|
59
|
-
|
|
60
|
-
const STYLE_LINKS = [...document.querySelectorAll('head link')];
|
|
61
|
-
const FRAMEPAY_STYLE = STYLE_LINKS.find(script => script.href === framePayStyleUrl);
|
|
62
|
-
expect(FRAMEPAY_STYLE.href).toEqual(framePayStyleUrl);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
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;
|
|
@@ -1,95 +0,0 @@
|
|
|
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;
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
state: {
|
|
12
|
-
options: {
|
|
13
|
-
_dev
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
} = {}) => {
|
|
17
|
-
const framePayUrls = {
|
|
18
|
-
script: _dev ? _dev.framePayScriptLink || 'https://framepay.rebilly.com/rebilly.js' : 'https://framepay.rebilly.com/rebilly.js',
|
|
19
|
-
style: _dev ? _dev.framePayStyleLink || 'https://framepay.rebilly.com/rebilly.css' : 'https://framepay.rebilly.com/rebilly.css'
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
if (!document.querySelectorAll('[framepay*="script"]').length) {
|
|
23
|
-
(0, _utils.addDOMElement)({
|
|
24
|
-
element: 'script',
|
|
25
|
-
attributes: {
|
|
26
|
-
framepay: 'script',
|
|
27
|
-
src: framePayUrls.script
|
|
28
|
-
},
|
|
29
|
-
target: 'head'
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!document.querySelectorAll('[framepay*="stylesheet"]').length) {
|
|
34
|
-
(0, _utils.addDOMElement)({
|
|
35
|
-
element: 'link',
|
|
36
|
-
attributes: {
|
|
37
|
-
framepay: 'stylesheet',
|
|
38
|
-
href: framePayUrls.style,
|
|
39
|
-
rel: 'stylesheet'
|
|
40
|
-
},
|
|
41
|
-
target: 'head'
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
exports.default = _default;
|
|
@@ -1,33 +0,0 @@
|
|
|
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;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.validateOptions = validateOptions;
|
|
7
|
-
exports.default = exports.defaults = void 0;
|
|
8
|
-
|
|
9
|
-
var _lodash = _interopRequireDefault(require("lodash.merge"));
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
const defaults = {
|
|
14
|
-
countryCode: 'US',
|
|
15
|
-
locale: 'auto',
|
|
16
|
-
theme: {
|
|
17
|
-
labels: 'floating'
|
|
18
|
-
},
|
|
19
|
-
paymentInstruments: {
|
|
20
|
-
address: {
|
|
21
|
-
name: 'default',
|
|
22
|
-
region: 'default',
|
|
23
|
-
hide: [],
|
|
24
|
-
show: [],
|
|
25
|
-
require: []
|
|
26
|
-
},
|
|
27
|
-
compactExpressInstruments: true,
|
|
28
|
-
googlePay: {
|
|
29
|
-
displayOptions: {
|
|
30
|
-
buttonColor: 'black',
|
|
31
|
-
buttonType: 'short',
|
|
32
|
-
buttonHeight: '44px'
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
applePay: {
|
|
36
|
-
displayOptions: {
|
|
37
|
-
buttonColor: 'black',
|
|
38
|
-
buttonType: 'plain',
|
|
39
|
-
buttonHeight: '44px'
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
paymentCard: {
|
|
43
|
-
popup: false
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
transactionType: 'purchase',
|
|
47
|
-
features: {
|
|
48
|
-
autoConfirmation: true,
|
|
49
|
-
autoResult: true
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
exports.defaults = defaults;
|
|
53
|
-
|
|
54
|
-
function validateOptions(options) {
|
|
55
|
-
// TODO: validate more options
|
|
56
|
-
const purchaseData = [options.items, options.invoiceId, options.money, options.transactionId].filter(v => v);
|
|
57
|
-
|
|
58
|
-
if (purchaseData.length === 0) {
|
|
59
|
-
throw new Error('Must provide purchase data');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (purchaseData.length > 1) {
|
|
63
|
-
throw new Error('Must provide only one purchase data type');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
var _default = ({
|
|
68
|
-
options = {}
|
|
69
|
-
} = {}) => {
|
|
70
|
-
validateOptions(options);
|
|
71
|
-
const _computed = {
|
|
72
|
-
paymentMethodsUrl: options._dev ? options._dev.paymentMethodsUrl || 'https://forms.local.rebilly.dev:3000' : 'https://forms.secure-payments.app'
|
|
73
|
-
};
|
|
74
|
-
const combinedOptions = (0, _lodash.default)({ ...defaults
|
|
75
|
-
}, {
|
|
76
|
-
organizationId: options.organizationId,
|
|
77
|
-
publishableKey: options.publishableKey,
|
|
78
|
-
websiteId: options.websiteId,
|
|
79
|
-
apiMode: options.apiMode,
|
|
80
|
-
i18n: options.i18n,
|
|
81
|
-
theme: options.theme,
|
|
82
|
-
css: options.css,
|
|
83
|
-
locale: options.locale,
|
|
84
|
-
countryCode: options.countryCode,
|
|
85
|
-
features: options.features,
|
|
86
|
-
paymentInstruments: options.paymentInstruments,
|
|
87
|
-
transactionType: options.transactionType,
|
|
88
|
-
_computed
|
|
89
|
-
}); // Add optional key's
|
|
90
|
-
|
|
91
|
-
['items', 'money', 'invoiceId', 'transactionId', 'customerJwt', '_dev'].forEach(key => {
|
|
92
|
-
if (options[key]) {
|
|
93
|
-
combinedOptions[key] = options[key];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
return combinedOptions;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
exports.default = _default;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _rebillyInstrumentsMock = require("../../../tests/mocks/rebilly-instruments-mock");
|
|
4
|
-
|
|
5
|
-
var _setupOptions = _interopRequireWildcard(require("./setup-options"));
|
|
6
|
-
|
|
7
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
8
|
-
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
-
|
|
11
|
-
describe('Setup mount options', () => {
|
|
12
|
-
it("should fill with default options", () => {
|
|
13
|
-
const options = (0, _setupOptions.default)({
|
|
14
|
-
options: {
|
|
15
|
-
items: [{
|
|
16
|
-
planId: "test-plan-id",
|
|
17
|
-
quantity: 1
|
|
18
|
-
}]
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
expect(options).toMatchObject(_setupOptions.defaults);
|
|
22
|
-
});
|
|
23
|
-
it("should setup options from mount", async () => {
|
|
24
|
-
const options = {
|
|
25
|
-
publishableKey: 'test-publishable-key',
|
|
26
|
-
organizationId: 'test-organization-id',
|
|
27
|
-
websiteId: 'test-website-id',
|
|
28
|
-
invoiceId: 'test-invoice-id',
|
|
29
|
-
customerJwt: 'test-customer-jwt'
|
|
30
|
-
};
|
|
31
|
-
const rebillyInstruments = await (0, _rebillyInstrumentsMock.RenderMockRebillyInstruments)(options);
|
|
32
|
-
expect(rebillyInstruments.state.options).toMatchObject(options);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe('Validate mount options', () => {
|
|
36
|
-
it("should throw an error with no purchase data", async () => {
|
|
37
|
-
let error = null;
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
const options = {};
|
|
41
|
-
(0, _setupOptions.validateOptions)(options);
|
|
42
|
-
} catch (e) {
|
|
43
|
-
error = e;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
expect(error.message).toBe('Must provide purchase data');
|
|
47
|
-
});
|
|
48
|
-
it("should throw error if there are more than one purchase property", () => {
|
|
49
|
-
let error = null;
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
const options = {
|
|
53
|
-
invoiceId: "test-invoice-id",
|
|
54
|
-
items: [{
|
|
55
|
-
planId: "test-plan-id",
|
|
56
|
-
quantity: 1
|
|
57
|
-
}]
|
|
58
|
-
};
|
|
59
|
-
(0, _setupOptions.validateOptions)(options);
|
|
60
|
-
} catch (e) {
|
|
61
|
-
error = e;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
expect(error.message).toBe('Must provide only one purchase data type');
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _storefront = _interopRequireDefault(require("../../storefront"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
var _default = ({
|
|
13
|
-
options: {
|
|
14
|
-
publishableKey,
|
|
15
|
-
orgnizationId,
|
|
16
|
-
apiMode,
|
|
17
|
-
_dev
|
|
18
|
-
}
|
|
19
|
-
}) => {
|
|
20
|
-
const storefront = {
|
|
21
|
-
publishableKey,
|
|
22
|
-
orgnizationId,
|
|
23
|
-
mode: apiMode || 'live'
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (_dev) {
|
|
27
|
-
storefront.liveUrl = _dev.liveUrl || 'https://api.rebilly.com';
|
|
28
|
-
storefront.sandboxUrl = _dev.sandboxUrl || 'https://api-sandbox.rebilly.com';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return (0, _storefront.default)(storefront);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
exports.default = _default;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _style = require("../../style");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../../utils");
|
|
11
|
-
|
|
12
|
-
var _default = async ({
|
|
13
|
-
options: {
|
|
14
|
-
theme = {},
|
|
15
|
-
css
|
|
16
|
-
}
|
|
17
|
-
} = {}) => {
|
|
18
|
-
// Adds base stylesheet
|
|
19
|
-
const style = await (0, _style.mainStyle)(theme || {});
|
|
20
|
-
(0, _utils.addDOMElement)({
|
|
21
|
-
element: 'style',
|
|
22
|
-
attributes: {
|
|
23
|
-
type: 'text/css'
|
|
24
|
-
},
|
|
25
|
-
content: style,
|
|
26
|
-
target: 'head'
|
|
27
|
-
}); // Adds options CSS to override any styles
|
|
28
|
-
|
|
29
|
-
if (css) {
|
|
30
|
-
(0, _utils.addDOMElement)({
|
|
31
|
-
element: 'style',
|
|
32
|
-
attributes: {
|
|
33
|
-
type: 'text/css'
|
|
34
|
-
},
|
|
35
|
-
content: css,
|
|
36
|
-
target: 'head'
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return style;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
exports.default = _default;
|
package/dist/functions/on.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.on = on;
|
|
7
|
-
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash.camelcase"));
|
|
9
|
-
|
|
10
|
-
var _events = _interopRequireWildcard(require("../events"));
|
|
11
|
-
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
@typedef OnParams
|
|
20
|
-
@type {Object}
|
|
21
|
-
@property {string} eventName - The name of the event
|
|
22
|
-
@property {function} callback - The function that is triggered by the event.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Register events that will be triggered
|
|
27
|
-
* @param {OnParams} params
|
|
28
|
-
*/
|
|
29
|
-
function on({
|
|
30
|
-
eventName,
|
|
31
|
-
callback
|
|
32
|
-
}) {
|
|
33
|
-
if (!_events.publicEventNames.includes(eventName)) {
|
|
34
|
-
throw new Error(`${eventName} is not a supported event`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const internalEventName = (0, _lodash.default)(eventName);
|
|
38
|
-
|
|
39
|
-
_events.default[internalEventName].addEventListener(callback);
|
|
40
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _lodash = _interopRequireDefault(require("lodash.camelcase"));
|
|
4
|
-
|
|
5
|
-
var _rebillyInstrumentsMock = require("../../tests/mocks/rebilly-instruments-mock");
|
|
6
|
-
|
|
7
|
-
var _events = _interopRequireDefault(require("../events"));
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
describe('RebillyInstruments on', () => {
|
|
12
|
-
it('should register event listeners', async () => {
|
|
13
|
-
const rebillyInstruments = await (0, _rebillyInstrumentsMock.RenderMockRebillyInstruments)();
|
|
14
|
-
const publicEventNames = ['instrument-ready', 'purchase-completed'];
|
|
15
|
-
await Promise.all(publicEventNames.map(async eventName => {
|
|
16
|
-
const callback = jest.fn();
|
|
17
|
-
rebillyInstruments.on(eventName, callback);
|
|
18
|
-
const details = {
|
|
19
|
-
test: 'data'
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
_events.default[(0, _lodash.default)(eventName)].dispatch(details);
|
|
23
|
-
|
|
24
|
-
expect(callback).toBeCalledTimes(1);
|
|
25
|
-
expect(callback).toBeCalledWith(details);
|
|
26
|
-
}));
|
|
27
|
-
});
|
|
28
|
-
it('should throw error for internal namespaced events', async () => {
|
|
29
|
-
const callback = jest.fn();
|
|
30
|
-
const rebillyInstruments = await (0, _rebillyInstrumentsMock.RenderMockRebillyInstruments)();
|
|
31
|
-
let error;
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
// rebilly-instruments-purchase-completed will be used internally but not available externally
|
|
35
|
-
await rebillyInstruments.on('rebilly-instruments-purchase-completed', callback);
|
|
36
|
-
} catch (e) {
|
|
37
|
-
error = e;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
expect(error).toEqual(new Error('rebilly-instruments-purchase-completed is not a supported event'));
|
|
41
|
-
});
|
|
42
|
-
it('should throw error for a non defined event', async () => {
|
|
43
|
-
const callback = jest.fn();
|
|
44
|
-
const rebillyInstruments = await (0, _rebillyInstrumentsMock.RenderMockRebillyInstruments)();
|
|
45
|
-
let error;
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
await rebillyInstruments.on('not-an-event', callback);
|
|
49
|
-
} catch (e) {
|
|
50
|
-
error = e;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
expect(error).toEqual(new Error('not-an-event is not a supported event'));
|
|
54
|
-
});
|
|
55
|
-
});
|