@paypercut/checkout-js 1.4.4 → 1.4.6

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.
package/dist/index.mjs CHANGED
@@ -100,7 +100,7 @@ class Emitter {
100
100
  }
101
101
  }
102
102
 
103
- const SDK_VERSION = "1.4.4";
103
+ const SDK_VERSION = "1.4.6";
104
104
 
105
105
  /**
106
106
  * Build-time configuration
@@ -4769,6 +4769,7 @@ class CardElementImpl {
4769
4769
  this.handleInitializationTimeout();
4770
4770
  return;
4771
4771
  }
4772
+ this.group.retryStalledControllerInitialization();
4772
4773
  const replacement = this.createFrame();
4773
4774
  const previousGeneration = this.componentGeneration;
4774
4775
  this.componentGeneration += 1;
@@ -5292,6 +5293,15 @@ const DEVELOPER_DISPLAY_OPTION_KEYS = [
5292
5293
  'buttonHeight',
5293
5294
  'buttonRadius',
5294
5295
  ];
5296
+ const CHECKOUT_DETAIL_OPTION_KEYS = [
5297
+ 'lineItems',
5298
+ 'emailRequired',
5299
+ 'phoneNumberRequired',
5300
+ 'billingAddressRequired',
5301
+ 'shippingAddressRequired',
5302
+ 'allowedShippingCountries',
5303
+ 'shippingRates',
5304
+ ];
5295
5305
  /**
5296
5306
  * Reviewable merchant-callback, layout, and payload limits for Express
5297
5307
  * Checkout. These are SDK behavior bounds, distinct from the cross-frame
@@ -5730,6 +5740,7 @@ class ExpressCheckoutElementImpl {
5730
5740
  }
5731
5741
  createFrame(options = this.options) {
5732
5742
  const iframe = document.createElement('iframe');
5743
+ const disableAnimations = this.group.getRenderableElementsOptions().appearance?.disableAnimations === true;
5733
5744
  iframe.id = `paypercut-express-checkout-element-${this.componentId}`;
5734
5745
  iframe.title = 'Express checkout';
5735
5746
  iframe.referrerPolicy = 'origin';
@@ -5758,8 +5769,8 @@ class ExpressCheckoutElementImpl {
5758
5769
  display: 'block',
5759
5770
  overflow: 'hidden',
5760
5771
  colorScheme: 'light dark',
5761
- transition: 'height 250ms ease-in-out, opacity 250ms ease-in-out',
5762
- willChange: 'height, opacity',
5772
+ transition: disableAnimations ? 'none' : 'height 250ms ease-in-out, opacity 250ms ease-in-out',
5773
+ willChange: disableAnimations ? 'auto' : 'height, opacity',
5763
5774
  });
5764
5775
  return iframe;
5765
5776
  }
@@ -6035,7 +6046,7 @@ class ExpressCheckoutElementImpl {
6035
6046
  this.activeAttempt.approved = true;
6036
6047
  }
6037
6048
  this.activeOptions = structuredCloneSafe(this.options);
6038
- this.group.resolveWalletClick(this.componentId, requestId, true, this.options);
6049
+ this.group.resolveWalletClick(this.componentId, requestId, true, checkoutDetailOptions(this.options));
6039
6050
  return;
6040
6051
  }
6041
6052
  let settled = false;
@@ -6751,19 +6762,8 @@ class ExpressCheckoutElementImpl {
6751
6762
  }
6752
6763
  const OPTION_KEYS = new Set([
6753
6764
  'paymentMethodOrder',
6754
- 'paymentMethods',
6755
- 'layout',
6756
- 'buttonType',
6757
- 'buttonTheme',
6758
- 'buttonHeight',
6759
- 'buttonRadius',
6760
- 'emailRequired',
6761
- 'phoneNumberRequired',
6762
- 'billingAddressRequired',
6763
- 'shippingAddressRequired',
6764
- 'allowedShippingCountries',
6765
- 'lineItems',
6766
- 'shippingRates',
6765
+ ...DEVELOPER_DISPLAY_OPTION_KEYS,
6766
+ ...CHECKOUT_DETAIL_OPTION_KEYS,
6767
6767
  ]);
6768
6768
  function developerDisplayOptions(options) {
6769
6769
  return structuredCloneSafe({
@@ -6916,16 +6916,7 @@ function validateRows(rows, labelKey, requireId = false) {
6916
6916
  function validateClickResolveOptions(options) {
6917
6917
  if (options === undefined)
6918
6918
  return undefined;
6919
- const allowed = new Set([
6920
- 'amount',
6921
- 'lineItems',
6922
- 'emailRequired',
6923
- 'phoneNumberRequired',
6924
- 'billingAddressRequired',
6925
- 'shippingAddressRequired',
6926
- 'allowedShippingCountries',
6927
- 'shippingRates',
6928
- ]);
6919
+ const allowed = new Set(['amount', ...CHECKOUT_DETAIL_OPTION_KEYS]);
6929
6920
  if (!isRecord(options) || Object.keys(options).some((key) => !allowed.has(key))) {
6930
6921
  throw invalidOptions();
6931
6922
  }
@@ -6961,6 +6952,21 @@ function validateClickResolveOptions(options) {
6961
6952
  : {}),
6962
6953
  });
6963
6954
  }
6955
+ /**
6956
+ * Selects the checkout details a wallet click may carry. The hosted component
6957
+ * rejects a click resolution containing presentation options, so an
6958
+ * auto-approved wallet attempt must never forward the full element options.
6959
+ */
6960
+ function checkoutDetailOptions(options) {
6961
+ const details = {};
6962
+ for (const key of CHECKOUT_DETAIL_OPTION_KEYS) {
6963
+ if (options[key] !== undefined)
6964
+ Object.assign(details, { [key]: options[key] });
6965
+ }
6966
+ if (Object.keys(details).length === 0)
6967
+ return undefined;
6968
+ return validateClickResolveOptions(details);
6969
+ }
6964
6970
  function validatePaymentMethodOrder(order) {
6965
6971
  if (order !== undefined &&
6966
6972
  (!Array.isArray(order) ||
@@ -11750,6 +11756,29 @@ class ElementsGroupImpl {
11750
11756
  window.addEventListener('message', this.windowMessageHandler);
11751
11757
  (document.body ?? document.documentElement).appendChild(iframe);
11752
11758
  }
11759
+ retryStalledControllerInitialization() {
11760
+ const current = this.controllerIframe;
11761
+ const parent = current?.parentNode;
11762
+ if (this.destroyed || this.controllerInitialized || !current || !parent)
11763
+ return false;
11764
+ // A component-only reload cannot recover a controller whose session request
11765
+ // or bootstrap never completed. Keep the group and its pending components,
11766
+ // but give the controller a fresh browsing context and navigation identity.
11767
+ let replacement;
11768
+ try {
11769
+ replacement = current.cloneNode(false);
11770
+ replacement.src = withElementsFrameNavigationIdentity(current.src, generateId());
11771
+ parent.replaceChild(replacement, current);
11772
+ }
11773
+ catch {
11774
+ return false;
11775
+ }
11776
+ this.controlPort?.close();
11777
+ this.controlPort = null;
11778
+ this.controllerBootstrapped = false;
11779
+ this.controllerIframe = replacement;
11780
+ return true;
11781
+ }
11753
11782
  attachComponent(element, port) {
11754
11783
  if (this.destroyed || !this.elements.has(element.componentId)) {
11755
11784
  port.close();