@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
@@ -1198,7 +1198,7 @@
1198
1198
  version: 'x-sdk-version',
1199
1199
  type: 'x-sdk-type'
1200
1200
  });
1201
- SDK._version = 'v1.143.0-beta';
1201
+ SDK._version = 'v1.144.0-beta';
1202
1202
 
1203
1203
  function isFunction(value) {
1204
1204
  return typeof value === 'function';
@@ -4808,127 +4808,162 @@
4808
4808
  }]);
4809
4809
  }(ApiBase);
4810
4810
 
4811
- var Url = /*#__PURE__*/function () {
4812
- function Url() {
4813
- _classCallCheck(this, Url);
4811
+ var WALLET_CAPTURE_LINK = '/v1/charges/wallet/capture';
4812
+ var WALLET_CALLBACK_LINK = '/v1/charges/wallet/callback';
4813
+ var STANDALONE_3DS_PROCESS_LINK = '/v1/charges/standalone-3ds/process';
4814
+ var STANDALONE_3DS_HANDLE_LINK = '/v1/charges/standalone-3ds/handle';
4815
+ var ApiChargeInternal = /*#__PURE__*/function () {
4816
+ function ApiChargeInternal(api) {
4817
+ _classCallCheck(this, ApiChargeInternal);
4818
+ this.api = api;
4814
4819
  }
4815
- return _createClass(Url, null, [{
4816
- key: "extendSearchParams",
4817
- value: function extendSearchParams(uri, key, val) {
4818
- return uri.replace(new RegExp("([?&]" + key + "(?=[=&#]|$)[^#&]*|(?=#|$))"), "&" + key + "=" + encodeURIComponent(val)).replace(/^([^?&]+)&/, "$1?");
4820
+ return _createClass(ApiChargeInternal, [{
4821
+ key: "walletCapture",
4822
+ value: function walletCapture(payload) {
4823
+ return this.api.getClientPromise('POST', WALLET_CAPTURE_LINK).send(payload);
4819
4824
  }
4820
4825
  }, {
4821
- key: "serialize",
4822
- value: function serialize(params) {
4823
- return Object.keys(params).map(function (key) {
4824
- return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
4825
- }).join('&');
4826
+ key: "walletCallback",
4827
+ value: function walletCallback(payload) {
4828
+ return this.api.getClientPromise('POST', WALLET_CALLBACK_LINK).send(payload);
4829
+ }
4830
+ }, {
4831
+ key: "standalone3dsProcess",
4832
+ value: function standalone3dsProcess(payload) {
4833
+ return this.api.getClientPromise('POST', STANDALONE_3DS_PROCESS_LINK).send(payload);
4834
+ }
4835
+ }, {
4836
+ key: "standalone3dsHandle",
4837
+ value: function standalone3dsHandle() {
4838
+ return this.api.getClientPromise('GET', STANDALONE_3DS_HANDLE_LINK).send(undefined);
4826
4839
  }
4827
4840
  }]);
4828
4841
  }();
4829
4842
 
4830
- var Uuid = /*#__PURE__*/function () {
4831
- function Uuid() {
4832
- _classCallCheck(this, Uuid);
4843
+ var CALLBACK_LINK = '/v1/checkouts/callback';
4844
+ var INSTRUCTION_LINK = '/v1/checkouts/instruction';
4845
+ var STATUS_LINK = '/v1/checkouts';
4846
+ var ApiCheckoutInternal = /*#__PURE__*/function () {
4847
+ function ApiCheckoutInternal(api) {
4848
+ _classCallCheck(this, ApiCheckoutInternal);
4849
+ this.api = api;
4850
+ this.getInstructionLink = function () {
4851
+ return "".concat(INSTRUCTION_LINK, "?time=").concat(Date.now());
4852
+ };
4833
4853
  }
4834
- return _createClass(Uuid, null, [{
4835
- key: "generate",
4836
- value: function generate() {
4837
- if (typeof window !== "undefined" && typeof window.crypto !== "undefined" && typeof window.crypto.getRandomValues !== "undefined") {
4838
- var buf = new Uint16Array(8);
4839
- window.crypto.getRandomValues(buf);
4840
- 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]);
4841
- } else {
4842
- return this.random() + this.random() + "-" + this.random() + "-" + this.random() + "-" + this.random() + "-" + this.random() + this.random() + this.random();
4843
- }
4854
+ return _createClass(ApiCheckoutInternal, [{
4855
+ key: "instructions",
4856
+ value: function instructions() {
4857
+ return this.api.requestObservable('GET', this.getInstructionLink(), {});
4844
4858
  }
4845
4859
  }, {
4846
- key: "hash",
4847
- value: function hash(number) {
4848
- var hash = number.toString(16);
4849
- while (hash.length < 4) {
4850
- hash = "0" + hash;
4851
- }
4852
- return hash;
4860
+ key: "callback",
4861
+ value: function callback(payload) {
4862
+ return this.api.getClientPromise('POST', CALLBACK_LINK).send(payload);
4853
4863
  }
4854
4864
  }, {
4855
- key: "random",
4856
- value: function random() {
4857
- return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
4865
+ key: "status",
4866
+ value: function status(id) {
4867
+ return this.api.getClientPromise('GET', "".concat(STATUS_LINK, "/").concat(id)).send('');
4858
4868
  }
4859
4869
  }]);
4860
4870
  }();
4861
4871
 
4862
- var WIDGET_LINK = '/remote-action';
4863
- var VAULT_DISPLAY_WIDGET_LINK = '/vault-display';
4864
- var PAYMENT_SOURCE_LINK = '/payment-sources';
4865
- var SECURE_3D = '/3ds/webhook';
4866
- var FLYPAY_LINK = '/wallet/flypay';
4867
- var FLYPAY_LOGO_LINK = '/images/coles-pay-logo.png';
4868
- var MESSAGE_WIDGET_LINK = '/message-widget';
4869
- var MASTERCARD_SRC = '/secure-remote-commerce/mastercard';
4870
- var Link = /*#__PURE__*/function () {
4871
- function Link(linkResource) {
4872
- _classCallCheck(this, Link);
4873
- this.params = {};
4874
- this.widgetId = Uuid.generate();
4875
- this.linkResource = linkResource;
4876
- this.env = new Env(WIDGET_URL);
4877
- this.setParams({
4878
- widget_id: this.widgetId
4879
- });
4872
+ var GET_WALLET_CONFIG = '/v1/gateways/:gateway_id/wallet-config';
4873
+ var ApiGatewayInternal = /*#__PURE__*/function () {
4874
+ function ApiGatewayInternal(api) {
4875
+ _classCallCheck(this, ApiGatewayInternal);
4876
+ this.api = api;
4880
4877
  }
4881
- return _createClass(Link, [{
4882
- key: "getNetUrl",
4883
- value: function getNetUrl() {
4884
- return this.env.getConf().url + this.linkResource;
4878
+ return _createClass(ApiGatewayInternal, [{
4879
+ key: "getWalletConfig",
4880
+ value: function getWalletConfig(gateway_id) {
4881
+ var url = GET_WALLET_CONFIG.replace(':gateway_id', gateway_id);
4882
+ return this.api.getClientPromise('GET', url).send(undefined);
4885
4883
  }
4886
- }, {
4887
- key: "getUrl",
4888
- value: function getUrl() {
4889
- var url = this.getNetUrl();
4890
- var params = this.getParams();
4891
- for (var key in params) {
4892
- if (params.hasOwnProperty(key)) url = Url.extendSearchParams(url, key, params[key]);
4893
- }
4894
- return url;
4884
+ }]);
4885
+ }();
4886
+
4887
+ var CREATE_OTT = '/v1/payment_sources/tokens';
4888
+ var CREATE_SESSION = '/v1/payment_sources/payment-session';
4889
+ var ApiPaymentSourceInternal = /*#__PURE__*/function () {
4890
+ function ApiPaymentSourceInternal(api) {
4891
+ _classCallCheck(this, ApiPaymentSourceInternal);
4892
+ this.api = api;
4893
+ }
4894
+ return _createClass(ApiPaymentSourceInternal, [{
4895
+ key: "createOTT",
4896
+ value: function createOTT(payload) {
4897
+ return this.api.getClientPromise('POST', CREATE_OTT).send(payload);
4895
4898
  }
4896
4899
  }, {
4897
- key: "setParams",
4898
- value: function setParams(params) {
4899
- this.params = _extends({}, this.params, params);
4900
+ key: "createSession",
4901
+ value: function createSession(payload) {
4902
+ return this.api.getClientPromise('POST', CREATE_SESSION).send(payload);
4900
4903
  }
4901
- }, {
4902
- key: "concatParams",
4903
- value: function concatParams(params) {
4904
- for (var key in params) {
4905
- if (!params.hasOwnProperty(key) || !params[key].length) continue;
4906
- if (typeof this.params[key] !== 'string') this.params[key] = '';
4907
- if (this.params[key].length) this.params[key] += ',' + params[key];else this.params[key] += params[key];
4908
- }
4904
+ }]);
4905
+ }();
4906
+
4907
+ var GET_CONFIG = '/v1/services/:service_id/config';
4908
+ var ApiServiceInternal = /*#__PURE__*/function () {
4909
+ function ApiServiceInternal(api) {
4910
+ _classCallCheck(this, ApiServiceInternal);
4911
+ this.api = api;
4912
+ }
4913
+ return _createClass(ApiServiceInternal, [{
4914
+ key: "getConfig",
4915
+ value: function getConfig(service_id) {
4916
+ var url = GET_CONFIG.replace(':service_id', service_id);
4917
+ return this.api.getClientPromise('GET', url).send(undefined);
4918
+ }
4919
+ }]);
4920
+ }();
4921
+ var SERVICE_TYPES;
4922
+ (function (SERVICE_TYPES) {
4923
+ SERVICE_TYPES["ACCERTIFY"] = "Accertify";
4924
+ SERVICE_TYPES["BOOKING"] = "Booking";
4925
+ SERVICE_TYPES["GPAYMENTS"] = "GPayments";
4926
+ SERVICE_TYPES["CLICK_TO_PAY"] = "ClickToPay";
4927
+ SERVICE_TYPES["MASTERCARD_NT"] = "MastercardSCOF";
4928
+ SERVICE_TYPES["VISA_NT"] = "VisaVTS";
4929
+ SERVICE_TYPES["FORTER"] = "Forter";
4930
+ SERVICE_TYPES["APPLE_PAY"] = "ApplePay";
4931
+ SERVICE_TYPES["GOOGLE_PAY"] = "GooglePay";
4932
+ })(SERVICE_TYPES || (SERVICE_TYPES = {}));
4933
+
4934
+ var ApiInternal = /*#__PURE__*/function (_ApiBase) {
4935
+ function ApiInternal() {
4936
+ _classCallCheck(this, ApiInternal);
4937
+ return _callSuper(this, ApiInternal, arguments);
4938
+ }
4939
+ _inherits(ApiInternal, _ApiBase);
4940
+ return _createClass(ApiInternal, [{
4941
+ key: "charge",
4942
+ value: function charge() {
4943
+ return new ApiChargeInternal(this);
4909
4944
  }
4910
4945
  }, {
4911
- key: "getParams",
4912
- value: function getParams() {
4913
- return this.params;
4946
+ key: "service",
4947
+ value: function service() {
4948
+ return new ApiServiceInternal(this);
4914
4949
  }
4915
4950
  }, {
4916
- key: "setEnv",
4917
- value: function setEnv(env, alias) {
4918
- this.env.setEnv(env, alias);
4951
+ key: "checkout",
4952
+ value: function checkout() {
4953
+ return new ApiCheckoutInternal(this);
4919
4954
  }
4920
4955
  }, {
4921
- key: "getEnv",
4922
- value: function getEnv() {
4923
- return this.env.getEnv();
4956
+ key: "gateway",
4957
+ value: function gateway() {
4958
+ return new ApiGatewayInternal(this);
4924
4959
  }
4925
4960
  }, {
4926
- key: "getBaseUrl",
4927
- value: function getBaseUrl() {
4928
- return this.env.getConf().url;
4961
+ key: "paymentSource",
4962
+ value: function paymentSource() {
4963
+ return new ApiPaymentSourceInternal(this);
4929
4964
  }
4930
4965
  }]);
4931
- }();
4966
+ }(ApiBase);
4932
4967
 
4933
4968
  var IFrame = /*#__PURE__*/function () {
4934
4969
  function IFrame(container) {
@@ -5125,10 +5160,10 @@
5125
5160
  }();
5126
5161
 
5127
5162
  var hiddenStyle = {
5128
- visibility: "hidden",
5129
- border: "0",
5130
- width: "0",
5131
- height: "0"
5163
+ visibility: 'hidden',
5164
+ border: '0',
5165
+ width: '0',
5166
+ height: '0'
5132
5167
  };
5133
5168
  var PROCESS_STANDALONE_3DS_STATUS;
5134
5169
  (function (PROCESS_STANDALONE_3DS_STATUS) {
@@ -5150,14 +5185,30 @@
5150
5185
  IFRAME_STATUS["TIMEOUT"] = "AuthTimedOut";
5151
5186
  IFRAME_STATUS["INVALID"] = "invalid_event";
5152
5187
  })(IFRAME_STATUS || (IFRAME_STATUS = {}));
5188
+ /**
5189
+ * Event name constants emitted during the Standalone 3DS (GPayments) flow.
5190
+ * Used internally by `GPaymentsService` and re-exported publicly as `CANVAS_3DS_EVENT`.
5191
+ */
5153
5192
  var GPAYMENTS_EVENT = {
5193
+ /** Authentication succeeded. Payload: `Canvas3dsAuthPayload`. */
5154
5194
  AUTH_SUCCESS: 'chargeAuthSuccess',
5195
+ /** Authentication failed — covers issuer rejection, iframe timeout (`AuthTimedOut`), and invalid-event outcomes. Payload: `Canvas3dsAuthPayload`. */
5155
5196
  AUTH_ERROR: 'chargeAuthReject',
5197
+ /** Decoupled authentication — issuer will authenticate out-of-band. Payload: `Canvas3dsAuthPayload`. */
5156
5198
  DECOUPLED: 'chargeAuthDecoupled',
5199
+ /** Challenge required — issuer demands user interaction. Payload: `Canvas3dsAuthPayload`. */
5157
5200
  CHALLENGE: 'chargeAuthChallenge',
5201
+ /** Informational signal emitted by the GPayments flow. Internal — not part of the public typed surface. */
5158
5202
  INFO: 'chargeAuthInfo',
5203
+ /** Error during the flow (network, parsing, etc.). Payload: `Canvas3dsErrorPayload`. */
5159
5204
  ERROR: 'error'
5160
5205
  };
5206
+ /**
5207
+ * Public alias for GPAYMENTS_EVENT. Same object reference — no behavioral change.
5208
+ * Prefer `CANVAS_3DS_EVENT` in public-facing code; `GPAYMENTS_EVENT` remains for
5209
+ * backwards-compatible internal usage.
5210
+ */
5211
+ var CANVAS_3DS_EVENT = GPAYMENTS_EVENT;
5161
5212
  var GPaymentsService = /*#__PURE__*/function () {
5162
5213
  function GPaymentsService(container, api, eventEmitter) {
5163
5214
  _classCallCheck(this, GPaymentsService);
@@ -5185,20 +5236,22 @@
5185
5236
  value: function initializeIFrames(initializationUrl, secondaryUrl, title) {
5186
5237
  var hideAuthorization = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
5187
5238
  var container = this.container.getElement();
5188
- if (!container) return;
5189
- var divAuthorization = document.createElement("div");
5190
- divAuthorization.setAttribute("id", "paydock_authorization_iframe");
5239
+ if (!container) {
5240
+ return;
5241
+ }
5242
+ var divAuthorization = document.createElement('div');
5243
+ divAuthorization.setAttribute('id', 'paydock_authorization_iframe');
5191
5244
  container.appendChild(divAuthorization);
5192
- this.browserAndChallengeContainer = new Container("#paydock_authorization_iframe");
5245
+ this.browserAndChallengeContainer = new Container('#paydock_authorization_iframe');
5193
5246
  this.iFrameAuthorization = new IFrame(this.browserAndChallengeContainer);
5194
5247
  this.iFrameAuthorization.load(initializationUrl, {
5195
5248
  title: title
5196
5249
  });
5197
5250
  if (secondaryUrl) {
5198
- var divSecondaryURL = document.createElement("div");
5199
- divSecondaryURL.setAttribute("id", "paydock_secondary_iframe");
5251
+ var divSecondaryURL = document.createElement('div');
5252
+ divSecondaryURL.setAttribute('id', 'paydock_secondary_iframe');
5200
5253
  container.appendChild(divSecondaryURL);
5201
- this.monitoringContainer = new Container("#paydock_secondary_iframe");
5254
+ this.monitoringContainer = new Container('#paydock_secondary_iframe');
5202
5255
  this.iFrameSecondaryUrl = new IFrame(this.monitoringContainer);
5203
5256
  this.iFrameSecondaryUrl.load(secondaryUrl, {
5204
5257
  title: title
@@ -5214,8 +5267,12 @@
5214
5267
  var hideAuthorization = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
5215
5268
  var _a;
5216
5269
  for (var prop in hiddenStyle) {
5217
- if (!hiddenStyle.hasOwnProperty(prop)) continue;
5218
- if (hideAuthorization) this.iFrameAuthorization.setStyle(prop, hiddenStyle[prop]);
5270
+ if (!Object.hasOwn(hiddenStyle, prop)) {
5271
+ continue;
5272
+ }
5273
+ if (hideAuthorization) {
5274
+ this.iFrameAuthorization.setStyle(prop, hiddenStyle[prop]);
5275
+ }
5219
5276
  (_a = this.iFrameSecondaryUrl) === null || _a === void 0 ? void 0 : _a.setStyle(prop, hiddenStyle[prop]);
5220
5277
  }
5221
5278
  }
@@ -5225,13 +5282,17 @@
5225
5282
  var _this = this;
5226
5283
  this.iFrameEvent.on(EVENT$4.CHARGE_AUTH, widgetId, function (data) {
5227
5284
  if (data.status === IFRAME_STATUS.SKIPPED || data.status === IFRAME_STATUS.FINISHED) {
5228
- if (data.info) _this.eventEmitter.emit(GPAYMENTS_EVENT.INFO, {
5229
- info: data.info
5230
- });
5285
+ if (data.info) {
5286
+ _this.eventEmitter.emit(GPAYMENTS_EVENT.INFO, {
5287
+ info: data.info
5288
+ });
5289
+ }
5231
5290
  _this.performAuthentication(data);
5232
- } else if (data.status === IFRAME_STATUS.TIMEOUT || data.status === IFRAME_STATUS.INVALID) _this.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this.parseHandleResponse({
5233
- status: data.status
5234
- }, data.charge_3ds_id));
5291
+ } else if (data.status === IFRAME_STATUS.TIMEOUT || data.status === IFRAME_STATUS.INVALID) {
5292
+ _this.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this.parseHandleResponse({
5293
+ status: data.status
5294
+ }, data.charge_3ds_id));
5295
+ }
5235
5296
  });
5236
5297
  this.iFrameEvent.on(EVENT$4.CHARGE_AUTH_SUCCESS, widgetId, function (data) {
5237
5298
  _this.processResult(data.charge_3ds_id);
@@ -5271,13 +5332,19 @@
5271
5332
  key: "processResult",
5272
5333
  value: function processResult(charge3dsId) {
5273
5334
  var _this2 = this;
5274
- if (this.resultRead) return;
5335
+ if (this.resultRead) {
5336
+ return;
5337
+ }
5275
5338
  this.resultRead = true;
5276
5339
  this.api.charge().standalone3dsHandle().then(function (result) {
5277
5340
  var _a;
5278
5341
  _this2.iFrameAuthorization.remove();
5279
5342
  (_a = _this2.iFrameSecondaryUrl) === null || _a === void 0 ? void 0 : _a.remove();
5280
- 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));
5343
+ if (result.status === PROCESS_STANDALONE_3DS_STATUS.SUCCESS) {
5344
+ _this2.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this2.parseResultData(result, charge3dsId));
5345
+ } else {
5346
+ _this2.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this2.parseResultData(result, charge3dsId));
5347
+ }
5281
5348
  }, function (err) {
5282
5349
  _this2.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this2.parseError(err, charge3dsId));
5283
5350
  });
@@ -5302,10 +5369,16 @@
5302
5369
  key: "doPolling",
5303
5370
  value: function doPolling(url, charge3dsId) {
5304
5371
  var _this3 = this;
5305
- this.externalAPI("GET", url).then(function (data) {
5306
- if (!data.event || data.event === "AuthResultNotReady") setTimeout(function () {
5307
- _this3.doPolling(url, charge3dsId);
5308
- }, 2000);else if (data.event === 'AuthResultReady') _this3.processResult(charge3dsId);else throw new Error("Event not supported");
5372
+ this.externalAPI('GET', url).then(function (data) {
5373
+ if (!data.event || data.event === 'AuthResultNotReady') {
5374
+ setTimeout(function () {
5375
+ _this3.doPolling(url, charge3dsId);
5376
+ }, 2000);
5377
+ } else if (data.event === 'AuthResultReady') {
5378
+ _this3.processResult(charge3dsId);
5379
+ } else {
5380
+ throw new Error('Event not supported');
5381
+ }
5309
5382
  })["catch"](function (err) {
5310
5383
  return _this3.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this3.parseError(err, charge3dsId));
5311
5384
  });
@@ -5322,16 +5395,24 @@
5322
5395
  charge_3ds_id: charge_3ds_id
5323
5396
  }).then(function (authenticationResult) {
5324
5397
  var _a, _b;
5325
- 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) {
5398
+ if (authenticationResult.status === AUTHENTICATION_STATUS.SUCCESS) {
5399
+ _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
5400
+ } else if (authenticationResult.status === AUTHENTICATION_STATUS.PENDING) {
5326
5401
  if ((_a = authenticationResult === null || authenticationResult === void 0 ? void 0 : authenticationResult.result) === null || _a === void 0 ? void 0 : _a.challenge) {
5327
5402
  _this4.eventEmitter.emit(GPAYMENTS_EVENT.CHALLENGE, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
5328
5403
  _this4.initializeIFrames(authenticationResult.result.challenge_url, undefined, 'Authentication Challenge', false);
5329
- if (authenticationResult.result.secondary_url) _this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
5404
+ if (authenticationResult.result.secondary_url) {
5405
+ _this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
5406
+ }
5330
5407
  } else if ((_b = authenticationResult === null || authenticationResult === void 0 ? void 0 : authenticationResult.result) === null || _b === void 0 ? void 0 : _b.decoupled_challenge) {
5331
5408
  _this4.eventEmitter.emit(GPAYMENTS_EVENT.DECOUPLED, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
5332
- if (authenticationResult.result.secondary_url) _this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
5409
+ if (authenticationResult.result.secondary_url) {
5410
+ _this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
5411
+ }
5333
5412
  }
5334
- } else return _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
5413
+ } else {
5414
+ return _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
5415
+ }
5335
5416
  }, function (err) {
5336
5417
  _this4.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this4.parseError(err, charge_3ds_id));
5337
5418
  });
@@ -5339,192 +5420,159 @@
5339
5420
  }]);
5340
5421
  }();
5341
5422
 
5342
- var WALLET_CAPTURE_LINK = '/v1/charges/wallet/capture';
5343
- var WALLET_CALLBACK_LINK = '/v1/charges/wallet/callback';
5344
- var STANDALONE_3DS_PROCESS_LINK = '/v1/charges/standalone-3ds/process';
5345
- var STANDALONE_3DS_HANDLE_LINK = '/v1/charges/standalone-3ds/handle';
5346
- var ApiChargeInternal = /*#__PURE__*/function () {
5347
- function ApiChargeInternal(api) {
5348
- _classCallCheck(this, ApiChargeInternal);
5349
- this.api = api;
5423
+ var STANDALONE_3DS_GATEWAYS = {
5424
+ GPAYMENTS: 'GPayments'
5425
+ };
5426
+ var Standalone3dsService = /*#__PURE__*/function () {
5427
+ function Standalone3dsService(container, eventEmitter) {
5428
+ _classCallCheck(this, Standalone3dsService);
5429
+ this.env = DEFAULT_ENV;
5430
+ this.container = container;
5431
+ this.eventEmitter = eventEmitter;
5350
5432
  }
5351
- return _createClass(ApiChargeInternal, [{
5352
- key: "walletCapture",
5353
- value: function walletCapture(payload) {
5354
- return this.api.getClientPromise('POST', WALLET_CAPTURE_LINK).send(payload);
5355
- }
5356
- }, {
5357
- key: "walletCallback",
5358
- value: function walletCallback(payload) {
5359
- return this.api.getClientPromise('POST', WALLET_CALLBACK_LINK).send(payload);
5360
- }
5361
- }, {
5362
- key: "standalone3dsProcess",
5363
- value: function standalone3dsProcess(payload) {
5364
- return this.api.getClientPromise('POST', STANDALONE_3DS_PROCESS_LINK).send(payload);
5433
+ return _createClass(Standalone3dsService, [{
5434
+ key: "load",
5435
+ value: function load(token, options) {
5436
+ var parsedToken = AccessToken.validateJWT(token);
5437
+ if (!parsedToken) {
5438
+ throw new Error('Invalid charge token');
5439
+ }
5440
+ var tokenData = AccessToken.extractData(parsedToken.body);
5441
+ var api = new ApiInternal(token, API_AUTH_TYPE.TOKEN);
5442
+ api.setEnv(this.env, this.alias);
5443
+ switch (tokenData.service_type) {
5444
+ case STANDALONE_3DS_GATEWAYS.GPAYMENTS:
5445
+ new GPaymentsService(this.container, api, this.eventEmitter).load(tokenData, options.title);
5446
+ break;
5447
+ }
5365
5448
  }
5366
5449
  }, {
5367
- key: "standalone3dsHandle",
5368
- value: function standalone3dsHandle() {
5369
- return this.api.getClientPromise('GET', STANDALONE_3DS_HANDLE_LINK).send(undefined);
5450
+ key: "setEnv",
5451
+ value: function setEnv(env, alias) {
5452
+ this.env = env;
5453
+ this.alias = alias;
5370
5454
  }
5371
5455
  }]);
5372
5456
  }();
5373
5457
 
5374
- var CALLBACK_LINK = '/v1/checkouts/callback';
5375
- var INSTRUCTION_LINK = '/v1/checkouts/instruction';
5376
- var STATUS_LINK = '/v1/checkouts';
5377
- var ApiCheckoutInternal = /*#__PURE__*/function () {
5378
- function ApiCheckoutInternal(api) {
5379
- _classCallCheck(this, ApiCheckoutInternal);
5380
- this.api = api;
5381
- this.getInstructionLink = function () {
5382
- return "".concat(INSTRUCTION_LINK, "?time=").concat(Date.now());
5383
- };
5458
+ var Url = /*#__PURE__*/function () {
5459
+ function Url() {
5460
+ _classCallCheck(this, Url);
5384
5461
  }
5385
- return _createClass(ApiCheckoutInternal, [{
5386
- key: "instructions",
5387
- value: function instructions() {
5388
- return this.api.requestObservable('GET', this.getInstructionLink(), {});
5389
- }
5390
- }, {
5391
- key: "callback",
5392
- value: function callback(payload) {
5393
- return this.api.getClientPromise('POST', CALLBACK_LINK).send(payload);
5462
+ return _createClass(Url, null, [{
5463
+ key: "extendSearchParams",
5464
+ value: function extendSearchParams(uri, key, val) {
5465
+ return uri.replace(new RegExp("([?&]" + key + "(?=[=&#]|$)[^#&]*|(?=#|$))"), "&" + key + "=" + encodeURIComponent(val)).replace(/^([^?&]+)&/, "$1?");
5394
5466
  }
5395
5467
  }, {
5396
- key: "status",
5397
- value: function status(id) {
5398
- return this.api.getClientPromise('GET', "".concat(STATUS_LINK, "/").concat(id)).send('');
5399
- }
5400
- }]);
5401
- }();
5402
-
5403
- var GET_WALLET_CONFIG = '/v1/gateways/:gateway_id/wallet-config';
5404
- var ApiGatewayInternal = /*#__PURE__*/function () {
5405
- function ApiGatewayInternal(api) {
5406
- _classCallCheck(this, ApiGatewayInternal);
5407
- this.api = api;
5408
- }
5409
- return _createClass(ApiGatewayInternal, [{
5410
- key: "getWalletConfig",
5411
- value: function getWalletConfig(gateway_id) {
5412
- var url = GET_WALLET_CONFIG.replace(':gateway_id', gateway_id);
5413
- return this.api.getClientPromise('GET', url).send(undefined);
5468
+ key: "serialize",
5469
+ value: function serialize(params) {
5470
+ return Object.keys(params).map(function (key) {
5471
+ return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
5472
+ }).join('&');
5414
5473
  }
5415
5474
  }]);
5416
5475
  }();
5417
5476
 
5418
- var CREATE_OTT = '/v1/payment_sources/tokens';
5419
- var CREATE_SESSION = '/v1/payment_sources/payment-session';
5420
- var ApiPaymentSourceInternal = /*#__PURE__*/function () {
5421
- function ApiPaymentSourceInternal(api) {
5422
- _classCallCheck(this, ApiPaymentSourceInternal);
5423
- this.api = api;
5477
+ var Uuid = /*#__PURE__*/function () {
5478
+ function Uuid() {
5479
+ _classCallCheck(this, Uuid);
5424
5480
  }
5425
- return _createClass(ApiPaymentSourceInternal, [{
5426
- key: "createOTT",
5427
- value: function createOTT(payload) {
5428
- return this.api.getClientPromise('POST', CREATE_OTT).send(payload);
5481
+ return _createClass(Uuid, null, [{
5482
+ key: "generate",
5483
+ value: function generate() {
5484
+ if (typeof window !== "undefined" && typeof window.crypto !== "undefined" && typeof window.crypto.getRandomValues !== "undefined") {
5485
+ var buf = new Uint16Array(8);
5486
+ window.crypto.getRandomValues(buf);
5487
+ 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]);
5488
+ } else {
5489
+ return this.random() + this.random() + "-" + this.random() + "-" + this.random() + "-" + this.random() + "-" + this.random() + this.random() + this.random();
5490
+ }
5429
5491
  }
5430
5492
  }, {
5431
- key: "createSession",
5432
- value: function createSession(payload) {
5433
- return this.api.getClientPromise('POST', CREATE_SESSION).send(payload);
5493
+ key: "hash",
5494
+ value: function hash(number) {
5495
+ var hash = number.toString(16);
5496
+ while (hash.length < 4) {
5497
+ hash = "0" + hash;
5498
+ }
5499
+ return hash;
5434
5500
  }
5435
- }]);
5436
- }();
5437
-
5438
- var GET_CONFIG = '/v1/services/:service_id/config';
5439
- var ApiServiceInternal = /*#__PURE__*/function () {
5440
- function ApiServiceInternal(api) {
5441
- _classCallCheck(this, ApiServiceInternal);
5442
- this.api = api;
5443
- }
5444
- return _createClass(ApiServiceInternal, [{
5445
- key: "getConfig",
5446
- value: function getConfig(service_id) {
5447
- var url = GET_CONFIG.replace(':service_id', service_id);
5448
- return this.api.getClientPromise('GET', url).send(undefined);
5501
+ }, {
5502
+ key: "random",
5503
+ value: function random() {
5504
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
5449
5505
  }
5450
5506
  }]);
5451
5507
  }();
5452
- var SERVICE_TYPES;
5453
- (function (SERVICE_TYPES) {
5454
- SERVICE_TYPES["ACCERTIFY"] = "Accertify";
5455
- SERVICE_TYPES["BOOKING"] = "Booking";
5456
- SERVICE_TYPES["GPAYMENTS"] = "GPayments";
5457
- SERVICE_TYPES["CLICK_TO_PAY"] = "ClickToPay";
5458
- SERVICE_TYPES["MASTERCARD_NT"] = "MastercardSCOF";
5459
- SERVICE_TYPES["VISA_NT"] = "VisaVTS";
5460
- SERVICE_TYPES["FORTER"] = "Forter";
5461
- SERVICE_TYPES["APPLE_PAY"] = "ApplePay";
5462
- SERVICE_TYPES["GOOGLE_PAY"] = "GooglePay";
5463
- })(SERVICE_TYPES || (SERVICE_TYPES = {}));
5464
5508
 
5465
- var ApiInternal = /*#__PURE__*/function (_ApiBase) {
5466
- function ApiInternal() {
5467
- _classCallCheck(this, ApiInternal);
5468
- return _callSuper(this, ApiInternal, arguments);
5509
+ var WIDGET_LINK = '/remote-action';
5510
+ var VAULT_DISPLAY_WIDGET_LINK = '/vault-display';
5511
+ var PAYMENT_SOURCE_LINK = '/payment-sources';
5512
+ var SECURE_3D = '/3ds/webhook';
5513
+ var FLYPAY_LINK = '/wallet/flypay';
5514
+ var FLYPAY_LOGO_LINK = '/images/coles-pay-logo.png';
5515
+ var MESSAGE_WIDGET_LINK = '/message-widget';
5516
+ var MASTERCARD_SRC = '/secure-remote-commerce/mastercard';
5517
+ var Link = /*#__PURE__*/function () {
5518
+ function Link(linkResource) {
5519
+ _classCallCheck(this, Link);
5520
+ this.params = {};
5521
+ this.widgetId = Uuid.generate();
5522
+ this.linkResource = linkResource;
5523
+ this.env = new Env(WIDGET_URL);
5524
+ this.setParams({
5525
+ widget_id: this.widgetId
5526
+ });
5469
5527
  }
5470
- _inherits(ApiInternal, _ApiBase);
5471
- return _createClass(ApiInternal, [{
5472
- key: "charge",
5473
- value: function charge() {
5474
- return new ApiChargeInternal(this);
5528
+ return _createClass(Link, [{
5529
+ key: "getNetUrl",
5530
+ value: function getNetUrl() {
5531
+ return this.env.getConf().url + this.linkResource;
5475
5532
  }
5476
5533
  }, {
5477
- key: "service",
5478
- value: function service() {
5479
- return new ApiServiceInternal(this);
5534
+ key: "getUrl",
5535
+ value: function getUrl() {
5536
+ var url = this.getNetUrl();
5537
+ var params = this.getParams();
5538
+ for (var key in params) {
5539
+ if (params.hasOwnProperty(key)) url = Url.extendSearchParams(url, key, params[key]);
5540
+ }
5541
+ return url;
5480
5542
  }
5481
5543
  }, {
5482
- key: "checkout",
5483
- value: function checkout() {
5484
- return new ApiCheckoutInternal(this);
5544
+ key: "setParams",
5545
+ value: function setParams(params) {
5546
+ this.params = _extends({}, this.params, params);
5485
5547
  }
5486
5548
  }, {
5487
- key: "gateway",
5488
- value: function gateway() {
5489
- return new ApiGatewayInternal(this);
5549
+ key: "concatParams",
5550
+ value: function concatParams(params) {
5551
+ for (var key in params) {
5552
+ if (!params.hasOwnProperty(key) || !params[key].length) continue;
5553
+ if (typeof this.params[key] !== 'string') this.params[key] = '';
5554
+ if (this.params[key].length) this.params[key] += ',' + params[key];else this.params[key] += params[key];
5555
+ }
5490
5556
  }
5491
5557
  }, {
5492
- key: "paymentSource",
5493
- value: function paymentSource() {
5494
- return new ApiPaymentSourceInternal(this);
5495
- }
5496
- }]);
5497
- }(ApiBase);
5498
-
5499
- var STANDALONE_3DS_GATEWAYS = {
5500
- GPAYMENTS: "GPayments"
5501
- };
5502
- var Standalone3dsService = /*#__PURE__*/function () {
5503
- function Standalone3dsService(container, eventEmitter) {
5504
- _classCallCheck(this, Standalone3dsService);
5505
- this.env = DEFAULT_ENV;
5506
- this.container = container;
5507
- this.eventEmitter = eventEmitter;
5508
- }
5509
- return _createClass(Standalone3dsService, [{
5510
- key: "load",
5511
- value: function load(token, options) {
5512
- var parsedToken = AccessToken.validateJWT(token);
5513
- if (!parsedToken) throw new Error("Invalid charge token");
5514
- var tokenData = AccessToken.extractData(parsedToken.body);
5515
- var api = new ApiInternal(token, API_AUTH_TYPE.TOKEN);
5516
- api.setEnv(this.env, this.alias);
5517
- switch (tokenData.service_type) {
5518
- case STANDALONE_3DS_GATEWAYS.GPAYMENTS:
5519
- new GPaymentsService(this.container, api, this.eventEmitter).load(tokenData, options.title);
5520
- break;
5521
- }
5558
+ key: "getParams",
5559
+ value: function getParams() {
5560
+ return this.params;
5522
5561
  }
5523
5562
  }, {
5524
5563
  key: "setEnv",
5525
5564
  value: function setEnv(env, alias) {
5526
- this.env = env;
5527
- this.alias = alias;
5565
+ this.env.setEnv(env, alias);
5566
+ }
5567
+ }, {
5568
+ key: "getEnv",
5569
+ value: function getEnv() {
5570
+ return this.env.getEnv();
5571
+ }
5572
+ }, {
5573
+ key: "getBaseUrl",
5574
+ value: function getBaseUrl() {
5575
+ return this.env.getConf().url;
5528
5576
  }
5529
5577
  }]);
5530
5578
  }();
@@ -5564,7 +5612,7 @@
5564
5612
  * @param {string} CHARGE_AUTH_CHALLENGE=chargeAuthChallenge
5565
5613
  * @param {string} CHARGE_AUTH_INFO=chargeAuthInfo
5566
5614
  * @param {string} ERROR=error
5567
- */
5615
+ */
5568
5616
  /**
5569
5617
  * Class Canvas3ds include method for working on html
5570
5618
  * @constructor
@@ -5600,13 +5648,21 @@
5600
5648
  *
5601
5649
  */
5602
5650
  function load() {
5603
- if (this.token.format === TOKEN_FORMAT$2.HTML) this.iFrame.loadFromHtml(this.token.content, {
5604
- title: '3d secure authentication'
5605
- }, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT$2.URL) this.iFrame.load(this.token.content, {
5606
- title: '3d secure authentication'
5607
- }, 'threeDSecure-iframe');else if (this.token.format === TOKEN_FORMAT$2.STANDALONE_3DS) this.standalone3dsService.load(this.token.content, {
5608
- title: '3d secure authentication'
5609
- });else console.error('Token contain unsupported payload');
5651
+ if (this.token.format === TOKEN_FORMAT$2.HTML) {
5652
+ this.iFrame.loadFromHtml(this.token.content, {
5653
+ title: '3d secure authentication'
5654
+ }, 'threeDSecure-iframe');
5655
+ } else if (this.token.format === TOKEN_FORMAT$2.URL) {
5656
+ this.iFrame.load(this.token.content, {
5657
+ title: '3d secure authentication'
5658
+ }, 'threeDSecure-iframe');
5659
+ } else if (this.token.format === TOKEN_FORMAT$2.STANDALONE_3DS) {
5660
+ this.standalone3dsService.load(this.token.content, {
5661
+ title: '3d secure authentication'
5662
+ });
5663
+ } else {
5664
+ console.error('Token contain unsupported payload');
5665
+ }
5610
5666
  }
5611
5667
  /**
5612
5668
  * Current method can change environment. By default environment = sandbox.
@@ -5623,7 +5679,9 @@
5623
5679
  this.link.setEnv(env, alias);
5624
5680
  this.standalone3dsService.setEnv(env, alias);
5625
5681
  for (var index in this.configs) {
5626
- if (!this.configs.hasOwnProperty(index)) continue;
5682
+ if (!Object.hasOwn(this.configs, index)) {
5683
+ continue;
5684
+ }
5627
5685
  this.configs[index].setEnv(env, alias);
5628
5686
  }
5629
5687
  }
@@ -5633,34 +5691,45 @@
5633
5691
  return this.link.getEnv();
5634
5692
  }
5635
5693
  /**
5636
- * Listen to events of widget
5694
+ * Listen to events of widget.
5637
5695
  *
5638
- * @example
5696
+ * Available event names are defined in {@link Canvas3dsEventMap} (typed) and
5697
+ * {@link CANVAS_3DS_EVENT} (string constants). Using a literal event name
5698
+ * narrows the callback payload via the typed overloads.
5639
5699
  *
5640
- * widget.on('chargeAuthReject', function (data) {
5641
- * console.log(data);
5700
+ * @example
5701
+ * // Callback form — payload is narrowed by the event name
5702
+ * widget.on('chargeAuthReject', (data) => {
5703
+ * console.log(data); // data is Canvas3dsAuthPayload | Canvas3dsChargeAuthEventPayload
5642
5704
  * });
5643
- * // or
5644
- * widget.on('chargeAuthReject').then(function (data) {
5645
- * console.log(data);
5705
+ *
5706
+ * // Promise form
5707
+ * widget.on('chargeAuthReject').then((data) => {
5708
+ * console.log(data);
5646
5709
  * });
5647
- * @param {string} eventName - Available event names [EVENT]{@link EVENT} [STANDALONE_3DS_EVENT]{@link STANDALONE_3DS_EVENT}
5648
- * @param {listener} [cb]
5649
- * @return {Promise<IEventData> | void}
5710
+ *
5711
+ * @param eventName - Event name from {@link Canvas3dsEventMap} or any string for dynamic events.
5712
+ * @param cb - Optional listener callback. If omitted, returns a Promise that resolves on the next emission.
5713
+ * @returns `void` when a callback is provided; otherwise a Promise that resolves with the event payload.
5650
5714
  */
5715
+ // biome-ignore lint/suspicious/noExplicitAny: implementation signature must accept any payload shape to satisfy all overloads above
5651
5716
  }, {
5652
5717
  key: "on",
5653
5718
  value: function on(eventName, cb) {
5654
5719
  var _this = this;
5655
5720
  if (this.token.format === TOKEN_FORMAT$2.STANDALONE_3DS) {
5656
- if (typeof cb === 'function') return this.eventEmitter.subscribe(eventName, cb);
5721
+ if (typeof cb === 'function') {
5722
+ return this.eventEmitter.subscribe(eventName, cb);
5723
+ }
5657
5724
  return new Promise(function (resolve) {
5658
5725
  return _this.eventEmitter.subscribe(eventName, function (res) {
5659
5726
  return resolve(res);
5660
5727
  });
5661
5728
  });
5662
5729
  } else {
5663
- if (typeof cb === 'function') return this.event.on(eventName, this.link.getParams().ref_id, cb);
5730
+ if (typeof cb === 'function') {
5731
+ return this.event.on(eventName, this.link.getParams().ref_id, cb);
5732
+ }
5664
5733
  return new Promise(function (resolve) {
5665
5734
  return _this.event.on(eventName, _this.link.getParams().ref_id, function (res) {
5666
5735
  return resolve(res);
@@ -5704,6 +5773,19 @@
5704
5773
  }]);
5705
5774
  }();
5706
5775
 
5776
+ /**
5777
+ * Public, tree-shakeable alias for the internal `TOKEN_FORMAT` enum in canvas-3ds.ts.
5778
+ * Mirrors the string values of that enum without exposing the private enum itself.
5779
+ */
5780
+ var Canvas3dsTokenFormat = {
5781
+ /** Token whose `content` is a complete HTML page. The SDK renders it inside an iframe. */
5782
+ HTML: 'html',
5783
+ /** Token whose `content` is a URL. The SDK loads it inside an iframe. */
5784
+ URL: 'url',
5785
+ /** Token whose `content` describes a standalone 3DS service (e.g. GPayments). The SDK delegates to that service's flow. */
5786
+ STANDALONE_3DS: 'standalone_3ds'
5787
+ };
5788
+
5707
5789
  var Spinner = /*#__PURE__*/function () {
5708
5790
  function Spinner() {
5709
5791
  _classCallCheck(this, Spinner);
@@ -12789,28 +12871,59 @@
12789
12871
  }
12790
12872
  }
12791
12873
 
12874
+ /**
12875
+ * Top-level classification of an error. Used by the SDK to route errors to the
12876
+ * right category in instrumentation and to give consumers a coarse-grained
12877
+ * tag for grouping/filtering. See {@link getErrorCategory} for the mapping
12878
+ * between {@link ERROR_CAUSE} and {@link ERROR_CATEGORY}.
12879
+ */
12792
12880
  var ERROR_CATEGORY = {
12881
+ /** SDK was misconfigured (missing keys, invalid options, etc.). */
12793
12882
  CONFIGURATION: 'configuration',
12883
+ /** Authentication or authorization failure. */
12794
12884
  IDENTITY: 'identity_access_management',
12885
+ /** SDK internal failure or upstream service problem. */
12795
12886
  INTERNAL: 'internal',
12887
+ /** Flow lifecycle event (user cancelled, aborted, etc.) — not a real fault. */
12796
12888
  PROCESS: 'process',
12889
+ /** Resource lookup failed or was rate-limited. */
12797
12890
  RESOURCE: 'resource',
12891
+ /** Invalid input or business-rule validation failure. */
12798
12892
  VALIDATION: 'validation'
12799
12893
  };
12894
+ /**
12895
+ * Concrete cause of an error. More specific than {@link ERROR_CATEGORY} —
12896
+ * useful for deciding programmatic responses (e.g. show a retry button only
12897
+ * when `cause` is `'service_unreachable'` or `'server_busy'`).
12898
+ */
12800
12899
  var ERROR_CAUSE = {
12900
+ /** Operation was aborted programmatically. */
12801
12901
  ABORTED: 'aborted',
12902
+ /** Caller has insufficient permissions for the operation. */
12802
12903
  ACCESS_FORBIDDEN: 'access_forbidden',
12904
+ /** Resource already exists when create was expected. */
12803
12905
  ALREADY_EXISTS: 'already_exists',
12906
+ /** User cancelled the flow (e.g. closed the wallet sheet). */
12804
12907
  CANCELED: 'canceled',
12908
+ /** SDK was instantiated or invoked with invalid configuration. */
12805
12909
  INVALID_CONFIGURATION: 'invalid_configuration',
12910
+ /** Input failed structural or business-rule validation. */
12806
12911
  INVALID_INPUT: 'invalid_input',
12912
+ /** Resource was not found by the backend. */
12807
12913
  NOT_FOUND: 'not_found',
12914
+ /** Operation is not supported in the current context or version. */
12808
12915
  NOT_IMPLEMENTED: 'not_implemented',
12916
+ /** Caller exceeded the allowed request rate. */
12809
12917
  RATE_LIMITED: 'rate_limited',
12918
+ /** Backend is healthy but currently overloaded — typically retryable. */
12810
12919
  SERVER_BUSY: 'server_busy',
12920
+ /** Backend or third-party service could not be reached — typically retryable. */
12811
12921
  SERVICE_UNREACHABLE: 'service_unreachable',
12922
+ /** Caller is not authenticated. */
12812
12923
  UNAUTHORIZED: 'unauthorized',
12924
+ /** Catch-all when no other cause applies. */
12813
12925
  UNKNOWN: 'unknown_error',
12926
+ /** Request was syntactically valid but semantically rejected. */
12814
12927
  UNPROCESSABLE_ENTITY: 'unprocessable_entity'
12815
12928
  };
12816
12929
  var EventError = /*#__PURE__*/function (_Error) {
@@ -14870,7 +14983,6 @@
14870
14983
  });
14871
14984
  canvas.on('chargeAuthReject', function () {
14872
14985
  var _a;
14873
- // **TODO add interface for chargeAuthReject event **//
14874
14986
  (_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
14875
14987
  _this.api.checkout().callback({
14876
14988
  event: 'callback.child_widget.status',
@@ -14887,13 +14999,13 @@
14887
14999
  });
14888
15000
  canvas.on('error', function (event) {
14889
15001
  var _a;
14890
- // **TODO add interface for error event **//
14891
15002
  (_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
15003
+ var message = (event && _typeof$1(event) === 'object' && 'event' in event ? event.event : null) || 'error in 3ds widget';
14892
15004
  _this.api.checkout().callback({
14893
15005
  event: 'callback.child_widget.status',
14894
15006
  payload: {
14895
15007
  status: 'error',
14896
- message: (event === null || event === void 0 ? void 0 : event.event) || 'error in 3ds widget'
15008
+ message: message
14897
15009
  }
14898
15010
  }).then(function () {
14899
15011
  return console.info('callback.child_widget.status: - errorEvent');
@@ -17261,7 +17373,6 @@
17261
17373
  });
17262
17374
  canvas.on('chargeAuthReject', function () {
17263
17375
  var _a;
17264
- // **TODO add interface for chargeAuthReject event **//
17265
17376
  (_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
17266
17377
  _this.api.checkout().callback({
17267
17378
  event: 'callback.child_widget.status',
@@ -17278,13 +17389,13 @@
17278
17389
  });
17279
17390
  canvas.on('error', function (event) {
17280
17391
  var _a;
17281
- // **TODO add interface for error event **//
17282
17392
  (_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
17393
+ var message = (event && _typeof$1(event) === 'object' && 'event' in event ? event.event : null) || 'error in 3ds widget';
17283
17394
  _this.api.checkout().callback({
17284
17395
  event: 'callback.child_widget.status',
17285
17396
  payload: {
17286
17397
  status: 'error',
17287
- message: (event === null || event === void 0 ? void 0 : event.event) || 'error in 3ds widget'
17398
+ message: message
17288
17399
  }
17289
17400
  }).then(function () {
17290
17401
  return console.info('callback.child_widget.status: - errorEvent');
@@ -18651,10 +18762,16 @@
18651
18762
  }
18652
18763
  }
18653
18764
 
18765
+ /** Event name emitted when a checkout payment completes successfully. */
18766
+ var PAYMENT_SUCCESSFUL = 'paymentSuccessful';
18767
+ /** Event name emitted when a checkout payment fails. */
18768
+ var PAYMENT_FAILURE = 'paymentFailure';
18769
+ /** Event name emitted when a checkout session expires. */
18770
+ var PAYMENT_EXPIRED = 'paymentExpired';
18654
18771
  var EVENT$2 = {
18655
- PAYMENT_SUCCESSFUL: 'paymentSuccessful',
18656
- PAYMENT_FAILURE: 'paymentFailure',
18657
- PAYMENT_EXPIRED: 'paymentExpired'
18772
+ PAYMENT_SUCCESSFUL: PAYMENT_SUCCESSFUL,
18773
+ PAYMENT_FAILURE: PAYMENT_FAILURE,
18774
+ PAYMENT_EXPIRED: PAYMENT_EXPIRED
18658
18775
  };
18659
18776
  /**
18660
18777
  * Class CheckoutButton transform usual button into checkout
@@ -18679,7 +18796,7 @@
18679
18796
  this.checkoutFinished = false;
18680
18797
  try {
18681
18798
  this.eventEmitter = new EventEmitter();
18682
- this.intentTokenPayload = this.extractIntentTokenPayload(intentToken);
18799
+ this.intentTokenPayload = this.extractCheckoutIntentTokenPayload(intentToken);
18683
18800
  this.checkoutVersionHandler = getCheckoutVersionHandler(this.intentTokenPayload.version);
18684
18801
  this.instructions = this.initContractVersion();
18685
18802
  this.api = new ApiInternal(this.intentToken, API_AUTH_TYPE.TOKEN);
@@ -18740,8 +18857,8 @@
18740
18857
  }, 14 * 60 * 1000 + 45 * 1000);
18741
18858
  }
18742
18859
  }, {
18743
- key: "extractIntentTokenPayload",
18744
- value: function extractIntentTokenPayload(intentToken) {
18860
+ key: "extractCheckoutIntentTokenPayload",
18861
+ value: function extractCheckoutIntentTokenPayload(intentToken) {
18745
18862
  var tokenContent = AccessToken.validateJWT(intentToken);
18746
18863
  if (!tokenContent) {
18747
18864
  throw new Error('Intent token is broken or expired. Please, issue new one.');
@@ -18769,7 +18886,7 @@
18769
18886
  value: function ready() {
18770
18887
  var _this3 = this;
18771
18888
  this.changeLoadingSpinnerVisibility(true);
18772
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
18889
+ // biome-ignore lint/suspicious/noExplicitAny: checkoutApi.status returns a dynamic shape whose fields are narrowed at the call-sites below
18773
18890
  this.checkoutApi.status(this.intentTokenPayload.intent_id).then(function (response) {
18774
18891
  if (!(response === null || response === void 0 ? void 0 : response.status)) {
18775
18892
  throw new Error('Checkout Intent Status structure inconsistent');
@@ -18878,8 +18995,8 @@
18878
18995
  * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
18879
18996
  *
18880
18997
  * @example
18881
- * widget.onPaymentInReview((data) => {
18882
- * console.log('Payment in fraud review');
18998
+ * widget.onPaymentExpired((data) => {
18999
+ * console.log('Payment session expired');
18883
19000
  * });
18884
19001
  */
18885
19002
  }, {
@@ -19000,6 +19117,7 @@
19000
19117
  function OpenWalletButtons(selector, publicKeyOrAccessToken, serviceId, meta) {
19001
19118
  _classCallCheck(this, OpenWalletButtons);
19002
19119
  this.env = DEFAULT_ENV;
19120
+ this.isDisabled = false;
19003
19121
  this.onShippingOptionsChangeHandlerRegistered = false;
19004
19122
  // Runtime guard: TypeScript's `abstract` keyword exists only at compile time.
19005
19123
  // Without this check, instantiating the base class directly silently fails
@@ -19144,6 +19262,68 @@
19144
19262
  _this.handleOnError(error instanceof Error ? error : new Error(String(error)), exports.ERROR_OPERATION.CONFIGURATION);
19145
19263
  });
19146
19264
  }
19265
+ /**
19266
+ * Enables the wallet button, restoring interactivity and visual appearance.
19267
+ * If the button was previously disabled via `disable()`, calling this method
19268
+ * re-enables clicks and removes the disabled visual state.
19269
+ *
19270
+ * Idempotent — calling on an already-enabled button has no effect.
19271
+ *
19272
+ * @example
19273
+ * button.enable();
19274
+ */
19275
+ }, {
19276
+ key: "enable",
19277
+ value: function enable() {
19278
+ this.isDisabled = false;
19279
+ this.applyDisabledStyles();
19280
+ }
19281
+ /**
19282
+ * Disables the wallet button, preventing clicks and applying a visual disabled state.
19283
+ * When disabled, the button appears grayed out (`opacity: 0.5`) and does not
19284
+ * respond to user interaction (`pointer-events: none`). For accessibility, the
19285
+ * `aria-disabled="true"` attribute is also set on the container.
19286
+ *
19287
+ * Programmatic clicks (e.g. invoked by the wallet provider's SDK) are blocked
19288
+ * by an explicit guard inside the click handler — the button's wallet service
19289
+ * checks the disabled state before processing.
19290
+ *
19291
+ * Idempotent — calling on an already-disabled button has no effect.
19292
+ * Safe to call before `load()` (no-throw); the styles are applied once the
19293
+ * container element exists.
19294
+ *
19295
+ * @example
19296
+ * button.disable();
19297
+ */
19298
+ }, {
19299
+ key: "disable",
19300
+ value: function disable() {
19301
+ this.isDisabled = true;
19302
+ this.applyDisabledStyles();
19303
+ }
19304
+ /**
19305
+ * Applies the disabled / enabled visual state to the container element.
19306
+ * Reads `this.isDisabled` and toggles the corresponding CSS + ARIA attributes.
19307
+ *
19308
+ * @private
19309
+ */
19310
+ }, {
19311
+ key: "applyDisabledStyles",
19312
+ value: function applyDisabledStyles() {
19313
+ var element = this.container.getElement();
19314
+ if (!element) {
19315
+ return;
19316
+ }
19317
+ if (this.isDisabled) {
19318
+ element.style.pointerEvents = 'none';
19319
+ element.style.opacity = '0.5';
19320
+ element.setAttribute('aria-disabled', 'true');
19321
+ } else {
19322
+ element.style.pointerEvents = '';
19323
+ element.style.opacity = '';
19324
+ element.removeAttribute('aria-disabled');
19325
+ }
19326
+ }
19147
19327
  /**
19148
19328
  * Current method can change environment. By default environment = sandbox.
19149
19329
  * Also we can change domain alias for this environment. By default domain_alias = paydock.com
@@ -19633,7 +19813,9 @@
19633
19813
  * Returns `undefined` if the resulting object has no remaining properties.
19634
19814
  */
19635
19815
  function stripEmpty(obj) {
19636
- if (!obj || _typeof$1(obj) !== 'object') return undefined;
19816
+ if (!obj || _typeof$1(obj) !== 'object') {
19817
+ return undefined;
19818
+ }
19637
19819
  var result = {};
19638
19820
  for (var _i = 0, _Object$entries = Object.entries(obj); _i < _Object$entries.length; _i++) {
19639
19821
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
@@ -19682,13 +19864,30 @@
19682
19864
  this.serviceGroup = SERVICE_GROUP.WALLET;
19683
19865
  }
19684
19866
  /**
19685
- * Creates a One-Time Token (OTT) by sending the payment data to the API.
19686
- * Emits {@link EVENT.SUCCESS} on success or {@link EVENT.ERROR} on failure.
19867
+ * Returns whether the wallet button is currently disabled.
19868
+ * Reads the `aria-disabled` attribute from the container element — set by the
19869
+ * button class via {@link OpenWalletButtons.disable} / {@link OpenWalletButtons.enable}.
19687
19870
  *
19688
- * @param data - The payment data including amount, shipping, billing, card info, and ref token.
19689
- * @returns A promise resolving to the OTT response.
19871
+ * Used to short-circuit click handlers in concrete wallet services for clicks
19872
+ * that bypass the DOM `pointer-events: none` guard (e.g. invoked by the wallet
19873
+ * provider's SDK callback).
19874
+ *
19875
+ * @returns `true` if the container is marked as disabled, `false` otherwise.
19690
19876
  */
19691
19877
  return _createClass(OpenWalletService, [{
19878
+ key: "isButtonDisabled",
19879
+ value: function isButtonDisabled() {
19880
+ var element = this.container.getElement();
19881
+ return (element === null || element === void 0 ? void 0 : element.getAttribute('aria-disabled')) === 'true';
19882
+ }
19883
+ /**
19884
+ * Creates a One-Time Token (OTT) by sending the payment data to the API.
19885
+ * Emits {@link EVENT.SUCCESS} on success or {@link EVENT.ERROR} on failure.
19886
+ *
19887
+ * @param data - The payment data including amount, shipping, billing, card info, and ref token.
19888
+ * @returns A promise resolving to the OTT response.
19889
+ */
19890
+ }, {
19692
19891
  key: "createOTT",
19693
19892
  value: function createOTT(data) {
19694
19893
  var _this = this;
@@ -20209,6 +20408,9 @@
20209
20408
  key: "onApplePayButtonClicked",
20210
20409
  value: function onApplePayButtonClicked() {
20211
20410
  var _this7 = this;
20411
+ if (this.isButtonDisabled()) {
20412
+ return;
20413
+ }
20212
20414
  var applePayApiVersion = getSupportedApplePayVersion();
20213
20415
  if (applePayApiVersion === 0) {
20214
20416
  this.handleOnUnavailable('Apple Pay version not supported');
@@ -20959,6 +21161,9 @@
20959
21161
  key: "onGooglePayButtonClicked",
20960
21162
  value: function onGooglePayButtonClicked() {
20961
21163
  var _this5 = this;
21164
+ if (this.isButtonDisabled()) {
21165
+ return;
21166
+ }
20962
21167
  if (this.processingButtonClick) {
20963
21168
  console.warn('Google Pay button clicked while processing.');
20964
21169
  return;
@@ -44485,8 +44690,11 @@
44485
44690
  exports.Api = Api;
44486
44691
  exports.ApplePayOpenWalletButton = ApplePayOpenWalletButton;
44487
44692
  exports.ApplePayWalletButtonExpress = ApplePayWalletButtonExpress;
44693
+ exports.CANVAS_3DS_EVENT = CANVAS_3DS_EVENT;
44488
44694
  exports.CHECKOUT_BUTTON_EVENT = CHECKOUT_BUTTON_EVENT;
44695
+ exports.CHECKOUT_EVENT = EVENT$2;
44489
44696
  exports.Canvas3ds = Canvas3ds;
44697
+ exports.Canvas3dsTokenFormat = Canvas3dsTokenFormat;
44490
44698
  exports.Checkout = Checkout;
44491
44699
  exports.ClickToPay = ClickToPay;
44492
44700
  exports.Configuration = Configuration;
@@ -44503,6 +44711,9 @@
44503
44711
  exports.HtmlWidget = HtmlWidget;
44504
44712
  exports.InstructionDebugger = InstructionDebugger;
44505
44713
  exports.MultiWidget = MultiWidget;
44714
+ exports.PAYMENT_EXPIRED = PAYMENT_EXPIRED;
44715
+ exports.PAYMENT_FAILURE = PAYMENT_FAILURE;
44716
+ exports.PAYMENT_SUCCESSFUL = PAYMENT_SUCCESSFUL;
44506
44717
  exports.PAYMENT_TYPE = PAYMENT_TYPE;
44507
44718
  exports.PayPalDataCollector = PayPalDataCollector;
44508
44719
  exports.PayPalSavePaymentSourceWidget = PayPalSavePaymentSourceWidget;