@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
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = exports.InstrumentReadyEventName = void 0;
|
|
9
|
-
|
|
10
|
-
var _baseEvent = _interopRequireDefault(require("./base-event"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
-
|
|
18
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
19
|
-
|
|
20
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
21
|
-
|
|
22
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
23
|
-
|
|
24
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
|
-
|
|
26
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
|
-
|
|
28
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
|
-
|
|
30
|
-
var InstrumentReadyEventName = 'rebilly-instruments-instrument-ready';
|
|
31
|
-
exports.InstrumentReadyEventName = InstrumentReadyEventName;
|
|
32
|
-
|
|
33
|
-
var InstrumentReadyEvent = /*#__PURE__*/function (_BaseEvent) {
|
|
34
|
-
_inherits(InstrumentReadyEvent, _BaseEvent);
|
|
35
|
-
|
|
36
|
-
var _super = _createSuper(InstrumentReadyEvent);
|
|
37
|
-
|
|
38
|
-
function InstrumentReadyEvent() {
|
|
39
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
40
|
-
_ref$name = _ref.name,
|
|
41
|
-
name = _ref$name === void 0 ? InstrumentReadyEventName : _ref$name;
|
|
42
|
-
|
|
43
|
-
_classCallCheck(this, InstrumentReadyEvent);
|
|
44
|
-
|
|
45
|
-
return _super.call(this, name);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return InstrumentReadyEvent;
|
|
49
|
-
}(_baseEvent["default"]);
|
|
50
|
-
|
|
51
|
-
exports["default"] = InstrumentReadyEvent;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = exports.InstrumentReadyEventName = void 0;
|
|
9
|
-
|
|
10
|
-
var _baseEvent = _interopRequireDefault(require("./base-event"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
-
|
|
18
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
19
|
-
|
|
20
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
21
|
-
|
|
22
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
23
|
-
|
|
24
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
|
-
|
|
26
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
|
-
|
|
28
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
|
-
|
|
30
|
-
var InstrumentReadyEventName = 'rebilly-instruments-purchase-complete';
|
|
31
|
-
exports.InstrumentReadyEventName = InstrumentReadyEventName;
|
|
32
|
-
|
|
33
|
-
var PurchaseCompleteEvent = /*#__PURE__*/function (_BaseEvent) {
|
|
34
|
-
_inherits(PurchaseCompleteEvent, _BaseEvent);
|
|
35
|
-
|
|
36
|
-
var _super = _createSuper(PurchaseCompleteEvent);
|
|
37
|
-
|
|
38
|
-
function PurchaseCompleteEvent() {
|
|
39
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
40
|
-
_ref$name = _ref.name,
|
|
41
|
-
name = _ref$name === void 0 ? InstrumentReadyEventName : _ref$name;
|
|
42
|
-
|
|
43
|
-
_classCallCheck(this, PurchaseCompleteEvent);
|
|
44
|
-
|
|
45
|
-
return _super.call(this, name);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return PurchaseCompleteEvent;
|
|
49
|
-
}(_baseEvent["default"]);
|
|
50
|
-
|
|
51
|
-
exports["default"] = PurchaseCompleteEvent;
|
package/dist/functions/mount.js
DELETED
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Mount = Mount;
|
|
7
|
-
|
|
8
|
-
var _riskDataCollector = require("@rebilly/risk-data-collector");
|
|
9
|
-
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
|
-
var _main = require("../styles/main");
|
|
13
|
-
|
|
14
|
-
var _utils = require("../utils");
|
|
15
|
-
|
|
16
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
-
|
|
18
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
-
|
|
20
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
21
|
-
|
|
22
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
|
-
|
|
24
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
25
|
-
|
|
26
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
|
-
|
|
28
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
29
|
-
|
|
30
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
31
|
-
|
|
32
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
|
-
|
|
34
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
35
|
-
|
|
36
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @typedef {Object} Item
|
|
40
|
-
* @property {string} planId - The Rebilly id of the plan.
|
|
41
|
-
* @property {number} quantity - The number of the plans to be purchased.
|
|
42
|
-
* @property {string} thumbnail - The source img for the product. Recommend 100px by 100px.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @typedef {Object} Intent
|
|
47
|
-
* @property {"purchase" | "vault"} mode - Which mode the mount is usings. Default "purchase".
|
|
48
|
-
* @property {Array.<Item>} items - Which plans the customer is purchasing.
|
|
49
|
-
* @property {string} customerId - Which customer is associated with the instrument.
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @typedef {Object} Options
|
|
54
|
-
* @property {Intent} intent - The information required for purchaseing or vaulting an instrument
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Mount library with configurations.
|
|
59
|
-
* @param {string | HTMLElement} form - The CSS class or HTML element were the form will be mounted.
|
|
60
|
-
* @param {string | HTMLElement} summary - The CSS class or HTML element were the summary will be mounted.
|
|
61
|
-
* @param {Options} options - The configurations that are to be passed to the library for use.
|
|
62
|
-
*/
|
|
63
|
-
function Mount() {
|
|
64
|
-
return _Mount.apply(this, arguments);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function _Mount() {
|
|
68
|
-
_Mount = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
69
|
-
var _this$configs,
|
|
70
|
-
_this$configs3,
|
|
71
|
-
_this = this;
|
|
72
|
-
|
|
73
|
-
var _ref,
|
|
74
|
-
_ref$form,
|
|
75
|
-
form,
|
|
76
|
-
_ref$summary,
|
|
77
|
-
summary,
|
|
78
|
-
_ref$_dev,
|
|
79
|
-
_dev,
|
|
80
|
-
_ref$options,
|
|
81
|
-
options,
|
|
82
|
-
framePayUrls,
|
|
83
|
-
_computed,
|
|
84
|
-
OPTIONS_DEFAULTS,
|
|
85
|
-
_riskMetadata$browser,
|
|
86
|
-
_this$configs2,
|
|
87
|
-
_yield$collectData,
|
|
88
|
-
riskMetadata,
|
|
89
|
-
language,
|
|
90
|
-
_i18n,
|
|
91
|
-
_yield$Promise$all,
|
|
92
|
-
_yield$Promise$all2,
|
|
93
|
-
readyToPayData,
|
|
94
|
-
summaryData,
|
|
95
|
-
plansData,
|
|
96
|
-
productsData,
|
|
97
|
-
i18n,
|
|
98
|
-
_args = arguments;
|
|
99
|
-
|
|
100
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
101
|
-
while (1) {
|
|
102
|
-
switch (_context.prev = _context.next) {
|
|
103
|
-
case 0:
|
|
104
|
-
_ref = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, _ref$form = _ref.form, form = _ref$form === void 0 ? '.rebilly-instruments' : _ref$form, _ref$summary = _ref.summary, summary = _ref$summary === void 0 ? '.rebilly-instruments-summary' : _ref$summary, _ref$_dev = _ref._dev, _dev = _ref$_dev === void 0 ? {
|
|
105
|
-
framePayScriptLink: null,
|
|
106
|
-
framePayStyleLink: null,
|
|
107
|
-
paymentMethodsUrl: null
|
|
108
|
-
} : _ref$_dev, _ref$options = _ref.options, options = _ref$options === void 0 ? {} : _ref$options;
|
|
109
|
-
this.form = form;
|
|
110
|
-
this.summary = summary;
|
|
111
|
-
framePayUrls = {
|
|
112
|
-
script: _dev.framePayScriptLink || 'https://framepay.rebilly.com/rebilly.js',
|
|
113
|
-
style: _dev.framePayStyleLink || 'https://framepay.rebilly.com/rebilly.css'
|
|
114
|
-
};
|
|
115
|
-
_computed = {
|
|
116
|
-
paymentMethodsUrl: _dev.paymentMethodsUrl || 'https://forms.secure-payments.app'
|
|
117
|
-
};
|
|
118
|
-
OPTIONS_DEFAULTS = {
|
|
119
|
-
intent: {
|
|
120
|
-
countryCode: 'US'
|
|
121
|
-
},
|
|
122
|
-
locale: 'auto',
|
|
123
|
-
paymentInstruments: {
|
|
124
|
-
compactExpressInstruments: true,
|
|
125
|
-
googlePay: {
|
|
126
|
-
displayOptions: {
|
|
127
|
-
buttonColor: 'black',
|
|
128
|
-
buttonType: 'short',
|
|
129
|
-
buttonHeight: '44px'
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
paymentCard: {
|
|
133
|
-
popup: false
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
flowFlags: {
|
|
137
|
-
autoConfirmation: true,
|
|
138
|
-
autoResult: true
|
|
139
|
-
}
|
|
140
|
-
}; // TODO: Only add _dev in dev enviroment
|
|
141
|
-
|
|
142
|
-
this.options = (0, _lodash.merge)(OPTIONS_DEFAULTS, _objectSpread(_objectSpread({}, options), {}, {
|
|
143
|
-
_dev: _dev,
|
|
144
|
-
_computed: _computed
|
|
145
|
-
}));
|
|
146
|
-
this.form = (0, _utils.processPropertyAsDOMElement)({
|
|
147
|
-
prop: this.form,
|
|
148
|
-
propName: 'form'
|
|
149
|
-
});
|
|
150
|
-
this.summary = (0, _utils.processPropertyAsDOMElement)({
|
|
151
|
-
prop: this.summary,
|
|
152
|
-
propName: 'summary',
|
|
153
|
-
isRequired: false
|
|
154
|
-
}); // Setup loader
|
|
155
|
-
|
|
156
|
-
this.loader.addDOMElement({
|
|
157
|
-
el: this.form
|
|
158
|
-
});
|
|
159
|
-
this.loader.addDOMElement({
|
|
160
|
-
section: 'summary',
|
|
161
|
-
el: this.summary
|
|
162
|
-
}); // Adds base stylesheet
|
|
163
|
-
|
|
164
|
-
(0, _utils.addDOMElement)({
|
|
165
|
-
element: 'style',
|
|
166
|
-
attributes: {
|
|
167
|
-
type: 'text/css'
|
|
168
|
-
},
|
|
169
|
-
content: (0, _main.MAIN_STYLE)(((_this$configs = this.configs) === null || _this$configs === void 0 ? void 0 : _this$configs.theme) || {}),
|
|
170
|
-
target: 'head'
|
|
171
|
-
}); // Adds configs CSS to override any styles
|
|
172
|
-
|
|
173
|
-
if (this.configs.css) {
|
|
174
|
-
(0, _utils.addDOMElement)({
|
|
175
|
-
element: 'style',
|
|
176
|
-
attributes: {
|
|
177
|
-
type: 'text/css'
|
|
178
|
-
},
|
|
179
|
-
content: this.configs.css,
|
|
180
|
-
target: 'head'
|
|
181
|
-
});
|
|
182
|
-
} // Adds FramePay
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (!document.querySelectorAll("[framepay*=\"script\"]").length) {
|
|
186
|
-
(0, _utils.addDOMElement)({
|
|
187
|
-
element: 'script',
|
|
188
|
-
attributes: {
|
|
189
|
-
'framepay': 'script',
|
|
190
|
-
src: framePayUrls.script
|
|
191
|
-
},
|
|
192
|
-
target: 'head'
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (!document.querySelectorAll("[framepay*=\"stylesheet\"]").length) {
|
|
197
|
-
(0, _utils.addDOMElement)({
|
|
198
|
-
element: 'link',
|
|
199
|
-
attributes: {
|
|
200
|
-
'framepay': 'stylesheet',
|
|
201
|
-
href: framePayUrls.style,
|
|
202
|
-
rel: 'stylesheet'
|
|
203
|
-
},
|
|
204
|
-
target: 'head'
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
_context.prev = 15;
|
|
209
|
-
this.loader.startLoading({
|
|
210
|
-
section: 'summary',
|
|
211
|
-
id: 'initSummary'
|
|
212
|
-
});
|
|
213
|
-
this.loader.startLoading({
|
|
214
|
-
id: 'initForm'
|
|
215
|
-
});
|
|
216
|
-
_context.next = 20;
|
|
217
|
-
return (0, _riskDataCollector.collectData)();
|
|
218
|
-
|
|
219
|
-
case 20:
|
|
220
|
-
_yield$collectData = _context.sent;
|
|
221
|
-
riskMetadata = _yield$collectData.riskMetadata;
|
|
222
|
-
|
|
223
|
-
if (this.options.locale === 'auto' && riskMetadata !== null && riskMetadata !== void 0 && (_riskMetadata$browser = riskMetadata.browserData) !== null && _riskMetadata$browser !== void 0 && _riskMetadata$browser.language) {
|
|
224
|
-
language = riskMetadata.browserData.language;
|
|
225
|
-
this.options.locale = language;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
_i18n = ((_this$configs2 = this.configs) === null || _this$configs2 === void 0 ? void 0 : _this$configs2.i18n) || {};
|
|
229
|
-
this.translate.init(this.options.locale, _i18n);
|
|
230
|
-
_context.next = 27;
|
|
231
|
-
return Promise.all([this._fetchReadyToPay(riskMetadata), this._fetchSummary()]);
|
|
232
|
-
|
|
233
|
-
case 27:
|
|
234
|
-
_yield$Promise$all = _context.sent;
|
|
235
|
-
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
236
|
-
readyToPayData = _yield$Promise$all2[0];
|
|
237
|
-
summaryData = _yield$Promise$all2[1];
|
|
238
|
-
_context.next = 33;
|
|
239
|
-
return this._fetchPlans({
|
|
240
|
-
data: summaryData
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
case 33:
|
|
244
|
-
plansData = _context.sent;
|
|
245
|
-
_context.next = 36;
|
|
246
|
-
return this._fetchProducts({
|
|
247
|
-
data: plansData
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
case 36:
|
|
251
|
-
productsData = _context.sent;
|
|
252
|
-
|
|
253
|
-
if (this.form) {
|
|
254
|
-
this.formOptions = {
|
|
255
|
-
readyToPay: readyToPayData,
|
|
256
|
-
summary: summaryData,
|
|
257
|
-
plans: plansData,
|
|
258
|
-
products: productsData
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
this._mountForm(this.formOptions);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (this.summary) {
|
|
265
|
-
this._mountSummary({
|
|
266
|
-
summary: summaryData,
|
|
267
|
-
plans: plansData,
|
|
268
|
-
products: productsData
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
_context.next = 44;
|
|
273
|
-
break;
|
|
274
|
-
|
|
275
|
-
case 41:
|
|
276
|
-
_context.prev = 41;
|
|
277
|
-
_context.t0 = _context["catch"](15);
|
|
278
|
-
throw _context.t0;
|
|
279
|
-
|
|
280
|
-
case 44:
|
|
281
|
-
i18n = ((_this$configs3 = this.configs) === null || _this$configs3 === void 0 ? void 0 : _this$configs3.i18n) || {};
|
|
282
|
-
this.translate.init(this.options.locale, i18n);
|
|
283
|
-
this.translate.translateItems();
|
|
284
|
-
|
|
285
|
-
if (this.options.flowFlags.autoConfirmation) {
|
|
286
|
-
this.on('instrument-ready', function (instrument) {
|
|
287
|
-
_this.show('confirmation', {
|
|
288
|
-
instrument: instrument
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (this.options.flowFlags.autoResult) {
|
|
294
|
-
this.on('purchase-complete', function (purchase) {
|
|
295
|
-
_this.show('result', {
|
|
296
|
-
purchase: purchase
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
case 49:
|
|
302
|
-
case "end":
|
|
303
|
-
return _context.stop();
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}, _callee, this, [[15, 41]]);
|
|
307
|
-
}));
|
|
308
|
-
return _Mount.apply(this, arguments);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _rebillyInstrumentsMock = require("tests/mocks/rebilly-instruments-mock");
|
|
4
|
-
|
|
5
|
-
var _framepayMock = require("tests/mocks/framepay-mock");
|
|
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
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
22
|
-
|
|
23
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24
|
-
|
|
25
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
26
|
-
|
|
27
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
28
|
-
|
|
29
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
30
|
-
|
|
31
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
32
|
-
|
|
33
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
34
|
-
|
|
35
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
36
|
-
|
|
37
|
-
describe('RebillyInstruments instance', function () {
|
|
38
|
-
it('should throw error when there is no DOM element to mount the form', function () {
|
|
39
|
-
document.body.innerHTML = "\n <div class=\"form-selector\"></div>\n <div class=\"summary-selector\"></div>\n ";
|
|
40
|
-
var rebillyInstruments = (0, _rebillyInstrumentsMock.MockRebillyInstruments)();
|
|
41
|
-
expect( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
42
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
43
|
-
while (1) {
|
|
44
|
-
switch (_context.prev = _context.next) {
|
|
45
|
-
case 0:
|
|
46
|
-
_context.next = 2;
|
|
47
|
-
return rebillyInstruments.mount({});
|
|
48
|
-
|
|
49
|
-
case 2:
|
|
50
|
-
case "end":
|
|
51
|
-
return _context.stop();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}, _callee);
|
|
55
|
-
}))).rejects.toEqual(new Error('Could not find DOM element with CSS class or id ".rebilly-instruments" to mount form'));
|
|
56
|
-
});
|
|
57
|
-
it('should throw error when providing the wrong type for the form property', function () {
|
|
58
|
-
document.body.innerHTML = "\n <div class=\"form-selector\"></div>\n <div class=\"summary-selector\"></div>\n ";
|
|
59
|
-
var options = {
|
|
60
|
-
form: []
|
|
61
|
-
};
|
|
62
|
-
var rebillyInstruments = (0, _rebillyInstrumentsMock.MockRebillyInstruments)();
|
|
63
|
-
expect( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
64
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
65
|
-
while (1) {
|
|
66
|
-
switch (_context2.prev = _context2.next) {
|
|
67
|
-
case 0:
|
|
68
|
-
_context2.next = 2;
|
|
69
|
-
return rebillyInstruments.mount(options);
|
|
70
|
-
|
|
71
|
-
case 2:
|
|
72
|
-
case "end":
|
|
73
|
-
return _context2.stop();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, _callee2);
|
|
77
|
-
}))).rejects.toEqual(new Error('Please provide a valid CSS class, id or DOM element for "form" property'));
|
|
78
|
-
});
|
|
79
|
-
it('should inject HTML to the merchant\'s website', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
80
|
-
var testPlan, testProduct, testSummary, framePayScriptUrl, framePayStyleUrl, options, framepayMock, rebillyInstruments, SUMMARY_CONTAINER, LINE_ITEM_TITLE, SCRIPTS, FRAMEPAY_SCRIPT, STYLE_LINKS, FRAMEPAY_STYLE;
|
|
81
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
82
|
-
while (1) {
|
|
83
|
-
switch (_context3.prev = _context3.next) {
|
|
84
|
-
case 0:
|
|
85
|
-
testPlan = new _planModel["default"]({
|
|
86
|
-
name: 'Test Plan',
|
|
87
|
-
id: 'test-plan-id-1'
|
|
88
|
-
});
|
|
89
|
-
testProduct = new _productModel["default"]({
|
|
90
|
-
description: 'My Awesome Product',
|
|
91
|
-
id: 'test-product-1'
|
|
92
|
-
});
|
|
93
|
-
testSummary = new _summaryModel["default"]({
|
|
94
|
-
currency: 'USD',
|
|
95
|
-
lineItems: [{
|
|
96
|
-
description: 'test-plan-id-1',
|
|
97
|
-
planId: 'test-plan-id-1',
|
|
98
|
-
productId: 'test-product-1',
|
|
99
|
-
quantity: 1
|
|
100
|
-
}]
|
|
101
|
-
});
|
|
102
|
-
framePayScriptUrl = 'https://framepay.rebilly.com/rebilly.js';
|
|
103
|
-
framePayStyleUrl = 'https://dev.framepay.rebilly.com/rebilly.css';
|
|
104
|
-
(0, _server.when)((0, _mswWhenThen.post)("".concat(_storefrontApiMock.storefrontURL, "/ready-to-pay"))).thenReturn(function () {
|
|
105
|
-
return (0, _mswWhenThen.ok)([{
|
|
106
|
-
method: 'payment-card',
|
|
107
|
-
feature: {
|
|
108
|
-
name: 'Google Pay'
|
|
109
|
-
},
|
|
110
|
-
brands: ['Visa', 'MasterCard', 'American Express', 'Discover'],
|
|
111
|
-
filters: []
|
|
112
|
-
}]);
|
|
113
|
-
}());
|
|
114
|
-
(0, _server.when)((0, _mswWhenThen.post)("".concat(_storefrontApiMock.storefrontURL, "/preview-purchase"))).thenReturn(function () {
|
|
115
|
-
return (0, _mswWhenThen.ok)(testSummary);
|
|
116
|
-
}());
|
|
117
|
-
(0, _server.when)((0, _mswWhenThen.get)("".concat(_storefrontApiMock.storefrontURL, "/plans"))).thenReturn(function () {
|
|
118
|
-
return (0, _mswWhenThen.ok)([testPlan]);
|
|
119
|
-
}());
|
|
120
|
-
(0, _server.when)((0, _mswWhenThen.get)("".concat(_storefrontApiMock.storefrontURL, "/products"))).thenReturn(function () {
|
|
121
|
-
return (0, _mswWhenThen.ok)([testProduct]);
|
|
122
|
-
}());
|
|
123
|
-
document.body.innerHTML = "\n <div class=\"form-selector\"></div>\n <div class=\"summary-selector\"></div>\n ";
|
|
124
|
-
options = {
|
|
125
|
-
form: '.form-selector',
|
|
126
|
-
summary: '.summary-selector',
|
|
127
|
-
_dev: {
|
|
128
|
-
framePayStyleLink: framePayStyleUrl
|
|
129
|
-
},
|
|
130
|
-
options: {
|
|
131
|
-
locale: 'auto',
|
|
132
|
-
intent: {
|
|
133
|
-
items: [{
|
|
134
|
-
planId: 'test-plan-id-1',
|
|
135
|
-
quantity: 1
|
|
136
|
-
}]
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
framepayMock = (0, _framepayMock.createFramepayMock)();
|
|
141
|
-
global.Rebilly = framepayMock;
|
|
142
|
-
rebillyInstruments = (0, _rebillyInstrumentsMock.MockRebillyInstruments)({
|
|
143
|
-
theme: {
|
|
144
|
-
color: {
|
|
145
|
-
background: '#000'
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
css: "\n .rebilly-instruments-summary-line-item-synopsis-title {\n color: rgb(0, 68, 212);\n }\n "
|
|
149
|
-
});
|
|
150
|
-
_context3.next = 16;
|
|
151
|
-
return rebillyInstruments.mount(options);
|
|
152
|
-
|
|
153
|
-
case 16:
|
|
154
|
-
// Mounts form and summary
|
|
155
|
-
expect(document.querySelector('.summary-selector').innerHTML).toMatch(testPlan.name); // Theme config overrides initial styles
|
|
156
|
-
|
|
157
|
-
SUMMARY_CONTAINER = document.querySelector('.rebilly-instruments-summary-container');
|
|
158
|
-
expect(getComputedStyle(SUMMARY_CONTAINER).background).toEqual('rgb(0, 0, 0)'); // CSS config property overrides initial styles
|
|
159
|
-
|
|
160
|
-
LINE_ITEM_TITLE = document.querySelector('.rebilly-instruments-summary-line-item-synopsis-title');
|
|
161
|
-
expect(getComputedStyle(LINE_ITEM_TITLE).color).toEqual('rgb(0, 68, 212)'); // Mounts default FramePay script
|
|
162
|
-
|
|
163
|
-
SCRIPTS = _toConsumableArray(document.querySelectorAll('head script'));
|
|
164
|
-
FRAMEPAY_SCRIPT = SCRIPTS.find(function (script) {
|
|
165
|
-
return script.src === framePayScriptUrl;
|
|
166
|
-
});
|
|
167
|
-
expect(FRAMEPAY_SCRIPT.src).toEqual(framePayScriptUrl); // Mounts _dev FramePay style
|
|
168
|
-
|
|
169
|
-
STYLE_LINKS = _toConsumableArray(document.querySelectorAll('head link'));
|
|
170
|
-
FRAMEPAY_STYLE = STYLE_LINKS.find(function (script) {
|
|
171
|
-
return script.href === framePayStyleUrl;
|
|
172
|
-
});
|
|
173
|
-
expect(FRAMEPAY_STYLE.href).toEqual(framePayStyleUrl); // objectContaining allows matching a subset (this could be done with sinon + mocha too)
|
|
174
|
-
|
|
175
|
-
expect(framepayMock.initialize).toHaveBeenCalledWith(expect.objectContaining({
|
|
176
|
-
digitalWallet: {
|
|
177
|
-
googlePayDisplayOptions: {
|
|
178
|
-
buttonColor: 'black',
|
|
179
|
-
buttonHeight: '44px',
|
|
180
|
-
buttonType: 'short'
|
|
181
|
-
},
|
|
182
|
-
merchantConfig: undefined,
|
|
183
|
-
transactionData: {
|
|
184
|
-
amount: 0,
|
|
185
|
-
countryCode: 'US',
|
|
186
|
-
currency: 'USD',
|
|
187
|
-
label: 'test-website-id'
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
organizationId: 'test-organization-id',
|
|
191
|
-
publishableKey: 'test-api-key'
|
|
192
|
-
})); //Simulate that framepay is ready
|
|
193
|
-
|
|
194
|
-
framepayMock.simulateEvent('ready');
|
|
195
|
-
|
|
196
|
-
case 29:
|
|
197
|
-
case "end":
|
|
198
|
-
return _context3.stop();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}, _callee3);
|
|
202
|
-
})));
|
|
203
|
-
});
|