@paydock/client-sdk 1.143.0-beta → 1.144.0-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 (72) hide show
  1. package/README.md +158 -0
  2. package/bundles/index.cjs +523 -312
  3. package/bundles/index.cjs.d.ts +751 -116
  4. package/bundles/index.mjs +518 -313
  5. package/bundles/index.mjs.d.ts +751 -116
  6. package/bundles/types/api/api-charge-internal.d.ts +3 -49
  7. package/bundles/types/api/api-charge-internal.d.ts.map +1 -1
  8. package/bundles/types/api/api-checkout-internal.d.ts +1 -47
  9. package/bundles/types/api/api-checkout-internal.d.ts.map +1 -1
  10. package/bundles/types/api/api-shared-types.d.ts +53 -0
  11. package/bundles/types/api/api-shared-types.d.ts.map +1 -0
  12. package/bundles/types/canvas-3ds/canvas-3ds-event-map.d.ts +95 -0
  13. package/bundles/types/canvas-3ds/canvas-3ds-event-map.d.ts.map +1 -0
  14. package/bundles/types/canvas-3ds/canvas-3ds.d.ts +10 -7
  15. package/bundles/types/canvas-3ds/canvas-3ds.d.ts.map +1 -1
  16. package/bundles/types/canvas-3ds/index.d.ts +4 -0
  17. package/bundles/types/canvas-3ds/index.d.ts.map +1 -1
  18. package/bundles/types/canvas-3ds/services/gpayments-service.d.ts +41 -12
  19. package/bundles/types/canvas-3ds/services/gpayments-service.d.ts.map +1 -1
  20. package/bundles/types/canvas-3ds/services/standalone3ds-service.d.ts +20 -2
  21. package/bundles/types/canvas-3ds/services/standalone3ds-service.d.ts.map +1 -1
  22. package/bundles/types/checkout/checkout-event-map.d.ts +43 -0
  23. package/bundles/types/checkout/checkout-event-map.d.ts.map +1 -0
  24. package/bundles/types/checkout/checkout.d.ts +25 -9
  25. package/bundles/types/checkout/checkout.d.ts.map +1 -1
  26. package/bundles/types/checkout/v1/instructions/instruction.canvas_3ds.show.d.ts.map +1 -1
  27. package/bundles/types/checkout/v3/instructions/instruction.canvas_3ds.show.d.ts.map +1 -1
  28. package/bundles/types/components/param.d.ts +29 -0
  29. package/bundles/types/components/param.d.ts.map +1 -1
  30. package/bundles/types/helper/event-error.d.ts +49 -1
  31. package/bundles/types/helper/event-error.d.ts.map +1 -1
  32. package/bundles/types/index-cba.d.ts +3 -1
  33. package/bundles/types/index-cba.d.ts.map +1 -1
  34. package/bundles/types/index.d.ts +12 -1
  35. package/bundles/types/index.d.ts.map +1 -1
  36. package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts +37 -0
  37. package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts.map +1 -1
  38. package/bundles/types/open-wallets/base/open-wallet.service.d.ts +12 -0
  39. package/bundles/types/open-wallets/base/open-wallet.service.d.ts.map +1 -1
  40. package/bundles/types/open-wallets/google-pay-open-wallet-button.d.ts.map +1 -1
  41. package/bundles/types/open-wallets/index.d.ts +25 -0
  42. package/bundles/types/open-wallets/index.d.ts.map +1 -1
  43. package/bundles/types/open-wallets/interfaces/apple-pay/apple-pay-payment-request.interface.d.ts +2 -2
  44. package/bundles/types/open-wallets/interfaces/apple-pay/apple-pay-payment-request.interface.d.ts.map +1 -1
  45. package/bundles/types/open-wallets/interfaces/apple-pay/index.d.ts +1 -1
  46. package/bundles/types/open-wallets/interfaces/apple-pay/index.d.ts.map +1 -1
  47. package/bundles/types/open-wallets/interfaces/events.interface.d.ts +1 -1
  48. package/bundles/types/open-wallets/interfaces/events.interface.d.ts.map +1 -1
  49. package/bundles/types/open-wallets/interfaces/google-pay/google-pay-meta.interface.d.ts +46 -0
  50. package/bundles/types/open-wallets/interfaces/google-pay/google-pay-meta.interface.d.ts.map +1 -1
  51. package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts +48 -2
  52. package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts.map +1 -1
  53. package/bundles/types/open-wallets/services/google-pay/google-pay.open-wallet.service.d.ts.map +1 -1
  54. package/bundles/types/open-wallets/types/index.d.ts +1 -1
  55. package/bundles/types/open-wallets/types/index.d.ts.map +1 -1
  56. package/bundles/types/open-wallets/types/payment-source.type.d.ts +104 -0
  57. package/bundles/types/open-wallets/types/payment-source.type.d.ts.map +1 -1
  58. package/bundles/types/wallet-buttons/interfaces.d.ts +55 -1
  59. package/bundles/types/wallet-buttons/interfaces.d.ts.map +1 -1
  60. package/bundles/types/wallet-buttons-express/interfaces/base-wallet-meta.interface.d.ts +7 -0
  61. package/bundles/types/wallet-buttons-express/interfaces/base-wallet-meta.interface.d.ts.map +1 -1
  62. package/bundles/types/wallet-buttons-express/services/apple-pay/interfaces/apple-pay-wallet-meta.interface.d.ts +23 -0
  63. package/bundles/types/wallet-buttons-express/services/apple-pay/interfaces/apple-pay-wallet-meta.interface.d.ts.map +1 -1
  64. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts +31 -0
  65. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts.map +1 -1
  66. package/bundles/widget.umd.js +523 -312
  67. package/bundles/widget.umd.js.d.ts +751 -116
  68. package/bundles/widget.umd.js.min.d.ts +751 -116
  69. package/bundles/widget.umd.min.js +1 -1
  70. package/docs/api-canvas3ds.md +19 -12
  71. package/docs/open-wallet-buttons.md +158 -0
  72. package/package.json +1 -1
package/bundles/index.cjs CHANGED
@@ -1194,7 +1194,7 @@ SDK.headerKeys = Object.freeze({
1194
1194
  version: 'x-sdk-version',
1195
1195
  type: 'x-sdk-type'
1196
1196
  });
1197
- SDK._version = 'v1.143.0-beta';
1197
+ SDK._version = 'v1.144.0-beta';
1198
1198
 
1199
1199
  function isFunction(value) {
1200
1200
  return typeof value === 'function';
@@ -4804,127 +4804,162 @@ var Api = /*#__PURE__*/function (_ApiBase) {
4804
4804
  }]);
4805
4805
  }(ApiBase);
4806
4806
 
