@paydock/client-sdk 1.141.0 → 1.143.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 (37) hide show
  1. package/README.md +85 -0
  2. package/bundles/index.cjs +370 -204
  3. package/bundles/index.cjs.d.ts +535 -481
  4. package/bundles/index.mjs +205 -38
  5. package/bundles/index.mjs.d.ts +535 -481
  6. package/bundles/types/components/apple-pay-version.d.ts +29 -0
  7. package/bundles/types/components/apple-pay-version.d.ts.map +1 -0
  8. package/bundles/types/index.d.ts +2 -2
  9. package/bundles/types/index.d.ts.map +1 -1
  10. package/bundles/types/open-wallets/base/open-wallet-buttons.d.ts.map +1 -1
  11. package/bundles/types/open-wallets/index.d.ts +1 -1
  12. package/bundles/types/open-wallets/index.d.ts.map +1 -1
  13. package/bundles/types/open-wallets/services/apple-pay/apple-pay.open-wallet.service.d.ts.map +1 -1
  14. package/bundles/types/payment-source-widget/index.d.ts +1 -1
  15. package/bundles/types/payment-source-widget/index.d.ts.map +1 -1
  16. package/bundles/types/vault-display-widget/vault-display-widget.d.ts.map +1 -1
  17. package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts +1 -0
  18. package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts.map +1 -1
  19. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts +16 -0
  20. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
  21. package/bundles/types/wallet-buttons-express/index.d.ts +36 -0
  22. package/bundles/types/wallet-buttons-express/index.d.ts.map +1 -1
  23. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
  24. package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts +1 -1
  25. package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
  26. package/bundles/types/widget/html-multi-widget.d.ts +4 -1
  27. package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
  28. package/bundles/types/widget/index.d.ts +2 -1
  29. package/bundles/types/widget/index.d.ts.map +1 -1
  30. package/bundles/types/widget/widget-event-map.d.ts +37 -0
  31. package/bundles/types/widget/widget-event-map.d.ts.map +1 -0
  32. package/bundles/widget.umd.js +370 -204
  33. package/bundles/widget.umd.js.d.ts +535 -481
  34. package/bundles/widget.umd.js.min.d.ts +535 -481
  35. package/bundles/widget.umd.min.js +1 -1
  36. package/docs/wallet-buttons-express.md +85 -0
  37. package/package.json +12 -5
package/bundles/index.mjs CHANGED
@@ -1192,7 +1192,7 @@ SDK.headerKeys = Object.freeze({
1192
1192
  version: 'x-sdk-version',
1193
1193
  type: 'x-sdk-type'
1194
1194
  });
1195
- SDK._version = 'v1.141.0';
1195
+ SDK._version = 'v1.143.0-beta';
1196
1196
 
1197
1197
  function isFunction(value) {
1198
1198
  return typeof value === 'function';
@@ -8088,7 +8088,7 @@ var AfterPayWalletService = /*#__PURE__*/function (_WalletService) {
8088
8088
  }]);
8089
8089
  }(WalletService);
8090
8090
 
8091
- /*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */
8091
+ /*! @license DOMPurify 3.4.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.0/LICENSE */
8092
8092
 
8093
8093
  var purify_cjs;
8094
8094
  var hasRequiredPurify_cjs;
@@ -8296,7 +8296,7 @@ function requirePurify_cjs () {
8296
8296
 
8297
8297
  const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);
8298
8298
  const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
8299
- const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
8299
+ const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnalign', 'columnlines', 'columnspacing', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lquote', 'lspace', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
8300
8300
  const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
8301
8301
 
8302
8302
  // eslint-disable-next-line unicorn/better-regex
