@paydock/client-sdk 1.103.1 → 1.103.11-beta

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 (36) hide show
  1. package/README.md +245 -21
  2. package/bundles/widget.umd.js +433 -160
  3. package/bundles/widget.umd.min.js +1 -1
  4. package/lib/components/container.d.ts +1 -0
  5. package/lib/components/container.js +3 -0
  6. package/lib/components/container.js.map +1 -1
  7. package/lib/components/wallet-background.d.ts +2 -1
  8. package/lib/components/wallet-background.js +4 -1
  9. package/lib/components/wallet-background.js.map +1 -1
  10. package/lib/configs/sdk.js +1 -1
  11. package/lib/wallet-buttons/apple.wallet-service.d.ts +2 -0
  12. package/lib/wallet-buttons/apple.wallet-service.js +38 -5
  13. package/lib/wallet-buttons/apple.wallet-service.js.map +1 -1
  14. package/lib/wallet-buttons/flypay-v2.wallet-service.d.ts +9 -1
  15. package/lib/wallet-buttons/flypay-v2.wallet-service.js +104 -131
  16. package/lib/wallet-buttons/flypay-v2.wallet-service.js.map +1 -1
  17. package/lib/wallet-buttons/google.wallet-service.d.ts +3 -0
  18. package/lib/wallet-buttons/google.wallet-service.js +41 -8
  19. package/lib/wallet-buttons/google.wallet-service.js.map +1 -1
  20. package/lib/wallet-buttons/helpers/flypay-v2.helper.d.ts +3 -0
  21. package/lib/wallet-buttons/helpers/flypay-v2.helper.js +151 -0
  22. package/lib/wallet-buttons/helpers/flypay-v2.helper.js.map +1 -0
  23. package/lib/wallet-buttons/index.d.ts +126 -0
  24. package/lib/wallet-buttons/index.js +126 -0
  25. package/lib/wallet-buttons/index.js.map +1 -1
  26. package/lib/wallet-buttons/interfaces.d.ts +3 -0
  27. package/lib/wallet-buttons/paypal.wallet-service.js +17 -2
  28. package/lib/wallet-buttons/paypal.wallet-service.js.map +1 -1
  29. package/lib/wallet-buttons/wallet-buttons.d.ts +62 -120
  30. package/lib/wallet-buttons/wallet-buttons.js +84 -60
  31. package/lib/wallet-buttons/wallet-buttons.js.map +1 -1
  32. package/lib/wallet-buttons/wallet-service.d.ts +7 -0
  33. package/lib/wallet-buttons/wallet-service.js +11 -0
  34. package/lib/wallet-buttons/wallet-service.js.map +1 -1
  35. package/package.json +1 -1
  36. package/slate.md +48 -19
@@ -684,7 +684,7 @@
684
684
  // the empty string is set in case if version not provided.
685
685
  //
686
686
  // e.g: grunt build --sdk-version=v1.0.0
687
- SDK._version = 'v1.103.1';
687
+ SDK._version = 'v1.103.11-beta';
688
688
 
