@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
package/dist/storefront/index.js
CHANGED
|
@@ -3,49 +3,38 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = exports.StorefrontInstance = void 0;
|
|
7
7
|
|
|
8
8
|
var _rebillyJsSdk = require("rebilly-js-sdk");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
sandbox: mode === 'sandbox',
|
|
36
|
-
timeout: Number.isNaN(parseInt(timeout, 10)) ? 10000 : parseInt(timeout, 10),
|
|
37
|
-
urls: urls
|
|
38
|
-
});
|
|
39
|
-
api.setPublishableKey(publishableKey);
|
|
40
|
-
this.api = api;
|
|
41
|
-
return this.api;
|
|
42
|
-
};
|
|
10
|
+
class StorefrontInstance {
|
|
11
|
+
constructor({
|
|
12
|
+
publishableKey = null,
|
|
13
|
+
organizationId = null,
|
|
14
|
+
mode = 'live',
|
|
15
|
+
timeout = 10000,
|
|
16
|
+
liveUrl = null,
|
|
17
|
+
sandboxUrl = null
|
|
18
|
+
} = {}) {
|
|
19
|
+
const urls = {
|
|
20
|
+
live: liveUrl || 'https://api.rebilly.com',
|
|
21
|
+
sandbox: sandboxUrl || 'https://api-sandbox.rebilly.com'
|
|
22
|
+
};
|
|
23
|
+
const api = (0, _rebillyJsSdk.RebillyStorefrontAPI)({
|
|
24
|
+
organizationId,
|
|
25
|
+
sandbox: mode === 'sandbox',
|
|
26
|
+
timeout: Number.isNaN(parseInt(timeout, 10)) ? 10000 : parseInt(timeout, 10),
|
|
27
|
+
urls
|
|
28
|
+
});
|
|
29
|
+
api.setPublishableKey(publishableKey);
|
|
30
|
+
this.api = api;
|
|
31
|
+
return this.api;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
43
35
|
|
|
44
36
|
exports.StorefrontInstance = StorefrontInstance;
|
|
45
37
|
|
|
46
|
-
var _default =
|
|
47
|
-
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
48
|
-
return new StorefrontInstance(config);
|
|
49
|
-
};
|
|
38
|
+
var _default = (config = {}) => new StorefrontInstance(config);
|
|
50
39
|
|
|
51
|
-
exports
|
|
40
|
+
exports.default = _default;
|
|
@@ -3,60 +3,43 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
class PlanModel {
|
|
9
|
+
constructor({
|
|
10
|
+
id = '',
|
|
11
|
+
name = '',
|
|
12
|
+
productId = '',
|
|
13
|
+
productOptions = {},
|
|
14
|
+
currency = '',
|
|
15
|
+
currencySign = '',
|
|
16
|
+
pricing = {},
|
|
17
|
+
recurringInterval = {},
|
|
18
|
+
trial = null,
|
|
19
|
+
isTrialOnly = false,
|
|
20
|
+
setup = null,
|
|
21
|
+
customFields = {},
|
|
22
|
+
createdTime = '',
|
|
23
|
+
updatedTime = '',
|
|
24
|
+
invoiceTimeShift = {}
|
|
25
|
+
} = {}) {
|
|
26
|
+
this.id = id;
|
|
27
|
+
this.name = name;
|
|
28
|
+
this.productId = productId;
|
|
29
|
+
this.productOptions = productOptions;
|
|
30
|
+
this.currency = currency;
|
|
31
|
+
this.currencySign = currencySign;
|
|
32
|
+
this.pricing = pricing;
|
|
33
|
+
this.recurringInterval = recurringInterval;
|
|
34
|
+
this.trial = trial;
|
|
35
|
+
this.isTrialOnly = isTrialOnly;
|
|
36
|
+
this.setup = setup;
|
|
37
|
+
this.customFields = customFields;
|
|
38
|
+
this.createdTime = createdTime;
|
|
39
|
+
this.updatedTime = updatedTime;
|
|
40
|
+
this.invoiceTimeShift = invoiceTimeShift;
|
|
41
|
+
}
|
|
9
42
|
|
|
10
|
-
|
|
11
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
12
|
-
_ref$id = _ref.id,
|
|
13
|
-
id = _ref$id === void 0 ? '' : _ref$id,
|
|
14
|
-
_ref$name = _ref.name,
|
|
15
|
-
name = _ref$name === void 0 ? '' : _ref$name,
|
|
16
|
-
_ref$productId = _ref.productId,
|
|
17
|
-
productId = _ref$productId === void 0 ? '' : _ref$productId,
|
|
18
|
-
_ref$productOptions = _ref.productOptions,
|
|
19
|
-
productOptions = _ref$productOptions === void 0 ? {} : _ref$productOptions,
|
|
20
|
-
_ref$currency = _ref.currency,
|
|
21
|
-
currency = _ref$currency === void 0 ? '' : _ref$currency,
|
|
22
|
-
_ref$currencySign = _ref.currencySign,
|
|
23
|
-
currencySign = _ref$currencySign === void 0 ? '' : _ref$currencySign,
|
|
24
|
-
_ref$pricing = _ref.pricing,
|
|
25
|
-
pricing = _ref$pricing === void 0 ? {} : _ref$pricing,
|
|
26
|
-
_ref$recurringInterva = _ref.recurringInterval,
|
|
27
|
-
recurringInterval = _ref$recurringInterva === void 0 ? {} : _ref$recurringInterva,
|
|
28
|
-
_ref$trial = _ref.trial,
|
|
29
|
-
trial = _ref$trial === void 0 ? null : _ref$trial,
|
|
30
|
-
_ref$isTrialOnly = _ref.isTrialOnly,
|
|
31
|
-
isTrialOnly = _ref$isTrialOnly === void 0 ? false : _ref$isTrialOnly,
|
|
32
|
-
_ref$setup = _ref.setup,
|
|
33
|
-
setup = _ref$setup === void 0 ? null : _ref$setup,
|
|
34
|
-
_ref$customFields = _ref.customFields,
|
|
35
|
-
customFields = _ref$customFields === void 0 ? {} : _ref$customFields,
|
|
36
|
-
_ref$createdTime = _ref.createdTime,
|
|
37
|
-
createdTime = _ref$createdTime === void 0 ? '' : _ref$createdTime,
|
|
38
|
-
_ref$updatedTime = _ref.updatedTime,
|
|
39
|
-
updatedTime = _ref$updatedTime === void 0 ? '' : _ref$updatedTime,
|
|
40
|
-
_ref$invoiceTimeShift = _ref.invoiceTimeShift,
|
|
41
|
-
invoiceTimeShift = _ref$invoiceTimeShift === void 0 ? {} : _ref$invoiceTimeShift;
|
|
43
|
+
}
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.id = id;
|
|
46
|
-
this.name = name;
|
|
47
|
-
this.productId = productId;
|
|
48
|
-
this.productOptions = productOptions;
|
|
49
|
-
this.currency = currency;
|
|
50
|
-
this.currencySign = currencySign;
|
|
51
|
-
this.pricing = pricing;
|
|
52
|
-
this.recurringInterval = recurringInterval;
|
|
53
|
-
this.trial = trial;
|
|
54
|
-
this.isTrialOnly = isTrialOnly;
|
|
55
|
-
this.setup = setup;
|
|
56
|
-
this.customFields = customFields;
|
|
57
|
-
this.createdTime = createdTime;
|
|
58
|
-
this.updatedTime = updatedTime;
|
|
59
|
-
this.invoiceTimeShift = invoiceTimeShift;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
exports["default"] = PlanModel;
|
|
45
|
+
exports.default = PlanModel;
|
|
@@ -3,42 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
class ProductModel {
|
|
9
|
+
constructor({
|
|
10
|
+
id = '',
|
|
11
|
+
name = '',
|
|
12
|
+
unitLabel = '',
|
|
13
|
+
description = {},
|
|
14
|
+
requiresShipping = false,
|
|
15
|
+
options = [],
|
|
16
|
+
customFields = {},
|
|
17
|
+
createdTime = '',
|
|
18
|
+
updatedTime = ''
|
|
19
|
+
} = {}) {
|
|
20
|
+
this.id = id;
|
|
21
|
+
this.name = name;
|
|
22
|
+
this.unitLabel = unitLabel;
|
|
23
|
+
this.description = description;
|
|
24
|
+
this.requiresShipping = requiresShipping;
|
|
25
|
+
this.options = options;
|
|
26
|
+
this.customFields = customFields;
|
|
27
|
+
this.createdTime = createdTime;
|
|
28
|
+
this.updatedTime = updatedTime;
|
|
29
|
+
}
|
|
9
30
|
|
|
10
|
-
|
|
11
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
12
|
-
_ref$id = _ref.id,
|
|
13
|
-
id = _ref$id === void 0 ? '' : _ref$id,
|
|
14
|
-
_ref$name = _ref.name,
|
|
15
|
-
name = _ref$name === void 0 ? '' : _ref$name,
|
|
16
|
-
_ref$unitLabel = _ref.unitLabel,
|
|
17
|
-
unitLabel = _ref$unitLabel === void 0 ? '' : _ref$unitLabel,
|
|
18
|
-
_ref$description = _ref.description,
|
|
19
|
-
description = _ref$description === void 0 ? {} : _ref$description,
|
|
20
|
-
_ref$requiresShipping = _ref.requiresShipping,
|
|
21
|
-
requiresShipping = _ref$requiresShipping === void 0 ? false : _ref$requiresShipping,
|
|
22
|
-
_ref$options = _ref.options,
|
|
23
|
-
options = _ref$options === void 0 ? [] : _ref$options,
|
|
24
|
-
_ref$customFields = _ref.customFields,
|
|
25
|
-
customFields = _ref$customFields === void 0 ? {} : _ref$customFields,
|
|
26
|
-
_ref$createdTime = _ref.createdTime,
|
|
27
|
-
createdTime = _ref$createdTime === void 0 ? '' : _ref$createdTime,
|
|
28
|
-
_ref$updatedTime = _ref.updatedTime,
|
|
29
|
-
updatedTime = _ref$updatedTime === void 0 ? '' : _ref$updatedTime;
|
|
31
|
+
}
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.id = id;
|
|
34
|
-
this.name = name;
|
|
35
|
-
this.unitLabel = unitLabel;
|
|
36
|
-
this.description = description;
|
|
37
|
-
this.requiresShipping = requiresShipping;
|
|
38
|
-
this.options = options;
|
|
39
|
-
this.customFields = customFields;
|
|
40
|
-
this.createdTime = createdTime;
|
|
41
|
-
this.updatedTime = updatedTime;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
exports["default"] = ProductModel;
|
|
33
|
+
exports.default = ProductModel;
|
|
@@ -3,48 +3,44 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
exports.default = exports.ReadyToPayFeatureModel = void 0;
|
|
7
|
+
|
|
8
|
+
class ReadyToPayFeatureModel {
|
|
9
|
+
constructor({
|
|
10
|
+
name = '',
|
|
11
|
+
// Google Pay fields
|
|
12
|
+
merchantName = '',
|
|
13
|
+
merchantOrigin = '',
|
|
14
|
+
// Plaid fields
|
|
15
|
+
linkToken = '',
|
|
16
|
+
expirationTime = ''
|
|
17
|
+
} = {}) {
|
|
18
|
+
this.name = name;
|
|
19
|
+
this.merchantName = merchantName;
|
|
20
|
+
this.merchantOrigin = merchantOrigin;
|
|
21
|
+
this.linkToken = linkToken;
|
|
22
|
+
this.expirationTime = expirationTime;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
25
26
|
|
|
26
27
|
exports.ReadyToPayFeatureModel = ReadyToPayFeatureModel;
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.brands = brands;
|
|
47
|
-
this.filters = filters;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
exports["default"] = ReadyToPayModel;
|
|
29
|
+
class ReadyToPayModel {
|
|
30
|
+
constructor({
|
|
31
|
+
index = null,
|
|
32
|
+
method = '',
|
|
33
|
+
feature = null,
|
|
34
|
+
brands = [],
|
|
35
|
+
filters = []
|
|
36
|
+
} = {}) {
|
|
37
|
+
this.index = index;
|
|
38
|
+
this.method = method;
|
|
39
|
+
this.feature = feature ? new ReadyToPayFeatureModel(feature) : null;
|
|
40
|
+
this.brands = brands;
|
|
41
|
+
this.filters = filters;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.default = ReadyToPayModel;
|
|
@@ -3,117 +3,90 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_classCallCheck(this, SummaryLineItemModel);
|
|
6
|
+
exports.default = exports.SummaryDiscountModel = exports.SummaryTaxModel = exports.SummaryLineItemModel = void 0;
|
|
7
|
+
|
|
8
|
+
class SummaryLineItemModel {
|
|
9
|
+
constructor({
|
|
10
|
+
type = '',
|
|
11
|
+
description = '',
|
|
12
|
+
unitPrice = 0.0,
|
|
13
|
+
quantity = 0,
|
|
14
|
+
price = 0.0,
|
|
15
|
+
planId = '',
|
|
16
|
+
productId = ''
|
|
17
|
+
} = {}) {
|
|
18
|
+
this.type = type;
|
|
19
|
+
this.description = description;
|
|
20
|
+
this.unitPrice = unitPrice;
|
|
21
|
+
this.quantity = quantity;
|
|
22
|
+
this.price = price;
|
|
23
|
+
this.planId = planId;
|
|
24
|
+
this.productId = productId;
|
|
25
|
+
}
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
this.description = description;
|
|
31
|
-
this.unitPrice = unitPrice;
|
|
32
|
-
this.quantity = quantity;
|
|
33
|
-
this.price = price;
|
|
34
|
-
this.planId = planId;
|
|
35
|
-
this.productId = productId;
|
|
36
|
-
};
|
|
27
|
+
}
|
|
37
28
|
|
|
38
29
|
exports.SummaryLineItemModel = SummaryLineItemModel;
|
|
39
30
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
class SummaryTaxModel {
|
|
32
|
+
constructor({
|
|
33
|
+
amount = '',
|
|
34
|
+
description = ''
|
|
35
|
+
} = {}) {
|
|
36
|
+
this.amount = amount;
|
|
37
|
+
this.description = description;
|
|
38
|
+
}
|
|
48
39
|
|
|
49
|
-
|
|
50
|
-
this.description = description;
|
|
51
|
-
};
|
|
40
|
+
}
|
|
52
41
|
|
|
53
42
|
exports.SummaryTaxModel = SummaryTaxModel;
|
|
54
43
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
class SummaryDiscountModel {
|
|
45
|
+
constructor({
|
|
46
|
+
couponId = '',
|
|
47
|
+
amount = 0,
|
|
48
|
+
description = ''
|
|
49
|
+
} = {}) {
|
|
50
|
+
this.couponId = couponId;
|
|
51
|
+
this.amount = amount;
|
|
52
|
+
this.description = description;
|
|
53
|
+
}
|
|
65
54
|
|
|
66
|
-
|
|
67
|
-
this.amount = amount;
|
|
68
|
-
this.description = description;
|
|
69
|
-
};
|
|
55
|
+
}
|
|
70
56
|
|
|
71
57
|
exports.SummaryDiscountModel = SummaryDiscountModel;
|
|
72
58
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return new instance(item);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
};
|
|
59
|
+
class SummaryModel {
|
|
60
|
+
constructor({
|
|
61
|
+
currency = '',
|
|
62
|
+
lineItems = [],
|
|
63
|
+
taxes = [],
|
|
64
|
+
discounts = [],
|
|
65
|
+
subtotalAmount = 0.0,
|
|
66
|
+
taxAmount = 0.0,
|
|
67
|
+
shippingAmount = 0.0,
|
|
68
|
+
discountsAmount = 0.0,
|
|
69
|
+
total = 0.0
|
|
70
|
+
} = {}) {
|
|
71
|
+
function map(array) {
|
|
72
|
+
const list = Array.isArray(array) ? array : [];
|
|
73
|
+
return {
|
|
74
|
+
// eslint-disable-next-line new-cap
|
|
75
|
+
to: instance => list.map(item => new instance(item))
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
this.currency = currency;
|
|
80
|
+
this.lineItems = map(lineItems).to(SummaryLineItemModel);
|
|
81
|
+
this.taxes = map(taxes).to(SummaryTaxModel);
|
|
82
|
+
this.discounts = map(discounts).to(SummaryDiscountModel);
|
|
83
|
+
this.subtotalAmount = subtotalAmount;
|
|
84
|
+
this.taxAmount = taxAmount;
|
|
85
|
+
this.shippingAmount = shippingAmount;
|
|
86
|
+
this.discountsAmount = discountsAmount;
|
|
87
|
+
this.total = total;
|
|
106
88
|
}
|
|
107
89
|
|
|
108
|
-
|
|
109
|
-
this.lineItems = map(lineItems).to(SummaryLineItemModel);
|
|
110
|
-
this.taxes = map(taxes).to(SummaryTaxModel);
|
|
111
|
-
this.discounts = map(discounts).to(SummaryDiscountModel);
|
|
112
|
-
this.subtotalAmount = subtotalAmount;
|
|
113
|
-
this.taxAmount = taxAmount;
|
|
114
|
-
this.shippingAmount = shippingAmount;
|
|
115
|
-
this.discountsAmount = discountsAmount;
|
|
116
|
-
this.total = total;
|
|
117
|
-
};
|
|
90
|
+
}
|
|
118
91
|
|
|
119
|
-
exports
|
|
92
|
+
exports.default = SummaryModel;
|
package/dist/storefront/plans.js
CHANGED
|
@@ -3,90 +3,43 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.fetchPlans = fetchPlans;
|
|
7
7
|
|
|
8
8
|
var _planModel = _interopRequireDefault(require("./models/plan-model"));
|
|
9
9
|
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (!(!this.configs || !this.options)) {
|
|
47
|
-
_context.next = 5;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
throw new Error('Could not use Rebilly Instruments configurations or mount options to fetch Rebilly data');
|
|
52
|
-
|
|
53
|
-
case 5:
|
|
54
|
-
_context.prev = 5;
|
|
55
|
-
_ref2 = data || {}, lineItems = _ref2.lineItems;
|
|
56
|
-
filterByPlanId = {
|
|
57
|
-
filter: ''
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
if (lineItems) {
|
|
61
|
-
filterByPlanId.filter = "id:".concat(lineItems.map(function (item) {
|
|
62
|
-
return item.planId;
|
|
63
|
-
}).join(','));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
_context.next = 11;
|
|
67
|
-
return this.storefront.plans.getAll(filterByPlanId);
|
|
68
|
-
|
|
69
|
-
case 11:
|
|
70
|
-
_yield$this$storefron = _context.sent;
|
|
71
|
-
planItems = _yield$this$storefron.items;
|
|
72
|
-
return _context.abrupt("return", planItems.map(function (_ref3) {
|
|
73
|
-
var fields = _ref3.fields;
|
|
74
|
-
return new _planModel["default"](fields);
|
|
75
|
-
}));
|
|
76
|
-
|
|
77
|
-
case 16:
|
|
78
|
-
_context.prev = 16;
|
|
79
|
-
_context.t0 = _context["catch"](5);
|
|
80
|
-
throw _context.t0;
|
|
81
|
-
|
|
82
|
-
case 19:
|
|
83
|
-
case "end":
|
|
84
|
-
return _context.stop();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, _callee, this, [[5, 16]]);
|
|
88
|
-
}));
|
|
89
|
-
return _FetchPlans.apply(this, arguments);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
;
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
async function fetchPlans({
|
|
13
|
+
data = null,
|
|
14
|
+
state = null
|
|
15
|
+
}) {
|
|
16
|
+
if (!state.storefront) {
|
|
17
|
+
throw new Error('Could not access rebilly-js-sdk instance');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!state.configs || !state.options) {
|
|
21
|
+
throw new Error('Could not use Rebilly Instruments configurations or mount options to fetch Rebilly data');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const {
|
|
26
|
+
lineItems
|
|
27
|
+
} = data || {};
|
|
28
|
+
const filterByPlanId = {
|
|
29
|
+
filter: ''
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (lineItems) {
|
|
33
|
+
filterByPlanId.filter = `id:${lineItems.map(item => item.planId).join(',')}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
items: planItems
|
|
38
|
+
} = await state.storefront.plans.getAll(filterByPlanId);
|
|
39
|
+
return planItems.map(({
|
|
40
|
+
fields
|
|
41
|
+
}) => new _planModel.default(fields));
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|