@@ -8393,7 +8393,7 @@ function requirePurify_cjs () {
8393
8393
  function createDOMPurify() {
8394
8394
  let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
8395
8395
  const DOMPurify = root => createDOMPurify(root);
8396
- DOMPurify.version = '3.3.3';
8396
+ DOMPurify.version = '3.4.0';
8397
8397
  DOMPurify.removed = [];
8398
8398
  if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
8399
8399
  // Not running in a browser, provide a factory function
@@ -8669,7 +8669,7 @@ function requirePurify_cjs () {
8669
8669
  NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
8670
8670
  MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
8671
8671
  HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
8672
- CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
8672
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || create(null);
8673
8673
  if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
8674
8674
  CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
8675
8675
  }
@@ -8709,13 +8709,10 @@ function requirePurify_cjs () {
8709
8709
  addToSet(ALLOWED_ATTR, xml);
8710
8710
  }
8711
8711
  }
8712
- /* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */
8713
- if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) {
8714
- EXTRA_ELEMENT_HANDLING.tagCheck = null;
8715
- }
8716
- if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) {
8717
- EXTRA_ELEMENT_HANDLING.attributeCheck = null;
8718
- }
8712
+ /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
8713
+ * leaking across calls when switching from function to array config */
8714
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
8715
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
8719
8716
  /* Merge configuration parameters */
8720
8717
  if (cfg.ADD_TAGS) {
8721
8718
  if (typeof cfg.ADD_TAGS === 'function') {
@@ -9038,6 +9035,11 @@ function requirePurify_cjs () {
9038
9035
  _forceRemove(currentNode);
9039
9036
  return true;
9040
9037
  }
9038
+ /* Remove risky CSS construction leading to mXSS */
9039
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
9040
+ _forceRemove(currentNode);
9041
+ return true;
9042
+ }
9041
9043
  /* Remove any occurrence of processing instructions */
9042
9044
  if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
9043
9045
  _forceRemove(currentNode);
@@ -9049,7 +9051,7 @@ function requirePurify_cjs () {
9049
9051
  return true;
9050
9052
  }
9051
9053
  /* Remove element if anything forbids its presence */
9052
- if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) {
9054
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
9053
9055
  /* Check if we have a custom element to handle */
9054
9056
  if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
9055
9057
  if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
@@ -9288,7 +9290,7 @@ function requirePurify_cjs () {
9288
9290
  *
9289
9291
  * @param fragment to iterate over recursively
9290
9292
  */
9291
- const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
9293
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
9292
9294
  let shadowNode = null;
9293
9295
  const shadowIterator = _createNodeIterator(fragment);
9294
9296
  /* Execute a hook if present */
@@ -9302,7 +9304,7 @@ function requirePurify_cjs () {
9302
9304
  _sanitizeAttributes(shadowNode);
9303
9305
  /* Deep shadow DOM detected */
9304
9306
  if (shadowNode.content instanceof DocumentFragment) {
9305
- _sanitizeShadowDOM(shadowNode.content);
9307
+ _sanitizeShadowDOM2(shadowNode.content);
9306
9308
  }
9307
9309
  }
9308
9310
  /* Execute a hook if present */
@@ -9397,7 +9399,7 @@ function requirePurify_cjs () {
9397
9399
  _sanitizeAttributes(currentNode);
9398
9400
  /* Shadow DOM detected, sanitize it */
9399
9401
  if (currentNode.content instanceof DocumentFragment) {
9400
- _sanitizeShadowDOM(currentNode.content);
9402
+ _sanitizeShadowDOM2(currentNode.content);
9401
9403
  }
9402
9404
  }
9403
9405
  /* If we sanitized `dirty` in-place, return it. */
@@ -9406,6 +9408,14 @@ function requirePurify_cjs () {
9406
9408
  }
9407
9409
  /* Return sanitized string or DOM */
9408
9410
  if (RETURN_DOM) {
9411
+ if (SAFE_FOR_TEMPLATES) {
9412
+ body.normalize();
9413
+ let html = body.innerHTML;
9414
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
9415
+ html = stringReplace(html, expr, ' ');
9416
+ });
9417
+ body.innerHTML = html;
9418
+ }
9409
9419
  if (RETURN_DOM_FRAGMENT) {
9410
9420
  returnNode = createDocumentFragment.call(body.ownerDocument);
9411
9421
  while (body.firstChild) {
@@ -10238,6 +10248,44 @@ var FlypayWalletService = /*#__PURE__*/function (_WalletService) {
10238
10248
  }]);
10239
10249
  }(WalletService);