689
689
  var ENV = {
690
690
  SANDBOX: 'sandbox',
@@ -2112,6 +2112,11 @@
2112
2112
  value: function getElement() {
2113
2113
  return document.querySelector(this.selector);
2114
2114
  }
2115
+ }, {
2116
+ key: "getSelector",
2117
+ value: function getSelector() {
2118
+ return this.selector;
2119
+ }
2115
2120
  }, {
2116
2121
  key: "convertConfigs",
2117
2122
  value: function convertConfigs(params, allowValue) {
@@ -6492,9 +6497,11 @@
6492
6497
  var _super = _createSuper(WalletBackground);
6493
6498
  function WalletBackground(bgImageUrl) {
6494
6499
  var _this;
6500
+ var hideCloseButton = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6495
6501
  _classCallCheck(this, WalletBackground);
6496
6502
  _this = _super.call(this);
6497
6503
  _this.bgImageUrl = bgImageUrl;
6504
+ _this.hideCloseButton = hideCloseButton;
6498
6505
  _this.imageStyle = null;
6499
6506
  return _this;
6500
6507
  }
@@ -6517,6 +6524,7 @@
6517
6524
  var _this2 = this;
6518
6525
  var body = document.body || document.getElementsByTagName("body")[0];
6519
6526
  var template = String(TEMPLATE$2);
6527
+ if (this.hideCloseButton === true) template = template.replace('<a href="#" data-close>Close</a>', '');
6520
6528
  this.overlay = document.createElement("div");
6521
6529
  this.overlay.classList.add("checkout-overlay");
6522
6530
  this.overlay.setAttribute("checkout-overlay", " ");
@@ -6550,7 +6558,10 @@
6550
6558
  PAYMENT_IN_REVIEW: 'payment_in_review',
6551
6559
  PAYMENT_ERROR: 'payment_error',
6552
6560
  CALLBACK: 'callback',
6553
- AUTH_TOKENS_CHANGED: 'auth_tokens_changed'
6561
+ AUTH_TOKENS_CHANGED: 'auth_tokens_changed',
6562
+ BUTTON_CLICK: 'button_click',
6563
+ CHECKOUT_OPEN: 'checkout_open',
6564
+ CHECKOUT_CLOSE: 'checkout_close'
6554
6565
  };
6555
6566
  var WalletService = /*#__PURE__*/function () {
6556
6567
  function WalletService(publicKey, meta) {
@@ -6592,6 +6603,18 @@
6592
6603
  // do nothing unless current wallet service overrides this method;
6593
6604
  return;
6594
6605
  }
6606
+ }, {
6607
+ key: "enable",
6608
+ value: function enable() {
6609
+ // do nothing unless current wallet service overrides this method;
6610
+ return;
6611
+ }
6612
+ }, {
6613
+ key: "disable",
6614
+ value: function disable() {
6615
+ // do nothing unless current wallet service overrides this method;
6616
+ return;
6617
+ }
6595
6618
  }, {
6596
6619
  key: "on",
6597
6620
  value: function on(eventName, cb) {
@@ -6865,6 +6888,23 @@
6865
6888
  return _extends(_extends({}, this.meta.style && {
6866
6889
  style: this.meta.style
6867
6890
  }), {
6891
+ onClick: function onClick(_data, actions) {
6892
+ var responseValue;
6893
+ _this4.eventEmitter.emit(WALLET_EVENT.BUTTON_CLICK, {
6894
+ attachResult: function attachResult(value) {
6895
+ if (value && value instanceof Promise) {
6896
+ responseValue = value.then(function () {
6897
+ return actions.resolve();
6898
+ })["catch"](function () {
6899
+ return actions.reject();
6900
+ });
6901
+ } else {
6902
+ responseValue = value;
6903
+ }
6904
+ }
6905
+ });
6906
+ return responseValue;
6907
+ },
6868
6908
  createOrder: function createOrder() {
6869
6909
  return new Promise(function (resolve, reject) {
6870
6910
  _this4.eventEmitter.emit(WALLET_EVENT.CALLBACK, {
@@ -6914,6 +6954,9 @@
6914
6954
  });
6915
6955
  return _this4.pendingApprovalPromise;
6916
6956
  },
6957
+ onCancel: function onCancel() {
6958
+ return _this4.eventEmitter.emit(WALLET_EVENT.CHECKOUT_CLOSE);
6959
+ },
6917
6960
  onError: function onError(err) {
6918
6961
  // Error handling so that paypal does not throw an uncaught error
6919
6962
  // We're already handling errors and notifying Merchants at "wallet-buttons.ts"
@@ -7230,11 +7273,20 @@
7230
7273
  _this.gatewayName = gatewayName;
7231
7274
  _this.eventEmitter = eventEmitter;
7232
7275
  _this.latestShippingData = {};
7276
+ _this.onCancelPayment = function (event) {
7277
+ return _this.eventEmitter.emit(WALLET_EVENT.CHECKOUT_CLOSE);
7278
+ };
7233
7279
  _this.onValidateMerchant = function (event) {
7234
- _this.getMerchantSession().then(function (merchantSession) {
7235
- _this.paymentSession.completeMerchantValidation(merchantSession);
7280
+ _this.handleMerchantOnButtonClickEvent().then(function () {
7281
+ _this.getMerchantSession().then(function (merchantSession) {
7282
+ _this.paymentSession.completeMerchantValidation(merchantSession);
7283
+ })["catch"](function (err) {
7284
+ console.error("Error fetching merchant session", err);
7285
+ _this.paymentSession.abort();
7286
+ });
7236
7287
  })["catch"](function (err) {
7237
- return console.error("Error fetching merchant session", err);
7288
+ console.error('Error while processing merchant callback', err);
7289
+ _this.paymentSession.abort();
7238
7290
  });
7239
7291
  };
7240
7292
  _this.onPaymentAuthorized = function (event) {
@@ -7485,6 +7537,7 @@
7485
7537
  this.paymentSession = new ApplePaySession(3, this.createRequest());
7486
7538
  this.paymentSession.onvalidatemerchant = this.onValidateMerchant;
7487
7539
  this.paymentSession.onpaymentauthorized = this.onPaymentAuthorized;
7540
+ this.paymentSession.oncancel = this.onCancelPayment;
7488
7541
  this.paymentSession.onshippingcontactselected = this.onShippingContactSelected;
7489
7542
  this.paymentSession.onshippingmethodselected = this.onShippingMethodSelected;
7490
7543
  this.paymentSession.begin();
@@ -7544,6 +7597,28 @@
7544
7597
  });
7545
7598
  });
7546
7599
  }
7600
+ }, {
7601
+ key: "handleMerchantOnButtonClickEvent",
7602
+ value: function handleMerchantOnButtonClickEvent() {
7603
+ var _this6 = this;
7604
+ return new Promise(function (resolve, reject) {
7605
+ var merchantResult;
7606
+ _this6.eventEmitter.emit(WALLET_EVENT.BUTTON_CLICK, {
7607
+ attachResult: function attachResult(value) {
7608
+ merchantResult = value;
7609
+ }
7610
+ });
7611
+ if (merchantResult instanceof Promise) {
7612
+ merchantResult.then(resolve)["catch"](reject);
7613
+ } else {
7614
+ if (merchantResult === false) {
7615
+ reject();
7616
+ } else {
7617
+ resolve();
7618
+ }
7619
+ }
7620
+ });
7621
+ }
7547
7622
  }, {
7548
7623
  key: "createButtonStyle",
7549
7624
  value: function createButtonStyle() {
@@ -7563,6 +7638,7 @@
7563
7638
  _this = _super.call(this, publicKey, meta);
7564
7639
  _this.gatewayName = gatewayName;
7565
7640
  _this.eventEmitter = eventEmitter;
7641
+ _this.processingButtonClick = false;
7566
7642
  _this.parseUpdateData = function (data) {
7567
7643
  var _a, _b, _c, _d, _e, _f;
7568
7644
  var shippingOption = (_b = (_a = _this.meta) === null || _a === void 0 ? void 0 : _a.shipping_options) === null || _b === void 0 ? void 0 : _b.find(function (o) {
@@ -7740,29 +7816,64 @@
7740
7816
  var _a, _b, _c;
7741
7817
  container.getElement().appendChild(this.paymentsClient.createButton({
7742
7818
  onClick: function onClick() {
7743
- return _this3.loadPaymentData();
7819
+ return _this3.onGooglePayButtonClicked();
7744
7820
  },
7745
7821
  buttonType: ((_a = this.getMetaStyles()) === null || _a === void 0 ? void 0 : _a.button_type) || 'pay',
7746
7822
  buttonSizeMode: ((_b = this.getMetaStyles()) === null || _b === void 0 ? void 0 : _b.button_size_mode) || "fill",
7747
7823
  buttonColor: ((_c = this.getMetaStyles()) === null || _c === void 0 ? void 0 : _c.button_color) || "default"
7748
7824
  }));
7749
7825
  }
7826
+ }, {
7827
+ key: "onGooglePayButtonClicked",
7828
+ value: function onGooglePayButtonClicked() {
7829
+ var _this4 = this;
7830
+ if (this.processingButtonClick) return;
7831
+ this.processingButtonClick = true;
7832
+ this.handleMerchantOnButtonClickEvent().then(function () {
7833
+ _this4.loadPaymentData()["finally"](function () {
7834
+ _this4.processingButtonClick = false;
7835
+ });
7836
+ })["catch"](function (err) {
7837
+ _this4.processingButtonClick = false;
7838
+ console.error('Error while processing merchant callback', err);
7839
+ });
7840
+ }
7841
+ }, {
7842
+ key: "handleMerchantOnButtonClickEvent",
7843
+ value: function handleMerchantOnButtonClickEvent() {
7844
+ var _this5 = this;
7845
+ return new Promise(function (resolve, reject) {
7846
+ var merchantResult;
7847
+ _this5.eventEmitter.emit(WALLET_EVENT.BUTTON_CLICK, {
7848
+ attachResult: function attachResult(value) {
7849
+ merchantResult = value;
7850
+ }
7851
+ });
7852
+ if (merchantResult instanceof Promise) {
7853
+ merchantResult.then(resolve)["catch"](reject);
7854
+ } else {
7855
+ if (merchantResult === false) {
7856
+ reject();
7857
+ } else {
7858
+ resolve();
7859
+ }
7860
+ }
7861
+ });
7862
+ }
7750
7863
  }, {
7751
7864
  key: "loadPaymentData",
7752
7865
  value: function loadPaymentData() {
7753
- this.paymentsClient.loadPaymentData(this.createPaymentDataRequest())
7754
- // .then((paymentData) => {
7755
- // // if using gateway tokenization, pass this token without modification
7756
- // // this.paymentToken = paymentData.paymentMethodData.tokenizationData.token;
7757
- // })
7758
- ["catch"](function () {
7759
- console.error('Error while loading payment data');
7866
+ var _this6 = this;
7867
+ return this.paymentsClient.loadPaymentData(this.createPaymentDataRequest())["catch"](function (err) {
7868
+ _this6.eventEmitter.emit(WALLET_EVENT.CHECKOUT_CLOSE);
7869
+ console.error('Error while loading payment data', err);
7870
+ throw err;
7760
7871
  });
7761
7872
  }
7762
7873
  }, {
7763
7874
  key: "onPaymentAuthorized",
7764
7875
  value: function onPaymentAuthorized(paymentData) {
7765
- var _this4 = this;
7876
+ var _this7 = this;
7766
7877
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
7767
7878
  var billingAddressLine1 = (_c = (_b = (_a = paymentData.paymentMethodData) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.billingAddress) === null || _c === void 0 ? void 0 : _c.address1;
7768
7879
  var billingAddressLine2 = (_f = (_e = (_d = paymentData.paymentMethodData) === null || _d === void 0 ? void 0 : _d.info) === null || _e === void 0 ? void 0 : _e.billingAddress) === null || _f === void 0 ? void 0 : _f.address2;
@@ -7778,7 +7889,7 @@
7778
7889
  var shippingContactPhone = (_q = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _q === void 0 ? void 0 : _q.phoneNumber;
7779
7890
  return new Promise(function (resolve) {
7780
7891
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
7781
- return _this4.eventEmitter.emit(WALLET_EVENT.PAYMENT_METHOD_SELECTED, {
7892
+ return _this7.eventEmitter.emit(WALLET_EVENT.PAYMENT_METHOD_SELECTED, {
7782
7893
  data: _extends({
7783
7894
  customer: {
7784
7895
  payment_source: _extends(_extends(_extends(_extends({
@@ -7800,11 +7911,11 @@
7800
7911
  ref_token: paymentData.paymentMethodData.tokenizationData.token
7801
7912
  })
7802
7913
  }
7803
- }, _this4.isShippingRequired() && {
7914
+ }, _this7.isShippingRequired() && {
7804
7915
  shipping: _extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends({}, shippingOptionMethod && {
7805
7916
  method: shippingOptionMethod
7806
- }), _this4.hasShippingOptions() && {
7807
- options: _this4.meta.shipping_options
7917
+ }), _this7.hasShippingOptions() && {
7918
+ options: _this7.meta.shipping_options
7808
7919
  }), shippingAddressLine1 && {
7809
7920
  address_line1: shippingAddressLine1
7810
7921
  }), shippingAddressLine2 && {
@@ -7848,12 +7959,12 @@
7848
7959
  }, {
7849
7960
  key: "onPaymentDataChanged",
7850
7961
  value: function onPaymentDataChanged(intermediatePaymentData) {
7851
- var _this5 = this;
7962
+ var _this8 = this;
7852
7963
  if (!this.isShippingRequired()) return;
7853
7964
  var parsedUpdateData = this.parseUpdateData(intermediatePaymentData);
7854
7965
  var returnPromise = new Promise(function (res, rej) {
7855
- _this5.latestShippingChangePromiseResolve = res;
7856
- _this5.latestShippingChangePromiseReject = rej;
7966
+ _this8.latestShippingChangePromiseResolve = res;
7967
+ _this8.latestShippingChangePromiseReject = rej;
7857
7968
  });
7858
7969
  this.eventEmitter.emit(WALLET_EVENT.UPDATE, parsedUpdateData);
7859
7970
  return returnPromise;
@@ -8536,6 +8647,16 @@
8536
8647
  return Checkout;
8537
8648
  }();
8538
8649
 
8650
+ function getFlypayV2Button() {
8651
+ return "\n <div id=\"loading-overlay\"></div>\n <div class=\"flypay-v2-checkout-btn__wrapper\">\n <svg viewBox=\"0 0 384 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g clip-path=\"url(#clip0_34013_168361)\">\n <rect width=\"384\" height=\"48\" rx=\"24\" fill=\"#212121\"/>\n <path d=\"M134.985 24.6006H132.387V29H129.847V16.7646H135.176C136.404 16.7646 137.384 17.0801 138.114 17.7109C138.845 18.3418 139.21 19.3185 139.21 20.6411C139.21 22.0854 138.845 23.1064 138.114 23.7041C137.384 24.3018 136.341 24.6006 134.985 24.6006ZM136.18 22.0522C136.512 21.759 136.678 21.2941 136.678 20.6577C136.678 20.0213 136.509 19.5675 136.172 19.2964C135.84 19.0252 135.372 18.8896 134.769 18.8896H132.387V22.4922H134.769C135.372 22.4922 135.843 22.3455 136.18 22.0522ZM141.277 20.9316C141.902 20.1348 142.976 19.7363 144.498 19.7363C145.488 19.7363 146.368 19.9328 147.137 20.3257C147.906 20.7186 148.291 21.4601 148.291 22.5503V26.7007C148.291 26.9884 148.297 27.3371 148.308 27.7466C148.324 28.0565 148.371 28.2668 148.449 28.3774C148.526 28.4881 148.642 28.5794 148.797 28.6514V29H146.224C146.152 28.8174 146.102 28.6458 146.075 28.4854C146.047 28.3249 146.025 28.1423 146.008 27.9375C145.682 28.2917 145.306 28.5933 144.879 28.8423C144.37 29.1356 143.795 29.2822 143.153 29.2822C142.334 29.2822 141.656 29.0498 141.119 28.585C140.588 28.1146 140.322 27.4505 140.322 26.5928C140.322 25.4805 140.751 24.6753 141.609 24.1772C142.079 23.9061 142.771 23.7124 143.684 23.5962L144.489 23.4966C144.926 23.4412 145.239 23.3721 145.427 23.2891C145.765 23.1452 145.934 22.9211 145.934 22.6167C145.934 22.2459 145.804 21.9914 145.543 21.853C145.289 21.7091 144.913 21.6372 144.415 21.6372C143.856 21.6372 143.46 21.7756 143.228 22.0522C143.062 22.257 142.951 22.5337 142.896 22.8823H140.613C140.663 22.091 140.884 21.4408 141.277 20.9316ZM143.037 27.29C143.258 27.4727 143.529 27.564 143.85 27.564C144.359 27.564 144.827 27.4146 145.253 27.1157C145.685 26.8169 145.909 26.2718 145.925 25.4805V24.6006C145.776 24.6947 145.624 24.7721 145.469 24.833C145.319 24.8883 145.112 24.9409 144.846 24.9907L144.315 25.0903C143.817 25.1789 143.46 25.2868 143.244 25.4141C142.879 25.6299 142.696 25.9647 142.696 26.4185C142.696 26.8224 142.81 27.113 143.037 27.29ZM154.077 26.626L155.944 19.9521H158.459L155.355 28.8506C154.757 30.5661 154.284 31.6286 153.936 32.0381C153.587 32.4531 152.89 32.6606 151.844 32.6606C151.633 32.6606 151.465 32.6579 151.337 32.6523C151.21 32.6523 151.019 32.644 150.765 32.6274V30.7349L151.063 30.7515C151.296 30.7625 151.517 30.7542 151.728 30.7266C151.938 30.6989 152.115 30.6353 152.259 30.5356C152.397 30.4416 152.524 30.2451 152.641 29.9463C152.762 29.6475 152.812 29.4648 152.79 29.3984L149.47 19.9521H152.101L154.077 26.626ZM171.458 29L170.039 22.4092L168.603 29H166.146L163.606 19.9521H166.146L167.557 26.4434L168.86 19.9521H171.259L172.637 26.4683L174.048 19.9521H176.514L173.891 29H171.458ZM180.257 19.9521V29H177.858V19.9521H180.257ZM180.257 16.6899V18.873H177.858V16.6899H180.257ZM186.699 27.3149V29.083L185.578 29.1245C184.46 29.1632 183.697 28.9696 183.287 28.5435C183.021 28.2723 182.889 27.8545 182.889 27.29V21.7202H181.627V20.0352H182.889V17.5117H185.229V20.0352H186.699V21.7202H185.229V26.5015C185.229 26.8722 185.277 27.1047 185.371 27.1987C185.465 27.2873 185.752 27.3315 186.234 27.3315C186.306 27.3315 186.381 27.3315 186.458 27.3315C186.541 27.326 186.621 27.3205 186.699 27.3149ZM196.394 23.6875V29H193.979V23.4966C193.979 23.0096 193.896 22.6167 193.729 22.3179C193.514 21.8973 193.104 21.687 192.501 21.687C191.876 21.687 191.4 21.8973 191.073 22.3179C190.752 22.7329 190.592 23.3278 190.592 24.1025V29H188.234V16.8062H190.592V21.1309C190.935 20.6051 191.331 20.2399 191.779 20.0352C192.233 19.8249 192.708 19.7197 193.207 19.7197C193.765 19.7197 194.272 19.8166 194.726 20.0103C195.185 20.2039 195.561 20.5 195.854 20.8984C196.104 21.236 196.256 21.5846 196.311 21.9443C196.366 22.2985 196.394 22.8796 196.394 23.6875Z\" fill=\"white\"/>\n <path d=\"M231.702 14.0094C231.71 13.9026 231.673 13.7973 231.601 13.7164C231.529 13.6354 231.428 13.5852 231.318 13.5766C231.296 13.5734 231.272 13.5734 231.25 13.5766H217.787C217.679 13.5725 217.573 13.6092 217.492 13.6791C217.411 13.749 217.362 13.8467 217.353 13.9517C217.344 14.0567 217.378 14.1609 217.446 14.2424C217.515 14.324 217.613 14.3765 217.72 14.3891C217.743 14.3924 217.767 14.3924 217.79 14.3891H231.256C231.367 14.396 231.476 14.3599 231.56 14.2888C231.643 14.2177 231.694 14.1172 231.702 14.0094V14.0094Z\" fill=\"white\"/>\n <path d=\"M226.501 35.2805C226.497 35.3338 226.503 35.3874 226.52 35.4382C226.537 35.4891 226.564 35.5362 226.6 35.5769C226.635 35.6176 226.679 35.6511 226.728 35.6754C226.776 35.6997 226.83 35.7144 226.884 35.7186H240.409C240.52 35.7272 240.629 35.6927 240.714 35.6227C240.798 35.5528 240.85 35.453 240.859 35.3454C240.868 35.2378 240.832 35.1312 240.761 35.049C240.689 34.9668 240.586 34.9158 240.476 34.9072H226.945C226.836 34.8998 226.728 34.9348 226.644 35.0047C226.561 35.0746 226.51 35.1738 226.501 35.2805Z\" fill=\"white\"/>\n <path d=\"M248.245 30.3548L251.02 19.1664C251.211 18.3788 251.052 17.6345 250.576 17.0708C250.109 16.5299 249.402 16.2227 248.578 16.2227H215.233C215.126 16.228 215.025 16.2733 214.951 16.3491C214.877 16.4249 214.836 16.5254 214.836 16.63C214.836 16.7345 214.877 16.8351 214.951 16.9108C215.025 16.9866 215.126 17.0319 215.233 17.0373H248.579C249.134 17.0373 249.597 17.2309 249.894 17.5782C250.203 17.9417 250.304 18.4437 250.172 18.9846L247.397 30.1731C247.112 31.3447 245.867 32.2989 244.622 32.2989H223.787C223.73 32.2961 223.674 32.3045 223.62 32.3237C223.567 32.3428 223.519 32.3724 223.477 32.4105C223.436 32.4486 223.403 32.4945 223.381 32.5453C223.359 32.5961 223.347 32.6509 223.347 32.7062C223.347 32.7616 223.359 32.8163 223.381 32.8671C223.403 32.918 223.436 32.9638 223.477 33.0019C223.519 33.0401 223.567 33.0696 223.62 33.0888C223.674 33.108 223.73 33.1164 223.787 33.1135H244.619C246.249 33.1157 247.876 31.8759 248.245 30.3548Z\" fill=\"white\"/>\n <path d=\"M213.705 16.2227L211.328 16.7625V28.9657H213.715V16.2227H213.705Z\" fill=\"white\"/>\n <path d=\"M218.82 29.0569C219.368 29.0431 219.909 28.9313 220.416 28.7269V30.2112C220.416 31.61 219.6 31.9908 218.89 31.9908H218.3V34.3406H218.896C221.322 34.3406 222.826 32.7579 222.826 30.2112V20.3945L220.416 20.9355V24.9762C220.416 26.0872 219.879 26.7071 218.823 26.7071C217.768 26.7071 217.231 26.0894 217.231 24.9762V20.3978L214.82 20.9387V24.9794C214.817 27.3822 216.427 29.0569 218.82 29.0569Z\" fill=\"white\"/>\n <path d=\"M206.282 22.6056H209.279V20.4765H206.282V20.4667H206.264C206.272 19.2951 207.062 18.3409 208.655 18.3409H210.542V16.2227H208.655C205.366 16.2227 203.906 18.1202 203.898 20.4635V28.9657H206.282V22.6056Z\" fill=\"white\"/>\n <path d=\"M226.233 28.9713L226.93 26.3749H228.558C229.111 26.3815 229.663 26.3086 230.195 26.1585C230.671 26.0264 231.117 25.806 231.508 25.5094C231.877 25.2255 232.178 24.8662 232.39 24.4568C232.613 24.0151 232.725 23.5276 232.715 23.0352C232.715 22.3017 232.493 21.7154 232.049 21.2761C231.742 20.9673 231.36 20.7386 230.939 20.6108C230.43 20.4649 229.901 20.3963 229.371 20.4074H226.652L224.352 28.9605H226.23L226.233 28.9713ZM229.302 22.1124C229.541 22.1057 229.778 22.1367 230.006 22.2044C230.186 22.2621 230.348 22.3612 230.48 22.4932C230.574 22.587 230.647 22.6982 230.695 22.8201C230.744 22.942 230.767 23.0722 230.762 23.2029C230.773 23.4234 230.726 23.6428 230.626 23.8407C230.525 24.0385 230.375 24.2081 230.188 24.3334C229.804 24.5985 229.3 24.7305 228.669 24.7305H227.386L228.084 22.1156H229.305L229.302 22.1124Z\" fill=\"white\"/>\n <path d=\"M230.516 28.9656H232.546L233.843 27.0475H237.462L237.731 28.9656H239.665L238.306 20.3477H236.498L230.516 28.9656ZM236.85 22.5752L237.239 25.4031H234.965L236.85 22.5752Z\" fill=\"white\"/>\n <path d=\"M241.671 25.5911L240.765 28.9632H242.651L243.518 25.761L248.204 20.4102H248.201H245.929L242.992 23.9543L241.989 20.4102H239.898L241.671 25.5911Z\" fill=\"white\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_34013_168361\">\n <rect width=\"384\" height=\"48\" rx=\"24\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n </div>\n ";
8652
+ }
8653
+ function getDisabledFlypayV2Button() {
8654
+ return "\n <div id=\"loading-overlay\"></div>\n <div class=\"flypay-v2-checkout-btn-disabled\">\n <svg viewBox=\"0 0 384 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g clip-path=\"url(#clip0_34032_180021)\">\n <rect x=\"0.5\" y=\"0.5\" width=\"383\" height=\"47\" rx=\"23.5\" stroke=\"#212121\"/>\n <path d=\"M134.985 24.6006H132.387V29H129.847V16.7646H135.176C136.404 16.7646 137.384 17.0801 138.114 17.7109C138.845 18.3418 139.21 19.3185 139.21 20.6411C139.21 22.0854 138.845 23.1064 138.114 23.7041C137.384 24.3018 136.341 24.6006 134.985 24.6006ZM136.18 22.0522C136.512 21.759 136.678 21.2941 136.678 20.6577C136.678 20.0213 136.509 19.5675 136.172 19.2964C135.84 19.0252 135.372 18.8896 134.769 18.8896H132.387V22.4922H134.769C135.372 22.4922 135.843 22.3455 136.18 22.0522ZM141.277 20.9316C141.902 20.1348 142.976 19.7363 144.498 19.7363C145.488 19.7363 146.368 19.9328 147.137 20.3257C147.906 20.7186 148.291 21.4601 148.291 22.5503V26.7007C148.291 26.9884 148.297 27.3371 148.308 27.7466C148.324 28.0565 148.371 28.2668 148.449 28.3774C148.526 28.4881 148.642 28.5794 148.797 28.6514V29H146.224C146.152 28.8174 146.102 28.6458 146.075 28.4854C146.047 28.3249 146.025 28.1423 146.008 27.9375C145.682 28.2917 145.306 28.5933 144.879 28.8423C144.37 29.1356 143.795 29.2822 143.153 29.2822C142.334 29.2822 141.656 29.0498 141.119 28.585C140.588 28.1146 140.322 27.4505 140.322 26.5928C140.322 25.4805 140.751 24.6753 141.609 24.1772C142.079 23.9061 142.771 23.7124 143.684 23.5962L144.489 23.4966C144.926 23.4412 145.239 23.3721 145.427 23.2891C145.765 23.1452 145.934 22.9211 145.934 22.6167C145.934 22.2459 145.804 21.9914 145.543 21.853C145.289 21.7091 144.913 21.6372 144.415 21.6372C143.856 21.6372 143.46 21.7756 143.228 22.0522C143.062 22.257 142.951 22.5337 142.896 22.8823H140.613C140.663 22.091 140.884 21.4408 141.277 20.9316ZM143.037 27.29C143.258 27.4727 143.529 27.564 143.85 27.564C144.359 27.564 144.827 27.4146 145.253 27.1157C145.685 26.8169 145.909 26.2718 145.925 25.4805V24.6006C145.776 24.6947 145.624 24.7721 145.469 24.833C145.319 24.8883 145.112 24.9409 144.846 24.9907L144.315 25.0903C143.817 25.1789 143.46 25.2868 143.244 25.4141C142.879 25.6299 142.696 25.9647 142.696 26.4185C142.696 26.8224 142.81 27.113 143.037 27.29ZM154.077 26.626L155.944 19.9521H158.459L155.355 28.8506C154.757 30.5661 154.284 31.6286 153.936 32.0381C153.587 32.4531 152.89 32.6606 151.844 32.6606C151.633 32.6606 151.465 32.6579 151.337 32.6523C151.21 32.6523 151.019 32.644 150.765 32.6274V30.7349L151.063 30.7515C151.296 30.7625 151.517 30.7542 151.728 30.7266C151.938 30.6989 152.115 30.6353 152.259 30.5356C152.397 30.4416 152.524 30.2451 152.641 29.9463C152.762 29.6475 152.812 29.4648 152.79 29.3984L149.47 19.9521H152.101L154.077 26.626ZM171.458 29L170.039 22.4092L168.603 29H166.146L163.606 19.9521H166.146L167.557 26.4434L168.86 19.9521H171.259L172.637 26.4683L174.048 19.9521H176.514L173.891 29H171.458ZM180.257 19.9521V29H177.858V19.9521H180.257ZM180.257 16.6899V18.873H177.858V16.6899H180.257ZM186.699 27.3149V29.083L185.578 29.1245C184.46 29.1632 183.697 28.9696 183.287 28.5435C183.021 28.2723 182.889 27.8545 182.889 27.29V21.7202H181.627V20.0352H182.889V17.5117H185.229V20.0352H186.699V21.7202H185.229V26.5015C185.229 26.8722 185.277 27.1047 185.371 27.1987C185.465 27.2873 185.752 27.3315 186.234 27.3315C186.306 27.3315 186.381 27.3315 186.458 27.3315C186.541 27.326 186.621 27.3205 186.699 27.3149ZM196.394 23.6875V29H193.979V23.4966C193.979 23.0096 193.896 22.6167 193.729 22.3179C193.514 21.8973 193.104 21.687 192.501 21.687C191.876 21.687 191.4 21.8973 191.073 22.3179C190.752 22.7329 190.592 23.3278 190.592 24.1025V29H188.234V16.8062H190.592V21.1309C190.935 20.6051 191.331 20.2399 191.779 20.0352C192.233 19.8249 192.708 19.7197 193.207 19.7197C193.765 19.7197 194.272 19.8166 194.726 20.0103C195.185 20.2039 195.561 20.5 195.854 20.8984C196.104 21.236 196.256 21.5846 196.311 21.9443C196.366 22.2985 196.394 22.8796 196.394 23.6875Z\" fill=\"#212121\"/>\n <path d=\"M231.702 14.0094C231.71 13.9026 231.673 13.7973 231.601 13.7164C231.529 13.6354 231.428 13.5852 231.318 13.5766C231.296 13.5734 231.272 13.5734 231.25 13.5766H217.787C217.679 13.5725 217.573 13.6092 217.492 13.6791C217.411 13.749 217.362 13.8467 217.353 13.9517C217.344 14.0567 217.378 14.1609 217.446 14.2424C217.515 14.324 217.613 14.3765 217.72 14.3891C217.743 14.3924 217.767 14.3924 217.79 14.3891H231.256C231.367 14.396 231.476 14.3599 231.56 14.2888C231.643 14.2177 231.694 14.1172 231.702 14.0094V14.0094Z\" fill=\"#212121\"/>\n <path d=\"M226.501 35.2805C226.497 35.3338 226.503 35.3874 226.52 35.4382C226.537 35.4891 226.564 35.5362 226.6 35.5769C226.635 35.6176 226.679 35.6511 226.728 35.6754C226.776 35.6997 226.83 35.7144 226.884 35.7186H240.409C240.52 35.7272 240.629 35.6927 240.714 35.6227C240.798 35.5528 240.85 35.453 240.859 35.3454C240.868 35.2378 240.832 35.1312 240.761 35.049C240.689 34.9668 240.586 34.9158 240.476 34.9072H226.945C226.836 34.8998 226.728 34.9348 226.644 35.0047C226.561 35.0746 226.51 35.1738 226.501 35.2805Z\" fill=\"#212121\"/>\n <path d=\"M248.245 30.3548L251.02 19.1664C251.211 18.3788 251.052 17.6345 250.576 17.0708C250.109 16.5299 249.402 16.2227 248.578 16.2227H215.233C215.126 16.228 215.025 16.2733 214.951 16.3491C214.877 16.4249 214.836 16.5254 214.836 16.63C214.836 16.7345 214.877 16.8351 214.951 16.9108C215.025 16.9866 215.126 17.0319 215.233 17.0373H248.579C249.134 17.0373 249.597 17.2309 249.894 17.5782C250.203 17.9417 250.304 18.4437 250.172 18.9846L247.397 30.1731C247.112 31.3447 245.867 32.2989 244.622 32.2989H223.787C223.73 32.2961 223.674 32.3045 223.62 32.3237C223.567 32.3428 223.519 32.3724 223.477 32.4105C223.436 32.4486 223.403 32.4945 223.381 32.5453C223.359 32.5961 223.347 32.6509 223.347 32.7062C223.347 32.7616 223.359 32.8163 223.381 32.8671C223.403 32.918 223.436 32.9638 223.477 33.0019C223.519 33.0401 223.567 33.0696 223.62 33.0888C223.674 33.108 223.73 33.1164 223.787 33.1135H244.619C246.249 33.1157 247.876 31.8759 248.245 30.3548Z\" fill=\"#212121\"/>\n <path d=\"M213.705 16.2227L211.328 16.7625V28.9657H213.715V16.2227H213.705Z\" fill=\"#212121\"/>\n <path d=\"M218.82 29.0569C219.368 29.0431 219.909 28.9313 220.416 28.7269V30.2112C220.416 31.61 219.6 31.9908 218.89 31.9908H218.3V34.3406H218.896C221.322 34.3406 222.826 32.7579 222.826 30.2112V20.3945L220.416 20.9355V24.9762C220.416 26.0872 219.879 26.7071 218.823 26.7071C217.768 26.7071 217.231 26.0894 217.231 24.9762V20.3978L214.82 20.9387V24.9794C214.817 27.3822 216.427 29.0569 218.82 29.0569Z\" fill=\"#212121\"/>\n <path d=\"M206.282 22.6056H209.279V20.4765H206.282V20.4667H206.264C206.272 19.2951 207.062 18.3409 208.655 18.3409H210.542V16.2227H208.655C205.366 16.2227 203.906 18.1202 203.898 20.4635V28.9657H206.282V22.6056Z\" fill=\"#212121\"/>\n <path d=\"M226.233 28.9713L226.93 26.3749H228.558C229.111 26.3815 229.663 26.3086 230.195 26.1585C230.671 26.0264 231.117 25.806 231.508 25.5094C231.877 25.2255 232.178 24.8662 232.39 24.4568C232.613 24.0151 232.725 23.5276 232.715 23.0352C232.715 22.3017 232.493 21.7154 232.049 21.2761C231.742 20.9673 231.36 20.7386 230.939 20.6108C230.43 20.4649 229.901 20.3963 229.371 20.4074H226.652L224.352 28.9605H226.23L226.233 28.9713ZM229.302 22.1124C229.541 22.1057 229.778 22.1367 230.006 22.2044C230.186 22.2621 230.348 22.3612 230.48 22.4932C230.574 22.587 230.647 22.6982 230.695 22.8201C230.744 22.942 230.767 23.0722 230.762 23.2029C230.773 23.4234 230.726 23.6428 230.626 23.8407C230.525 24.0385 230.375 24.2081 230.188 24.3334C229.804 24.5985 229.3 24.7305 228.669 24.7305H227.386L228.084 22.1156H229.305L229.302 22.1124Z\" fill=\"#212121\"/>\n <path d=\"M230.516 28.9656H232.546L233.843 27.0475H237.462L237.731 28.9656H239.665L238.306 20.3477H236.498L230.516 28.9656ZM236.85 22.5752L237.239 25.4031H234.965L236.85 22.5752Z\" fill=\"#212121\"/>\n <path d=\"M241.671 25.5911L240.765 28.9632H242.651L243.518 25.761L248.204 20.4102H248.201H245.929L242.992 23.9543L241.989 20.4102H239.898L241.671 25.5911Z\" fill=\"#212121\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_34032_180021\">\n <rect width=\"384\" height=\"48\" rx=\"24\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n </div>\n ";
8655
+ }
8656
+ function createFlypayV2ButtonStyle(containerId) {
8657
+ return "\n ".concat(containerId, " {\n position: relative;\n }\n\n #loading-overlay {\n position: absolute;\n height: 100%;\n width: 100%;\n background: rgba(255, 255, 255, 0.7);\n display: none;\n justify-content: center;\n align-items: center;\n cursor: not-allowed; /* Make it look not clickable */\n }\n\n #loading-overlay::after {\n content: \"\";\n height: 60%;\n aspect-ratio: 1 / 1;\n display: inline-block;\n border: 4px solid #ccc;\n border-top-color: #333;\n border-radius: 50%;\n\n /* Vendor prefixes for animation property */\n -webkit-animation: spin 1s infinite linear;\n -moz-animation: spin 1s infinite linear;\n -o-animation: spin 1s infinite linear;\n animation: spin 1s infinite linear;\n }\n\n @-webkit-keyframes spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n\n @-moz-keyframes spin {\n 0% {\n -moz-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -moz-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n\n @-o-keyframes spin {\n 0% {\n -o-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -o-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n\n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n\n .flypay-v2-checkout-btn {\n width: 100%;\n height: fit-content;\n border: none; /* Remove borders */\n background: transparent; /* Make the button background transparent */\n cursor: pointer; /* Make it look clickable */\n outline: none; /* Remove focus outline */\n padding: 0; /* Remove any default padding */\n }\n\n .flypay-v2-checkout-btn-disabled {\n width: 100%;\n height: fit-content;\n border: none; /* Remove borders */\n background: transparent; /* Make the button background transparent */\n cursor: not-allowed; /* Make it look not clickable */\n outline: none; /* Remove focus outline */\n padding: 0; /* Remove any default padding */\n }\n ");
8658
+ }
8659
+
8539
8660
  var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
8540
8661
  function adopt(value) {
8541
8662
  return value instanceof P ? value : new P(function (resolve) {
@@ -8570,47 +8691,79 @@
8570
8691
  var _this;
8571
8692
  _classCallCheck(this, FlypayV2WalletService);
8572
8693
  _this = _super.call(this, publicKey, meta);
8694
+ _this.processingButtonClick = false;
8573
8695
  _this.onFlypayV2ButtonClick = function () {
8574
- return __awaiter(_assertThisInitialized(_this), void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8575
- var loadingOverlay, button;
8576
- return _regeneratorRuntime().wrap(function _callee$(_context) {
8577
- while (1) switch (_context.prev = _context.next) {
8696
+ return __awaiter(_assertThisInitialized(_this), void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
8697
+ var _this2 = this;
8698
+ var setLoadingOverlayDisplay;
8699
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
8700
+ while (1) switch (_context2.prev = _context2.next) {
8578
8701
  case 0:
8579
- loadingOverlay = document.getElementById('loading-overlay');
8580
- button = document.getElementById('flypay-v2-button');
8581
- if (button) button.disabled = true;
8582
- _context.prev = 3;
8583
- if (this.orderId) {
8584
- _context.next = 9;
8702
+ setLoadingOverlayDisplay = function setLoadingOverlayDisplay(displayStyle) {
8703
+ var loadingOverlay = document.getElementById('loading-overlay');
8704
+ if (loadingOverlay) loadingOverlay.style.display = displayStyle;
8705
+ };
8706
+ this.disable();
8707
+ setLoadingOverlayDisplay('flex');
8708
+ if (!this.processingButtonClick) {
8709
+ _context2.next = 5;
8585
8710
  break;
8586
8711
  }
8587
- if (loadingOverlay) loadingOverlay.style.display = 'flex';
8588
- _context.next = 8;
8589
- return this.getOrderId();
8590
- case 8:
8591
- this.orderId = _context.sent;
8592
- case 9:
8593
- if (loadingOverlay) loadingOverlay.style.display = 'none';
8594
- if (this.orderId) {
8595
- this.flypayV2Checkout(this.orderId);
8596
- } else {
8597
- this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE);
8598
- }
8599
- _context.next = 18;
8600
- break;
8601
- case 13:
8602
- _context.prev = 13;
8603
- _context.t0 = _context["catch"](3);
8604
- if (loadingOverlay) loadingOverlay.style.display = 'none';
8605
- if (button) button.disabled = false;
8606
- this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, {
8607
- err: _context.t0
8712
+ return _context2.abrupt("return");
8713
+ case 5:
8714
+ this.processingButtonClick = true;
8715
+ this.handleMerchantOnButtonClickEvent().then(function () {
8716
+ return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8717
+ var _a, _b;
8718
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
8719
+ while (1) switch (_context.prev = _context.next) {
8720
+ case 0:
8721
+ _context.prev = 0;
8722
+ this.processingButtonClick = false;
8723
+ if (this.orderId) {
8724
+ _context.next = 6;
8725
+ break;
8726
+ }
8727
+ _context.next = 5;
8728
+ return this.getOrderId();
8729
+ case 5:
8730
+ this.orderId = _context.sent;
8731
+ case 6:
8732
+ setLoadingOverlayDisplay('none');
8733
+ this.background = this.initBackground();
8734
+ if (this.orderId) {
8735
+ (_a = this.background) === null || _a === void 0 ? void 0 : _a.initControl();
8736
+ this.flypayV2Checkout(this.orderId);
8737
+ } else {
8738
+ this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE);
8739
+ }
8740
+ _context.next = 17;
8741
+ break;
8742
+ case 11:
8743
+ _context.prev = 11;
8744
+ _context.t0 = _context["catch"](0);
8745
+ (_b = this.background) === null || _b === void 0 ? void 0 : _b.clear();
8746
+ setLoadingOverlayDisplay('none');
8747
+ this.enable();
8748
+ this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, {
8749
+ err: _context.t0
8750
+ });
8751
+ case 17:
8752
+ case "end":
8753
+ return _context.stop();
8754
+ }
8755
+ }, _callee, this, [[0, 11]]);
8756
+ }));
8757
+ })["catch"](function (err) {
8758
+ _this2.processingButtonClick = false;
8759
+ setLoadingOverlayDisplay('none');
8760
+ _this2.enable();
8608
8761
  });
8609
- case 18:
8762
+ case 7:
8610
8763
  case "end":
8611
- return _context.stop();
8764
+ return _context2.stop();
8612
8765
  }
8613
- }, _callee, this, [[3, 13]]);
8766
+ }, _callee2, this);
8614
8767
  }));
8615
8768
  };
8616
8769
  _this.accessToken = meta === null || meta === void 0 ? void 0 : meta.access_token;
@@ -8621,6 +8774,7 @@
8621
8774
  _createClass(FlypayV2WalletService, [{
8622
8775
  key: "load",
8623
8776
  value: function load(container) {
8777
+ this.containerId = container.getSelector();
8624
8778
  this.mount(container);
8625
8779
  }
8626
8780
  }, {
@@ -8629,37 +8783,73 @@
8629
8783
  this.link.setEnv(env);
8630
8784
  return _get(_getPrototypeOf(FlypayV2WalletService.prototype), "setEnv", this).call(this, env);
8631
8785
  }
8786
+ }, {
8787
+ key: "enable",
8788
+ value: function enable() {
8789
+ var button = document.getElementById('flypay-v2-button');
8790
+ if (button) {
8791
+ button.disabled = false;
8792
+ this.flypayV2Button.innerHTML = getFlypayV2Button();
8793
+ }
8794
+ }
8795
+ }, {
8796
+ key: "disable",
8797
+ value: function disable() {
8798
+ var button = document.getElementById('flypay-v2-button');
8799
+ if (button) {
8800
+ button.disabled = true;
8801
+ this.flypayV2Button.innerHTML = getDisabledFlypayV2Button();
8802
+ }
8803
+ }
8632
8804
  }, {
8633
8805
  key: "mount",
8634
8806
  value: function mount(container) {
8635
- var flypayV2Button = this.getButton();
8636
- flypayV2Button.onclick = this.onFlypayV2ButtonClick;
8637
- container.getElement().appendChild(flypayV2Button);
8807
+ this.flypayV2Button = this.getButton();
8808
+ this.flypayV2Button.onclick = this.onFlypayV2ButtonClick;
8809
+ container.getElement().appendChild(this.flypayV2Button);
8638
8810
  }
8639
8811
  }, {
8640
8812
  key: "getButton",
8641
8813
  value: function getButton() {
8642
8814
  var style = document.createElement('style');
8643
- style.innerHTML = this.createButtonStyle();
8815
+ style.innerHTML = createFlypayV2ButtonStyle(this.containerId);
8644
8816
  document.head.appendChild(style);
8645
- var flypayV2Button = document.createElement('button');
8646
- flypayV2Button.classList.add('flypay-v2-checkout-btn');
8647
- flypayV2Button.setAttribute('type', 'button');
8648
- flypayV2Button.setAttribute('id', 'flypay-v2-button');
8649
- flypayV2Button.innerHTML = "\n <div id=\"loading-overlay\"></div>\n <div class=\"flypay-v2-checkout-btn__wrapper\">\n <img src=\"".concat(this.link.getBaseUrl(), "/images/flypay-checkout.png\" alt=\"Flypay Checkout\" class=\"flypay-v2-image\">\n </div>\n ");
8650
- return flypayV2Button;
8817
+ this.flypayV2Button = document.createElement('button');
8818
+ this.flypayV2Button.classList.add('flypay-v2-checkout-btn');
8819
+ this.flypayV2Button.setAttribute('type', 'button');
8820
+ this.flypayV2Button.setAttribute('aria-label', 'Pay with flypay');
8821
+ this.flypayV2Button.setAttribute('id', 'flypay-v2-button');
8822
+ this.flypayV2Button.innerHTML = getFlypayV2Button();
8823
+ return this.flypayV2Button;
8651
8824
  }
8652
8825
  }, {
8653
- key: "createButtonStyle",
8654
- value: function createButtonStyle() {
8655
- return "\n\t\t\t#widget {\n\t\t\t\tposition: relative;\n\t\t\t}\n\n\t\t\t#loading-overlay {\n\t\t\t\tposition: absolute;\n\t\t\t\twidth: 268px;\n\t\t\t\theight: 74px;\n\t\t\t\tbackground: rgba(255, 255, 255, 0.7);\n\t\t\t\tdisplay: none;\n\t\t\t\tjustify-content: center;\n\t\t\t\talign-items: center;\n\t\t\t}\n\n\t\t\t#loading-overlay::after {\n\t\t\t\tcontent: \"\";\n\t\t\t\tdisplay: inline-block;\n\t\t\t\twidth: 40px;\n\t\t\t\theight: 40px;\n\t\t\t\tborder: 4px solid #ccc;\n\t\t\t\tborder-top-color: #333;\n\t\t\t\tborder-radius: 50%;\n\n\t\t\t\t/* Vendor prefixes for animation property */\n\t\t\t\t-webkit-animation: spin 1s infinite linear;\n\t\t\t\t-moz-animation: spin 1s infinite linear;\n\t\t\t\t-o-animation: spin 1s infinite linear;\n\t\t\t\tanimation: spin 1s infinite linear;\n\t\t\t}\n\n\t\t\t@-webkit-keyframes spin {\n\t\t\t\t0% {\n\t\t\t\t-webkit-transform: rotate(0deg);\n\t\t\t\ttransform: rotate(0deg);\n\t\t\t\t}\n\t\t\t\t100% {\n\t\t\t\t-webkit-transform: rotate(360deg);\n\t\t\t\ttransform: rotate(360deg);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@-moz-keyframes spin {\n\t\t\t\t0% {\n\t\t\t\t-moz-transform: rotate(0deg);\n\t\t\t\ttransform: rotate(0deg);\n\t\t\t\t}\n\t\t\t\t100% {\n\t\t\t\t-moz-transform: rotate(360deg);\n\t\t\t\ttransform: rotate(360deg);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@-o-keyframes spin {\n\t\t\t\t0% {\n\t\t\t\t-o-transform: rotate(0deg);\n\t\t\t\ttransform: rotate(0deg);\n\t\t\t\t}\n\t\t\t\t100% {\n\t\t\t\t-o-transform: rotate(360deg);\n\t\t\t\ttransform: rotate(360deg);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@keyframes spin {\n\t\t\t\t0% {\n\t\t\t\ttransform: rotate(0deg);\n\t\t\t\t}\n\t\t\t\t100% {\n\t\t\t\ttransform: rotate(360deg);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t.flypay-v2-checkout-btn {\n\t\t\t\tborder: none; /* Remove borders */\n\t\t\t\tbackground: transparent; /* Make the button background transparent */\n\t\t\t\tcursor: pointer; /* Make it look clickable */\n\t\t\t\toutline: none; /* Remove focus outline */\n\t\t\t\tpadding: 0; /* Remove any default padding */\n\t\t\t}\n\n\t\t\t.flypay-v2-image {\n\t\t\t\tdisplay: block; /* Display the image as block to remove any gaps */\n\t\t\t\tborder: none; /* Ensure the image doesn't have a border */\n\t\t\t\twidth: 100%; /* Make the image take full width of the container */\n\t\t\t}\n\t\t";
8826
+ key: "handleMerchantOnButtonClickEvent",
8827
+ value: function handleMerchantOnButtonClickEvent() {
8828
+ var _this3 = this;
8829
+ return new Promise(function (resolve, reject) {
8830
+ var merchantResult;
8831
+ _this3.eventEmitter.emit(WALLET_EVENT.BUTTON_CLICK, {
8832
+ attachResult: function attachResult(value) {
8833
+ merchantResult = value;
8834
+ }
8835
+ });
8836
+ if (merchantResult instanceof Promise) {
8837
+ merchantResult.then(resolve)["catch"](reject);
8838
+ } else {
8839
+ if (merchantResult === false) {
8840
+ reject();
8841
+ } else {
8842
+ resolve();
8843
+ }
8844
+ }
8845
+ });
8656
8846
  }
8657
8847
  }, {
8658
8848
  key: "getOrderId",
8659
8849
  value: function getOrderId() {
8660
- var _this2 = this;
8850
+ var _this4 = this;
8661
8851
  return new Promise(function (resolve, reject) {
8662
- return _this2.eventEmitter.emit(WALLET_EVENT.CALLBACK, {
8852
+ return _this4.eventEmitter.emit(WALLET_EVENT.CALLBACK, {
8663
8853
  data: {
8664
8854
  request_type: 'CREATE_SESSION'
8665
8855
  },
@@ -8675,7 +8865,7 @@
8675
8865
  }, {
8676
8866
  key: "flypayV2Checkout",
8677
8867
  value: function flypayV2Checkout(orderId) {
8678
- var _this3 = this;
8868
+ var _this5 = this;
8679
8869
  var _a, _b;
8680
8870
  this.checkout = new Checkout(_extends(_extends({
8681
8871
  orderId: orderId
@@ -8685,41 +8875,59 @@
8685
8875
  }), this.refreshToken && {
8686
8876
  refresh_token: this.refreshToken
8687
8877
  }),
8688
- mode: "express"
8878
+ mode: 'express'
8689
8879
  }), {
8690
8880
  clientId: ((_a = this.meta) === null || _a === void 0 ? void 0 : _a.gateway_mode) === 'live' ? 'dbbd114e-3583-4db5-915e-59f1b3dcd08b' : '924ac1ce-00f4-44e4-8277-06cae751ef1a',
8691
8881
  url: ((_b = this.meta) === null || _b === void 0 ? void 0 : _b.gateway_mode) === 'live' ? 'https://checkout.cxbflypay.com.au' : 'https://checkout.sandbox.cxbflypay.com.au',
8692
8882
  onCheckoutClosed: function onCheckoutClosed() {
8693
- var button = document.getElementById('flypay-v2-button');
8694
- if (button) button.disabled = false;
8883
+ var _a;
8884
+ _this5.eventEmitter.emit(WALLET_EVENT.CHECKOUT_CLOSE);
8885
+ (_a = _this5.background) === null || _a === void 0 ? void 0 : _a.clear();
8886
+ _this5.enable();
8695
8887
  },
8696
8888
  onError: function onError(err) {
8697
- return _this3.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
8889
+ return _this5.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
8698
8890
  error: err
8699
8891
  });
8700
8892
  },
8701
8893
  onPaymentSuccess: function onPaymentSuccess(data) {
8702
- return _this3.eventEmitter.emit(WALLET_EVENT.PAYMENT_SUCCESS, data);
8894
+ return _this5.eventEmitter.emit(WALLET_EVENT.PAYMENT_SUCCESS, data);
8703
8895
  },
8704
8896
  onPaymentError: function onPaymentError(err) {
8705
- return _this3.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
8897
+ return _this5.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
8706
8898
  error: err
8707
8899
  });
8708
8900
  },
8709
8901
  onTokensChanged: function onTokensChanged(_ref) {
8710
8902
  var accessToken = _ref.accessToken,
8711
8903
  refreshToken = _ref.refreshToken;
8712
- _this3.accessToken = accessToken;
8713
- _this3.refreshToken = refreshToken;
8714
- _this3.eventEmitter.emit(WALLET_EVENT.AUTH_TOKENS_CHANGED, {
8904
+ _this5.accessToken = accessToken;
8905
+ _this5.refreshToken = refreshToken;
8906
+ _this5.eventEmitter.emit(WALLET_EVENT.AUTH_TOKENS_CHANGED, {
8715
8907
  accessToken: accessToken,
8716
8908
  refreshToken: refreshToken
8717
8909
  });
8718
8910
  }
8719
8911
  }));
8720
8912
  this.checkout.open();
8913
+ if (this.checkout.isCheckoutOpen) this.eventEmitter.emit(WALLET_EVENT.CHECKOUT_OPEN, {});
8721
8914
  this.checkout.listenMessage();
8722
8915
  }
8916
+ }, {
8917
+ key: "initBackground",
8918
+ value: function initBackground() {
8919
+ var _this6 = this;
8920
+ var hideCloseButton = true;
8921
+ var bg = new WalletBackground(this.link.getNetUrl() + FLYPAY_LOGO_LINK, hideCloseButton);
8922
+ bg.setBackdropTitle("");
8923
+ bg.setBackdropDescription("");
8924
+ bg.onTrigger(TRIGGER$1.CLOSE, function () {
8925
+ var _a;
8926
+ _this6.checkout.close();
8927
+ (_a = _this6.background) === null || _a === void 0 ? void 0 : _a.clear();
8928
+ });
8929
+ return bg;
8930
+ }
8723
8931
  }]);
8724
8932
  return FlypayV2WalletService;
8725
8933
  }(WalletService);
@@ -8733,6 +8941,7 @@
8733
8941
  * @param {string} UPDATE=update
8734
8942
  * @param {string} PAYMENT_SUCCESSFUL=paymentSuccessful
8735
8943
  * @param {string} PAYMENT_ERROR=paymentError
8944
+ * @param {string} ON_CLICK=onClick
8736
8945
  */
8737
8946
  var EVENT$1 = {
8738
8947
  UNAVAILABLE: "unavailable",
@@ -8740,68 +8949,11 @@
8740
8949
  PAYMENT_SUCCESSFUL: "paymentSuccessful",
8741
8950
  PAYMENT_ERROR: "paymentError",
8742
8951
  PAYMENT_IN_REVIEW: "paymentInReview",
8743
- AUTH_TOKENS_CHANGED: "authTokensChanged"
8952
+ AUTH_TOKENS_CHANGED: "authTokensChanged",
8953
+ ON_CLICK: "onClick",
8954
+ ON_CHECKOUT_OPEN: "onCheckoutOpen",
8955
+ ON_CHECKOUT_CLOSE: "onCheckoutClose"
8744
8956
  };
8745
- /**
8746
- * Interface of data used by the wallet checkout and payment proccess.
8747
- * @interface IWalletMeta
8748
- *
8749
- * @type {object}
8750
- * @param {string} [amount_label] Label shown next to the total amount to be paid. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, Flypay V2, PayPal, Afterpay].
8751
- * @param {string} [country] Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay, GooglePay, Afterpay]. N/A for [FlyPay, Flypay V2, PayPal].
8752
- * @param {boolean} [pay_later] Used to enable Pay Later feature in PayPal Smart Checkout WalletButton integration when available. Optional for [PayPal]. N/A for other wallets.
8753
- * @param {boolean} [standalone] Used to enable Standalone Buttons feature in PayPal Smart Checkout WalletButton integration. Used together with `pay_later`. Optional for [PayPal]. N/A for other wallets.
8754
- * @param {boolean} [show_billing_address] Used to hide/show the billing address on ApplePay and GooglePay popups. Default value is false. Optional for [ApplePay, GooglePay]. N/A for other wallets.
8755
- * @param {boolean} [request_payer_name] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
8756
- * @param {boolean} [request_payer_email] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
8757
- * @param {boolean} [request_payer_phone] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
8758
- * @param {string} [access_token] Used for Flypay V2 express flow. Optional for [Flypay V2]. N/A for other wallets.
8759
- * @param {string} [refresh_token] Used for Flypay V2 express flow. Optional for [Flypay V2]. N/A for other wallets.
8760
- * @param {boolean} [request_shipping] Used to request or not shipping address in the Wallet checkout, being able to handle amount changes via the `update` event. Optional for [FlyPay, PayPal, ApplePay, GooglePay]. N/A for [Flypay V2, Stripe, Afterpay].
8761
- * @param {IApplePayShippingOption[] | IPayPalShippingOption[]} [shipping_options] Used to provide available shipping options.(To use shipping_options the request_shipping flag should be true). Optional for [ApplePay]. N/A for the other wallets.
8762
- * @param {string} [merchant_name] Merchant Name used for GooglePay integration via MPGS. Required for [GooglePay]. N/A for other wallets.
8763
- * @param {object} [raw_data_initialization] Used to provide values to initialize wallet with raw data. Optional for [ApplePay]. N/A for the other wallets.
8764
- * @param {object} [style] For **Paypal**: used to style the buttons, check possible values in the [style guide](https://developer.paypal.com/docs/business/checkout/reference/style-guide).
8765
- * When `standalone` and `pay_later`, extra options can be provided in `style.messages` with the [messages style options](https://developer.paypal.com/docs/checkout/pay-later/us/integrate/reference/#stylelayout).
8766
- * Also used at **ApplePay**, **GooglePay** and **Afterpay** to select button type.
8767
- * Optional for [PayPal, ApplePay, GooglePay, Afterpay]. N/A for [Stripe, FlyPay, Flypay V2].
8768
- * @param {object} [style.button_type] Used to select ApplePay button type (e.g: 'buy','donate', etc), check possible values at https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons_using_css.
8769
- * Also select button type for GooglePay (check GooglePayStyles) and Afterpay (check AfterpayStyles). Optional for [ApplePay, GooglePay, Afterpay]. N/A for other wallets.
8770
- * @param {object} [style.height] Used to select Afterpay button height. Optional for [Afterpay]. N/A for other wallets.
8771
- * @param {array} [wallets] By default if this is not sent or empty, we will try to show either Apple Pay or Google Pay buttons. This can be limited sending the following array in this field: ['apple','google]. Optional for [Stripe, ApplePay, GooglePay]. N/A for other wallets.
8772
- */
8773
- /**
8774
- * Interface of Shipping Options for ApplePay
8775
- * @interface IApplePayShippingOption
8776
- *
8777
- * @type {object}
8778
- * @param {string} [id] Identifier of the Shipping Option. Required.
8779
- * @param {string} [label] Identifier of the Shipping Option. Required.
8780
- * @param {string} [amount] Amount of the Shipping Option. Required.
8781
- * @param {string} [detail] Details of the Shipping Option. Required.
8782
- * @param {string} [type] Type of the Shipping Option. Values can be 'ELECTRONIC', 'GROUND', 'NOT_SHIPPED', 'OVERNIGHT', 'PICKUP', 'PRIORITY', 'SAME_DAY'. Optional.
8783
- */
8784
- /**
8785
- * Interface of Shipping Options for GooglePay
8786
- * @interface IGooglePayShippingOption
8787
- *
8788
- * @type {object}
8789
- * @param {string} [id] Identifier of the Shipping Option. Required.
8790
- * @param {string} [label] Identifier of the Shipping Option. Required.
8791
- * @param {string} [detail] Details of the Shipping Option. Optional.
8792
- * @param {string} [type] Type of the Shipping Option. Values can be 'ELECTRONIC', 'GROUND', 'NOT_SHIPPED', 'OVERNIGHT', 'PICKUP', 'PRIORITY', 'SAME_DAY'. Optional.
8793
- */
8794
- /**
8795
- * Interface of Shipping Options for PayPal
8796
- * @interface IPayPalShippingOption
8797
- *
8798
- * @type {object}
8799
- * @param {string} [id] Identifier of the Shipping Option. Required.
8800
- * @param {string} [label] Identifier of the Shipping Option. Required.
8801
- * @param {string} [amount] Amount of the Shipping Option. Required.
8802
- * @param {string} [currency] Currency of the Shipping Option. Required.
8803
- * @param {string} [type] Type of the Shipping Option. Values can be 'SHIPPING' or 'PICKUP'. Required.
8804
- */
8805
8957
  /**
8806
8958
  * Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Flypay V2, Paypal, Afterpay)
8807
8959
  * @constructor
@@ -8976,6 +9128,28 @@
8976
9128
  this.api.setEnv(env, alias);
8977
9129
  this.service.setEnv(env);
8978
9130
  }
9131
+ /**
9132
+ * Current method can enable the payment button. This method is only supported for Flypay V2.
9133
+ *
9134
+ * @example
9135
+ * button.enable();
9136
+ */
9137
+ }, {
9138
+ key: "enable",
9139
+ value: function enable() {
9140
+ this.service.enable();
9141
+ }
9142
+ /**
9143
+ * Current method can disable the payment button. This method is only supported for Flypay V2.
9144
+ *
9145
+ * @example
9146
+ * button.disable('production', 'paydock.com');
9147
+ */
9148
+ }, {
9149
+ key: "disable",
9150
+ value: function disable() {
9151
+ this.service.disable();
9152
+ }
8979
9153
  /**
8980
9154
  * Closes the checkout forcibly. Currently supported in Flypay wallet.
8981
9155
  *
@@ -9179,6 +9353,69 @@
9179
9353
  });
9180
9354
  });
9181
9355
  }
9356
+ /**
9357
+ * Registers a callback function to be invoked when the wallet button gets clicked.
9358
+ * There are two operational modes supported, Synchronous and Asynchronous.
9359
+ * When asynchronous operations need to occur on the callback handler, attaching the Promise via `attachResult` is required to have the wallet wait for a result.
9360
+ * When synchronous operations occur on the callback handler, attaching a boolean result via `attachResult` is optional to control the execution flow.
9361
+ * Note this is supported for Paypal, GooglePay and ApplePay wallet buttons at the moment.
9362
+ *
9363
+ * @example
9364
+ * button.onClick((data) => {
9365
+ * performValidationLogic();
9366
+ * });
9367
+ *
9368
+ * @param {listener} handler - Function to be called when the wallet button is clicked.
9369
+ */
9370
+ }, {
9371
+ key: "onClick",
9372
+ value: function onClick(handler) {
9373
+ if (typeof handler === 'function') return this.eventEmitter.subscribe(EVENT$1.ON_CLICK, handler);
9374
+ }
9375
+ /**
9376
+ * Registers a callback function to be invoked when the wallet checkout opens.
9377
+ * Note this is supported for FlypayV2 wallet button at the moment.
9378
+ *
9379
+ * @example
9380
+ * button.onCheckoutOpen((data) => {
9381
+ * console.log('Checkout opens');
9382
+ * });
9383
+ *
9384
+ * @param {listener} handler - Function to be called when the wallet checkout opens.
9385
+ */
9386
+ }, {
9387
+ key: "onCheckoutOpen",
9388
+ value: function onCheckoutOpen(handler) {
9389
+ var _this8 = this;
9390
+ if (typeof handler === 'function') return this.eventEmitter.subscribe(EVENT$1.ON_CHECKOUT_OPEN, handler);
9391
+ return new Promise(function (resolve) {
9392
+ return _this8.eventEmitter.subscribe(EVENT$1.ON_CHECKOUT_OPEN, function (err) {
9393
+ return resolve(err);
9394
+ });
9395
+ });
9396
+ }
9397
+ /**
9398
+ * Registers a callback function to be invoked when the wallet checkout closes.
9399
+ * Note this is supported for FlypayV2 wallet button at the moment.
9400
+ *
9401
+ * @example
9402
+ * button.onCheckoutClose(() => {
9403
+ * console.log('Wallet checkout closes');
9404
+ * });
9405
+ *
9406
+ * @param {listener} handler - Function to be called when the wallet checkout closes.
9407
+ */
9408
+ }, {
9409
+ key: "onCheckoutClose",
9410
+ value: function onCheckoutClose(handler) {
9411
+ var _this9 = this;
9412
+ if (typeof handler === 'function') return this.eventEmitter.subscribe(EVENT$1.ON_CHECKOUT_CLOSE, handler);
9413
+ return new Promise(function (resolve) {
9414
+ return _this9.eventEmitter.subscribe(EVENT$1.ON_CHECKOUT_CLOSE, function (err) {
9415
+ return resolve(err);
9416
+ });
9417
+ });
9418
+ }
9182
9419
  }, {
9183
9420
  key: "setupServiceCallbacks",
9184
9421
  value: function setupServiceCallbacks() {
@@ -9190,13 +9427,16 @@
9190
9427
  this.setupPaymentInReviewCallback();
9191
9428
  this.setupPaymentErrorCallback();
9192
9429
  this.setupAuthTokensChangedCallback();
9430
+ this.setupOnClickCallback();
9431
+ this.setupOnCheckoutOpenCallback();
9432
+ this.setupOnCheckoutCloseCallback();
9193
9433
  }
9194
9434
  }, {
9195
9435
  key: "setupUnavailableCallback",
9196
9436
  value: function setupUnavailableCallback() {
9197
- var _this8 = this;
9437
+ var _this10 = this;
9198
9438
  this.service.on(WALLET_EVENT.UNAVAILABLE, function (eventData) {
9199
- return _this8.eventEmitter.emit(EVENT$1.UNAVAILABLE, {
9439
+ return _this10.eventEmitter.emit(EVENT$1.UNAVAILABLE, {
9200
9440
  event: EVENT$1.UNAVAILABLE,
9201
9441
  data: eventData
9202
9442
  });
@@ -9205,25 +9445,58 @@
9205
9445
  }, {
9206
9446
  key: "setupUpdateCallback",
9207
9447
  value: function setupUpdateCallback() {
9208
- var _this9 = this;
9448
+ var _this11 = this;
9209
9449
  this.service.on(WALLET_EVENT.UPDATE, function (eventData) {
9210
- return _this9.hasUpdateHandler ? _this9.eventEmitter.emit(EVENT$1.UPDATE, {
9450
+ return _this11.hasUpdateHandler ? _this11.eventEmitter.emit(EVENT$1.UPDATE, {
9211
9451
  event: EVENT$1.UPDATE,
9212
9452
  data: eventData
9213
- }) : _this9.update({
9453
+ }) : _this11.update({
9214
9454
  success: true
9215
9455
  });
9216
9456
  });
9217
9457
  }
9458
+ }, {
9459
+ key: "setupOnClickCallback",
9460
+ value: function setupOnClickCallback() {
9461
+ var _this12 = this;
9462
+ this.service.on(WALLET_EVENT.BUTTON_CLICK, function (data) {
9463
+ return _this12.eventEmitter.emit(EVENT$1.ON_CLICK, {
9464
+ event: EVENT$1.ON_CLICK,
9465
+ data: data
9466
+ });
9467
+ });
9468
+ }
9469
+ }, {
9470
+ key: "setupOnCheckoutOpenCallback",
9471
+ value: function setupOnCheckoutOpenCallback() {
9472
+ var _this13 = this;
9473
+ this.service.on(WALLET_EVENT.CHECKOUT_OPEN, function (data) {
9474
+ return _this13.eventEmitter.emit(EVENT$1.ON_CHECKOUT_OPEN, {
9475
+ event: EVENT$1.ON_CHECKOUT_OPEN,
9476
+ data: data
9477
+ });
9478
+ });
9479
+ }
9480
+ }, {
9481
+ key: "setupOnCheckoutCloseCallback",
9482
+ value: function setupOnCheckoutCloseCallback() {
9483
+ var _this14 = this;
9484
+ this.service.on(WALLET_EVENT.CHECKOUT_CLOSE, function (data) {
9485
+ return _this14.eventEmitter.emit(EVENT$1.ON_CHECKOUT_CLOSE, {
9486
+ event: EVENT$1.ON_CHECKOUT_CLOSE,
9487
+ data: data
9488
+ });
9489
+ });
9490
+ }
9218
9491
  }, {
9219
9492
  key: "setupWalletCallback",
9220
9493
  value: function setupWalletCallback() {
9221
- var _this10 = this;
9494
+ var _this15 = this;
9222
9495
  this.service.on(WALLET_EVENT.CALLBACK, function (eventData) {
9223
9496
  var data = eventData.data,
9224
9497
  onSuccess = eventData.onSuccess,
9225
9498
  onError = eventData.onError;
9226
- _this10.api.charge().walletCallback(data).then(function (res) {
9499
+ _this15.api.charge().walletCallback(data).then(function (res) {
9227
9500
  return onSuccess(res);
9228
9501
  }, function (err) {
9229
9502
  return onError(err.message);
@@ -9233,15 +9506,15 @@
9233
9506
  }, {
9234
9507
  key: "setupPaymentCallback",
9235
9508
  value: function setupPaymentCallback() {
9236
- var _this11 = this;
9509
+ var _this16 = this;
9237
9510
  this.service.on(WALLET_EVENT.PAYMENT_METHOD_SELECTED, function (eventData) {
9238
9511
  var data = eventData.data,
9239
9512
  onSuccess = eventData.onSuccess,
9240
9513
  onError = eventData.onError;
9241
- _this11.api.charge().walletCapture(data).then(function (captureResult) {
9514
+ _this16.api.charge().walletCapture(data).then(function (captureResult) {
9242
9515
  if (typeof onSuccess === 'function') onSuccess();
9243
9516
  var event = captureResult.status === 'inreview' ? EVENT$1.PAYMENT_IN_REVIEW : EVENT$1.PAYMENT_SUCCESSFUL;
9244
- _this11.eventEmitter.emit(event, {
9517
+ _this16.eventEmitter.emit(event, {
9245
9518
  event: event,
9246
9519
  data: _extends(_extends({}, captureResult), data.customer && {
9247
9520
  payer_name: data.customer.payer_name,
@@ -9251,7 +9524,7 @@
9251
9524
  });
9252
9525
  }, function (err) {
9253
9526
  if (typeof onError === 'function') onError(err);
9254
- _this11.eventEmitter.emit(EVENT$1.PAYMENT_ERROR, {
9527
+ _this16.eventEmitter.emit(EVENT$1.PAYMENT_ERROR, {
9255
9528
  event: EVENT$1.PAYMENT_ERROR,
9256
9529
  data: err
9257
9530
  });
@@ -9261,9 +9534,9 @@
9261
9534
  }, {
9262
9535
  key: "setupPaymentSuccessCallback",
9263
9536
  value: function setupPaymentSuccessCallback() {
9264
- var _this12 = this;
9537
+ var _this17 = this;
9265
9538
  this.service.on(WALLET_EVENT.PAYMENT_SUCCESS, function (eventData) {
9266
- return _this12.eventEmitter.emit(EVENT$1.PAYMENT_SUCCESSFUL, {
9539
+ return _this17.eventEmitter.emit(EVENT$1.PAYMENT_SUCCESSFUL, {
9267
9540
  event: EVENT$1.PAYMENT_SUCCESSFUL,
9268
9541
  data: eventData
9269
9542
  });
@@ -9272,9 +9545,9 @@
9272
9545
  }, {
9273
9546
  key: "setupPaymentInReviewCallback",
9274
9547
  value: function setupPaymentInReviewCallback() {
9275
- var _this13 = this;
9548
+ var _this18 = this;
9276
9549
  this.service.on(WALLET_EVENT.PAYMENT_IN_REVIEW, function (eventData) {
9277
- return _this13.eventEmitter.emit(EVENT$1.PAYMENT_IN_REVIEW, {
9550
+ return _this18.eventEmitter.emit(EVENT$1.PAYMENT_IN_REVIEW, {
9278
9551
  event: EVENT$1.PAYMENT_IN_REVIEW,
9279
9552
  data: eventData
9280
9553
  });
@@ -9283,9 +9556,9 @@
9283
9556
  }, {
9284
9557
  key: "setupPaymentErrorCallback",
9285
9558
  value: function setupPaymentErrorCallback() {
9286
- var _this14 = this;
9559
+ var _this19 = this;
9287
9560
  this.service.on(WALLET_EVENT.PAYMENT_ERROR, function (eventData) {
9288
- return _this14.eventEmitter.emit(EVENT$1.PAYMENT_ERROR, {
9561
+ return _this19.eventEmitter.emit(EVENT$1.PAYMENT_ERROR, {
9289
9562
  event: EVENT$1.PAYMENT_ERROR,
9290
9563
  data: eventData
9291
9564
  });
@@ -9294,9 +9567,9 @@
9294
9567
  }, {
9295
9568
  key: "setupAuthTokensChangedCallback",
9296
9569
  value: function setupAuthTokensChangedCallback() {
9297
- var _this15 = this;
9570
+ var _this20 = this;
9298
9571
  this.service.on(WALLET_EVENT.AUTH_TOKENS_CHANGED, function (eventData) {
9299
- return _this15.eventEmitter.emit(EVENT$1.AUTH_TOKENS_CHANGED, {
9572
+ return _this20.eventEmitter.emit(EVENT$1.AUTH_TOKENS_CHANGED, {
9300
9573
  event: EVENT$1.AUTH_TOKENS_CHANGED,
9301
9574
  data: eventData
9302
9575
  });