@rebilly/instruments 1.0.1-beta → 1.0.2-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +23 -5
- package/.eslintrc.js +27 -0
- package/.prettierrc.js +11 -0
- package/CONTRIBUTING.md +4 -0
- package/README.md +361 -2
- package/dist/events/base-event.js +51 -37
- package/dist/events/events.spec.js +18 -0
- package/dist/events/index.js +11 -8
- package/dist/functions/destroy.js +27 -5
- package/dist/functions/destroy.spec.js +69 -0
- package/dist/functions/initialize.js +60 -41
- package/dist/functions/initialize.spec.js +13 -13
- package/dist/functions/mount/fetch-summary-data.js +46 -0
- package/dist/functions/mount/fetch-summary-data.spec.js +44 -0
- package/dist/functions/mount/index.js +346 -0
- package/dist/functions/mount/mount.spec.js +135 -0
- package/dist/functions/on.js +26 -18
- package/dist/functions/on.spec.js +45 -63
- package/dist/functions/purchase.js +41 -154
- package/dist/functions/purchase.spec.js +60 -76
- package/dist/functions/show.js +39 -43
- package/dist/functions/show.spec.js +57 -0
- package/dist/functions/update.js +60 -5
- package/dist/functions/update.spec.js +100 -0
- package/dist/i18n/en.json +19 -0
- package/dist/i18n/es.json +19 -0
- package/dist/i18n/i18n.spec.js +6 -23
- package/dist/i18n/index.js +44 -67
- package/dist/index.js +70 -71
- package/dist/index.spec.js +24 -44
- package/dist/loader/index.js +63 -62
- package/dist/loader/loader.spec.js +14 -11
- package/dist/storefront/index.js +28 -39
- package/dist/storefront/models/plan-model.js +37 -54
- package/dist/storefront/models/product-model.js +25 -36
- package/dist/storefront/models/ready-to-pay-model.js +38 -42
- package/dist/storefront/models/summary-model.js +72 -99
- package/dist/storefront/plans.js +37 -84
- package/dist/storefront/plans.spec.js +61 -151
- package/dist/storefront/products.js +35 -83
- package/dist/storefront/products.spec.js +60 -150
- package/dist/storefront/purchase.js +27 -64
- package/dist/storefront/purchase.spec.js +51 -87
- package/dist/storefront/ready-to-pay.js +45 -107
- package/dist/storefront/ready-to-pay.spec.js +72 -147
- package/dist/storefront/storefront.spec.js +6 -6
- package/dist/storefront/summary.js +37 -84
- package/dist/storefront/summary.spec.js +135 -240
- package/dist/style/base/__snapshots__/theme.spec.js.snap +52 -0
- package/dist/style/base/index.js +72 -0
- package/dist/style/base/theme.js +73 -0
- package/dist/style/base/theme.spec.js +30 -0
- package/dist/style/browserslist.js +8 -0
- package/dist/style/components/address.js +64 -0
- package/dist/style/components/button.js +61 -0
- package/dist/style/components/divider.js +48 -0
- package/dist/style/components/forms/checkbox.js +83 -0
- package/dist/style/components/forms/field.js +53 -0
- package/dist/style/components/forms/form.js +28 -0
- package/dist/style/components/forms/input.js +45 -0
- package/dist/style/components/forms/label.js +43 -0
- package/dist/style/components/forms/select.js +63 -0
- package/dist/style/components/forms/validation.js +34 -0
- package/dist/style/components/icons.js +22 -0
- package/dist/style/components/index.js +57 -0
- package/dist/style/components/loader.js +48 -0
- package/dist/style/components/methods.js +104 -0
- package/dist/style/components/overlay.js +33 -0
- package/dist/style/helpers/index.js +59 -0
- package/dist/style/index.js +48 -0
- package/dist/style/payment-instruments/content.js +17 -0
- package/dist/style/payment-instruments/index.js +20 -0
- package/dist/style/payment-instruments/payment-card.js +35 -0
- package/dist/style/utils/color-values.js +22 -0
- package/dist/style/vendor/framepay.js +34 -0
- package/dist/style/vendor/postmate.js +17 -0
- package/dist/style/views/confirmation.js +85 -0
- package/dist/style/views/index.js +29 -0
- package/dist/style/views/method-selector.js +20 -0
- package/dist/style/views/modal.js +93 -0
- package/dist/style/views/result.js +61 -0
- package/dist/style/views/summary.js +123 -0
- package/dist/utils/add-dom-element.js +12 -34
- package/dist/utils/format-currency.js +4 -4
- package/dist/utils/has-valid-css-selector.js +2 -2
- package/dist/utils/index.js +15 -31
- package/dist/utils/is-dom-element.js +1 -1
- package/dist/utils/process-property-as-dom-element.js +12 -17
- package/dist/utils/sleep.js +10 -0
- package/{src/components → dist/views}/__snapshots__/summary.spec.js.snap +7 -3
- package/dist/views/common/iframe/base-iframe.js +57 -0
- package/dist/views/common/iframe/event-listeners.js +50 -0
- package/dist/views/common/iframe/index.js +19 -0
- package/dist/views/common/iframe/method-iframe.js +33 -0
- package/dist/views/common/iframe/modal-iframe.js +38 -0
- package/dist/views/common/iframe/view-iframe.js +31 -0
- package/dist/views/common/render-utilities.js +11 -0
- package/dist/views/confirmation.js +82 -0
- package/dist/views/method-selector/__snapshots__/method-selector.spec.js.snap +3 -0
- package/dist/views/method-selector/express-methods/apple-pay.js +92 -0
- package/dist/views/method-selector/express-methods/google-pay.js +32 -0
- package/dist/views/method-selector/express-methods/paypal.js +19 -0
- package/dist/views/method-selector/generate-digital-wallet.js +59 -0
- package/dist/views/method-selector/generate-digital-wallet.spec.js +132 -0
- package/dist/views/method-selector/get-method-data.js +25 -0
- package/dist/views/method-selector/get-payment-methods.js +55 -0
- package/dist/views/method-selector/get-payment-methods.spec.js +44 -0
- package/dist/views/method-selector/index.js +133 -0
- package/dist/views/method-selector/method-selector.spec.js +139 -0
- package/dist/views/method-selector/mount-express-methods.js +69 -0
- package/dist/views/method-selector/mount-methods.js +78 -0
- package/dist/views/modal.js +83 -0
- package/dist/views/result.js +42 -0
- package/dist/views/summary.js +162 -0
- package/dist/views/summary.spec.js +148 -0
- package/package.json +12 -6
- package/src/events/base-event.js +35 -12
- package/src/events/events.spec.js +11 -0
- package/src/events/index.js +12 -6
- package/src/functions/destroy.js +22 -3
- package/src/functions/destroy.spec.js +63 -0
- package/src/functions/initialize.js +43 -20
- package/src/functions/initialize.spec.js +9 -7
- package/src/functions/mount/fetch-summary-data.js +29 -0
- package/src/functions/mount/fetch-summary-data.spec.js +41 -0
- package/src/functions/mount/index.js +312 -0
- package/src/functions/mount/mount.spec.js +171 -0
- package/src/functions/on.js +17 -14
- package/src/functions/on.spec.js +39 -29
- package/src/functions/purchase.js +24 -64
- package/src/functions/purchase.spec.js +19 -17
- package/src/functions/show.js +27 -7
- package/src/functions/show.spec.js +61 -0
- package/src/functions/update.js +50 -3
- package/src/functions/update.spec.js +107 -0
- package/src/i18n/i18n.spec.js +6 -4
- package/src/i18n/index.js +20 -12
- package/src/index.js +43 -49
- package/src/index.spec.js +11 -42
- package/src/loader/index.js +55 -39
- package/src/loader/loader.spec.js +30 -23
- package/src/storefront/index.js +9 -7
- package/src/storefront/models/plan-model.js +1 -1
- package/src/storefront/models/product-model.js +1 -1
- package/src/storefront/models/ready-to-pay-model.js +10 -4
- package/src/storefront/models/summary-model.js +8 -15
- package/src/storefront/plans.js +16 -12
- package/src/storefront/plans.spec.js +29 -37
- package/src/storefront/products.js +16 -12
- package/src/storefront/products.spec.js +28 -39
- package/src/storefront/purchase.js +8 -6
- package/src/storefront/purchase.spec.js +18 -17
- package/src/storefront/ready-to-pay.js +19 -13
- package/src/storefront/ready-to-pay.spec.js +41 -41
- package/src/storefront/storefront.spec.js +1 -1
- package/src/storefront/summary.js +14 -12
- package/src/storefront/summary.spec.js +37 -50
- package/src/style/base/__snapshots__/theme.spec.js.snap +52 -0
- package/src/style/base/index.js +63 -0
- package/src/style/base/theme.js +61 -0
- package/src/style/base/theme.spec.js +32 -0
- package/src/style/browserslist.js +1 -0
- package/src/style/components/address.js +55 -0
- package/src/style/components/button.js +54 -0
- package/src/style/components/divider.js +39 -0
- package/src/style/components/forms/checkbox.js +76 -0
- package/src/style/components/forms/field.js +44 -0
- package/src/style/components/forms/form.js +19 -0
- package/src/style/components/forms/input.js +36 -0
- package/src/style/components/forms/label.js +34 -0
- package/src/style/components/forms/select.js +54 -0
- package/src/style/components/forms/validation.js +25 -0
- package/src/style/components/icons.js +13 -0
- package/src/style/components/index.js +35 -0
- package/src/style/components/loader.js +41 -0
- package/src/style/components/methods.js +93 -0
- package/src/style/components/overlay.js +24 -0
- package/src/style/helpers/index.js +51 -0
- package/src/style/index.js +30 -0
- package/src/style/payment-instruments/content.js +8 -0
- package/src/style/payment-instruments/index.js +10 -0
- package/src/style/payment-instruments/payment-card.js +26 -0
- package/src/style/utils/color-values.js +9 -0
- package/src/style/vendor/framepay.js +25 -0
- package/src/style/vendor/postmate.js +8 -0
- package/src/style/views/confirmation.js +76 -0
- package/src/style/views/index.js +16 -0
- package/src/style/views/method-selector.js +11 -0
- package/src/style/views/modal.js +84 -0
- package/src/style/views/result.js +52 -0
- package/src/style/views/summary.js +114 -0
- package/src/utils/add-dom-element.js +12 -13
- package/src/utils/format-currency.js +4 -1
- package/src/utils/has-valid-css-selector.js +2 -2
- package/src/utils/index.js +2 -6
- package/src/utils/is-dom-element.js +1 -1
- package/src/utils/process-property-as-dom-element.js +27 -24
- package/src/utils/sleep.js +3 -0
- package/src/views/__snapshots__/summary.spec.js.snap +292 -0
- package/src/views/common/iframe/base-iframe.js +46 -0
- package/src/views/common/iframe/event-listeners.js +27 -0
- package/src/views/common/iframe/index.js +7 -0
- package/src/views/common/iframe/method-iframe.js +21 -0
- package/src/views/common/iframe/modal-iframe.js +27 -0
- package/src/views/common/iframe/view-iframe.js +18 -0
- package/src/views/common/render-utilities.js +4 -0
- package/src/views/confirmation.js +57 -0
- package/src/views/method-selector/__snapshots__/method-selector.spec.js.snap +3 -0
- package/src/views/method-selector/express-methods/apple-pay.js +78 -0
- package/src/views/method-selector/express-methods/google-pay.js +25 -0
- package/src/views/method-selector/express-methods/paypal.js +7 -0
- package/src/views/method-selector/generate-digital-wallet.js +44 -0
- package/src/views/method-selector/generate-digital-wallet.spec.js +131 -0
- package/src/{components/form → views/method-selector}/get-method-data.js +9 -5
- package/src/views/method-selector/get-payment-methods.js +40 -0
- package/src/views/method-selector/get-payment-methods.spec.js +40 -0
- package/src/views/method-selector/index.js +110 -0
- package/src/views/method-selector/method-selector.spec.js +146 -0
- package/src/views/method-selector/mount-express-methods.js +53 -0
- package/src/views/method-selector/mount-methods.js +71 -0
- package/src/views/modal.js +84 -0
- package/src/views/result.js +30 -0
- package/src/{components → views}/summary.js +90 -21
- package/src/views/summary.spec.js +170 -0
- package/tests/async-utilities.js +22 -0
- package/tests/mocks/rebilly-instruments-mock.js +105 -7
- package/dist/components/confirmation.js +0 -103
- package/dist/components/form/form.js +0 -110
- package/dist/components/form/form.spec.js +0 -135
- package/dist/components/form/get-method-data.js +0 -21
- package/dist/components/form/get-payment-methods.js +0 -42
- package/dist/components/form/method-selector.js +0 -61
- package/dist/components/form/mount-express-payment-methods.js +0 -102
- package/dist/components/form/process-digital-wallet-options.js +0 -20
- package/dist/components/form/zoid-helpers.js +0 -130
- package/dist/components/result.js +0 -66
- package/dist/components/summary.js +0 -60
- package/dist/components/summary.spec.js +0 -144
- package/dist/events/instrument-ready.js +0 -51
- package/dist/events/purchase-complete.js +0 -51
- package/dist/functions/mount.js +0 -311
- package/dist/functions/mount.spec.js +0 -203
- package/dist/styles/base-styles.js +0 -12
- package/dist/styles/flat-theme-object.js +0 -42
- package/dist/styles/framepay.js +0 -15
- package/dist/styles/main.js +0 -25
- package/dist/styles/payment-card.js +0 -12
- package/dist/styles/shade-tint-values-helper.js +0 -28
- package/dist/styles/style-variables.js +0 -43
- package/dist/utils/camel-case.js +0 -12
- package/dist/utils/kebab-case.js +0 -10
- package/dist/utils/un-kebab-case.js +0 -10
- package/src/components/confirmation.js +0 -77
- package/src/components/form/__snapshots__/form.spec.js.snap +0 -43
- package/src/components/form/form.js +0 -88
- package/src/components/form/form.spec.js +0 -109
- package/src/components/form/get-payment-methods.js +0 -32
- package/src/components/form/method-selector.js +0 -47
- package/src/components/form/mount-express-payment-methods.js +0 -84
- package/src/components/form/process-digital-wallet-options.js +0 -11
- package/src/components/form/zoid-helpers.js +0 -114
- package/src/components/result.js +0 -50
- package/src/components/summary.spec.js +0 -106
- package/src/events/instrument-ready.js +0 -11
- package/src/events/purchase-complete.js +0 -11
- package/src/functions/mount.js +0 -204
- package/src/functions/mount.spec.js +0 -172
- package/src/styles/base-styles.js +0 -741
- package/src/styles/flat-theme-object.js +0 -12
- package/src/styles/framepay.js +0 -30
- package/src/styles/main.js +0 -17
- package/src/styles/payment-card.js +0 -18
- package/src/styles/shade-tint-values-helper.js +0 -13
- package/src/styles/style-variables.js +0 -34
- package/src/utils/camel-case.js +0 -3
- package/src/utils/kebab-case.js +0 -3
- package/src/utils/un-kebab-case.js +0 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dispatchRebillyInsturmentEventHandler = dispatchRebillyInsturmentEventHandler;
|
|
7
|
+
exports.resizeComponentHandler = resizeComponentHandler;
|
|
8
|
+
exports.stopLoaderHandler = stopLoaderHandler;
|
|
9
|
+
exports.changeIframeSrcHandler = changeIframeSrcHandler;
|
|
10
|
+
|
|
11
|
+
var _lodash = _interopRequireDefault(require("lodash.camelcase"));
|
|
12
|
+
|
|
13
|
+
var _events = _interopRequireDefault(require("../../../events"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
function dispatchRebillyInsturmentEventHandler(iframe) {
|
|
18
|
+
iframe.component.on(`${iframe.name}-dispatch`, ({
|
|
19
|
+
event,
|
|
20
|
+
detail
|
|
21
|
+
}) => {
|
|
22
|
+
_events.default[(0, _lodash.default)(event).replace(/-/, '')].dispatch(detail);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function resizeComponentHandler(iframe) {
|
|
27
|
+
iframe.component.on(`${iframe.name}-resize-frame`, height => {
|
|
28
|
+
iframe.component.frame.style.height = height;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function stopLoaderHandler(iframe, data = {
|
|
33
|
+
section: 'form'
|
|
34
|
+
}) {
|
|
35
|
+
iframe.component.on(`${iframe.name}-stop-loading`, (id = null) => {
|
|
36
|
+
var _data$loader;
|
|
37
|
+
|
|
38
|
+
(_data$loader = data.loader) === null || _data$loader === void 0 ? void 0 : _data$loader.stopLoading({
|
|
39
|
+
section: data.section,
|
|
40
|
+
id: id || data.id
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function changeIframeSrcHandler(iframe) {
|
|
46
|
+
iframe.component.on(`${iframe.name}-change-iframe-src`, (url = null) => {
|
|
47
|
+
iframe.component.frame.src = url;
|
|
48
|
+
iframe.component.frame.style.height = '75vh';
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ModalIframe = exports.ViewIframe = exports.MethodIframe = void 0;
|
|
7
|
+
|
|
8
|
+
var _methodIframe = require("./method-iframe");
|
|
9
|
+
|
|
10
|
+
var _viewIframe = require("./view-iframe");
|
|
11
|
+
|
|
12
|
+
var _modalIframe = require("./modal-iframe");
|
|
13
|
+
|
|
14
|
+
const MethodIframe = _methodIframe.MethodIframe;
|
|
15
|
+
exports.MethodIframe = MethodIframe;
|
|
16
|
+
const ViewIframe = _viewIframe.ViewIframe;
|
|
17
|
+
exports.ViewIframe = ViewIframe;
|
|
18
|
+
const ModalIframe = _modalIframe.ModalIframe;
|
|
19
|
+
exports.ModalIframe = ModalIframe;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MethodIframe = void 0;
|
|
7
|
+
|
|
8
|
+
var _baseIframe = _interopRequireDefault(require("./base-iframe"));
|
|
9
|
+
|
|
10
|
+
var _eventListeners = require("./event-listeners");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
class MethodIframe extends _baseIframe.default {
|
|
15
|
+
constructor(args = {}) {
|
|
16
|
+
super(args);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
bindEventListeners({
|
|
20
|
+
loader,
|
|
21
|
+
id
|
|
22
|
+
} = {}) {
|
|
23
|
+
(0, _eventListeners.dispatchRebillyInsturmentEventHandler)(this);
|
|
24
|
+
(0, _eventListeners.resizeComponentHandler)(this);
|
|
25
|
+
(0, _eventListeners.stopLoaderHandler)(this, {
|
|
26
|
+
loader,
|
|
27
|
+
id
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.MethodIframe = MethodIframe;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ModalIframe = void 0;
|
|
7
|
+
|
|
8
|
+
var _baseIframe = _interopRequireDefault(require("./base-iframe"));
|
|
9
|
+
|
|
10
|
+
var _eventListeners = require("./event-listeners");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
class ModalIframe extends _baseIframe.default {
|
|
15
|
+
constructor(args = {}) {
|
|
16
|
+
super(args);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
bindEventListeners({
|
|
20
|
+
close = () => {},
|
|
21
|
+
loader
|
|
22
|
+
} = {}) {
|
|
23
|
+
(0, _eventListeners.dispatchRebillyInsturmentEventHandler)(this);
|
|
24
|
+
(0, _eventListeners.resizeComponentHandler)(this);
|
|
25
|
+
(0, _eventListeners.changeIframeSrcHandler)(this);
|
|
26
|
+
this.component.on(`${this.name}-close`, (...args) => {
|
|
27
|
+
close(...args);
|
|
28
|
+
});
|
|
29
|
+
(0, _eventListeners.stopLoaderHandler)(this, {
|
|
30
|
+
loader,
|
|
31
|
+
section: 'modal',
|
|
32
|
+
id: 'modal-content'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.ModalIframe = ModalIframe;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ViewIframe = void 0;
|
|
7
|
+
|
|
8
|
+
var _baseIframe = _interopRequireDefault(require("./base-iframe"));
|
|
9
|
+
|
|
10
|
+
var _eventListeners = require("./event-listeners");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
class ViewIframe extends _baseIframe.default {
|
|
15
|
+
constructor(args = {}) {
|
|
16
|
+
super(args);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
bindEventListeners({
|
|
20
|
+
loader
|
|
21
|
+
} = {}) {
|
|
22
|
+
(0, _eventListeners.dispatchRebillyInsturmentEventHandler)(this);
|
|
23
|
+
(0, _eventListeners.resizeComponentHandler)(this);
|
|
24
|
+
(0, _eventListeners.stopLoaderHandler)(this, {
|
|
25
|
+
loader
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.ViewIframe = ViewIframe;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.replaceContent = replaceContent;
|
|
7
|
+
|
|
8
|
+
function replaceContent(form, newContent) {
|
|
9
|
+
const contentElement = form.querySelector('.rebilly-instruments-content');
|
|
10
|
+
contentElement.innerHTML = newContent;
|
|
11
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mountConfirmation = mountConfirmation;
|
|
7
|
+
exports.baseConfirmationHTML = void 0;
|
|
8
|
+
|
|
9
|
+
var _purchase = require("../functions/purchase");
|
|
10
|
+
|
|
11
|
+
var _iframe = require("./common/iframe");
|
|
12
|
+
|
|
13
|
+
var _renderUtilities = require("./common/render-utilities");
|
|
14
|
+
|
|
15
|
+
var _methodSelector = require("./method-selector");
|
|
16
|
+
|
|
17
|
+
var _summary = require("./summary");
|
|
18
|
+
|
|
19
|
+
const baseConfirmationHTML = '<div class="rebilly-instruments-confirmation"></div>';
|
|
20
|
+
exports.baseConfirmationHTML = baseConfirmationHTML;
|
|
21
|
+
|
|
22
|
+
async function mountConfirmation({
|
|
23
|
+
instrument,
|
|
24
|
+
mainStyle,
|
|
25
|
+
state
|
|
26
|
+
}) {
|
|
27
|
+
if (instrument.billingAddress && state.summary) {
|
|
28
|
+
(0, _summary.updateSummary)({
|
|
29
|
+
state,
|
|
30
|
+
instrument
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
(0, _renderUtilities.replaceContent)(state.form, baseConfirmationHTML);
|
|
35
|
+
state.loader.startLoading({
|
|
36
|
+
id: 'confirmation'
|
|
37
|
+
});
|
|
38
|
+
const container = document.querySelector('.rebilly-instruments-confirmation');
|
|
39
|
+
const {
|
|
40
|
+
paymentMethodsUrl
|
|
41
|
+
} = state.options._computed;
|
|
42
|
+
const model = {
|
|
43
|
+
configs: state.configs,
|
|
44
|
+
options: state.options,
|
|
45
|
+
mainStyle,
|
|
46
|
+
instrument
|
|
47
|
+
};
|
|
48
|
+
const name = 'rebilly-instruments-confirmation';
|
|
49
|
+
const iframe = await new _iframe.ViewIframe({
|
|
50
|
+
name,
|
|
51
|
+
url: `${paymentMethodsUrl}/confirmation`,
|
|
52
|
+
container,
|
|
53
|
+
model
|
|
54
|
+
});
|
|
55
|
+
iframe.bindEventListeners({
|
|
56
|
+
loader: state.loader
|
|
57
|
+
});
|
|
58
|
+
iframe.component.on(`${name}-confirm-purchase`, confirmedInstrument => {
|
|
59
|
+
(0, _purchase.purchase)({
|
|
60
|
+
state,
|
|
61
|
+
payload: confirmedInstrument
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
iframe.component.on('choose-another-method', () => {
|
|
65
|
+
state.iframeComponents = state.iframeComponents.filter(item => {
|
|
66
|
+
if (item.name === iframe.name) {
|
|
67
|
+
item.destroy();
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return true;
|
|
72
|
+
});
|
|
73
|
+
(0, _summary.updateSummary)({
|
|
74
|
+
state
|
|
75
|
+
});
|
|
76
|
+
(0, _methodSelector.updateMethodSelector)({
|
|
77
|
+
state,
|
|
78
|
+
mainStyle
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
state.iframeComponents.push(iframe);
|
|
82
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = mountApplePay;
|
|
7
|
+
|
|
8
|
+
var _events = _interopRequireDefault(require("../../../events"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const browserIsSafari = () => window.ApplePaySession;
|
|
13
|
+
|
|
14
|
+
function mountApplePay({
|
|
15
|
+
state,
|
|
16
|
+
METHOD_ID,
|
|
17
|
+
METHOD_TYPE,
|
|
18
|
+
EXPRESS_METHODS,
|
|
19
|
+
EXPRESS_METHODS_CONTAINER
|
|
20
|
+
}) {
|
|
21
|
+
const container = document.querySelector(`.rebilly-instruments-${METHOD_ID}-method`);
|
|
22
|
+
const digitalWallet = state.configs.digitalWallet.applePay;
|
|
23
|
+
|
|
24
|
+
function mountApplePayButton() {
|
|
25
|
+
if (!container.children.length) {
|
|
26
|
+
Rebilly.applePay.mount(`.rebilly-instruments-${METHOD_ID}-method`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
state.loader.stopLoading({
|
|
30
|
+
id: `${METHOD_TYPE}-express`
|
|
31
|
+
});
|
|
32
|
+
} // Hack: The correct way to do this is to accept the options via the framepay package
|
|
33
|
+
// Will remove once these options are added to framepay
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function updateBtnStyling() {
|
|
37
|
+
const applePayButton = document.querySelector('#rebilly-apple-pay-button');
|
|
38
|
+
applePayButton.style.margin = '0px';
|
|
39
|
+
applePayButton.style.width = '100%';
|
|
40
|
+
applePayButton.style.height = digitalWallet.applePayDisplayOptions.buttonHeight;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!browserIsSafari()) {
|
|
44
|
+
if (EXPRESS_METHODS.length === 1) {
|
|
45
|
+
EXPRESS_METHODS_CONTAINER.parentNode.style.display = 'none';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
state.loader.stopLoading({
|
|
49
|
+
id: `${METHOD_TYPE}-express`
|
|
50
|
+
});
|
|
51
|
+
container.style.display = 'none';
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
container.style.height = digitalWallet.applePayDisplayOptions.buttonHeight;
|
|
56
|
+
|
|
57
|
+
if (!Rebilly.initialized) {
|
|
58
|
+
Rebilly.initialize({
|
|
59
|
+
publishableKey: state.configs.publishableKey,
|
|
60
|
+
organizationId: state.configs.organizationId,
|
|
61
|
+
digitalWallet
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
mountApplePayButton();
|
|
65
|
+
updateBtnStyling();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Rebilly.on('ready', () => {
|
|
69
|
+
mountApplePayButton();
|
|
70
|
+
updateBtnStyling();
|
|
71
|
+
});
|
|
72
|
+
Rebilly.on('token-ready', token => {
|
|
73
|
+
const instrumentReadyPayload = {
|
|
74
|
+
websiteId: state.configs.websiteId,
|
|
75
|
+
items: state.options.intent.items,
|
|
76
|
+
paymentInstruction: {
|
|
77
|
+
token: token.id
|
|
78
|
+
},
|
|
79
|
+
billingAddress: token.billingAddress,
|
|
80
|
+
_raw: token
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (!token.shippingAddress) {
|
|
84
|
+
instrumentReadyPayload.deliveryAddress = token.shippingAddress;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_events.default.instrumentReady.dispatch(instrumentReadyPayload);
|
|
88
|
+
});
|
|
89
|
+
Rebilly.on('error', error => {
|
|
90
|
+
console.error(error);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = mountGooglePay;
|
|
7
|
+
|
|
8
|
+
var _iframe = require("../../common/iframe");
|
|
9
|
+
|
|
10
|
+
async function mountGooglePay({
|
|
11
|
+
state,
|
|
12
|
+
METHOD_ID
|
|
13
|
+
}) {
|
|
14
|
+
const container = document.querySelector(`.rebilly-instruments-${METHOD_ID}-method`);
|
|
15
|
+
const {
|
|
16
|
+
paymentMethodsUrl
|
|
17
|
+
} = state.options._computed;
|
|
18
|
+
const model = {
|
|
19
|
+
configs: state.configs,
|
|
20
|
+
options: state.options
|
|
21
|
+
};
|
|
22
|
+
const iframe = await new _iframe.MethodIframe({
|
|
23
|
+
name: METHOD_ID,
|
|
24
|
+
url: `${paymentMethodsUrl}/${METHOD_ID}`,
|
|
25
|
+
container,
|
|
26
|
+
model
|
|
27
|
+
});
|
|
28
|
+
iframe.bindEventListeners({
|
|
29
|
+
loader: state.loader
|
|
30
|
+
});
|
|
31
|
+
state.iframeComponents.push(iframe);
|
|
32
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = mountPaypal;
|
|
7
|
+
|
|
8
|
+
async function mountPaypal({
|
|
9
|
+
state,
|
|
10
|
+
METHOD_ID,
|
|
11
|
+
METHOD_TYPE
|
|
12
|
+
}) {
|
|
13
|
+
console.log('PayPal - work in progress');
|
|
14
|
+
const container = document.querySelector(`.rebilly-instruments-${METHOD_ID}-method`);
|
|
15
|
+
container.style.display = 'none';
|
|
16
|
+
state.loader.stopLoading({
|
|
17
|
+
id: `${METHOD_TYPE}-express`
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.generateDigitalWallet = generateDigitalWallet;
|
|
7
|
+
|
|
8
|
+
var _getMethodData = require("./get-method-data");
|
|
9
|
+
|
|
10
|
+
function generateDigitalWallet({
|
|
11
|
+
state,
|
|
12
|
+
summary,
|
|
13
|
+
EXPRESS_METHODS
|
|
14
|
+
}) {
|
|
15
|
+
const output = {};
|
|
16
|
+
const {
|
|
17
|
+
paymentInstruments
|
|
18
|
+
} = state.options;
|
|
19
|
+
const transactionData = {
|
|
20
|
+
amount: summary.total,
|
|
21
|
+
currency: summary.currency,
|
|
22
|
+
countryCode: state.options.intent.countryCode,
|
|
23
|
+
label: state.configs.websiteId
|
|
24
|
+
};
|
|
25
|
+
EXPRESS_METHODS.forEach(method => {
|
|
26
|
+
var _method$feature, _method$feature2;
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
METHOD_TYPE
|
|
30
|
+
} = (0, _getMethodData.getMethodData)(method);
|
|
31
|
+
|
|
32
|
+
if (((_method$feature = method.feature) === null || _method$feature === void 0 ? void 0 : _method$feature.name) === 'Google Pay') {
|
|
33
|
+
output[METHOD_TYPE] = {
|
|
34
|
+
transactionData,
|
|
35
|
+
merchantConfig: {
|
|
36
|
+
merchantName: method.feature.merchantName,
|
|
37
|
+
merchantOrigin: method.feature.merchantOrigin
|
|
38
|
+
},
|
|
39
|
+
googlePayDisplayOptions: paymentInstruments.googlePay.displayOptions
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (((_method$feature2 = method.feature) === null || _method$feature2 === void 0 ? void 0 : _method$feature2.name) === 'Apple Pay') {
|
|
44
|
+
var _paymentInstruments$a;
|
|
45
|
+
|
|
46
|
+
output[METHOD_TYPE] = {
|
|
47
|
+
transactionData,
|
|
48
|
+
merchantConfig: {
|
|
49
|
+
merchantName: (_paymentInstruments$a = paymentInstruments.applePay.merchantConfig) === null || _paymentInstruments$a === void 0 ? void 0 : _paymentInstruments$a.merchantName,
|
|
50
|
+
// Apple Pay code cannot run in an iframe, and the merchant origin must be
|
|
51
|
+
// registered as a merchant domain, so we can just send the current URL.
|
|
52
|
+
merchantOrigin: window.location.hostname
|
|
53
|
+
},
|
|
54
|
+
applePayDisplayOptions: paymentInstruments.applePay.displayOptions
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return output;
|
|
59
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _generateDigitalWallet = require("./generate-digital-wallet");
|
|
4
|
+
|
|
5
|
+
var _readyToPayModel = _interopRequireDefault(require("../../storefront/models/ready-to-pay-model"));
|
|
6
|
+
|
|
7
|
+
var _summaryModel = _interopRequireDefault(require("../../storefront/models/summary-model"));
|
|
8
|
+
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
|
|
11
|
+
describe('generateDigitalWallet', () => {
|
|
12
|
+
class TestInstance {
|
|
13
|
+
constructor({
|
|
14
|
+
configs = {},
|
|
15
|
+
options = {}
|
|
16
|
+
} = {}) {
|
|
17
|
+
this.configs = configs;
|
|
18
|
+
this.options = options;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const summary = new _summaryModel.default({
|
|
24
|
+
currency: 'USD',
|
|
25
|
+
total: 1
|
|
26
|
+
});
|
|
27
|
+
const configs = {
|
|
28
|
+
websiteId: 'test-website-id'
|
|
29
|
+
};
|
|
30
|
+
const options = {
|
|
31
|
+
intent: {
|
|
32
|
+
countryCode: 'US'
|
|
33
|
+
},
|
|
34
|
+
paymentInstruments: {
|
|
35
|
+
googlePay: {
|
|
36
|
+
displayOptions: {
|
|
37
|
+
buttonColor: 'black',
|
|
38
|
+
buttonType: 'short',
|
|
39
|
+
buttonHeight: '44px'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
applePay: {
|
|
43
|
+
displayOptions: {
|
|
44
|
+
buttonColor: 'black',
|
|
45
|
+
buttonType: 'buy',
|
|
46
|
+
buttonHeight: '44px'
|
|
47
|
+
},
|
|
48
|
+
merchantConfig: {
|
|
49
|
+
merchantName: 'Test Store Name'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
it('should generate the correct digital wallet config for Google pay', () => {
|
|
55
|
+
const expressMethods = [new _readyToPayModel.default({
|
|
56
|
+
method: 'payment-card',
|
|
57
|
+
feature: {
|
|
58
|
+
name: 'Google Pay',
|
|
59
|
+
merchantName: 'google-pay-merchant-name',
|
|
60
|
+
merchantOrigin: 'google-pay-merchant-origin'
|
|
61
|
+
},
|
|
62
|
+
brands: ['Visa']
|
|
63
|
+
})];
|
|
64
|
+
const output = (0, _generateDigitalWallet.generateDigitalWallet)({
|
|
65
|
+
state: new TestInstance({
|
|
66
|
+
configs,
|
|
67
|
+
options
|
|
68
|
+
}),
|
|
69
|
+
EXPRESS_METHODS: expressMethods,
|
|
70
|
+
summary
|
|
71
|
+
});
|
|
72
|
+
const expectedOutput = {
|
|
73
|
+
googlePay: {
|
|
74
|
+
transactionData: {
|
|
75
|
+
amount: 1,
|
|
76
|
+
currency: 'USD',
|
|
77
|
+
countryCode: 'US',
|
|
78
|
+
label: 'test-website-id'
|
|
79
|
+
},
|
|
80
|
+
merchantConfig: {
|
|
81
|
+
merchantName: 'google-pay-merchant-name',
|
|
82
|
+
merchantOrigin: 'google-pay-merchant-origin'
|
|
83
|
+
},
|
|
84
|
+
googlePayDisplayOptions: {
|
|
85
|
+
buttonColor: 'black',
|
|
86
|
+
buttonType: 'short',
|
|
87
|
+
buttonHeight: '44px'
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
expect(output).toMatchObject(expectedOutput);
|
|
92
|
+
});
|
|
93
|
+
it('should generate the correct digital wallet config for Apple pay', () => {
|
|
94
|
+
delete window.location;
|
|
95
|
+
window.location = new URL('https://rebilly-apple-pay-test-tunnel.ngrok.io/');
|
|
96
|
+
const expressMethods = [new _readyToPayModel.default({
|
|
97
|
+
method: 'payment-card',
|
|
98
|
+
feature: {
|
|
99
|
+
name: 'Apple Pay'
|
|
100
|
+
},
|
|
101
|
+
brands: ['Visa']
|
|
102
|
+
})];
|
|
103
|
+
const output = (0, _generateDigitalWallet.generateDigitalWallet)({
|
|
104
|
+
state: new TestInstance({
|
|
105
|
+
configs,
|
|
106
|
+
options
|
|
107
|
+
}),
|
|
108
|
+
EXPRESS_METHODS: expressMethods,
|
|
109
|
+
summary
|
|
110
|
+
});
|
|
111
|
+
const expectedOutput = {
|
|
112
|
+
applePay: {
|
|
113
|
+
transactionData: {
|
|
114
|
+
amount: 1,
|
|
115
|
+
currency: 'USD',
|
|
116
|
+
countryCode: 'US',
|
|
117
|
+
label: 'test-website-id'
|
|
118
|
+
},
|
|
119
|
+
merchantConfig: {
|
|
120
|
+
merchantName: 'Test Store Name',
|
|
121
|
+
merchantOrigin: 'rebilly-apple-pay-test-tunnel.ngrok.io'
|
|
122
|
+
},
|
|
123
|
+
applePayDisplayOptions: {
|
|
124
|
+
buttonColor: 'black',
|
|
125
|
+
buttonType: 'buy',
|
|
126
|
+
buttonHeight: '44px'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
expect(output).toMatchObject(expectedOutput);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getMethodData = void 0;
|
|
7
|
+
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash.kebabcase"));
|
|
9
|
+
|
|
10
|
+
var _lodash2 = _interopRequireDefault(require("lodash.camelcase"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
const getMethodData = method => {
|
|
15
|
+
var _method$feature, _method$feature2;
|
|
16
|
+
|
|
17
|
+
const METHOD_ID = (0, _lodash.default)(((_method$feature = method.feature) === null || _method$feature === void 0 ? void 0 : _method$feature.name) || method.method);
|
|
18
|
+
const METHOD_TYPE = (0, _lodash2.default)(((_method$feature2 = method.feature) === null || _method$feature2 === void 0 ? void 0 : _method$feature2.name) || method.method).replace('-', '');
|
|
19
|
+
return {
|
|
20
|
+
METHOD_ID,
|
|
21
|
+
METHOD_TYPE
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.getMethodData = getMethodData;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPaymentMethods = getPaymentMethods;
|
|
7
|
+
|
|
8
|
+
var _getMethodData = require("./get-method-data");
|
|
9
|
+
|
|
10
|
+
/* eslint-disable no-unused-expressions, arrow-body-style */
|
|
11
|
+
const SUPPORTED_EXPRESS_METHODS = ['Google Pay', 'Apple Pay', 'paypal'];
|
|
12
|
+
const SUPPORTED_METHODS = ['payment-card'];
|
|
13
|
+
|
|
14
|
+
const isExpressMethod = ({
|
|
15
|
+
method,
|
|
16
|
+
feature
|
|
17
|
+
}) => {
|
|
18
|
+
return SUPPORTED_EXPRESS_METHODS.includes(method) || SUPPORTED_EXPRESS_METHODS.includes(feature === null || feature === void 0 ? void 0 : feature.name);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const isSupportedMethod = ({
|
|
22
|
+
method
|
|
23
|
+
}) => {
|
|
24
|
+
return SUPPORTED_METHODS.includes(method);
|
|
25
|
+
}; // TODO: just loader is used. We could simplify signature
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function getPaymentMethods({
|
|
29
|
+
methods,
|
|
30
|
+
state
|
|
31
|
+
}) {
|
|
32
|
+
const result = {
|
|
33
|
+
EXPRESS_METHODS: [],
|
|
34
|
+
METHODS: []
|
|
35
|
+
};
|
|
36
|
+
methods.forEach(method => {
|
|
37
|
+
if (isExpressMethod(method)) {
|
|
38
|
+
const {
|
|
39
|
+
METHOD_TYPE
|
|
40
|
+
} = (0, _getMethodData.getMethodData)(method); // Add loader entry per express method
|
|
41
|
+
|
|
42
|
+
state.loader.startLoading({
|
|
43
|
+
id: `${METHOD_TYPE}-express`
|
|
44
|
+
});
|
|
45
|
+
result.EXPRESS_METHODS.push(method);
|
|
46
|
+
} else if (isSupportedMethod(method)) {
|
|
47
|
+
// Add loader entry per method
|
|
48
|
+
state.loader.startLoading({
|
|
49
|
+
id: method.method
|
|
50
|
+
});
|
|
51
|
+
result.METHODS.push(method);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return result;
|
|
55
|
+
}
|