@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/README.md CHANGED
@@ -1761,7 +1761,7 @@ Tip: Prefer subscribing with the SdkEvent enum for stronger typing.
1761
1761
  <body>
1762
1762
  <div id="checkout"></div>
1763
1763
 
1764
- <script src="https://cdn.jsdelivr.net/npm/@paypercut/checkout-js@1.4.4/dist/paypercut-checkout.iife.min.js"></script>
1764
+ <script src="https://cdn.jsdelivr.net/npm/@paypercut/checkout-js@1.4.6/dist/paypercut-checkout.iife.min.js"></script>
1765
1765
  <script>
1766
1766
  const checkout = PaypercutCheckout({
1767
1767
  id: '01KB23M9EC960C50G3AH14FTTT',
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
4
- const SDK_VERSION = "1.4.4";
4
+ const SDK_VERSION = "1.4.6";
5
5
 
6
6
  const ELEMENTS_APPEARANCE_VARIABLE_NAMES = [
7
7
  'colorPrimary',
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "1.4.4";
1
+ const SDK_VERSION = "1.4.6";
2
2
 
3
3
  const ELEMENTS_APPEARANCE_VARIABLE_NAMES = [
4
4
  'colorPrimary',
package/dist/index.cjs CHANGED
@@ -105,7 +105,7 @@ class Emitter {
105
105
  }
106
106
  }
107
107
 
108
- const SDK_VERSION = "1.4.4";
108
+ const SDK_VERSION = "1.4.6";
109
109
 
110
110
  /**
111
111
  * Build-time configuration
@@ -4774,6 +4774,7 @@ class CardElementImpl {
4774
4774
  this.handleInitializationTimeout();
4775
4775
  return;
4776
4776
  }
4777
+ this.group.retryStalledControllerInitialization();
4777
4778
  const replacement = this.createFrame();
4778
4779
  const previousGeneration = this.componentGeneration;
4779
4780
  this.componentGeneration += 1;
@@ -5297,6 +5298,15 @@ const DEVELOPER_DISPLAY_OPTION_KEYS = [
5297
5298
  'buttonHeight',
5298
5299
  'buttonRadius',
5299
5300
  ];
5301
+ const CHECKOUT_DETAIL_OPTION_KEYS = [
5302
+ 'lineItems',
5303
+ 'emailRequired',
5304
+ 'phoneNumberRequired',
5305
+ 'billingAddressRequired',
5306
+ 'shippingAddressRequired',
5307
+ 'allowedShippingCountries',
5308
+ 'shippingRates',
5309
+ ];
5300
5310
  /**
5301
5311
  * Reviewable merchant-callback, layout, and payload limits for Express
5302
5312
  * Checkout. These are SDK behavior bounds, distinct from the cross-frame
@@ -5735,6 +5745,7 @@ class ExpressCheckoutElementImpl {
5735
5745
  }
5736
5746
  createFrame(options = this.options) {
5737
5747
  const iframe = document.createElement('iframe');
5748
+ const disableAnimations = this.group.getRenderableElementsOptions().appearance?.disableAnimations === true;
5738
5749
  iframe.id = `paypercut-express-checkout-element-${this.componentId}`;
5739
5750
  iframe.title = 'Express checkout';
5740
5751
  iframe.referrerPolicy = 'origin';
@@ -5763,8 +5774,8 @@ class ExpressCheckoutElementImpl {
5763
5774
  display: 'block',
5764
5775
  overflow: 'hidden',
5765
5776
  colorScheme: 'light dark',
5766
- transition: 'height 250ms ease-in-out, opacity 250ms ease-in-out',
5767
- willChange: 'height, opacity',
5777
+ transition: disableAnimations ? 'none' : 'height 250ms ease-in-out, opacity 250ms ease-in-out',
5778
+ willChange: disableAnimations ? 'auto' : 'height, opacity',
5768
5779
  });
5769
5780
  return iframe;
5770
5781
  }
@@ -6040,7 +6051,7 @@ class ExpressCheckoutElementImpl {
6040
6051
  this.activeAttempt.approved = true;
6041
6052
  }
6042
6053
  this.activeOptions = structuredCloneSafe(this.options);
6043
- this.group.resolveWalletClick(this.componentId, requestId, true, this.options);
6054
+ this.group.resolveWalletClick(this.componentId, requestId, true, checkoutDetailOptions(this.options));
6044
6055
  return;
6045
6056
  }
6046
6057
  let settled = false;
@@ -6756,19 +6767,8 @@ class ExpressCheckoutElementImpl {
6756
6767
  }
6757
6768
  const OPTION_KEYS = new Set([
6758
6769
  'paymentMethodOrder',
6759
- 'paymentMethods',
6760
- 'layout',
6761
- 'buttonType',
6762
- 'buttonTheme',
6763
- 'buttonHeight',
6764
- 'buttonRadius',
6765
- 'emailRequired',
6766
- 'phoneNumberRequired',
6767
- 'billingAddressRequired',
6768
- 'shippingAddressRequired',
6769
- 'allowedShippingCountries',
6770
- 'lineItems',
6771
- 'shippingRates',
6770
+ ...DEVELOPER_DISPLAY_OPTION_KEYS,
6771
+ ...CHECKOUT_DETAIL_OPTION_KEYS,
6772
6772
  ]);
6773
6773
  function developerDisplayOptions(options) {
6774
6774
  return structuredCloneSafe({
@@ -6921,16 +6921,7 @@ function validateRows(rows, labelKey, requireId = false) {
6921
6921
  function validateClickResolveOptions(options) {
6922
6922
  if (options === undefined)
6923
6923
  return undefined;
6924
- const allowed = new Set([
6925
- 'amount',
6926
- 'lineItems',
6927
- 'emailRequired',
6928
- 'phoneNumberRequired',
6929
- 'billingAddressRequired',
6930
- 'shippingAddressRequired',
6931
- 'allowedShippingCountries',
6932
- 'shippingRates',
6933
- ]);
6924
+ const allowed = new Set(['amount', ...CHECKOUT_DETAIL_OPTION_KEYS]);
6934
6925
  if (!isRecord(options) || Object.keys(options).some((key) => !allowed.has(key))) {
6935
6926
  throw invalidOptions();
6936
6927
  }
@@ -6966,6 +6957,21 @@ function validateClickResolveOptions(options) {
6966
6957
  : {}),
6967
6958
  });
6968
6959
  }
6960
+ /**
6961
+ * Selects the checkout details a wallet click may carry. The hosted component
6962
+ * rejects a click resolution containing presentation options, so an
6963
+ * auto-approved wallet attempt must never forward the full element options.
6964
+ */
6965
+ function checkoutDetailOptions(options) {
6966
+ const details = {};
6967
+ for (const key of CHECKOUT_DETAIL_OPTION_KEYS) {
6968
+ if (options[key] !== undefined)
6969
+ Object.assign(details, { [key]: options[key] });
6970
+ }
6971
+ if (Object.keys(details).length === 0)
6972
+ return undefined;
6973
+ return validateClickResolveOptions(details);
6974
+ }
6969
6975
  function validatePaymentMethodOrder(order) {
6970
6976
  if (order !== undefined &&
6971
6977
  (!Array.isArray(order) ||
@@ -11755,6 +11761,29 @@ class ElementsGroupImpl {
11755
11761
  window.addEventListener('message', this.windowMessageHandler);
11756
11762
  (document.body ?? document.documentElement).appendChild(iframe);
11757
11763
  }
11764
+ retryStalledControllerInitialization() {
11765
+ const current = this.controllerIframe;
11766
+ const parent = current?.parentNode;
11767
+ if (this.destroyed || this.controllerInitialized || !current || !parent)
11768
+ return false;
11769
+ // A component-only reload cannot recover a controller whose session request
11770
+ // or bootstrap never completed. Keep the group and its pending components,
11771
+ // but give the controller a fresh browsing context and navigation identity.
11772
+ let replacement;
11773
+ try {
11774
+ replacement = current.cloneNode(false);
11775
+ replacement.src = withElementsFrameNavigationIdentity(current.src, generateId());
11776
+ parent.replaceChild(replacement, current);
11777
+ }
11778
+ catch {
11779
+ return false;
11780
+ }
11781
+ this.controlPort?.close();
11782
+ this.controlPort = null;
11783
+ this.controllerBootstrapped = false;
11784
+ this.controllerIframe = replacement;
11785
+ return true;
11786
+ }
11758
11787
  attachComponent(element, port) {
11759
11788
  if (this.destroyed || !this.elements.has(element.componentId)) {
11760
11789
  port.close();