10240
10250
 
10251
+ /**
10252
+ * Maximum Apple Pay JS API version the SDK targets.
10253
+ * Bump this when adopting features from a newer version.
10254
+ */
10255
+ var APPLE_PAY_MAX_VERSION = 14;
10256
+ /**
10257
+ * Minimum Apple Pay JS API version the SDK can operate with.
10258
+ *
10259
+ * Version 3 (iOS 11 / macOS 10.13) is required because the SDK uses:
10260
+ * - `ApplePayError` constructor
10261
+ * - Object-form `completeShippingContactSelection(update)`
10262
+ * - Object-form `completeShippingMethodSelection(update)`
10263
+ * - `supportedCountries` in payment requests
10264
+ *
10265
+ * All of these were introduced in version 3.
10266
+ */
10267
+ var APPLE_PAY_MIN_VERSION = 3;
10268
+ /**
10269
+ * Detects the highest Apple Pay JS API version the current device supports,
10270
+ * starting from {@link APPLE_PAY_MAX_VERSION} down to {@link APPLE_PAY_MIN_VERSION}.
10271
+ *
10272
+ * Returns `0` if Apple Pay is not available or the device does not support
10273
+ * the minimum required version.
10274
+ *
10275
+ * @see https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/supportsversion
10276
+ */
10277
+ function getSupportedApplePayVersion() {
10278
+ if (!window.ApplePaySession) {
10279
+ return 0;
10280
+ }
10281
+ for (var v = APPLE_PAY_MAX_VERSION; v >= APPLE_PAY_MIN_VERSION; v--) {
10282
+ if (ApplePaySession.supportsVersion(v)) {
10283
+ return v;
10284
+ }
10285
+ }
10286
+ return 0;
10287
+ }
10288
+
10241
10289
  var DEFAULT_APPLE_PAY_CAPABILITIES$2 = ['paymentCredentialsAvailable'];