4807
- var Url = /*#__PURE__*/function () {
4808
- function Url() {
4809
- _classCallCheck(this, Url);
4807
+ var WALLET_CAPTURE_LINK = '/v1/charges/wallet/capture';
4808
+ var WALLET_CALLBACK_LINK = '/v1/charges/wallet/callback';
4809
+ var STANDALONE_3DS_PROCESS_LINK = '/v1/charges/standalone-3ds/process';
4810
+ var STANDALONE_3DS_HANDLE_LINK = '/v1/charges/standalone-3ds/handle';
4811
+ var ApiChargeInternal = /*#__PURE__*/function () {
4812
+ function ApiChargeInternal(api) {
4813
+ _classCallCheck(this, ApiChargeInternal);
4814
+ this.api = api;
4810
4815
  }
4811
- return _createClass(Url, null, [{
4812
- key: "extendSearchParams",
4813
- value: function extendSearchParams(uri, key, val) {
4814
- return uri.replace(new RegExp("([?&]" + key + "(?=[=&#]|$)[^#&]*|(?=#|$))"), "&" + key + "=" + encodeURIComponent(val)).replace(/^([^?&]+)&/, "$1?");
4816
+ return _createClass(ApiChargeInternal, [{
4817
+ key: "walletCapture",
4818
+ value: function walletCapture(payload) {
4819
+ return this.api.getClientPromise('POST', WALLET_CAPTURE_LINK).send(payload);
4815
4820
  }
4816
4821
  }, {
4817
- key: "serialize",
4818
- value: function serialize(params) {
4819
- return Object.keys(params).map(function (key) {
4820
- return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
4821
- }).join('&');
4822
+ key: "walletCallback",
4823
+ value: function walletCallback(payload) {
4824
+ return this.api.getClientPromise('POST', WALLET_CALLBACK_LINK).send(payload);
4825
+ }
4826
+ }, {
4827
+ key: "standalone3dsProcess",
4828
+ value: function standalone3dsProcess(payload) {
4829
+ return this.api.getClientPromise('POST', STANDALONE_3DS_PROCESS_LINK).send(payload);
4830
+ }
4831
+ }, {
4832
+ key: "standalone3dsHandle",
4833
+ value: function standalone3dsHandle() {
4834
+ return this.api.getClientPromise('GET', STANDALONE_3DS_HANDLE_LINK).send(undefined);
4822
4835
  }
4823
4836
  }]);
4824
4837
  }();
4825
4838
 
4826
- var Uuid = /*#__PURE__*/function () {
4827
- function Uuid() {
4828
- _classCallCheck(this, Uuid);
4839
+ var CALLBACK_LINK = '/v1/checkouts/callback';
4840
+ var INSTRUCTION_LINK = '/v1/checkouts/instruction';
4841
+ var STATUS_LINK = '/v1/checkouts';
4842
+ var ApiCheckoutInternal = /*#__PURE__*/function () {
4843
+ function ApiCheckoutInternal(api) {
4844
+ _classCallCheck(this, ApiCheckoutInternal);
4845
+ this.api = api;
4846
+ this.getInstructionLink = function () {
4847
+ return "".concat(INSTRUCTION_LINK, "?time=").concat(Date.now());
4848
+ };
4829
4849
  }
4830
- return _createClass(Uuid, null, [{
4831
- key: "generate",
4832
- value: function generate() {
4833
- if (typeof window !== "undefined" && typeof window.crypto !== "undefined" && typeof window.crypto.getRandomValues !== "undefined") {
4834
- var buf = new Uint16Array(8);
4835
- window.crypto.getRandomValues(buf);
4836
- return this.hash(buf[0]) + this.hash(buf[1]) + "-" + this.hash(buf[2]) + "-" + this.hash(buf[3]) + "-" + this.hash(buf[4]) + "-" + this.hash(buf[5]) + this.hash(buf[6]) + this.hash(buf[7]);
4837
- } else {
4838
- return this.random() + this.random() + "-" + this.random() + "-" + this.random() + "-" + this.random() + "-" + this.random() + this.random() + this.random();
4839
- }
4850
+ return _createClass(ApiCheckoutInternal, [{
4851
+ key: "instructions",
4852
+ value: function instructions() {
4853
+ return this.api.requestObservable('GET', this.getInstructionLink(), {});
4840
4854
  }
4841
4855
  }, {
4842
- key: "hash",
4843
- value: function hash(number) {
4844
- var hash = number.toString(16);
4845
- while (hash.length < 4) {
4846
- hash = "0" + hash;
4847
- }
4848
- return hash;
4856
+ key: "callback",
4857
+ value: function callback(payload) {
4858
+ return this.api.getClientPromise('POST', CALLBACK_LINK).send(payload);
4849
4859
  }
4850
4860
  }, {
4851
- key: "random",
4852
- value: function random() {
4853
- return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
4861
+ key: "status",
4862
+ value: function status(id) {
4863
+ return this.api.getClientPromise('GET', "".concat(STATUS_LINK, "/").concat(id)).send('');
4854
4864
  }
4855
4865
  }]);
4856
4866
  }();
4857
4867
 
4858
- var WIDGET_LINK = '/remote-action';
4859
- var VAULT_DISPLAY_WIDGET_LINK = '/vault-display';
4860
- var PAYMENT_SOURCE_LINK = '/payment-sources';
4861
- var SECURE_3D = '/3ds/webhook';
4862
- var FLYPAY_LINK = '/wallet/flypay';
4863
- var FLYPAY_LOGO_LINK = '/images/coles-pay-logo.png';
4864
- var MESSAGE_WIDGET_LINK = '/message-widget';
4865
- var MASTERCARD_SRC = '/secure-remote-commerce/mastercard';
4866
- var Link = /*#__PURE__*/function () {
4867
- function Link(linkResource) {
4868
- _classCallCheck(this, Link);
4869
- this.params = {};
4870
- this.widgetId = Uuid.generate();
4871
- this.linkResource = linkResource;
4872
- this.env = new Env(WIDGET_URL);
4873
- this.setParams({
4874
- widget_id: this.widgetId
4875
- });
4868
+ var GET_WALLET_CONFIG = '/v1/gateways/:gateway_id/wallet-config';
4869
+ var ApiGatewayInternal = /*#__PURE__*/function () {
4870
+ function ApiGatewayInternal(api) {
4871
+ _classCallCheck(this, ApiGatewayInternal);
4872
+ this.api = api;
4876
4873
  }
4877
- return _createClass(Link, [{
4878
- key: "getNetUrl",
4879
- value: function getNetUrl() {
4880
- return this.env.getConf().url + this.linkResource;
4874
+ return _createClass(ApiGatewayInternal, [{
4875
+ key: "getWalletConfig",
4876
+ value: function getWalletConfig(gateway_id) {
4877
+ var url = GET_WALLET_CONFIG.replace(':gateway_id', gateway_id);
4878
+ return this.api.getClientPromise('GET', url).send(undefined);
4881
4879
  }
4882
- }, {
4883
- key: "getUrl",
4884
- value: function getUrl() {
4885
- var url = this.getNetUrl();
4886
- var params = this.getParams();
4887
- for (var key in params) {
4888
- if (params.hasOwnProperty(key)) url = Url.extendSearchParams(url, key, params[key]);
4889
- }
4890
- return url;
4880
+ }]);
4881
+ }();
4882
+
4883
+ var CREATE_OTT = '/v1/payment_sources/tokens';
4884
+ var CREATE_SESSION = '/v1/payment_sources/payment-session';
4885
+ var ApiPaymentSourceInternal = /*#__PURE__*/function () {
4886
+ function ApiPaymentSourceInternal(api) {
4887
+ _classCallCheck(this, ApiPaymentSourceInternal);
4888
+ this.api = api;
4889
+ }
4890
+ return _createClass(ApiPaymentSourceInternal, [{
4891
+ key: "createOTT",
4892
+ value: function createOTT(payload) {
4893
+ return this.api.getClientPromise('POST', CREATE_OTT).send(payload);
4891
4894
  }
4892
4895
  }, {
4893
- key: "setParams",
4894
- value: function setParams(params) {
4895
- this.params = _extends({}, this.params, params);
4896
+ key: "createSession",
4897
+ value: function createSession(payload) {
4898
+ return this.api.getClientPromise('POST', CREATE_SESSION).send(payload);
4896
4899
  }
4897
- }, {
4898
- key: "concatParams",
4899
- value: function concatParams(params) {
4900
- for (var key in params) {
4901
- if (!params.hasOwnProperty(key) || !params[key].length) continue;
4902
- if (typeof this.params[key] !== 'string') this.params[key] = '';
4903
- if (this.params[key].length) this.params[key] += ',' + params[key];else this.params[key] += params[key];
4904
- }
4900
+ }]);
4901
+ }();
4902
+
4903
+ var GET_CONFIG = '/v1/services/:service_id/config';
4904
+ var ApiServiceInternal = /*#__PURE__*/function () {
4905
+ function ApiServiceInternal(api) {
4906
+ _classCallCheck(this, ApiServiceInternal);
4907
+ this.api = api;
4908
+ }
4909
+ return _createClass(ApiServiceInternal, [{
4910
+ key: "getConfig",
4911
+ value: function getConfig(service_id) {
4912
+ var url = GET_CONFIG.replace(':service_id', service_id);
4913
+ return this.api.getClientPromise('GET', url).send(undefined);
4914
+ }
4915
+ }]);
4916
+ }();
4917
+ var SERVICE_TYPES;
4918
+ (function (SERVICE_TYPES) {
4919
+ SERVICE_TYPES["ACCERTIFY"] = "Accertify";
4920
+ SERVICE_TYPES["BOOKING"] = "Booking";
4921
+ SERVICE_TYPES["GPAYMENTS"] = "GPayments";
4922
+ SERVICE_TYPES["CLICK_TO_PAY"] = "ClickToPay";
4923
+ SERVICE_TYPES["MASTERCARD_NT"] = "MastercardSCOF";
4924
+ SERVICE_TYPES["VISA_NT"] = "VisaVTS";
4925
+ SERVICE_TYPES["FORTER"] = "Forter";
4926
+ SERVICE_TYPES["APPLE_PAY"] = "ApplePay";
4927
+ SERVICE_TYPES["GOOGLE_PAY"] = "GooglePay";
4928
+ })(SERVICE_TYPES || (SERVICE_TYPES = {}));
4929
+
4930
+ var ApiInternal = /*#__PURE__*/function (_ApiBase) {
4931
+ function ApiInternal() {
4932
+ _classCallCheck(this, ApiInternal);
4933
+ return _callSuper(this, ApiInternal, arguments);
4934
+ }
4935
+ _inherits(ApiInternal, _ApiBase);
4936
+ return _createClass(ApiInternal, [{
4937
+ key: "charge",
4938
+ value: function charge() {
4939
+ return new ApiChargeInternal(this);
4905
4940
  }
4906
4941
  }, {
4907
- key: "getParams",
4908
- value: function getParams() {
4909
- return this.params;
4942
+ key: "service",
4943
+ value: function service() {
4944
+ return new ApiServiceInternal(this);
4910
4945
  }
4911
4946
  }, {
4912
- key: "setEnv",
4913
- value: function setEnv(env, alias) {
4914
- this.env.setEnv(env, alias);
4947
+ key: "checkout",
4948
+ value: function checkout() {
4949
+ return new ApiCheckoutInternal(this);
4915
4950
  }
4916
4951
  }, {
4917
- key: "getEnv",
4918
- value: function getEnv() {
4919
- return this.env.getEnv();
4952
+ key: "gateway",
4953
+ value: function gateway() {
4954
+ return new ApiGatewayInternal(this);
4920
4955
  }
4921
4956
  }, {
4922
- key: "getBaseUrl",
4923
- value: function getBaseUrl() {
4924
- return this.env.getConf().url;
4957
+ key: "paymentSource",
4958
+ value: function paymentSource() {
4959
+ return new ApiPaymentSourceInternal(this);
4925
4960
  }
4926
4961
  }]);
4927
- }();
4962
+ }(ApiBase);
4928
4963
 
4929
4964
  var IFrame = /*#__PURE__*/function () {
4930
4965
  function IFrame(container) {
@@ -5121,10 +5156,10 @@ var IFrameEvent = /*#__PURE__*/function () {
5121
5156
  }();
5122
5157
 
5123
5158
  var hiddenStyle = {
5124
- visibility: "hidden",
5125
- border: "0",
5126
- width: "0",
5127
- height: "0"
5159
+ visibility: 'hidden',
5160
+ border: '0',
5161
+ width: '0',
5162
+ height: '0'
5128
5163
  };
5129
5164
  var PROCESS_STANDALONE_3DS_STATUS;
5130
5165
  (function (PROCESS_STANDALONE_3DS_STATUS) {
@@ -5146,14 +5181,30 @@ var IFRAME_STATUS;
5146
5181
  IFRAME_STATUS["TIMEOUT"] = "AuthTimedOut";
5147
5182
  IFRAME_STATUS["INVALID"] = "invalid_event";
5148
5183
  })(IFRAME_STATUS || (IFRAME_STATUS = {}));
5184
+ /**
5185
+ * Event name constants emitted during the Standalone 3DS (GPayments) flow.
5186
+ * Used internally by `GPaymentsService` and re-exported publicly as `CANVAS_3DS_EVENT`.
5187
+ */
5149
5188
  var GPAYMENTS_EVENT = {
5189
+ /** Authentication succeeded. Payload: `Canvas3dsAuthPayload`. */
5150
5190
  AUTH_SUCCESS: 'chargeAuthSuccess',
5191
+ /** Authentication failed — covers issuer rejection, iframe timeout (`AuthTimedOut`), and invalid-event outcomes. Payload: `Canvas3dsAuthPayload`. */
5151
5192
  AUTH_ERROR: 'chargeAuthReject',
5193
+ /** Decoupled authentication — issuer will authenticate out-of-band. Payload: `Canvas3dsAuthPayload`. */
5152
5194
  DECOUPLED: 'chargeAuthDecoupled',
5195
+ /** Challenge required — issuer demands user interaction. Payload: `Canvas3dsAuthPayload`. */
5153
5196
  CHALLENGE: 'chargeAuthChallenge',
5197
+ /** Informational signal emitted by the GPayments flow. Internal — not part of the public typed surface. */
5154
5198
  INFO: 'chargeAuthInfo',
5199
+ /** Error during the flow (network, parsing, etc.). Payload: `Canvas3dsErrorPayload`. */
5155
5200
  ERROR: 'error'
5156
5201
  };
5202
+ /**
5203
+ * Public alias for GPAYMENTS_EVENT. Same object reference — no behavioral change.
5204
+ * Prefer `CANVAS_3DS_EVENT` in public-facing code; `GPAYMENTS_EVENT` remains for
5205
+ * backwards-compatible internal usage.
5206
+ */
5207
+ var CANVAS_3DS_EVENT = GPAYMENTS_EVENT;
5157
5208
  var GPaymentsService = /*#__PURE__*/function () {
5158
5209
  function GPaymentsService(container, api, eventEmitter) {
5159
5210
  _classCallCheck(this, GPaymentsService);
@@ -5181,20 +5232,22 @@ var GPaymentsService = /*#__PURE__*/function () {
5181
5232
  value: function initializeIFrames(initializationUrl, secondaryUrl, title) {
5182
5233
  var hideAuthorization = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
5183
5234
  var container = this.container.getElement();
5184
- if (!container) return;
5185
- var divAuthorization = document.createElement("div");
5186
- divAuthorization.setAttribute("id", "paydock_authorization_iframe");
5235
+ if (!container) {
5236
+ return;
5237
+ }
5238
+ var divAuthorization = document.createElement('div');
5239
+ divAuthorization.setAttribute('id', 'paydock_authorization_iframe');
5187
5240
  container.appendChild(divAuthorization);
5188
- this.browserAndChallengeContainer = new Container("#paydock_authorization_iframe");
5241
+ this.browserAndChallengeContainer = new Container('#paydock_authorization_iframe');
5189
5242
  this.iFrameAuthorization = new IFrame(this.browserAndChallengeContainer);
5190
5243
  this.iFrameAuthorization.load(initializationUrl, {
5191
5244
  title: title
5192
5245
  });
5193
5246
  if (secondaryUrl) {
5194
- var divSecondaryURL = document.createElement("div");
5195
- divSecondaryURL.setAttribute("id", "paydock_secondary_iframe");
5247
+ var divSecondaryURL = document.createElement('div');
5248
+ divSecondaryURL.setAttribute('id', 'paydock_secondary_iframe');
5196
5249
  container.appendChild(divSecondaryURL);
5197
- this.monitoringContainer = new Container("#paydock_secondary_iframe");
5250
+ this.monitoringContainer = new Container('#paydock_secondary_iframe');
5198
5251
  this.iFrameSecondaryUrl = new IFrame(this.monitoringContainer);
5199
5252
  this.iFrameSecondaryUrl.load(secondaryUrl, {
5200
5253
  title: title
@@ -5210,8 +5263,12 @@ var GPaymentsService = /*#__PURE__*/function () {
5210
5263
  var hideAuthorization = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
5211
5264
  var _a;
5212
5265
  for (var prop in hiddenStyle) {
5213
- if (!hiddenStyle.hasOwnProperty(prop)) continue;
5214
- if (hideAuthorization) this.iFrameAuthorization.setStyle(prop, hiddenStyle[prop]);
5266
+ if (!Object.hasOwn(hiddenStyle, prop)) {
5267
+ continue;
5268
+ }
5269
+ if (hideAuthorization) {
5270
+ this.iFrameAuthorization.setStyle(prop, hiddenStyle[prop]);
5271
+ }
5215
5272
  (_a = this.iFrameSecondaryUrl) === null || _a === void 0 ? void 0 : _a.setStyle(prop, hiddenStyle[prop]);
5216
5273
  }
5217
5274
  }
@@ -5221,13 +5278,17 @@ var GPaymentsService = /*#__PURE__*/function () {
5221
5278
  var _this = this;
5222
5279
  this.iFrameEvent.on(EVENT$4.CHARGE_AUTH, widgetId, function (data) {
5223
5280
  if (data.status === IFRAME_STATUS.SKIPPED || data.status === IFRAME_STATUS.FINISHED) {
5224
- if (data.info) _this.eventEmitter.emit(GPAYMENTS_EVENT.INFO, {
5225
- info: data.info
5226
- });
5281
+ if (data.info) {
5282
+ _this.eventEmitter.emit(GPAYMENTS_EVENT.INFO, {
5283
+ info: data.info
5284
+ });
5285
+ }
5227
5286
  _this.performAuthentication(data);
5228
- } else if (data.status === IFRAME_STATUS.TIMEOUT || data.status === IFRAME_STATUS.INVALID) _this.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this.parseHandleResponse({
5229
- status: data.status
5230
- }, data.charge_3ds_id));
5287
+ } else if (data.status === IFRAME_STATUS.TIMEOUT || data.status === IFRAME_STATUS.INVALID) {
5288
+ _this.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this.parseHandleResponse({
5289
+ status: data.status
5290
+ }, data.charge_3ds_id));
5291
+ }
5231
5292
  });
5232
5293
  this.iFrameEvent.on(EVENT$4.CHARGE_AUTH_SUCCESS, widgetId, function (data) {
5233
5294
  _this.processResult(data.charge_3ds_id);
@@ -5267,13 +5328,19 @@ var GPaymentsService = /*#__PURE__*/function () {
5267
5328
  key: "processResult",
5268
5329
  value: function processResult(charge3dsId) {
5269
5330
  var _this2 = this;
5270
- if (this.resultRead) return;
5331
+ if (this.resultRead) {
5332
+ return;
5333
+ }
5271
5334
  this.resultRead = true;
5272
5335
  this.api.charge().standalone3dsHandle().then(function (result) {
5273
5336
  var _a;
5274
5337
  _this2.iFrameAuthorization.remove();
5275
5338
  (_a = _this2.iFrameSecondaryUrl) === null || _a === void 0 ? void 0 : _a.remove();
5276
- if (result.status === PROCESS_STANDALONE_3DS_STATUS.SUCCESS) _this2.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this2.parseResultData(result, charge3dsId));else _this2.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this2.parseResultData(result, charge3dsId));
5339
+ if (result.status === PROCESS_STANDALONE_3DS_STATUS.SUCCESS) {
5340
+ _this2.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this2.parseResultData(result, charge3dsId));
5341
+ } else {
5342
+ _this2.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this2.parseResultData(result, charge3dsId));
5343
+ }
5277
5344
  }, function (err) {
5278
5345
  _this2.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this2.parseError(err, charge3dsId));
5279
5346
  });
@@ -5298,10 +5365,16 @@ var GPaymentsService = /*#__PURE__*/function () {
5298
5365
  key: "doPolling",
5299
5366
  value: function doPolling(url, charge3dsId) {
5300
5367
  var _this3 = this;
5301
- this.externalAPI("GET", url).then(function (data) {
5302
- if (!data.event || data.event === "AuthResultNotReady") setTimeout(function () {
5303
- _this3.doPolling(url, charge3dsId);
5304
- }, 2000);else if (data.event === 'AuthResultReady') _this3.processResult(charge3dsId);else throw new Error("Event not supported");
5368
+ this.externalAPI('GET', url).then(function (data) {
5369
+ if (!data.event || data.event === 'AuthResultNotReady') {
5370
+ setTimeout(function () {
5371
+ _this3.doPolling(url, charge3dsId);
5372
+ }, 2000);
5373
+ } else if (data.event === 'AuthResultReady') {
5374
+ _this3.processResult(charge3dsId);
5375
+ } else {
5376
+ throw new Error('Event not supported');
5377
+ }
5305
5378
  })["catch"](function (err) {
5306
5379
  return _this3.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this3.parseError(err, charge3dsId));
5307
5380
  });
@@ -5318,16 +5391,24 @@ var GPaymentsService = /*#__PURE__*/function () {
5318
5391
  charge_3ds_id: charge_3ds_id
5319
5392
  }).then(function (authenticationResult) {
5320
5393
  var _a, _b;
5321
- if (authenticationResult.status === AUTHENTICATION_STATUS.SUCCESS) _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));else if (authenticationResult.status === AUTHENTICATION_STATUS.PENDING) {
5394
+ if (authenticationResult.status === AUTHENTICATION_STATUS.SUCCESS) {
5395
+ _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
5396
+ } else if (authenticationResult.status === AUTHENTICATION_STATUS.PENDING) {
5322
5397
  if ((_a = authenticationResult === null || authenticationResult === void 0 ? void 0 : authenticationResult.result) === null || _a === void 0 ? void 0 : _a.challenge) {
5323
5398
  _this4.eventEmitter.emit(GPAYMENTS_EVENT.CHALLENGE, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
5324
5399
  _this4.initializeIFrames(authenticationResult.result.challenge_url, undefined, 'Authentication Challenge', false);
5325
- if (authenticationResult.result.secondary_url) _this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
5400
+ if (authenticationResult.result.secondary_url) {
5401
+ _this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
5402
+ }
5326
5403
  } else if ((_b = authenticationResult === null || authenticationResult === void 0 ? void 0 : authenticationResult.result) === null || _b === void 0 ? void 0 : _b.decoupled_challenge) {
5327
5404
  _this4.eventEmitter.emit(GPAYMENTS_EVENT.DECOUPLED, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
5328
- if (authenticationResult.result.secondary_url) _this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
5405
+ if (authenticationResult.result.secondary_url) {
5406
+ _this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
5407
+ }
5329
5408
  }
5330
- } else return _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
5409
+ } else {
5410
+ return _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
5411
+ }
5331
5412
  }, function (err) {
5332
5413
  _this4.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this4.parseError(err, charge_3ds_id));
5333
5414
  });
@@ -5335,192 +5416,159 @@ var GPaymentsService = /*#__PURE__*/function () {
5335
5416
  }]);
5336
5417
  }();
5337
5418
 
5338
- var WALLET_CAPTURE_LINK = '/v1/charges/wallet/capture';
5339
- var WALLET_CALLBACK_LINK = '/v1/charges/wallet/callback';
5340
- var STANDALONE_3DS_PROCESS_LINK = '/v1/charges/standalone-3ds/process';
5341
- var STANDALONE_3DS_HANDLE_LINK = '/v1/charges/standalone-3ds/handle';
5342
- var ApiChargeInternal = /*#__PURE__*/function () {
5343
- function ApiChargeInternal(api) {
5344
- _classCallCheck(this, ApiChargeInternal);
5345
- this.api = api;
5419
+ var STANDALONE_3DS_GATEWAYS = {
5420
+ GPAYMENTS: 'GPayments'
5421
+ };
5422
+ var Standalone3dsService = /*#__PURE__*/function () {
5423
+ function Standalone3dsService(container, eventEmitter) {
5424
+ _classCallCheck(this, Standalone3dsService);
5425
+ this.env = DEFAULT_ENV;
5426
+ this.container = container;
5427
+ this.eventEmitter = eventEmitter;
5346
5428
  }
5347
- return _createClass(ApiChargeInternal, [{
5348
- key: "walletCapture",
5349
- value: function walletCapture(payload) {
5350
- return this.api.getClientPromise('POST', WALLET_CAPTURE_LINK).send(payload);
5351
- }
5352
- }, {
5353
- key: "walletCallback",
5354
- value: function walletCallback(payload) {
5355
- return this.api.getClientPromise('POST', WALLET_CALLBACK_LINK).send(payload);
5356
- }
5357
- }, {
5358
- key: "standalone3dsProcess",
5359
- value: function standalone3dsProcess(payload) {
5360
- return this.api.getClientPromise('POST', STANDALONE_3DS_PROCESS_LINK).send(payload);
5429
+ return _createClass(Standalone3dsService, [{
5430
+ key: "load",
5431
+ value: function load(token, options) {
5432
+ var parsedToken = AccessToken.validateJWT(token);
5433
+ if (!parsedToken) {
5434
+ throw new Error('Invalid charge token');
5435
+ }
5436
+ var tokenData = AccessToken.extractData(parsedToken.body);
5437
+ var api = new ApiInternal(token, API_AUTH_TYPE.TOKEN);
5438
+ api.setEnv(this.env, this.alias);
5439
+ switch (tokenData.service_type) {
5440
+ case STANDALONE_3DS_GATEWAYS.GPAYMENTS:
5441
+ new GPaymentsService(this.container, api, this.eventEmitter).load(tokenData, options.title);
5442
+ break;
5443
+ }
5361
5444
  }
5362
5445
  }, {
5363
- key: "standalone3dsHandle",
5364
- value: function standalone3dsHandle() {
5365
- return this.api.getClientPromise('GET', STANDALONE_3DS_HANDLE_LINK).send(undefined);
5446
+ key: "setEnv",
5447
+ value: function setEnv(env, alias) {
5448
+ this.env = env;
5449
+ this.alias = alias;
5366
5450
  }
5367
5451
  }]);
5368
5452
  }();
5369
5453
 
5370
- var CALLBACK_LINK = '/v1/checkouts/callback';
5371
- var INSTRUCTION_LINK = '/v1/checkouts/instruction';
5372
- var STATUS_LINK = '/v1/checkouts';
5373
- var ApiCheckoutInternal = /*#__PURE__*/function () {
5374
- function ApiCheckoutInternal(api) {
5375
- _classCallCheck(this, ApiCheckoutInternal);
5376
- this.api = api;
5377
- this.getInstructionLink = function () {
5378
- return "".concat(INSTRUCTION_LINK, "?time=").concat(Date.now());
5379
- };
5454
+ var Url = /*#__PURE__*/function () {
5455
+ function Url() {
5456
+ _classCallCheck(this, Url);
5380
5457
  }
5381
- return _createClass(ApiCheckoutInternal, [{
5382
- key: "instructions",
5383
- value: function instructions() {
5384
- return this.api.requestObservable('GET', this.getInstructionLink(), {});
5385
- }
5386
- }, {
5387
- key: "callback",
5388
- value: function callback(payload) {
5389
- return this.api.getClientPromise('POST', CALLBACK_LINK).send(payload);
5458
+ return _createClass(Url, null, [{
5459
+ key: "extendSearchParams",
5460
+ value: function extendSearchParams(uri, key, val) {
5461
+ return uri.replace(new RegExp("([?&]" + key + "(?=[=&#]|$)[^#&]*|(?=#|$))"), "&" + key + "=" + encodeURIComponent(val)).replace(/^([^?&]+)&/, "$1?");
5390
5462
  }
5391
5463
  }, {
5392
- key: "status",
5393
- value: function status(id) {
5394
- return this.api.getClientPromise('GET', "".concat(STATUS_LINK, "/").concat(id)).send('');
5395
- }
5396
- }]);
5397
- }();
5398
-
5399
- var GET_WALLET_CONFIG = '/v1/gateways/:gateway_id/wallet-config';
5400
- var ApiGatewayInternal = /*#__PURE__*/function () {
5401
- function ApiGatewayInternal(api) {
5402
- _classCallCheck(this, ApiGatewayInternal);
5403
- this.api = api;
5404
- }
5405
- return _createClass(ApiGatewayInternal, [{
5406
- key: "getWalletConfig",
5407
- value: function getWalletConfig(gateway_id) {
5408
- var url = GET_WALLET_CONFIG.replace(':gateway_id', gateway_id);
5409
- return this.api.getClientPromise('GET', url).send(undefined);
5464
+ key: "serialize",
5465
+ value: function serialize(params) {
5466
+ return Object.keys(params).map(function (key) {
5467
+ return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
5468
+ }).join('&');
5410
5469
  }
5411
5470
  }]);
5412
5471
  }();
5413
5472
 
5414
- var CREATE_OTT = '/v1/payment_sources/tokens';
5415
- var CREATE_SESSION = '/v1/payment_sources/payment-session';
5416
- var ApiPaymentSourceInternal = /*#__PURE__*/function () {
5417
- function ApiPaymentSourceInternal(api) {
5418
- _classCallCheck(this, ApiPaymentSourceInternal);
5419
- this.api = api;
5473
+ var Uuid = /*#__PURE__*/function () {
5474
+ function Uuid() {
5475
+ _classCallCheck(this, Uuid);
5420
5476
  }
5421
- return _createClass(ApiPaymentSourceInternal, [{
5422
- key: "createOTT",
5423
- value: function createOTT(payload) {
5424
- return this.api.getClientPromise('POST', CREATE_OTT).send(payload);
5477
+ return _createClass(Uuid, null, [{
5478
+ key: "generate",
5479
+ value: function generate() {
5480
+ if (typeof window !== "undefined" && typeof window.crypto !== "undefined" && typeof window.crypto.getRandomValues !== "undefined") {
5481
+ var buf = new Uint16Array(8);
5482
+ window.crypto.getRandomValues(buf);
5483
+ return this.hash(buf[0]) + this.hash(buf[1]) + "-" + this.hash(buf[2]) + "-" + this.hash(buf[3]) + "-" + this.hash(buf[4]) + "-" + this.hash(buf[5]) + this.hash(buf[6]) + this.hash(buf[7]);
5484
+ } else {
5485
+ return this.random() + this.random() + "-" + this.random() + "-" + this.random() + "-" + this.random() + "-" + this.random() + this.random() + this.random();
5486
+ }
5425
5487
  }
5426
5488
  }, {
5427
- key: "createSession",
5428
- value: function createSession(payload) {
5429
- return this.api.getClientPromise('POST', CREATE_SESSION).send(payload);
5489
+ key: "hash",
5490
+ value: function hash(number) {
5491
+ var hash = number.toString(16);
5492
+ while (hash.length < 4) {
5493
+ hash = "0" + hash;
5494
+ }
5495
+ return hash;
5430
5496
  }
5431
- }]);
5432
- }();
5433
-
5434
- var GET_CONFIG = '/v1/services/:service_id/config';
5435
- var ApiServiceInternal = /*#__PURE__*/function () {
5436
- function ApiServiceInternal(api) {
5437
- _classCallCheck(this, ApiServiceInternal);
5438
- this.api = api;
5439
- }
5440
- return _createClass(ApiServiceInternal, [{
5441
- key: "getConfig",
5442
- value: function getConfig(service_id) {
5443
- var url = GET_CONFIG.replace(':service_id', service_id);
5444
- return this.api.getClientPromise('GET', url).send(undefined);
5497
+ }, {
5498
+ key: "random",
5499
+ value: function random() {
5500
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
5445
5501
  }
5446
5502
  }]);
5447
5503
  }();
5448
- var SERVICE_TYPES;
5449
- (function (SERVICE_TYPES) {
5450
- SERVICE_TYPES["ACCERTIFY"] = "Accertify";
5451
- SERVICE_TYPES["BOOKING"] = "Booking";
5452
- SERVICE_TYPES["GPAYMENTS"] = "GPayments";
5453
- SERVICE_TYPES["CLICK_TO_PAY"] = "ClickToPay";
5454
- SERVICE_TYPES["MASTERCARD_NT"] = "MastercardSCOF";
5455
- SERVICE_TYPES["VISA_NT"] = "VisaVTS";
5456
- SERVICE_TYPES["FORTER"] = "Forter";
5457
- SERVICE_TYPES["APPLE_PAY"] = "ApplePay";
5458
- SERVICE_TYPES["GOOGLE_PAY"] = "GooglePay";
5459
- })(SERVICE_TYPES || (SERVICE_TYPES = {}));
5460
5504
 
5461
- var ApiInternal = /*#__PURE__*/function (_ApiBase) {
5462
- function ApiInternal() {
5463
- _classCallCheck(this, ApiInternal);
5464
- return _callSuper(this, ApiInternal, arguments);
5505
+ var WIDGET_LINK = '/remote-action';
5506
+ var VAULT_DISPLAY_WIDGET_LINK = '/vault-display';
5507
+ var PAYMENT_SOURCE_LINK = '/payment-sources';
5508
+ var SECURE_3D = '/3ds/webhook';
5509
+ var FLYPAY_LINK = '/wallet/flypay';
5510
+ var FLYPAY_LOGO_LINK = '/images/coles-pay-logo.png';
5511
+ var MESSAGE_WIDGET_LINK = '/message-widget';
5512
+ var MASTERCARD_SRC = '/secure-remote-commerce/mastercard';
5513
+ var Link = /*#__PURE__*/function () {
5514
+ function Link(linkResource) {
5515
+ _classCallCheck(this, Link);
5516
+ this.params = {};
5517
+ this.widgetId = Uuid.generate();
5518
+ this.linkResource = linkResource;
5519
+ this.env = new Env(WIDGET_URL);
5520
+ this.setParams({
5521
+ widget_id: this.widgetId
5522
+ });
5465
5523
  }
5466
- _inherits(ApiInternal, _ApiBase);
5467
- return _createClass(ApiInternal, [{
5468
- key: "charge",
5469
- value: function charge() {
5470
- return new ApiChargeInternal(this);
5524
+ return _createClass(Link, [{
5525
+ key: "getNetUrl",
5526
+ value: function getNetUrl() {
5527
+ return this.env.getConf().url + this.linkResource;
5471
5528
  }
5472
5529
  }, {
5473
- key: "service",
5474
- value: function service() {
5475
- return new ApiServiceInternal(this);
5530
+ key: "getUrl",
5531
+ value: function getUrl() {
5532
+ var url = this.getNetUrl();
5533
+ var params = this.getParams();
5534
+ for (var key in params) {
5535
+ if (params.hasOwnProperty(key)) url = Url.extendSearchParams(url, key, params[key]);
5536
+ }
5537
+ return url;
5476
5538
  }
5477
5539
  }, {
5478
- key: "checkout",
5479
- value: function checkout() {
5480
- return new ApiCheckoutInternal(this);
5540
+ key: "setParams",
5541
+ value: function setParams(params) {
5542
+ this.params = _extends({}, this.params, params);
5481
5543
  }
5482
5544
  }, {
5483
- key: "gateway",
5484
- value: function gateway() {
5485
- return new ApiGatewayInternal(this);
5545
+ key: "concatParams",
5546
+ value: function concatParams(params) {
5547
+ for (var key in params) {
5548
+ if (!params.hasOwnProperty(key) || !params[key].length) continue;
5549
+ if (typeof this.params[key] !== 'string') this.params[key] = '';
5550
+ if (this.params[key].length) this.params[key] += ',' + params[key];else this.params[key] += params[key];
5551
+ }
5486
5552
  }
5487
5553
  }, {
5488
- key: "paymentSource",
5489
- value: function paymentSource() {
5490
- return new ApiPaymentSourceInternal(this);
5491
- }
5492
- }]);
5493
- }(ApiBase);
5494
-
5495
- var STANDALONE_3DS_GATEWAYS = {
5496
- GPAYMENTS: "GPayments"
5497
- };
5498
- var Standalone3dsService = /*#__PURE__*/function () {
5499
- function Standalone3dsService(container, eventEmitter) {
5500
- _classCallCheck(this, Standalone3dsService);
5501
- this.env = DEFAULT_ENV;
5502
- this.container = container;
5503
- this.eventEmitter = eventEmitter;
5504
- }
5505
- return _createClass(Standalone3dsService, [{
5506
- key: "load",
5507
- value: function load(token, options) {
5508
- var parsedToken = AccessToken.validateJWT(token);
5509
- if (!parsedToken) throw new Error("Invalid charge token");
5510
- var tokenData = AccessToken.extractData(parsedToken.body);
5511
- var api = new ApiInternal(token, API_AUTH_TYPE.TOKEN);
5512
- api.setEnv(this.env, this.alias);
5513
- switch (tokenData.service_type) {
5514
- case STANDALONE_3DS_GATEWAYS.GPAYMENTS:
5515
- new GPaymentsService(this.container, api, this.eventEmitter).load(tokenData, options.title);
5516
- break;
5517
- }
5554
+ key: "getParams",
5555
+ value: function getParams() {
5556
+ return this.params;
5518
5557
  }
5519
5558
  }, {
5520
5559
  key: "setEnv",
5521
5560
  value: function setEnv(env, alias) {
5522
- this.env = env;
5523
- this.alias = alias;
5561
+ this.env.setEnv(env, alias);
5562
+ }
5563
+ }, {
5564
+ key: "getEnv",
5565
+ value: function getEnv() {
5566
+ return this.env.getEnv();
5567
+ }
5568
+ }, {
5569
+ key: "getBaseUrl",
5570
+ value: function getBaseUrl() {
5571
+ return this.env.getConf().url;
5524
5572
  }
5525
5573
  }]);
5526
5574
  }();
@@ -5560,7 +5608,7 @@ var TOKEN_FORMAT$2;
5560
5608
  * @param {string} CHARGE_AUTH_CHALLENGE=chargeAuthChallenge
5561
5609
  * @param {string} CHARGE_AUTH_INFO=chargeAuthInfo
5562
5610
  * @param {string} ERROR=error
5563
- */
5611
+ */
5564
5612
  /**
5565
5613
  * Class Canvas3ds include method for working on html
5566
5614
  * @constructor
@@ -5596,13 +5644,21 @@ var Canvas3ds = /*#__PURE__*/function () {
5596
5644
  *
5597
5645
  */
5598
5646
  function load() {
5599
- if (this.token.format === TOKEN_FORMAT$2.HTML) this.iFrame.loadFromHtml(this.token.content, {
5600
- title: '3d secure authentication'
5601
- }, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT$2.URL) this.iFrame.load(this.token.content, {
5602
- title: '3d secure authentication'
5603
- }, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT$2.STANDALONE_3DS) this.standalone3dsService.load(this.token.content, {
5604
- title: '3d secure authentication'
5605
- });else console.error('Token contain unsupported payload');
5647
+ if (this.token.format === TOKEN_FORMAT$2.HTML) {
5648
+ this.iFrame.loadFromHtml(this.token.content, {
5649
+ title: '3d secure authentication'
5650
+ }, 'threeDSecure-iframe');
5651
+ } else if (this.token.format === TOKEN_FORMAT$2.URL) {
5652
+ this.iFrame.load(this.token.content, {
5653
+ title: '3d secure authentication'
5654
+ }, 'threeDSecure-iframe');
5655
+ } else if (this.token.format === TOKEN_FORMAT$2.STANDALONE_3DS) {
5656
+ this.standalone3dsService.load(this.token.content, {
5657
+ title: '3d secure authentication'
5658
+ });
5659
+ } else {
5660
+ console.error('Token contain unsupported payload');
5661
+ }
5606
5662
  }
5607
5663
  /**
5608
5664
  * Current method can change environment. By default environment = sandbox.
@@ -5619,7 +5675,9 @@ var Canvas3ds = /*#__PURE__*/function () {
5619
5675
  this.link.setEnv(env, alias);
5620
5676
  this.standalone3dsService.setEnv(env, alias);
5621
5677
  for (var index in this.configs) {
5622
- if (!this.configs.hasOwnProperty(index)) continue;
5678
+ if (!Object.hasOwn(this.configs, index)) {
5679
+ continue;
5680
+ }
5623
5681
  this.configs[index].setEnv(env, alias);
5624
5682
  }
5625
5683
  }
@@ -5629,34 +5687,45 @@ var Canvas3ds = /*#__PURE__*/function () {
5629
5687
  return this.link.getEnv();
5630
5688
  }
5631
5689
  /**
5632
- * Listen to events of widget
5690
+ * Listen to events of widget.
5633
5691
  *
5634
- * @example
5692
+ * Available event names are defined in {@link Canvas3dsEventMap} (typed) and
5693
+ * {@link CANVAS_3DS_EVENT} (string constants). Using a literal event name
5694
+ * narrows the callback payload via the typed overloads.
5635
5695
  *
5636
- * widget.on('chargeAuthReject', function (data) {
5637
- * console.log(data);
5696
+ * @example
5697
+ * // Callback form — payload is narrowed by the event name
5698
+ * widget.on('chargeAuthReject', (data) => {
5699
+ * console.log(data); // data is Canvas3dsAuthPayload | Canvas3dsChargeAuthEventPayload
5638
5700
  * });
5639
- * // or
5640
- * widget.on('chargeAuthReject').then(function (data) {
5641
- * console.log(data);
5701
+ *
5702
+ * // Promise form
5703
+ * widget.on('chargeAuthReject').then((data) => {
5704
+ * console.log(data);
5642
5705
  * });
5643
- * @param {string} eventName - Available event names [EVENT]{@link EVENT} [STANDALONE_3DS_EVENT]{@link STANDALONE_3DS_EVENT}
5644
- * @param {listener} [cb]
5645
- * @return {Promise<IEventData> | void}
5706
+ *
5707
+ * @param eventName - Event name from {@link Canvas3dsEventMap} or any string for dynamic events.
5708
+ * @param cb - Optional listener callback. If omitted, returns a Promise that resolves on the next emission.
5709
+ * @returns `void` when a callback is provided; otherwise a Promise that resolves with the event payload.
5646
5710
  */
5711
+ // biome-ignore lint/suspicious/noExplicitAny: implementation signature must accept any payload shape to satisfy all overloads above
5647
5712
  }, {
5648
5713
  key: "on",
5649
5714
  value: function on(eventName, cb) {
5650
5715
  var _this = this;
5651
5716
  if (this.token.format === TOKEN_FORMAT$2.STANDALONE_3DS) {
5652
- if (typeof cb === 'function') return this.eventEmitter.subscribe(eventName, cb);
5717
+ if (typeof cb === 'function') {
5718
+ return this.eventEmitter.subscribe(eventName, cb);
5719
+ }
5653
5720
  return new Promise(function (resolve) {
5654
5721
  return _this.eventEmitter.subscribe(eventName, function (res) {
5655
5722
  return resolve(res);
5656
5723
  });
5657
5724
  });
5658
5725
  } else {
5659
- if (typeof cb === 'function') return this.event.on(eventName, this.link.getParams().ref_id, cb);
5726
+ if (typeof cb === 'function') {
5727
+ return this.event.on(eventName, this.link.getParams().ref_id, cb);
5728
+ }
5660
5729
  return new Promise(function (resolve) {
5661
5730
  return _this.event.on(eventName, _this.link.getParams().ref_id, function (res) {
5662
5731
  return resolve(res);
@@ -5700,6 +5769,19 @@ var Canvas3ds = /*#__PURE__*/function () {
5700
5769
  }]);
5701
5770
  }();
5702
5771
 
5772
+ /**
5773
+ * Public, tree-shakeable alias for the internal `TOKEN_FORMAT` enum in canvas-3ds.ts.
5774
+ * Mirrors the string values of that enum without exposing the private enum itself.
5775
+ */
5776
+ var Canvas3dsTokenFormat = {
5777
+ /** Token whose `content` is a complete HTML page. The SDK renders it inside an iframe. */
5778
+ HTML: 'html',
5779
+ /** Token whose `content` is a URL. The SDK loads it inside an iframe. */
5780
+ URL: 'url',
5781
+ /** Token whose `content` describes a standalone 3DS service (e.g. GPayments). The SDK delegates to that service's flow. */
5782
+ STANDALONE_3DS: 'standalone_3ds'
5783
+ };
5784
+
5703
5785
  var Spinner = /*#__PURE__*/function () {
5704
5786
  function Spinner() {
5705
5787
  _classCallCheck(this, Spinner);
@@ -12785,28 +12867,59 @@ function getHandleCvv(configuration) {
12785
12867
  }
12786
12868
  }
12787
12869
 
12870
+ /**
12871
+ * Top-level classification of an error. Used by the SDK to route errors to the
12872
+ * right category in instrumentation and to give consumers a coarse-grained
12873
+ * tag for grouping/filtering. See {@link getErrorCategory} for the mapping
12874
+ * between {@link ERROR_CAUSE} and {@link ERROR_CATEGORY}.
12875
+ */
12788
12876
  var ERROR_CATEGORY = {
12877
+ /** SDK was misconfigured (missing keys, invalid options, etc.). */
12789
12878
  CONFIGURATION: 'configuration',
12879
+ /** Authentication or authorization failure. */
12790
12880
  IDENTITY: 'identity_access_management',
12881
+ /** SDK internal failure or upstream service problem. */
12791
12882
  INTERNAL: 'internal',
12883
+ /** Flow lifecycle event (user cancelled, aborted, etc.) — not a real fault. */
12792
12884
  PROCESS: 'process',
12885
+ /** Resource lookup failed or was rate-limited. */
12793
12886
  RESOURCE: 'resource',
12887
+ /** Invalid input or business-rule validation failure. */
12794
12888
  VALIDATION: 'validation'
12795
12889
  };
12890
+ /**
12891
+ * Concrete cause of an error. More specific than {@link ERROR_CATEGORY} —
12892
+ * useful for deciding programmatic responses (e.g. show a retry button only
12893
+ * when `cause` is `'service_unreachable'` or `'server_busy'`).
12894
+ */
12796
12895
  var ERROR_CAUSE = {
12896
+ /** Operation was aborted programmatically. */
12797
12897
  ABORTED: 'aborted',
12898
+ /** Caller has insufficient permissions for the operation. */
12798
12899
  ACCESS_FORBIDDEN: 'access_forbidden',
12900
+ /** Resource already exists when create was expected. */
12799
12901
  ALREADY_EXISTS: 'already_exists',
12902
+ /** User cancelled the flow (e.g. closed the wallet sheet). */
12800
12903
  CANCELED: 'canceled',
12904
+ /** SDK was instantiated or invoked with invalid configuration. */
12801
12905
  INVALID_CONFIGURATION: 'invalid_configuration',
12906
+ /** Input failed structural or business-rule validation. */
12802
12907
  INVALID_INPUT: 'invalid_input',
12908
+ /** Resource was not found by the backend. */
12803
12909
  NOT_FOUND: 'not_found',
12910
+ /** Operation is not supported in the current context or version. */
12804
12911
  NOT_IMPLEMENTED: 'not_implemented',
12912
+ /** Caller exceeded the allowed request rate. */
12805
12913
  RATE_LIMITED: 'rate_limited',
12914
+ /** Backend is healthy but currently overloaded — typically retryable. */
12806
12915
  SERVER_BUSY: 'server_busy',
12916
+ /** Backend or third-party service could not be reached — typically retryable. */
12807
12917
  SERVICE_UNREACHABLE: 'service_unreachable',
12918
+ /** Caller is not authenticated. */
12808
12919
  UNAUTHORIZED: 'unauthorized',
12920
+ /** Catch-all when no other cause applies. */
12809
12921
  UNKNOWN: 'unknown_error',
12922
+ /** Request was syntactically valid but semantically rejected. */
12810
12923
  UNPROCESSABLE_ENTITY: 'unprocessable_entity'
12811
12924
  };
12812
12925
  var EventError = /*#__PURE__*/function (_Error) {
@@ -14866,7 +14979,6 @@ var InstructionCanvas3dsShow$1 = /*#__PURE__*/function (_InstructionHandler) {
14866
14979
  });
14867
14980
  canvas.on('chargeAuthReject', function () {
14868
14981
  var _a;
14869
- // **TODO add interface for chargeAuthReject event **//
14870
14982
  (_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
14871
14983
  _this.api.checkout().callback({
14872
14984
  event: 'callback.child_widget.status',
@@ -14883,13 +14995,13 @@ var InstructionCanvas3dsShow$1 = /*#__PURE__*/function (_InstructionHandler) {
14883
14995
  });
14884
14996
  canvas.on('error', function (event) {
14885
14997
  var _a;
14886
- // **TODO add interface for error event **//
14887
14998
  (_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
14999
+ var message = (event && _typeof$1(event) === 'object' && 'event' in event ? event.event : null) || 'error in 3ds widget';
14888
15000
  _this.api.checkout().callback({
14889
15001
  event: 'callback.child_widget.status',
14890
15002
  payload: {
14891
15003
  status: 'error',
14892
- message: (event === null || event === void 0 ? void 0 : event.event) || 'error in 3ds widget'
15004
+ message: message
14893
15005
  }
14894
15006
  }).then(function () {
14895
15007
  return console.info('callback.child_widget.status: - errorEvent');
@@ -17257,7 +17369,6 @@ var InstructionCanvas3dsShow = /*#__PURE__*/function (_InstructionHandler) {
17257
17369
  });
17258
17370
  canvas.on('chargeAuthReject', function () {
17259
17371
  var _a;
17260
- // **TODO add interface for chargeAuthReject event **//
17261
17372
  (_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
17262
17373
  _this.api.checkout().callback({
17263
17374
  event: 'callback.child_widget.status',
@@ -17274,13 +17385,13 @@ var InstructionCanvas3dsShow = /*#__PURE__*/function (_InstructionHandler) {
17274
17385
  });
17275
17386
  canvas.on('error', function (event) {
17276
17387
  var _a;
17277
- // **TODO add interface for error event **//
17278
17388
  (_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
17389
+ var message = (event && _typeof$1(event) === 'object' && 'event' in event ? event.event : null) || 'error in 3ds widget';
17279
17390
  _this.api.checkout().callback({
17280
17391
  event: 'callback.child_widget.status',
17281
17392
  payload: {
17282
17393
  status: 'error',
17283
- message: (event === null || event === void 0 ? void 0 : event.event) || 'error in 3ds widget'
17394
+ message: message
17284
17395
  }
17285
17396
  }).then(function () {
17286
17397
  return console.info('callback.child_widget.status: - errorEvent');
@@ -18647,10 +18758,16 @@ function getCheckoutVersionHandler(version) {
18647
18758
  }
18648
18759
  }
18649
18760
 
18761
+ /** Event name emitted when a checkout payment completes successfully. */
18762
+ var PAYMENT_SUCCESSFUL = 'paymentSuccessful';
18763
+ /** Event name emitted when a checkout payment fails. */
18764
+ var PAYMENT_FAILURE = 'paymentFailure';
18765
+ /** Event name emitted when a checkout session expires. */
18766
+ var PAYMENT_EXPIRED = 'paymentExpired';
18650
18767
  var EVENT$2 = {
18651
- PAYMENT_SUCCESSFUL: 'paymentSuccessful',
18652
- PAYMENT_FAILURE: 'paymentFailure',
18653
- PAYMENT_EXPIRED: 'paymentExpired'
18768
+ PAYMENT_SUCCESSFUL: PAYMENT_SUCCESSFUL,
18769
+ PAYMENT_FAILURE: PAYMENT_FAILURE,
18770
+ PAYMENT_EXPIRED: PAYMENT_EXPIRED
18654
18771
  };
18655
18772
  /**
18656
18773
  * Class CheckoutButton transform usual button into checkout
@@ -18675,7 +18792,7 @@ var Checkout = /*#__PURE__*/function () {
18675
18792
  this.checkoutFinished = false;
18676
18793
  try {
18677
18794
  this.eventEmitter = new EventEmitter();
18678
- this.intentTokenPayload = this.extractIntentTokenPayload(intentToken);
18795
+ this.intentTokenPayload = this.extractCheckoutIntentTokenPayload(intentToken);
18679
18796
  this.checkoutVersionHandler = getCheckoutVersionHandler(this.intentTokenPayload.version);
18680
18797
  this.instructions = this.initContractVersion();
18681
18798
  this.api = new ApiInternal(this.intentToken, API_AUTH_TYPE.TOKEN);
@@ -18736,8 +18853,8 @@ var Checkout = /*#__PURE__*/function () {
18736
18853
  }, 14 * 60 * 1000 + 45 * 1000);
18737
18854
  }
18738
18855
  }, {
18739
- key: "extractIntentTokenPayload",
18740
- value: function extractIntentTokenPayload(intentToken) {
18856
+ key: "extractCheckoutIntentTokenPayload",
18857
+ value: function extractCheckoutIntentTokenPayload(intentToken) {
18741
18858
  var tokenContent = AccessToken.validateJWT(intentToken);
18742
18859
  if (!tokenContent) {
18743
18860
  throw new Error('Intent token is broken or expired. Please, issue new one.');
@@ -18765,7 +18882,7 @@ var Checkout = /*#__PURE__*/function () {
18765
18882
  value: function ready() {
18766
18883
  var _this3 = this;
18767
18884
  this.changeLoadingSpinnerVisibility(true);
18768
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
18885
+ // biome-ignore lint/suspicious/noExplicitAny: checkoutApi.status returns a dynamic shape whose fields are narrowed at the call-sites below
18769
18886
  this.checkoutApi.status(this.intentTokenPayload.intent_id).then(function (response) {
18770
18887
  if (!(response === null || response === void 0 ? void 0 : response.status)) {
18771
18888
  throw new Error('Checkout Intent Status structure inconsistent');
@@ -18874,8 +18991,8 @@ var Checkout = /*#__PURE__*/function () {
18874
18991
  * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
18875
18992
  *
18876
18993
  * @example
18877
- * widget.onPaymentInReview((data) => {
18878
- * console.log('Payment in fraud review');
18994
+ * widget.onPaymentExpired((data) => {
18995
+ * console.log('Payment session expired');
18879
18996
  * });
18880
18997
  */
18881
18998
  }, {
@@ -18996,6 +19113,7 @@ var OpenWalletButtons = /*#__PURE__*/function () {
18996
19113
  function OpenWalletButtons(selector, publicKeyOrAccessToken, serviceId, meta) {
18997
19114
  _classCallCheck(this, OpenWalletButtons);
18998
19115
  this.env = DEFAULT_ENV;
19116
+ this.isDisabled = false;
18999
19117
  this.onShippingOptionsChangeHandlerRegistered = false;
19000
19118
  // Runtime guard: TypeScript's `abstract` keyword exists only at compile time.
19001
19119
  // Without this check, instantiating the base class directly silently fails
@@ -19140,6 +19258,68 @@ var OpenWalletButtons = /*#__PURE__*/function () {
19140
19258
  _this.handleOnError(error instanceof Error ? error : new Error(String(error)), exports.ERROR_OPERATION.CONFIGURATION);
19141
19259
  });
19142
19260
  }
19261
+ /**
19262
+ * Enables the wallet button, restoring interactivity and visual appearance.
19263
+ * If the button was previously disabled via `disable()`, calling this method
19264
+ * re-enables clicks and removes the disabled visual state.
19265
+ *
19266
+ * Idempotent — calling on an already-enabled button has no effect.
19267
+ *
19268
+ * @example
19269
+ * button.enable();
19270
+ */
19271
+ }, {
19272
+ key: "enable",
19273
+ value: function enable() {
19274
+ this.isDisabled = false;
19275
+ this.applyDisabledStyles();
19276
+ }
19277
+ /**
19278
+ * Disables the wallet button, preventing clicks and applying a visual disabled state.
19279
+ * When disabled, the button appears grayed out (`opacity: 0.5`) and does not
19280
+ * respond to user interaction (`pointer-events: none`). For accessibility, the
19281
+ * `aria-disabled="true"` attribute is also set on the container.
19282
+ *
19283
+ * Programmatic clicks (e.g. invoked by the wallet provider's SDK) are blocked
19284
+ * by an explicit guard inside the click handler — the button's wallet service
19285
+ * checks the disabled state before processing.
19286
+ *
19287
+ * Idempotent — calling on an already-disabled button has no effect.
19288
+ * Safe to call before `load()` (no-throw); the styles are applied once the
19289
+ * container element exists.
19290
+ *
19291
+ * @example
19292
+ * button.disable();
19293
+ */
19294
+ }, {
19295
+ key: "disable",
19296
+ value: function disable() {
19297
+ this.isDisabled = true;
19298
+ this.applyDisabledStyles();
19299
+ }
19300
+ /**
19301
+ * Applies the disabled / enabled visual state to the container element.
19302
+ * Reads `this.isDisabled` and toggles the corresponding CSS + ARIA attributes.
19303
+ *
19304
+ * @private
19305
+ */
19306
+ }, {
19307
+ key: "applyDisabledStyles",
19308
+ value: function applyDisabledStyles() {
19309
+ var element = this.container.getElement();
19310
+ if (!element) {
19311
+ return;
19312
+ }
19313
+ if (this.isDisabled) {
19314
+ element.style.pointerEvents = 'none';
19315
+ element.style.opacity = '0.5';
19316
+ element.setAttribute('aria-disabled', 'true');
19317
+ } else {
19318
+ element.style.pointerEvents = '';
19319
+ element.style.opacity = '';
19320
+ element.removeAttribute('aria-disabled');
19321
+ }
19322
+ }
19143
19323
  /**
19144
19324
  * Current method can change environment. By default environment = sandbox.
19145
19325
  * Also we can change domain alias for this environment. By default domain_alias = paydock.com
@@ -19629,7 +19809,9 @@ var SERVICE_GROUP;
19629
19809
  * Returns `undefined` if the resulting object has no remaining properties.
19630
19810
  */
19631
19811
  function stripEmpty(obj) {
19632
- if (!obj || _typeof$1(obj) !== 'object') return undefined;
19812
+ if (!obj || _typeof$1(obj) !== 'object') {
19813
+ return undefined;
19814
+ }
19633
19815
  var result = {};
19634
19816
  for (var _i = 0, _Object$entries = Object.entries(obj); _i < _Object$entries.length; _i++) {
19635
19817
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
@@ -19678,13 +19860,30 @@ var OpenWalletService = /*#__PURE__*/function () {
19678
19860
  this.serviceGroup = SERVICE_GROUP.WALLET;
19679
19861
  }
19680
19862
  /**
19681
- * Creates a One-Time Token (OTT) by sending the payment data to the API.
19682
- * Emits {@link EVENT.SUCCESS} on success or {@link EVENT.ERROR} on failure.
19863
+ * Returns whether the wallet button is currently disabled.
19864
+ * Reads the `aria-disabled` attribute from the container element — set by the
19865
+ * button class via {@link OpenWalletButtons.disable} / {@link OpenWalletButtons.enable}.
19683
19866
  *
19684
- * @param data - The payment data including amount, shipping, billing, card info, and ref token.
19685
- * @returns A promise resolving to the OTT response.
19867
+ * Used to short-circuit click handlers in concrete wallet services for clicks
19868
+ * that bypass the DOM `pointer-events: none` guard (e.g. invoked by the wallet
19869
+ * provider's SDK callback).
19870
+ *
19871
+ * @returns `true` if the container is marked as disabled, `false` otherwise.
19686
19872
  */
19687
19873
  return _createClass(OpenWalletService, [{
19874
+ key: "isButtonDisabled",
19875
+ value: function isButtonDisabled() {
19876
+ var element = this.container.getElement();
19877
+ return (element === null || element === void 0 ? void 0 : element.getAttribute('aria-disabled')) === 'true';
19878
+ }
19879
+ /**
19880
+ * Creates a One-Time Token (OTT) by sending the payment data to the API.
19881
+ * Emits {@link EVENT.SUCCESS} on success or {@link EVENT.ERROR} on failure.
19882
+ *
19883
+ * @param data - The payment data including amount, shipping, billing, card info, and ref token.
19884
+ * @returns A promise resolving to the OTT response.
19885
+ */
19886
+ }, {
19688
19887
  key: "createOTT",
19689
19888
  value: function createOTT(data) {
19690
19889
  var _this = this;
@@ -20205,6 +20404,9 @@ var ApplePayOpenWalletService = /*#__PURE__*/function (_OpenWalletService) {
20205
20404
  key: "onApplePayButtonClicked",
20206
20405
  value: function onApplePayButtonClicked() {
20207
20406
  var _this7 = this;
20407
+ if (this.isButtonDisabled()) {
20408
+ return;
20409
+ }
20208
20410
  var applePayApiVersion = getSupportedApplePayVersion();
20209
20411
  if (applePayApiVersion === 0) {
20210
20412
  this.handleOnUnavailable('Apple Pay version not supported');
@@ -20955,6 +21157,9 @@ var GooglePayOpenWalletService = /*#__PURE__*/function (_OpenWalletService) {
20955
21157
  key: "onGooglePayButtonClicked",
20956
21158
  value: function onGooglePayButtonClicked() {
20957
21159
  var _this5 = this;
21160
+ if (this.isButtonDisabled()) {
21161
+ return;
21162
+ }
20958
21163
  if (this.processingButtonClick) {
20959
21164
  console.warn('Google Pay button clicked while processing.');
20960
21165
  return;
@@ -44481,8 +44686,11 @@ exports.AfterpayOnSiteMessaging = AfterpayOnSiteMessaging;
44481
44686
  exports.Api = Api;
44482
44687
  exports.ApplePayOpenWalletButton = ApplePayOpenWalletButton;
44483
44688
  exports.ApplePayWalletButtonExpress = ApplePayWalletButtonExpress;
44689
+ exports.CANVAS_3DS_EVENT = CANVAS_3DS_EVENT;
44484
44690
  exports.CHECKOUT_BUTTON_EVENT = CHECKOUT_BUTTON_EVENT;
44691
+ exports.CHECKOUT_EVENT = EVENT$2;
44485
44692
  exports.Canvas3ds = Canvas3ds;
44693
+ exports.Canvas3dsTokenFormat = Canvas3dsTokenFormat;
44486
44694
  exports.Checkout = Checkout;
44487
44695
  exports.ClickToPay = ClickToPay;
44488
44696
  exports.Configuration = Configuration;
@@ -44499,6 +44707,9 @@ exports.HtmlPaymentSourceWidget = HtmlPaymentSourceWidget;
44499
44707
  exports.HtmlWidget = HtmlWidget;
44500
44708
  exports.InstructionDebugger = InstructionDebugger;
44501
44709
  exports.MultiWidget = MultiWidget;
44710
+ exports.PAYMENT_EXPIRED = PAYMENT_EXPIRED;
44711
+ exports.PAYMENT_FAILURE = PAYMENT_FAILURE;
44712
+ exports.PAYMENT_SUCCESSFUL = PAYMENT_SUCCESSFUL;
44502
44713
  exports.PAYMENT_TYPE = PAYMENT_TYPE;
44503
44714
  exports.PayPalDataCollector = PayPalDataCollector;
44504
44715
  exports.PayPalSavePaymentSourceWidget = PayPalSavePaymentSourceWidget;