@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.
Files changed (277) hide show
  1. package/.babelrc +23 -5
  2. package/.eslintrc.js +27 -0
  3. package/.prettierrc.js +11 -0
  4. package/CONTRIBUTING.md +4 -0
  5. package/README.md +361 -2
  6. package/dist/events/base-event.js +51 -37
  7. package/dist/events/events.spec.js +18 -0
  8. package/dist/events/index.js +11 -8
  9. package/dist/functions/destroy.js +27 -5
  10. package/dist/functions/destroy.spec.js +69 -0
  11. package/dist/functions/initialize.js +60 -41
  12. package/dist/functions/initialize.spec.js +13 -13
  13. package/dist/functions/mount/fetch-summary-data.js +46 -0
  14. package/dist/functions/mount/fetch-summary-data.spec.js +44 -0
  15. package/dist/functions/mount/index.js +346 -0
  16. package/dist/functions/mount/mount.spec.js +135 -0
  17. package/dist/functions/on.js +26 -18
  18. package/dist/functions/on.spec.js +45 -63
  19. package/dist/functions/purchase.js +41 -154
  20. package/dist/functions/purchase.spec.js +60 -76
  21. package/dist/functions/show.js +39 -43
  22. package/dist/functions/show.spec.js +57 -0
  23. package/dist/functions/update.js +60 -5
  24. package/dist/functions/update.spec.js +100 -0
  25. package/dist/i18n/en.json +19 -0
  26. package/dist/i18n/es.json +19 -0
  27. package/dist/i18n/i18n.spec.js +6 -23
  28. package/dist/i18n/index.js +44 -67
  29. package/dist/index.js +70 -71
  30. package/dist/index.spec.js +24 -44
  31. package/dist/loader/index.js +63 -62
  32. package/dist/loader/loader.spec.js +14 -11
  33. package/dist/storefront/index.js +28 -39
  34. package/dist/storefront/models/plan-model.js +37 -54
  35. package/dist/storefront/models/product-model.js +25 -36
  36. package/dist/storefront/models/ready-to-pay-model.js +38 -42
  37. package/dist/storefront/models/summary-model.js +72 -99
  38. package/dist/storefront/plans.js +37 -84
  39. package/dist/storefront/plans.spec.js +61 -151
  40. package/dist/storefront/products.js +35 -83
  41. package/dist/storefront/products.spec.js +60 -150
  42. package/dist/storefront/purchase.js +27 -64
  43. package/dist/storefront/purchase.spec.js +51 -87
  44. package/dist/storefront/ready-to-pay.js +45 -107
  45. package/dist/storefront/ready-to-pay.spec.js +72 -147
  46. package/dist/storefront/storefront.spec.js +6 -6
  47. package/dist/storefront/summary.js +37 -84
  48. package/dist/storefront/summary.spec.js +135 -240
  49. package/dist/style/base/__snapshots__/theme.spec.js.snap +52 -0
  50. package/dist/style/base/index.js +72 -0
  51. package/dist/style/base/theme.js +73 -0
  52. package/dist/style/base/theme.spec.js +30 -0
  53. package/dist/style/browserslist.js +8 -0
  54. package/dist/style/components/address.js +64 -0
  55. package/dist/style/components/button.js +61 -0
  56. package/dist/style/components/divider.js +48 -0
  57. package/dist/style/components/forms/checkbox.js +83 -0
  58. package/dist/style/components/forms/field.js +53 -0
  59. package/dist/style/components/forms/form.js +28 -0
  60. package/dist/style/components/forms/input.js +45 -0
  61. package/dist/style/components/forms/label.js +43 -0
  62. package/dist/style/components/forms/select.js +63 -0
  63. package/dist/style/components/forms/validation.js +34 -0
  64. package/dist/style/components/icons.js +22 -0
  65. package/dist/style/components/index.js +57 -0
  66. package/dist/style/components/loader.js +48 -0
  67. package/dist/style/components/methods.js +104 -0
  68. package/dist/style/components/overlay.js +33 -0
  69. package/dist/style/helpers/index.js +59 -0
  70. package/dist/style/index.js +48 -0
  71. package/dist/style/payment-instruments/content.js +17 -0
  72. package/dist/style/payment-instruments/index.js +20 -0
  73. package/dist/style/payment-instruments/payment-card.js +35 -0
  74. package/dist/style/utils/color-values.js +22 -0
  75. package/dist/style/vendor/framepay.js +34 -0
  76. package/dist/style/vendor/postmate.js +17 -0
  77. package/dist/style/views/confirmation.js +85 -0
  78. package/dist/style/views/index.js +29 -0
  79. package/dist/style/views/method-selector.js +20 -0
  80. package/dist/style/views/modal.js +93 -0
  81. package/dist/style/views/result.js +61 -0
  82. package/dist/style/views/summary.js +123 -0
  83. package/dist/utils/add-dom-element.js +12 -34
  84. package/dist/utils/format-currency.js +4 -4
  85. package/dist/utils/has-valid-css-selector.js +2 -2
  86. package/dist/utils/index.js +15 -31
  87. package/dist/utils/is-dom-element.js +1 -1
  88. package/dist/utils/process-property-as-dom-element.js +12 -17
  89. package/dist/utils/sleep.js +10 -0
  90. package/{src/components → dist/views}/__snapshots__/summary.spec.js.snap +7 -3
  91. package/dist/views/common/iframe/base-iframe.js +57 -0
  92. package/dist/views/common/iframe/event-listeners.js +50 -0
  93. package/dist/views/common/iframe/index.js +19 -0
  94. package/dist/views/common/iframe/method-iframe.js +33 -0
  95. package/dist/views/common/iframe/modal-iframe.js +38 -0
  96. package/dist/views/common/iframe/view-iframe.js +31 -0
  97. package/dist/views/common/render-utilities.js +11 -0
  98. package/dist/views/confirmation.js +82 -0
  99. package/dist/views/method-selector/__snapshots__/method-selector.spec.js.snap +3 -0
  100. package/dist/views/method-selector/express-methods/apple-pay.js +92 -0
  101. package/dist/views/method-selector/express-methods/google-pay.js +32 -0
  102. package/dist/views/method-selector/express-methods/paypal.js +19 -0
  103. package/dist/views/method-selector/generate-digital-wallet.js +59 -0
  104. package/dist/views/method-selector/generate-digital-wallet.spec.js +132 -0
  105. package/dist/views/method-selector/get-method-data.js +25 -0
  106. package/dist/views/method-selector/get-payment-methods.js +55 -0
  107. package/dist/views/method-selector/get-payment-methods.spec.js +44 -0
  108. package/dist/views/method-selector/index.js +133 -0
  109. package/dist/views/method-selector/method-selector.spec.js +139 -0
  110. package/dist/views/method-selector/mount-express-methods.js +69 -0
  111. package/dist/views/method-selector/mount-methods.js +78 -0
  112. package/dist/views/modal.js +83 -0
  113. package/dist/views/result.js +42 -0
  114. package/dist/views/summary.js +162 -0
  115. package/dist/views/summary.spec.js +148 -0
  116. package/package.json +12 -6
  117. package/src/events/base-event.js +35 -12
  118. package/src/events/events.spec.js +11 -0
  119. package/src/events/index.js +12 -6
  120. package/src/functions/destroy.js +22 -3
  121. package/src/functions/destroy.spec.js +63 -0
  122. package/src/functions/initialize.js +43 -20
  123. package/src/functions/initialize.spec.js +9 -7
  124. package/src/functions/mount/fetch-summary-data.js +29 -0
  125. package/src/functions/mount/fetch-summary-data.spec.js +41 -0
  126. package/src/functions/mount/index.js +312 -0
  127. package/src/functions/mount/mount.spec.js +171 -0
  128. package/src/functions/on.js +17 -14
  129. package/src/functions/on.spec.js +39 -29
  130. package/src/functions/purchase.js +24 -64
  131. package/src/functions/purchase.spec.js +19 -17
  132. package/src/functions/show.js +27 -7
  133. package/src/functions/show.spec.js +61 -0
  134. package/src/functions/update.js +50 -3
  135. package/src/functions/update.spec.js +107 -0
  136. package/src/i18n/i18n.spec.js +6 -4
  137. package/src/i18n/index.js +20 -12
  138. package/src/index.js +43 -49
  139. package/src/index.spec.js +11 -42
  140. package/src/loader/index.js +55 -39
  141. package/src/loader/loader.spec.js +30 -23
  142. package/src/storefront/index.js +9 -7
  143. package/src/storefront/models/plan-model.js +1 -1
  144. package/src/storefront/models/product-model.js +1 -1
  145. package/src/storefront/models/ready-to-pay-model.js +10 -4
  146. package/src/storefront/models/summary-model.js +8 -15
  147. package/src/storefront/plans.js +16 -12
  148. package/src/storefront/plans.spec.js +29 -37
  149. package/src/storefront/products.js +16 -12
  150. package/src/storefront/products.spec.js +28 -39
  151. package/src/storefront/purchase.js +8 -6
  152. package/src/storefront/purchase.spec.js +18 -17
  153. package/src/storefront/ready-to-pay.js +19 -13
  154. package/src/storefront/ready-to-pay.spec.js +41 -41
  155. package/src/storefront/storefront.spec.js +1 -1
  156. package/src/storefront/summary.js +14 -12
  157. package/src/storefront/summary.spec.js +37 -50
  158. package/src/style/base/__snapshots__/theme.spec.js.snap +52 -0
  159. package/src/style/base/index.js +63 -0
  160. package/src/style/base/theme.js +61 -0
  161. package/src/style/base/theme.spec.js +32 -0
  162. package/src/style/browserslist.js +1 -0
  163. package/src/style/components/address.js +55 -0
  164. package/src/style/components/button.js +54 -0
  165. package/src/style/components/divider.js +39 -0
  166. package/src/style/components/forms/checkbox.js +76 -0
  167. package/src/style/components/forms/field.js +44 -0
  168. package/src/style/components/forms/form.js +19 -0
  169. package/src/style/components/forms/input.js +36 -0
  170. package/src/style/components/forms/label.js +34 -0
  171. package/src/style/components/forms/select.js +54 -0
  172. package/src/style/components/forms/validation.js +25 -0
  173. package/src/style/components/icons.js +13 -0
  174. package/src/style/components/index.js +35 -0
  175. package/src/style/components/loader.js +41 -0
  176. package/src/style/components/methods.js +93 -0
  177. package/src/style/components/overlay.js +24 -0
  178. package/src/style/helpers/index.js +51 -0
  179. package/src/style/index.js +30 -0
  180. package/src/style/payment-instruments/content.js +8 -0
  181. package/src/style/payment-instruments/index.js +10 -0
  182. package/src/style/payment-instruments/payment-card.js +26 -0
  183. package/src/style/utils/color-values.js +9 -0
  184. package/src/style/vendor/framepay.js +25 -0
  185. package/src/style/vendor/postmate.js +8 -0
  186. package/src/style/views/confirmation.js +76 -0
  187. package/src/style/views/index.js +16 -0
  188. package/src/style/views/method-selector.js +11 -0
  189. package/src/style/views/modal.js +84 -0
  190. package/src/style/views/result.js +52 -0
  191. package/src/style/views/summary.js +114 -0
  192. package/src/utils/add-dom-element.js +12 -13
  193. package/src/utils/format-currency.js +4 -1
  194. package/src/utils/has-valid-css-selector.js +2 -2
  195. package/src/utils/index.js +2 -6
  196. package/src/utils/is-dom-element.js +1 -1
  197. package/src/utils/process-property-as-dom-element.js +27 -24
  198. package/src/utils/sleep.js +3 -0
  199. package/src/views/__snapshots__/summary.spec.js.snap +292 -0
  200. package/src/views/common/iframe/base-iframe.js +46 -0
  201. package/src/views/common/iframe/event-listeners.js +27 -0
  202. package/src/views/common/iframe/index.js +7 -0
  203. package/src/views/common/iframe/method-iframe.js +21 -0
  204. package/src/views/common/iframe/modal-iframe.js +27 -0
  205. package/src/views/common/iframe/view-iframe.js +18 -0
  206. package/src/views/common/render-utilities.js +4 -0
  207. package/src/views/confirmation.js +57 -0
  208. package/src/views/method-selector/__snapshots__/method-selector.spec.js.snap +3 -0
  209. package/src/views/method-selector/express-methods/apple-pay.js +78 -0
  210. package/src/views/method-selector/express-methods/google-pay.js +25 -0
  211. package/src/views/method-selector/express-methods/paypal.js +7 -0
  212. package/src/views/method-selector/generate-digital-wallet.js +44 -0
  213. package/src/views/method-selector/generate-digital-wallet.spec.js +131 -0
  214. package/src/{components/form → views/method-selector}/get-method-data.js +9 -5
  215. package/src/views/method-selector/get-payment-methods.js +40 -0
  216. package/src/views/method-selector/get-payment-methods.spec.js +40 -0
  217. package/src/views/method-selector/index.js +110 -0
  218. package/src/views/method-selector/method-selector.spec.js +146 -0
  219. package/src/views/method-selector/mount-express-methods.js +53 -0
  220. package/src/views/method-selector/mount-methods.js +71 -0
  221. package/src/views/modal.js +84 -0
  222. package/src/views/result.js +30 -0
  223. package/src/{components → views}/summary.js +90 -21
  224. package/src/views/summary.spec.js +170 -0
  225. package/tests/async-utilities.js +22 -0
  226. package/tests/mocks/rebilly-instruments-mock.js +105 -7
  227. package/dist/components/confirmation.js +0 -103
  228. package/dist/components/form/form.js +0 -110
  229. package/dist/components/form/form.spec.js +0 -135
  230. package/dist/components/form/get-method-data.js +0 -21
  231. package/dist/components/form/get-payment-methods.js +0 -42
  232. package/dist/components/form/method-selector.js +0 -61
  233. package/dist/components/form/mount-express-payment-methods.js +0 -102
  234. package/dist/components/form/process-digital-wallet-options.js +0 -20
  235. package/dist/components/form/zoid-helpers.js +0 -130
  236. package/dist/components/result.js +0 -66
  237. package/dist/components/summary.js +0 -60
  238. package/dist/components/summary.spec.js +0 -144
  239. package/dist/events/instrument-ready.js +0 -51
  240. package/dist/events/purchase-complete.js +0 -51
  241. package/dist/functions/mount.js +0 -311
  242. package/dist/functions/mount.spec.js +0 -203
  243. package/dist/styles/base-styles.js +0 -12
  244. package/dist/styles/flat-theme-object.js +0 -42
  245. package/dist/styles/framepay.js +0 -15
  246. package/dist/styles/main.js +0 -25
  247. package/dist/styles/payment-card.js +0 -12
  248. package/dist/styles/shade-tint-values-helper.js +0 -28
  249. package/dist/styles/style-variables.js +0 -43
  250. package/dist/utils/camel-case.js +0 -12
  251. package/dist/utils/kebab-case.js +0 -10
  252. package/dist/utils/un-kebab-case.js +0 -10
  253. package/src/components/confirmation.js +0 -77
  254. package/src/components/form/__snapshots__/form.spec.js.snap +0 -43
  255. package/src/components/form/form.js +0 -88
  256. package/src/components/form/form.spec.js +0 -109
  257. package/src/components/form/get-payment-methods.js +0 -32
  258. package/src/components/form/method-selector.js +0 -47
  259. package/src/components/form/mount-express-payment-methods.js +0 -84
  260. package/src/components/form/process-digital-wallet-options.js +0 -11
  261. package/src/components/form/zoid-helpers.js +0 -114
  262. package/src/components/result.js +0 -50
  263. package/src/components/summary.spec.js +0 -106
  264. package/src/events/instrument-ready.js +0 -11
  265. package/src/events/purchase-complete.js +0 -11
  266. package/src/functions/mount.js +0 -204
  267. package/src/functions/mount.spec.js +0 -172
  268. package/src/styles/base-styles.js +0 -741
  269. package/src/styles/flat-theme-object.js +0 -12
  270. package/src/styles/framepay.js +0 -30
  271. package/src/styles/main.js +0 -17
  272. package/src/styles/payment-card.js +0 -18
  273. package/src/styles/shade-tint-values-helper.js +0 -13
  274. package/src/styles/style-variables.js +0 -34
  275. package/src/utils/camel-case.js +0 -3
  276. package/src/utils/kebab-case.js +0 -3
  277. package/src/utils/un-kebab-case.js +0 -3
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getPaymentMethods = getPaymentMethods;
7
-
8
- /* eslint-disable no-unused-expressions, arrow-body-style */
9
- var SUPPORTED_EXPRESS_METHODS = ['Google Pay', 'Apple Pay', 'paypal'];
10
-
11
- var isExpressMethod = function isExpressMethod(_ref) {
12
- var method = _ref.method,
13
- feature = _ref.feature;
14
- return SUPPORTED_EXPRESS_METHODS.includes(method) || SUPPORTED_EXPRESS_METHODS.includes(feature === null || feature === void 0 ? void 0 : feature.name);
15
- };
16
-
17
- function getPaymentMethods(methods) {
18
- var _this = this;
19
-
20
- var result = {
21
- EXPRESS_METHODS: [],
22
- METHODS: []
23
- };
24
- methods.forEach(function (method) {
25
- if (isExpressMethod(method)) {
26
- // Add loader entry per express method
27
- _this.loader.startLoading({
28
- id: "".concat(method.method, "-express")
29
- });
30
-
31
- result.EXPRESS_METHODS.push(method);
32
- } else {
33
- // Add loader entry per method
34
- _this.loader.startLoading({
35
- id: method.method
36
- });
37
-
38
- result.METHODS.push(method);
39
- }
40
- });
41
- return result;
42
- }
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MountMethodSelector = MountMethodSelector;
7
-
8
- var _main = require("../../styles/main");
9
-
10
- var _zoidHelpers = require("./zoid-helpers");
11
-
12
- var _getMethodData2 = require("./get-method-data");
13
-
14
- function MountMethodSelector(_ref) {
15
- var _this = this;
16
-
17
- var METHODS_CONTAINER = _ref.METHODS_CONTAINER,
18
- METHODS = _ref.METHODS,
19
- plans = _ref.plans,
20
- products = _ref.products;
21
- METHODS_CONTAINER.innerHTML = "<div class=\"rebilly-instruments-method-selector\"></div>";
22
- var SELECTOR_CONTAINER = document.querySelector('.rebilly-instruments-method-selector');
23
- METHODS.forEach(function (method) {
24
- var _this$configs, _this$options$payment;
25
-
26
- var _getMethodData = (0, _getMethodData2.getMethodData)(method),
27
- METHOD_ID = _getMethodData.METHOD_ID,
28
- METHOD_TYPE = _getMethodData.METHOD_TYPE;
29
-
30
- var _ref2 = _this.options._computed || 'https://www.example.com',
31
- paymentMethodsUrl = _ref2.paymentMethodsUrl;
32
-
33
- var zoidComponent = METHOD_ID;
34
- var zoidCreateConfig = {
35
- tag: METHOD_ID,
36
- url: "".concat(paymentMethodsUrl, "/").concat(METHOD_ID)
37
- };
38
- var zoidMountConfig = {
39
- configs: _this.configs,
40
- options: _this.options,
41
- MAIN_STYLE: (0, _main.MAIN_STYLE)(((_this$configs = _this.configs) === null || _this$configs === void 0 ? void 0 : _this$configs.theme) || {}),
42
- method: method,
43
- plans: plans,
44
- products: products,
45
- dispatch: function dispatch(event, detail) {
46
- _zoidHelpers.dispatch.call(_this, event, detail);
47
- }
48
- };
49
- var isiFrame = METHOD_ID === 'payment-card' && !((_this$options$payment = _this.options.paymentInstruments[METHOD_TYPE]) !== null && _this$options$payment !== void 0 && _this$options$payment.popup);
50
- var zoidDefaultContext = isiFrame ? _zoidHelpers.zoidIframe : _zoidHelpers.zoidPopup;
51
- _this.zoidComponents[METHOD_ID] = zoidDefaultContext.call(_this, {
52
- zoidComponent: zoidComponent,
53
- zoidCreateConfig: zoidCreateConfig,
54
- zoidMountConfig: zoidMountConfig
55
- }, {
56
- SELECTOR_CONTAINER: SELECTOR_CONTAINER,
57
- METHOD_ID: METHOD_ID,
58
- method: method
59
- });
60
- });
61
- }
@@ -1,102 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mountExpressPaymentMethods = mountExpressPaymentMethods;
7
-
8
- var _zoidHelpers = require("./zoid-helpers");
9
-
10
- var _getMethodData = require("./get-method-data");
11
-
12
- var _main = require("../../styles/main");
13
-
14
- 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; }
15
-
16
- 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; }
17
-
18
- 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; }
19
-
20
- function mountGooglePay(_ref) {
21
- var _this$configs;
22
-
23
- var METHOD_ID = _ref.METHOD_ID;
24
- var SELECTOR_CONTAINER = document.querySelector('.rebilly-instruments-form-express');
25
- var paymentMethodsUrl = this.options._computed.paymentMethodsUrl;
26
- var zoidComponent = 'googlePay';
27
- var zoidCreateConfig = {
28
- tag: METHOD_ID,
29
- url: "".concat(paymentMethodsUrl, "/").concat(METHOD_ID),
30
- prerenderTemplate: function prerenderTemplate() {
31
- return null;
32
- }
33
- };
34
- var zoidMountConfig = {
35
- configs: this.configs,
36
- options: this.options,
37
- MAIN_STYLE: (0, _main.MAIN_STYLE)(((_this$configs = this.configs) === null || _this$configs === void 0 ? void 0 : _this$configs.theme) || {}),
38
- dispatch: _zoidHelpers.dispatch
39
- };
40
- this.zoidComponents.googlePay = _zoidHelpers.zoidIframe.call(this, {
41
- zoidComponent: zoidComponent,
42
- zoidCreateConfig: zoidCreateConfig,
43
- zoidMountConfig: zoidMountConfig
44
- }, {
45
- SELECTOR_CONTAINER: SELECTOR_CONTAINER,
46
- METHOD_ID: METHOD_ID
47
- });
48
- }
49
-
50
- function mountApplePay(_ref2) {
51
- var EXPRESS_METHODS_CONTAINER = _ref2.EXPRESS_METHODS_CONTAINER,
52
- METHOD_ID = _ref2.METHOD_ID,
53
- METHOD_TYPE = _ref2.METHOD_TYPE;
54
- EXPRESS_METHODS_CONTAINER.innerHTML += "\n <div id=\"rebilly-instruments-".concat(METHOD_ID, "\" data-rebilly-instruments-express-type=\"").concat(METHOD_TYPE, "\"></div>\n ");
55
- Rebilly.applePay.mount("#rebilly-instruments-".concat(METHOD_ID));
56
- Rebilly.on('token-ready', function (token) {
57
- (0, _zoidHelpers.dispatch)('instrument-ready', token);
58
- });
59
- }
60
-
61
- function mountPaypal() {
62
- console.log('PayPal - work in progress');
63
- this.loader.stopLoading({
64
- id: 'paypal-express'
65
- });
66
- }
67
-
68
- var browserIsSafari = function browserIsSafari() {
69
- return window.ApplePaySession;
70
- };
71
-
72
- function mountExpressPaymentMethods(_ref3) {
73
- var _this = this;
74
-
75
- var EXPRESS_METHODS = _ref3.EXPRESS_METHODS,
76
- EXPRESS_METHODS_CONTAINER = _ref3.EXPRESS_METHODS_CONTAINER;
77
- EXPRESS_METHODS.forEach(function (expressMethod) {
78
- var method = expressMethod.method,
79
- feature = expressMethod.feature;
80
- var methodData = (0, _getMethodData.getMethodData)(expressMethod);
81
-
82
- if (method === 'paypal') {
83
- mountPaypal.call(_this);
84
- }
85
-
86
- ;
87
-
88
- if ((feature === null || feature === void 0 ? void 0 : feature.name) === 'Google Pay') {
89
- mountGooglePay.call(_this, _objectSpread({}, methodData));
90
- }
91
-
92
- if ((feature === null || feature === void 0 ? void 0 : feature.name) === 'Apple Pay' && browserIsSafari()) {
93
- mountApplePay.call(_this, _objectSpread({
94
- EXPRESS_METHODS_CONTAINER: EXPRESS_METHODS_CONTAINER
95
- }, methodData));
96
- } else {
97
- _this.loader.stopLoading({
98
- id: 'payment-card-express'
99
- });
100
- }
101
- });
102
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.processDigitalWalletOptions = processDigitalWalletOptions;
7
-
8
- function processDigitalWalletOptions(options) {
9
- var paymentInstruments = options.paymentInstruments;
10
- var digitalWalletOptions = {};
11
-
12
- if (paymentInstruments !== null && paymentInstruments !== void 0 && paymentInstruments.googlePay) {
13
- var googlePay = paymentInstruments.googlePay;
14
- digitalWalletOptions.merchantConfig = googlePay.merchantConfig; // Throw error?
15
-
16
- digitalWalletOptions.googlePayDisplayOptions = googlePay.displayOptions;
17
- }
18
-
19
- return digitalWalletOptions;
20
- }
@@ -1,130 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.containerTemplate = containerTemplate;
7
- exports.zoidIframe = zoidIframe;
8
- exports.zoidPopup = zoidPopup;
9
- exports.dispatch = void 0;
10
-
11
- var _zoid = _interopRequireDefault(require("zoid"));
12
-
13
- var _events = _interopRequireDefault(require("../../events"));
14
-
15
- var _index = require("../../utils/index");
16
-
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
18
-
19
- 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; }
20
-
21
- 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; }
22
-
23
- 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; }
24
-
25
- var dispatch = function dispatch(event, detail) {
26
- _events["default"][(0, _index.camelCase)(event).replace(/-/, '')].dispatch(detail);
27
- };
28
-
29
- exports.dispatch = dispatch;
30
-
31
- function containerTemplate(_ref) {
32
- var _this$translate;
33
-
34
- var doc = _ref.doc,
35
- uid = _ref.uid,
36
- focus = _ref.focus;
37
-
38
- if (doc === null || doc === undefined) {
39
- doc = document;
40
- }
41
-
42
- var container = doc.createElement('div');
43
- var text = doc.createElement('p');
44
- text.dataset.rebillyI18n = 'form.popupOverlayText';
45
- text.innerText = ((_this$translate = this.translate) === null || _this$translate === void 0 ? void 0 : _this$translate.translateItem(text)) || 'Click here to show popup window';
46
- container.id = uid;
47
- container.append(text);
48
- container.classList.add('rebilly-instruments-overlay');
49
- container.addEventListener('click', focus);
50
- return container;
51
- }
52
-
53
- ;
54
-
55
- function zoidIframe(_ref2, _ref3) {
56
- var _this = this;
57
-
58
- var zoidComponent = _ref2.zoidComponent,
59
- zoidCreateConfig = _ref2.zoidCreateConfig,
60
- zoidMountConfig = _ref2.zoidMountConfig;
61
- var SELECTOR_CONTAINER = _ref3.SELECTOR_CONTAINER,
62
- METHOD_ID = _ref3.METHOD_ID;
63
- var component = typeof this.zoidComponents[zoidComponent] === "function" ? this.zoidComponents[zoidComponent] : undefined;
64
- var selector = "rebilly-instruments-".concat(METHOD_ID);
65
- SELECTOR_CONTAINER.innerHTML += "<div id=\"".concat(selector, "\" data-rebilly-instruments-type=\"").concat(METHOD_ID, "\"></div>");
66
- var METHOD_WRAPPER = document.querySelector("#".concat(selector));
67
-
68
- if (!component) {
69
- component = _zoid["default"].create(_objectSpread(_objectSpread({}, zoidCreateConfig), {}, {
70
- defaultContext: 'iframe',
71
- dimensions: {
72
- width: '100%',
73
- height: '100%'
74
- }
75
- }));
76
- }
77
-
78
- component({
79
- RebillyInstruments: _objectSpread(_objectSpread({}, zoidMountConfig), {}, {
80
- onFrameResize: function onFrameResize(height) {
81
- METHOD_WRAPPER.style.height = height;
82
- },
83
- onLoading: function onLoading(id) {
84
- _this.loader.stopLoading({
85
- id: id
86
- });
87
- }
88
- }),
89
- onDestroy: function onDestroy() {
90
- setTimeout(function () {
91
- METHOD_WRAPPER.remove();
92
- }, 1000);
93
- }
94
- }).render("#".concat(selector));
95
- return component;
96
- }
97
-
98
- function zoidPopup(_ref4, _ref5) {
99
- var zoidComponent = _ref4.zoidComponent,
100
- zoidCreateConfig = _ref4.zoidCreateConfig,
101
- zoidMountConfig = _ref4.zoidMountConfig;
102
- var SELECTOR_CONTAINER = _ref5.SELECTOR_CONTAINER,
103
- METHOD_ID = _ref5.METHOD_ID,
104
- method = _ref5.method;
105
- var component = typeof this.zoidComponents[zoidComponent] === "function" ? this.zoidComponents[zoidComponent] : undefined;
106
-
107
- if (!component) {
108
- component = _zoid["default"].create(_objectSpread(_objectSpread({}, zoidCreateConfig), {}, {
109
- defaultContext: 'popup',
110
- dimensions: {
111
- width: '600px',
112
- height: '600px'
113
- },
114
- containerTemplate: containerTemplate.bind(this)
115
- }));
116
- }
117
-
118
- var selector = "rebilly-instruments-".concat(METHOD_ID);
119
- SELECTOR_CONTAINER.innerHTML += "<div id=\"".concat(selector, "\" data-rebilly-instruments-type=\"").concat(METHOD_ID, "\">\n <button data-rebilly-i18n=\"paymentMethods.").concat(method.method, "\" class=\"rebilly-instruments-button\">").concat((0, _index.unKebabCase)(method.method), "</button>\n </div>");
120
- this.loader.stopLoading({
121
- id: method.method
122
- });
123
- var PAYMENT_CARD_BUTTON = document.querySelector("#".concat(selector, " button"));
124
- PAYMENT_CARD_BUTTON.addEventListener('click', function () {
125
- component({
126
- RebillyInstruments: _objectSpread({}, zoidMountConfig)
127
- }).render();
128
- });
129
- return component;
130
- }
@@ -1,66 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MountResult = MountResult;
7
-
8
- var _zoid = _interopRequireDefault(require("zoid"));
9
-
10
- var _main = require("../styles/main");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
- function MountResult(_ref) {
15
- var _this$configs,
16
- _this = this;
17
-
18
- var purchase = _ref.purchase;
19
- var resultContainerClassName = 'rebilly-instruments-result';
20
- this.form.innerHTML += "<div class=\"".concat(resultContainerClassName, "\"></div>");
21
- this.loader.startLoading({
22
- id: 'result'
23
- });
24
- var RESULT_CONTAINER = document.querySelector(".".concat(resultContainerClassName));
25
- this.form.querySelectorAll(":not(.".concat(resultContainerClassName, ")")).forEach(function (element) {
26
- if (!element.classList.contains('rebilly-instruments-loader') && !element.classList.contains('rebilly-instruments-loader-spinner')) {
27
- element.remove();
28
- }
29
- });
30
- var paymentMethodsUrl = this.options._computed.paymentMethodsUrl;
31
- var zoidCreateConfig = {
32
- tag: 'rebilly-instruments-result',
33
- url: "".concat(paymentMethodsUrl, "/result"),
34
- defaultContext: 'iframe',
35
- dimensions: {
36
- width: '100%',
37
- height: '100%'
38
- }
39
- };
40
- var zoidMountConfig = {
41
- configs: this.configs,
42
- options: this.options,
43
- MAIN_STYLE: (0, _main.MAIN_STYLE)(((_this$configs = this.configs) === null || _this$configs === void 0 ? void 0 : _this$configs.theme) || {}),
44
- purchase: purchase,
45
- onFrameResize: function onFrameResize(height) {
46
- RESULT_CONTAINER.style.height = height;
47
- },
48
- onLoading: function onLoading(id) {
49
- setTimeout(function () {
50
- _this.loader.stopLoading({
51
- id: id
52
- });
53
- }, 1);
54
- }
55
- };
56
-
57
- if (!this.zoidComponents.result) {
58
- this.zoidComponents.result = _zoid["default"].create(zoidCreateConfig);
59
- }
60
-
61
- this.zoidComponents.result({
62
- RebillyInstruments: zoidMountConfig
63
- }).render(".".concat(resultContainerClassName));
64
- }
65
-
66
- ;
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MountSummary = MountSummary;
7
- exports.baseSummaryHTML = void 0;
8
-
9
- var _utils = require("../utils");
10
-
11
- var baseSummaryHTML = "\n <div class=\"rebilly-instruments-summary-container\">\n <div class=\"rebilly-instruments-summary-line-items\"></div>\n <div class=\"rebilly-instruments-summary-breakdown\"></div>\n </div>\n";
12
- exports.baseSummaryHTML = baseSummaryHTML;
13
-
14
- function MountSummary() {
15
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
16
- summary = _ref.summary,
17
- plans = _ref.plans,
18
- products = _ref.products;
19
-
20
- this.summary.innerHTML += baseSummaryHTML;
21
- var itemsContainer = document.querySelector('.rebilly-instruments-summary-line-items');
22
- var summaryBreakdown = document.querySelector('.rebilly-instruments-summary-breakdown');
23
- var optionItems = this.options.intent.items;
24
- var hasThumbnails = optionItems.some(function (optionItem) {
25
- return optionItem.thumbnail;
26
- });
27
- var lineItems = summary.lineItems,
28
- currency = summary.currency,
29
- discountsAmount = summary.discountsAmount,
30
- shippingAmount = summary.shippingAmount,
31
- subtotalAmount = summary.subtotalAmount,
32
- taxAmount = summary.taxAmount,
33
- total = summary.total;
34
- lineItems.forEach(function (lineItem) {
35
- var _optionItems$find = optionItems.find(function (optionItem) {
36
- return optionItem.planId === lineItem.planId;
37
- }),
38
- thumbnail = _optionItems$find.thumbnail;
39
-
40
- var _plans$find = plans.find(function (plan) {
41
- return plan.id === lineItem.planId;
42
- }),
43
- name = _plans$find.name;
44
-
45
- var _products$find = products.find(function (product) {
46
- return product.id === lineItem.productId;
47
- }),
48
- description = _products$find.description;
49
-
50
- itemsContainer.innerHTML += "\n <div class=\"rebilly-instruments-summary-line-item\">\n ".concat(hasThumbnails ? "\n <figure class=\"rebilly-instruments-summary-line-item-figure\">\n ".concat(thumbnail ? "<img src=\"".concat(thumbnail, "\" alt=\"").concat(name, "\">") : '', "\n </figure>\n ") : "", "\n <div class=\"rebilly-instruments-summary-line-item-synopsis\">\n <p class=\"rebilly-instruments-summary-line-item-synopsis-title\">").concat(name, "</p>\n <p class=\"rebilly-instruments-summary-line-item-synopsis-description\">").concat(description, "</p>\n </div>\n <div class=\"rebilly-instruments-summary-line-item-price-breakdown\">\n <p class=\"rebilly-instruments-summary-line-item-price-breakdown-quantity\">").concat(lineItem.quantity, "</p>\n <svg class=\"rebilly-instruments-icon\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 10.5858l2.8284-2.8284c.3906-.3906 1.0237-.3906 1.4142 0 .3906.3905.3906 1.0236 0 1.4142L13.4142 12l2.8284 2.8284c.3906.3906.3906 1.0237 0 1.4142-.3905.3906-1.0236.3906-1.4142 0L12 13.4142l-2.8284 2.8284c-.3906.3906-1.0237.3906-1.4142 0-.3906-.3905-.3906-1.0236 0-1.4142L10.5858 12 7.7574 9.1716c-.3906-.3906-.3906-1.0237 0-1.4142.3905-.3906 1.0236-.3906 1.4142 0L12 10.5858z\" fill-rule=\"nonzero\"/>\n </svg>\n <p class=\"rebilly-instruments-summary-line-item-price-breakdown-unit-price\">").concat((0, _utils.formatCurrency)(lineItem.unitPrice, currency), "</p>\n </div>\n </div>\n ");
51
- });
52
- summaryBreakdown.innerHTML = "\n <table>\n <colgroup>\n <col>\n <col>\n </colgroup>\n <tr class=\"rebilly-instruments-summary-breakdown-sub-total\">\n <td data-rebilly-i18n=\"summary.subTotal\">Sub Total</td>\n <td>".concat((0, _utils.formatCurrency)(subtotalAmount, currency), "</td>\n </tr>\n <tr class=\"rebilly-instruments-summary-breakdown-discounts\">\n <td data-rebilly-i18n=\"summary.discounts\">Discounts</td>\n <td>").concat((0, _utils.formatCurrency)(discountsAmount, currency), "</td>\n </tr>\n <tr class=\"rebilly-instruments-summary-breakdown-taxes\">\n <td data-rebilly-i18n=\"summary.taxes\">Taxes</td>\n <td>").concat((0, _utils.formatCurrency)(taxAmount, currency), "</td>\n </tr>\n <tr class=\"rebilly-instruments-summary-breakdown-taxes\">\n <td data-rebilly-i18n=\"summary.shipping\">Shipping</td>\n <td>").concat((0, _utils.formatCurrency)(shippingAmount, currency), "</td>\n </tr>\n </table>\n <div class=\"rebilly-instruments-summary-breakdown-total\">\n <p data-rebilly-i18n=\"summary.total\">Total</p>\n <p class=\"rebilly-instruments-summary-breakdown-total-amount\">\n <span class=\"rebilly-instruments-summary-breakdown-total-amount-currency\">").concat(currency, "</span>").concat((0, _utils.formatCurrency)(total, currency), "\n </p>\n </div>\n ");
53
- this.translate.translateItems();
54
- this.loader.stopLoading({
55
- section: 'summary',
56
- id: 'initSummary'
57
- });
58
- }
59
-
60
- ;
@@ -1,144 +0,0 @@
1
- "use strict";
2
-
3
- var _summaryModel = _interopRequireDefault(require("@/storefront/models/summary-model"));
4
-
5
- var _planModel = _interopRequireDefault(require("@/storefront/models/plan-model"));
6
-
7
- var _productModel = _interopRequireDefault(require("@/storefront/models/product-model"));
8
-
9
- var _loader = require("../loader");
10
-
11
- var _i18n = require("../i18n");
12
-
13
- var _summary = require("./summary");
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
-
17
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
-
19
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
20
-
21
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
22
-
23
- describe('Summary component', function () {
24
- var summaryElement;
25
- beforeEach(function () {
26
- summaryElement = document.createElement('div');
27
- document.body.append(summaryElement);
28
- });
29
-
30
- var TestMountSummaryInstance = /*#__PURE__*/function () {
31
- function TestMountSummaryInstance() {
32
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
33
- _ref$configs = _ref.configs,
34
- configs = _ref$configs === void 0 ? {} : _ref$configs,
35
- _ref$options = _ref.options,
36
- options = _ref$options === void 0 ? {} : _ref$options,
37
- _ref$summary = _ref.summary,
38
- summary = _ref$summary === void 0 ? summaryElement : _ref$summary,
39
- _ref$loader = _ref.loader,
40
- loader = _ref$loader === void 0 ? new _loader.Loader() : _ref$loader,
41
- _ref$translate = _ref.translate,
42
- translate = _ref$translate === void 0 ? new _i18n.Translate() : _ref$translate;
43
-
44
- _classCallCheck(this, TestMountSummaryInstance);
45
-
46
- this.configs = configs;
47
- this.options = options;
48
- this.summary = summary;
49
- this.loader = loader;
50
- this.translate = translate;
51
- }
52
-
53
- _createClass(TestMountSummaryInstance, [{
54
- key: "mountSummary",
55
- value: function mountSummary(summaryProductsPlans) {
56
- this.loader.DOM.summary = this.summary;
57
-
58
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
59
- args[_key - 1] = arguments[_key];
60
- }
61
-
62
- return _summary.MountSummary.apply(this, args.concat(summaryProductsPlans));
63
- }
64
- }]);
65
-
66
- return TestMountSummaryInstance;
67
- }();
68
-
69
- var options = {
70
- intent: {
71
- countryCode: 'US',
72
- items: [{
73
- planId: 'my-awesome-product',
74
- quantity: 1,
75
- thumbnail: ''
76
- }, {
77
- planId: 'awesome-t-shirt',
78
- quantity: 2,
79
- thumbnail: ''
80
- }]
81
- }
82
- };
83
- var summaryData = new _summaryModel["default"]({
84
- currency: "USD",
85
- lineItems: [{
86
- type: "debit",
87
- description: "My Awesome Product",
88
- unitPrice: 30,
89
- quantity: 1,
90
- price: 30,
91
- productId: "test-product-1",
92
- planId: "my-awesome-product"
93
- }, {
94
- type: "debit",
95
- description: "Awesome T-Shirt",
96
- unitPrice: 20,
97
- quantity: 2,
98
- price: 40,
99
- productId: "test-product-2",
100
- planId: "awesome-t-shirt"
101
- }],
102
- subtotalAmount: 70,
103
- taxAmount: 0,
104
- shippingAmount: 0,
105
- discountsAmount: 0,
106
- total: 70
107
- });
108
- var planData = [new _planModel["default"]({
109
- name: 'My Awesome Product',
110
- id: 'my-awesome-product',
111
- productId: 'test-product-1'
112
- }), new _planModel["default"]({
113
- name: 'My Awesome T-Shirt',
114
- id: 'awesome-t-shirt',
115
- productId: 'test-product-2'
116
- })];
117
- var productData = [new _productModel["default"]({
118
- description: 'My Awesome Product',
119
- id: 'test-product-1'
120
- }), new _productModel["default"]({
121
- description: 'My Awesome T-Shirt',
122
- id: 'test-product-2'
123
- })];
124
- var configs = {
125
- websiteId: 'test-website-id'
126
- };
127
- it('should render the summary correctly', function () {
128
- var mountSummaryInstance = new TestMountSummaryInstance({
129
- configs: configs,
130
- options: options
131
- });
132
- mountSummaryInstance.mountSummary({
133
- summary: summaryData,
134
- plans: planData,
135
- products: productData
136
- }); // Number of line items
137
-
138
- var itemsContainer = document.querySelector('.rebilly-instruments-summary-line-items');
139
- expect(itemsContainer).toMatchSnapshot(); // Breakdown
140
-
141
- var summaryBreakdown = document.querySelector('.rebilly-instruments-summary-breakdown');
142
- expect(summaryBreakdown).toMatchSnapshot();
143
- });
144
- });