10242
10290
  var AppleWalletService = /*#__PURE__*/function (_WalletService) {
10243
10291
  function AppleWalletService(publicKey, meta, gatewayName, eventEmitter) {
@@ -10566,13 +10614,32 @@ var AppleWalletService = /*#__PURE__*/function (_WalletService) {
10566
10614
  }, {
10567
10615
  key: "onApplePayButtonClicked",
10568
10616
  value: function onApplePayButtonClicked() {
10569
- this.paymentSession = new ApplePaySession(14, this.createRequest());
10617
+ var _this5 = this;
10618
+ var applePayApiVersion = getSupportedApplePayVersion();
10619
+ if (applePayApiVersion === 0) {
10620
+ this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, {
10621
+ wallet: WALLET_TYPE.APPLE
10622
+ });
10623
+ return;
10624
+ }
10625
+ this.paymentSession = new ApplePaySession(applePayApiVersion, this.createRequest());
10570
10626
  this.paymentSession.onvalidatemerchant = this.onValidateMerchant;
10571
10627
  this.paymentSession.onpaymentauthorized = this.onPaymentAuthorized;
10572
10628
  this.paymentSession.oncancel = this.onCancelPayment;
10573
10629
  this.paymentSession.onshippingcontactselected = this.onShippingContactSelected;
10574
10630
  this.paymentSession.onshippingmethodselected = this.onShippingMethodSelected;
10575
10631
  this.paymentSession.begin();
10632
+ // As part of PAYCA-2065 we detect that the paymentSession.onvalidatemerchant is not
10633
+ // executed if the browser is not safari. In that case, we handle it outside the
10634
+ // actual merchant validation function.
10635
+ var isIOS = /iPhone|iPad|iPod/.test(navigator.userAgent);
10636
+ var isDesktopRequestIOS = navigator.maxTouchPoints > 1 && /Macintosh/.test(navigator.userAgent);
10637
+ if (!window.safari && !isIOS && !isDesktopRequestIOS) {
10638
+ this.handleMerchantOnButtonClickEvent()["catch"](function (err) {
10639
+ console.error('Error while processing merchant callback', err);
10640
+ _this5.paymentSession.abort();
10641
+ });
10642
+ }
10576
10643
  }
10577
10644
  }, {
10578
10645
  key: "createRequest",
@@ -10616,22 +10683,22 @@ var AppleWalletService = /*#__PURE__*/function (_WalletService) {
10616
10683
  }, {
10617
10684
  key: "getMerchantSession",
10618
10685
  value: function getMerchantSession() {
10619
- var _this5 = this;
10686
+ var _this6 = this;
10620
10687
  return new Promise(function (resolve, reject) {
10621
- return _this5.eventEmitter.emit(WALLET_EVENT.CALLBACK, {
10688
+ return _this6.eventEmitter.emit(WALLET_EVENT.CALLBACK, {
10622
10689
  data: _extends({
10623
10690
  request_type: 'CREATE_SESSION',
10624
10691
  wallet_type: WALLET_TYPE.APPLE,
10625
10692
  session_id: window.location.hostname
10626
- }, _this5.isShippingRequired() && {
10627
- request_shipping: _this5.meta.request_shipping
10693
+ }, _this6.isShippingRequired() && {
10694
+ request_shipping: _this6.meta.request_shipping
10628
10695
  }),
10629
10696
  onSuccess: function onSuccess(res) {
10630
10697
  return resolve(res);
10631
10698
  },
10632
10699
  onError: function onError(message) {
10633
10700
  console.error('Error generating order id', message);
10634
- _this5.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
10701
+ _this6.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
10635
10702
  message: message
10636
10703
  });
10637
10704
  reject(message);
@@ -18928,6 +18995,13 @@ var OpenWalletButtons = /*#__PURE__*/function () {
18928
18995
  _classCallCheck(this, OpenWalletButtons);
18929
18996
  this.env = DEFAULT_ENV;
18930
18997
  this.onShippingOptionsChangeHandlerRegistered = false;
18998
+ // Runtime guard: TypeScript's `abstract` keyword exists only at compile time.
18999
+ // Without this check, instantiating the base class directly silently fails
19000
+ // later when `this.validateWalletMeta()` resolves to `undefined`, producing
19001
+ // a confusing "is not a function" error far from the actual mistake.
19002
+ if ((this instanceof OpenWalletButtons ? this.constructor : void 0) === OpenWalletButtons) {
19003
+ throw new Error('OpenWalletButtons is an abstract base class and cannot be instantiated directly. ' + 'Use ApplePayOpenWalletButton or GooglePayOpenWalletButton instead.');
19004
+ }
18931
19005
  this.eventEmitter = new EventEmitter();
18932
19006
  this.container = new Container(selector);
18933
19007
  this.api = new ApiInternal(publicKeyOrAccessToken, this.getApiAuthType(publicKeyOrAccessToken));
@@ -20128,25 +20202,42 @@ var ApplePayOpenWalletService = /*#__PURE__*/function (_OpenWalletService) {
20128
20202
  }, {
20129
20203
  key: "onApplePayButtonClicked",
20130
20204
  value: function onApplePayButtonClicked() {
20131
- this.paymentSession = new ApplePaySession(14, this.mapMetaToApplePayPaymentRequest());
20205
+ var _this7 = this;
20206
+ var applePayApiVersion = getSupportedApplePayVersion();
20207
+ if (applePayApiVersion === 0) {
20208
+ this.handleOnUnavailable('Apple Pay version not supported');
20209
+ return;
20210
+ }
20211
+ this.paymentSession = new ApplePaySession(applePayApiVersion, this.mapMetaToApplePayPaymentRequest());
20132
20212
  this.paymentSession.onvalidatemerchant = this.onValidateMerchant;
20133
20213
  this.paymentSession.onpaymentauthorized = this.onPaymentAuthorized;
20134
20214
  this.paymentSession.oncancel = this.onCancelPayment;
20135
20215
  this.paymentSession.onshippingcontactselected = this.onShippingContactUpdated;
20136
20216
  this.paymentSession.onshippingmethodselected = this.onShippingMethodUpdated;
20137
20217
  this.paymentSession.begin();
20218
+ // As part of PAYCA-2065 we detect that the paymentSession.onvalidatemerchant is not
20219
+ // executed if the browser is not safari. In that case, we handle it outside the
20220
+ // actual merchant validation function.
20221
+ var isIOS = /iPhone|iPad|iPod/.test(navigator.userAgent);
20222
+ var isDesktopRequestIOS = navigator.maxTouchPoints > 1 && /Macintosh/.test(navigator.userAgent);
20223
+ if (!window.safari && !isIOS && !isDesktopRequestIOS) {
20224
+ this.handleMerchantOnButtonClickEvent()["catch"](function (err) {
20225
+ console.error('Error while processing merchant callback', err);
20226
+ _this7.paymentSession.abort();
20227
+ });
20228
+ }
20138
20229
  }
20139
20230
  }, {
20140
20231
  key: "getMerchantSession",
20141
20232
  value: function getMerchantSession() {
20142
- var _this7 = this;
20233
+ var _this8 = this;
20143
20234
  return new Promise(function (resolve, reject) {
20144
- return _this7.api.paymentSource().createSession(_extends({
20145
- service_id: _this7.serviceId,
20235
+ return _this8.api.paymentSource().createSession(_extends({
20236
+ service_id: _this8.serviceId,
20146
20237
  session_id: window.location.hostname,
20147
- store_name: _this7.meta.store_name
20148
- }, _this7.isShippingRequired() && {
20149
- request_shipping: _this7.meta.request_shipping
20238
+ store_name: _this8.meta.store_name
20239
+ }, _this8.isShippingRequired() && {
20240
+ request_shipping: _this8.meta.request_shipping
20150
20241
  })).then(function (res) {
20151
20242
  resolve(res);
20152
20243
  })["catch"](function (err) {
@@ -22975,6 +23066,7 @@ var BaseWalletButton = /*#__PURE__*/function () {
22975
23066
  function BaseWalletButton(selector, publicKeyOrAccessToken, gatewayId, meta, requiredMetaFields) {
22976
23067
  _classCallCheck(this, BaseWalletButton);
22977
23068
  this.env = DEFAULT_ENV;
23069
+ this.isDisabled = false;
22978
23070
  this.onShippingOptionsChangeHandlerRegistered = false;
22979
23071
  this.eventEmitter = new EventEmitter();
22980
23072
  this.container = new Container(selector);
@@ -23007,6 +23099,30 @@ var BaseWalletButton = /*#__PURE__*/function () {
23007
23099
  this.env = env;
23008
23100
  this.api.setEnv(env, alias);
23009
23101
  }
23102
+ /**
23103
+ * Enables the wallet button, restoring interactivity and visual appearance.
23104
+ *
23105
+ * @example
23106
+ * button.enable();
23107
+ */
23108
+ }, {
23109
+ key: "enable",
23110
+ value: function enable() {
23111
+ this.isDisabled = false;
23112
+ this.applyDisabledStyles();
23113
+ }
23114
+ /**
23115
+ * Disables the wallet button, preventing clicks and applying a visual disabled state.
23116
+ *
23117
+ * @example
23118
+ * button.disable();
23119
+ */
23120
+ }, {
23121
+ key: "disable",
23122
+ value: function disable() {
23123
+ this.isDisabled = true;
23124
+ this.applyDisabledStyles();
23125
+ }
23010
23126
  /**
23011
23127
  * Callback for onClick method.
23012
23128
  *
@@ -23471,6 +23587,23 @@ var BaseWalletButton = /*#__PURE__*/function () {
23471
23587
  code: ((_c = err === null || err === void 0 ? void 0 : err.error) === null || _c === void 0 ? void 0 : _c.code) || (err === null || err === void 0 ? void 0 : err.code) || ((_d = err === null || err === void 0 ? void 0 : err.error_summary) === null || _d === void 0 ? void 0 : _d.code)
23472
23588
  };
23473
23589
  }
23590
+ }, {
23591
+ key: "applyDisabledStyles",
23592
+ value: function applyDisabledStyles() {
23593
+ var element = this.container.getElement();
23594
+ if (!element) {
23595
+ return;
23596
+ }
23597
+ if (this.isDisabled) {
23598
+ element.style.pointerEvents = 'none';
23599
+ element.style.opacity = '0.5';
23600
+ element.setAttribute('aria-disabled', 'true');
23601
+ } else {
23602
+ element.style.pointerEvents = '';
23603
+ element.style.opacity = '';
23604
+ element.removeAttribute('aria-disabled');
23605
+ }
23606
+ }
23474
23607
  }, {
23475
23608
  key: "validateRequiredMetaFields",
23476
23609
  value: function validateRequiredMetaFields(requiredMetaFields) {
@@ -23542,7 +23675,14 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
23542
23675
  _classCallCheck(this, ApplePayWalletButtonExpress);
23543
23676
  _this = _callSuper(this, ApplePayWalletButtonExpress, [selector, publicKeyOrAccessToken, gatewayId, meta, ['amount_label', 'country']]);
23544
23677
  _this.onApplePayButtonClicked = function () {
23545
- var applePayApiVersion = 14;
23678
+ if (_this.isDisabled) {
23679
+ return;
23680
+ }
23681
+ var applePayApiVersion = getSupportedApplePayVersion();
23682
+ if (applePayApiVersion === 0) {
23683
+ _this.handleOnUnavailable();
23684
+ return;
23685
+ }
23546
23686
  _this.paymentSession = new ApplePaySession(applePayApiVersion, _this.createRequest());
23547
23687
  _this.paymentSession.onvalidatemerchant = _this.onValidateMerchant;
23548
23688
  _this.paymentSession.onpaymentauthorized = _this.onPaymentAuthorized;
@@ -23550,6 +23690,17 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
23550
23690
  _this.paymentSession.onshippingmethodselected = _this.onApplePayShippingMethodUpdate;
23551
23691
  _this.paymentSession.onshippingcontactselected = _this.onApplePayShippingContactUpdate;
23552
23692
  _this.paymentSession.begin();
23693
+ // As part of PAYCA-2065 we detect that the paymentSession.onvalidatemerchant is not
23694
+ // executed if the browser is not safari. In that case, we handle it outside the
23695
+ // actual merchant validation function.
23696
+ var isIOS = /iPhone|iPad|iPod/.test(navigator.userAgent);
23697
+ var isDesktopRequestIOS = navigator.maxTouchPoints > 1 && /Macintosh/.test(navigator.userAgent);
23698
+ if (!window.safari && !isIOS && !isDesktopRequestIOS) {
23699
+ _this.handleMerchantOnExpressButtonClickEvent()["catch"](function (err) {
23700
+ console.error('Error while processing merchant callback', err);
23701
+ _this.paymentSession.abort();
23702
+ });
23703
+ }
23553
23704
  };
23554
23705
  _this.onValidateMerchant = function (event) {
23555
23706
  _this.handleMerchantOnExpressButtonClickEvent().then(function () {
@@ -23809,6 +23960,7 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
23809
23960
  return;
23810
23961
  }
23811
23962
  applePayButton.addEventListener('click', this.onApplePayButtonClicked.bind(this));
23963
+ this.applyDisabledStyles();
23812
23964
  }
23813
23965
  }, {
23814
23966
  key: "createRequest",
@@ -24001,13 +24153,20 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
24001
24153
  key: "load",
24002
24154
  value: function load() {
24003
24155
  var _this2 = this;
24004
- if (!window.Promise) return this.handleOnUnavailable();
24156
+ if (!window.Promise) {
24157
+ return this.handleOnUnavailable();
24158
+ }
24005
24159
  this.getGatewayWalletConfig().then(function (config) {
24006
- if (!config || config.type !== 'Paypal' || !config.credentials || !config.credentials.client_auth) throw new Error('Invalid configuration');
24160
+ if (!config || config.type !== 'Paypal' || !config.credentials || !config.credentials.client_auth) {
24161
+ throw new Error('Invalid configuration');
24162
+ }
24007
24163
  _this2.config = config;
24008
24164
  _this2.renderPaypalButton();
24165
+ _this2.applyDisabledStyles();
24009
24166
  })["catch"](function (err) {
24010
- if (err) _this2.handleOnError(err);
24167
+ if (err) {
24168
+ _this2.handleOnError(err);
24169
+ }
24011
24170
  _this2.handleOnUnavailable();
24012
24171
  });
24013
24172
  }
@@ -24024,6 +24183,7 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
24024
24183
  value: function setMeta(meta) {
24025
24184
  this.meta = meta;
24026
24185
  this.renderPaypalButton();
24186
+ this.applyDisabledStyles();
24027
24187
  }
24028
24188
  }, {
24029
24189
  key: "renderPaypalButton",
@@ -24040,7 +24200,7 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
24040
24200
  var _this3 = this;
24041
24201
  var _a, _b;
24042
24202
  var buttonId = ((_a = this.container.getElement()) === null || _a === void 0 ? void 0 : _a.id) || '';
24043
- var paypalScript = document.createElement("script");
24203
+ var paypalScript = document.createElement('script');
24044
24204
  paypalScript.src = "https://www.paypal.com/sdk/js?client-id=".concat((_b = this.config.credentials) === null || _b === void 0 ? void 0 : _b.client_auth, "&currency=").concat(this.meta.currency).concat(this.meta.pay_later === true ? '&enable-funding=paylater&disable-funding=card' : '&disable-funding=credit,card').concat(!this.meta.capture ? '&intent=authorize' : '');
24045
24205
  paypalScript.async = true;
24046
24206
  paypalScript.onload = function () {
@@ -24059,7 +24219,7 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
24059
24219
  var _this4 = this;
24060
24220
  var _a, _b, _c;
24061
24221
  var buttonId = ((_a = this.container.getElement()) === null || _a === void 0 ? void 0 : _a.id) || '';
24062
- var paypalScript = document.createElement("script");
24222
+ var paypalScript = document.createElement('script');
24063
24223
  // buyer-country is only used in Sandbox. It shouldn't be used in production. Based on buyer's geolocation this parameter determine which funding sources are eligible for a given buyer. Refer the link https://developer.paypal.com/sdk/js/configuration/#link-buyercountry
24064
24224
  paypalScript.src = "https://www.paypal.com/sdk/js?client-id=".concat((_b = this.config.credentials) === null || _b === void 0 ? void 0 : _b.client_auth, "&currency=").concat(this.meta.currency, "&components=buttons,funding-eligibility,messages&enable-funding=paylater").concat(!this.meta.capture ? '&intent=authorize' : '').concat(((_c = this.config) === null || _c === void 0 ? void 0 : _c.mode) === 'live' ? '' : '&buyer-country=AU');
24065
24225
  paypalScript.async = true;
@@ -24100,6 +24260,9 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
24100
24260
  style: this.meta.style
24101
24261
  }), {
24102
24262
  onClick: function onClick(_data, actions) {
24263
+ if (_this5.isDisabled) {
24264
+ return actions.reject();
24265
+ }
24103
24266
  return _this5.handleMerchantOnExpressButtonClickEvent().then(function () {
24104
24267
  return actions.resolve();
24105
24268
  })["catch"](function () {
@@ -24110,7 +24273,9 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
24110
24273
  createOrder: function createOrder() {
24111
24274
  return new Promise(function (resolve, reject) {
24112
24275
  var _a, _b;
24113
- if (!_this5.api.auth) return reject(new Error('Wallet Token not injected. Please handle onClick correctly.'));
24276
+ if (!_this5.api.auth) {
24277
+ return reject(new Error('Wallet Token not injected. Please handle onClick correctly.'));
24278
+ }
24114
24279
  var shipping = (_b = (_a = _this5.chargeWalletTokenMeta) === null || _a === void 0 ? void 0 : _a.charge) === null || _b === void 0 ? void 0 : _b.shipping;
24115
24280
  if (shipping) {
24116
24281
  var hasCompleteShippingAddress = ['address_line1', 'address_city', 'address_country', 'address_state', 'address_postcode'].every(function (key) {
@@ -24129,7 +24294,9 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
24129
24294
  });
24130
24295
  },
24131
24296
  onApprove: function onApprove(data) {
24132
- if (_this5.pendingApprovalPromise) return _this5.pendingApprovalPromise;
24297
+ if (_this5.pendingApprovalPromise) {
24298
+ return _this5.pendingApprovalPromise;
24299
+ }
24133
24300
  _this5.pendingApprovalPromise = _this5.executeWalletCapture({
24134
24301
  payment_method_id: data.orderID,
24135
24302
  customer: {
@@ -44307,4 +44474,4 @@ var browser = /*#__PURE__*/Object.freeze({
44307
44474
  zlibSync: zlibSync
44308
44475
  });
44309
44476
 
44310
- export { AfterpayCheckoutButton, AfterpayOnSiteMessaging, Api, ApplePayOpenWalletButton, ApplePayWalletButtonExpress, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, ClickToPay, Configuration, ELEMENT, ERROR_OPERATION, EVENT$5 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD$1 as FORM_FIELD, FRAUD_PREVENTION_EVENTS, FraudPreventionService, GooglePayOpenWalletButton, HtmlMultiWidget, HtmlPaymentSourceWidget, HtmlWidget, InstructionDebugger, MultiWidget, OpenWalletButtons, PAYMENT_TYPE, PURPOSE, PayPalDataCollector, PayPalSavePaymentSourceWidget, Builder as PaymentSourceBuilder, PaymentSourceWidget, PaypalCheckoutButton, PaypalWalletButtonExpress, STYLABLE_ELEMENT, STYLABLE_ELEMENT_STATE, STYLE$2 as STYLE, SUPPORTED_CARD_TYPES, TEXT, TOKEN_TYPE, TRIGGER$1 as TRIGGER, TYPE, VAULT_DISPLAY_STYLE, VaultDisplayWidget, WALLET_TYPES, WalletButtons, ZipmoneyCheckoutButton };
44477
+ export { AfterpayCheckoutButton, AfterpayOnSiteMessaging, Api, ApplePayOpenWalletButton, ApplePayWalletButtonExpress, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, ClickToPay, Configuration, ContactShippingEditingMode, ELEMENT, ERROR_OPERATION, EVENT$5 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD$1 as FORM_FIELD, FRAUD_PREVENTION_EVENTS, FraudPreventionService, GooglePayOpenWalletButton, HtmlMultiWidget, HtmlPaymentSourceWidget, HtmlWidget, InstructionDebugger, MultiWidget, PAYMENT_TYPE, PURPOSE, PayPalDataCollector, PayPalSavePaymentSourceWidget, Builder as PaymentSourceBuilder, PaymentSourceWidget, PaypalCheckoutButton, PaypalWalletButtonExpress, STYLABLE_ELEMENT, STYLABLE_ELEMENT_STATE, STYLE$2 as STYLE, SUPPORTED_CARD_TYPES, TEXT, TOKEN_TYPE, TRIGGER$1 as TRIGGER, TYPE, VAULT_DISPLAY_STYLE, VaultDisplayWidget, EVENT as WALLET_BUTTONS_EXPRESS_EVENT, WALLET_TYPES, WalletButtons, ZipmoneyCheckoutButton };