@paypercut/checkout-js 1.4.0 → 1.4.1

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.cjs CHANGED
@@ -105,7 +105,7 @@ class Emitter {
105
105
  }
106
106
  }
107
107
 
108
- const SDK_VERSION = "1.4.0";
108
+ const SDK_VERSION = "1.4.1";
109
109
 
110
110
  /**
111
111
  * Build-time configuration
@@ -3022,7 +3022,10 @@ function fileUrlFor(filename) {
3022
3022
  function resolveBrowserArtifactUrl(coreUrl) {
3023
3023
  const url = new URL(coreUrl);
3024
3024
  if (IIFE_ARTIFACT_PATH.test(url.pathname)) {
3025
- return new URL(DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT, url).href;
3025
+ const artifactUrl = new URL(DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT, url);
3026
+ artifactUrl.search = url.search;
3027
+ artifactUrl.hash = '';
3028
+ return artifactUrl.href;
3026
3029
  }
3027
3030
  if (/\.js$/.test(url.pathname)) {
3028
3031
  url.pathname = url.pathname.replace(/[^/]+$/, DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT);
@@ -3033,7 +3036,6 @@ function resolveBrowserArtifactUrl(coreUrl) {
3033
3036
  else {
3034
3037
  url.pathname = `${url.pathname.replace(/\/$/, '')}/dist/${DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT}`;
3035
3038
  }
3036
- url.search = '';
3037
3039
  url.hash = '';
3038
3040
  return url.href;
3039
3041
  }
@@ -3085,21 +3087,77 @@ function safelyUnregister(entry) {
3085
3087
  }
3086
3088
  entry.delegate = null;
3087
3089
  }
3090
+ function safelyAttach(entry, provider) {
3091
+ if (!entry.registered || entry.delegate)
3092
+ return;
3093
+ try {
3094
+ entry.delegate = provider.register(entry.target);
3095
+ }
3096
+ catch {
3097
+ // A target can register before its hosted component is ready. Keep the
3098
+ // provider available for the other targets and retry this one on refresh.
3099
+ }
3100
+ }
3101
+ function isTargetVisible(entry) {
3102
+ try {
3103
+ return entry.target.isVisible?.() ?? true;
3104
+ }
3105
+ catch {
3106
+ // Developer Assistance is optional. A stale owner node must never make the
3107
+ // merchant page fail while its visibility is being reconciled.
3108
+ return false;
3109
+ }
3110
+ }
3111
+ function syncAttachment(entry, registry) {
3112
+ if (!entry.registered)
3113
+ return;
3114
+ if (!isTargetVisible(entry)) {
3115
+ safelyUnregister(entry);
3116
+ return;
3117
+ }
3118
+ if (registry.provider?.version === SDK_VERSION) {
3119
+ safelyAttach(entry, registry.provider);
3120
+ return;
3121
+ }
3122
+ requestDeveloperAssistance(() => hasAttachedDeveloperAssistant(registry));
3123
+ }
3124
+ let visibilityObserver = null;
3125
+ function observeTargetVisibility(registry) {
3126
+ if (visibilityObserver ||
3127
+ typeof MutationObserver === 'undefined' ||
3128
+ typeof document === 'undefined' ||
3129
+ !document.documentElement) {
3130
+ return;
3131
+ }
3132
+ visibilityObserver = new MutationObserver(() => {
3133
+ for (const entry of registry.registrations)
3134
+ syncAttachment(entry, registry);
3135
+ });
3136
+ visibilityObserver.observe(document.documentElement, {
3137
+ attributes: true,
3138
+ attributeFilter: ['aria-hidden', 'class', 'hidden', 'style'],
3139
+ childList: true,
3140
+ subtree: true,
3141
+ });
3142
+ }
3143
+ function stopObservingTargetVisibilityIfIdle(registry) {
3144
+ if (registry.registrations.size > 0)
3145
+ return;
3146
+ visibilityObserver?.disconnect();
3147
+ visibilityObserver = null;
3148
+ }
3149
+ function hasAttachedDeveloperAssistant(registry) {
3150
+ if (registry.provider?.version !== SDK_VERSION)
3151
+ return false;
3152
+ return Array.from(registry.registrations).some((entry) => entry.registered && entry.delegate !== null);
3153
+ }
3088
3154
  function registerDeveloperAssistantTarget(target) {
3089
3155
  const registry = getRegistry();
3090
3156
  announceDeveloperAssistantCore();
3091
3157
  const entry = { target, delegate: null, registered: true };
3092
3158
  registry.registrations.add(entry);
3093
- requestDeveloperAssistance(() => registry.provider?.version === SDK_VERSION);
3094
- if (registry.provider?.version === SDK_VERSION) {
3095
- try {
3096
- entry.delegate = registry.provider.register(target);
3097
- }
3098
- catch {
3099
- // Developer Assistance is optional. A registration failure must not
3100
- // interrupt the Element lifecycle or payment flow.
3101
- }
3102
- }
3159
+ observeTargetVisibility(registry);
3160
+ syncAttachment(entry, registry);
3103
3161
  return {
3104
3162
  unregister() {
3105
3163
  if (!entry.registered)
@@ -3107,10 +3165,13 @@ function registerDeveloperAssistantTarget(target) {
3107
3165
  entry.registered = false;
3108
3166
  registry.registrations.delete(entry);
3109
3167
  safelyUnregister(entry);
3168
+ stopObservingTargetVisibilityIfIdle(registry);
3110
3169
  },
3111
3170
  refresh() {
3112
- if (entry.registered)
3113
- entry.delegate?.refresh();
3171
+ if (!entry.registered)
3172
+ return;
3173
+ syncAttachment(entry, registry);
3174
+ entry.delegate?.refresh();
3114
3175
  },
3115
3176
  collapse() {
3116
3177
  if (entry.registered)
@@ -3119,6 +3180,26 @@ function registerDeveloperAssistantTarget(target) {
3119
3180
  };
3120
3181
  }
3121
3182
 
3183
+ function isElementVisible(element) {
3184
+ if (!element?.isConnected)
3185
+ return false;
3186
+ for (let current = element; current; current = current.parentElement) {
3187
+ if (current.hidden ||
3188
+ current.inert ||
3189
+ current.getAttribute('aria-hidden') === 'true') {
3190
+ return false;
3191
+ }
3192
+ const style = current.ownerDocument.defaultView?.getComputedStyle(current);
3193
+ if (style?.display === 'none' ||
3194
+ style?.visibility === 'hidden' ||
3195
+ style?.visibility === 'collapse' ||
3196
+ style?.contentVisibility === 'hidden') {
3197
+ return false;
3198
+ }
3199
+ }
3200
+ return true;
3201
+ }
3202
+
3122
3203
  const FRAME_URL_LENGTH_WARNING_THRESHOLD = 4096;
3123
3204
  let hasWarnedAboutLongFrameUrl = false;
3124
3205
  const ELEMENTS_FRAME_NAVIGATION_QUERY = '__paypercut_navigation';
@@ -4875,6 +4956,7 @@ class CardElementImpl {
4875
4956
  configurationIdentity: this.group.configurationIdentity,
4876
4957
  appearanceScopeId: this.group.controllerId,
4877
4958
  presets,
4959
+ isVisible: () => isElementVisible(this.iframe?.parentElement ?? null),
4878
4960
  isAvailable: () => this.canApplyDeveloperPreset(),
4879
4961
  isAppearanceAvailable: () => this.isMounted(),
4880
4962
  appearancePreviewClearsTestData: () => true,
@@ -5069,6 +5151,100 @@ function patchApplePayModalFocus(modal, attempts = 0) {
5069
5151
  root.appendChild(style);
5070
5152
  }
5071
5153
 
5154
+ const GOOGLE_PAY_POPUP_RECOVERY_POLICY = {
5155
+ closedPollIntervalMs: 250,
5156
+ providerSettlementGraceMs: 3500,
5157
+ };
5158
+ /**
5159
+ * Captures the popup synchronously opened by a provider launch and supplies a
5160
+ * bounded fallback when the provider leaves its result promise pending after
5161
+ * the popup has actually closed.
5162
+ */
5163
+ const launchWithProviderPopupRecovery = (launch, onAbandoned, host = window) => {
5164
+ const originalOpen = host.open;
5165
+ let capturedPopup = null;
5166
+ let captureInstalled = false;
5167
+ let stopped = false;
5168
+ let pollTimer = null;
5169
+ let settlementTimer = null;
5170
+ const captureOpen = ((url, target, features) => {
5171
+ const popup = originalOpen.call(host, url, target, features);
5172
+ if (!capturedPopup && popup)
5173
+ capturedPopup = popup;
5174
+ return popup;
5175
+ });
5176
+ try {
5177
+ host.open = captureOpen;
5178
+ captureInstalled = host.open === captureOpen;
5179
+ }
5180
+ catch {
5181
+ captureInstalled = false;
5182
+ }
5183
+ let result;
5184
+ try {
5185
+ result = launch();
5186
+ }
5187
+ finally {
5188
+ if (captureInstalled && host.open === captureOpen)
5189
+ host.open = originalOpen;
5190
+ }
5191
+ const stop = () => {
5192
+ if (stopped)
5193
+ return;
5194
+ stopped = true;
5195
+ if (pollTimer !== null)
5196
+ host.clearTimeout(pollTimer);
5197
+ if (settlementTimer !== null)
5198
+ host.clearTimeout(settlementTimer);
5199
+ pollTimer = null;
5200
+ settlementTimer = null;
5201
+ capturedPopup = null;
5202
+ };
5203
+ const merchantDocumentHasFocus = () => {
5204
+ try {
5205
+ return host.document?.hasFocus() ?? true;
5206
+ }
5207
+ catch {
5208
+ return false;
5209
+ }
5210
+ };
5211
+ const poll = () => {
5212
+ if (stopped || !capturedPopup)
5213
+ return;
5214
+ let closed = false;
5215
+ try {
5216
+ closed = capturedPopup.closed;
5217
+ }
5218
+ catch {
5219
+ stop();
5220
+ return;
5221
+ }
5222
+ // Chrome can close Google's short-lived launcher window after handing the
5223
+ // flow to its native payment-handler window. The launcher closing is only
5224
+ // a customer dismissal once focus has returned to the merchant document.
5225
+ if (!closed || !merchantDocumentHasFocus()) {
5226
+ pollTimer = host.setTimeout(poll, GOOGLE_PAY_POPUP_RECOVERY_POLICY.closedPollIntervalMs);
5227
+ return;
5228
+ }
5229
+ pollTimer = null;
5230
+ settlementTimer = host.setTimeout(() => {
5231
+ if (stopped)
5232
+ return;
5233
+ settlementTimer = null;
5234
+ if (!merchantDocumentHasFocus()) {
5235
+ pollTimer = host.setTimeout(poll, GOOGLE_PAY_POPUP_RECOVERY_POLICY.closedPollIntervalMs);
5236
+ return;
5237
+ }
5238
+ stop();
5239
+ onAbandoned();
5240
+ }, GOOGLE_PAY_POPUP_RECOVERY_POLICY.providerSettlementGraceMs);
5241
+ };
5242
+ if (capturedPopup) {
5243
+ pollTimer = host.setTimeout(poll, GOOGLE_PAY_POPUP_RECOVERY_POLICY.closedPollIntervalMs);
5244
+ }
5245
+ return { result, stop };
5246
+ };
5247
+
5072
5248
  const MAX_IFRAME_HEIGHT = 4096;
5073
5249
  const EXPRESS_PREVIEW_INITIALIZATION_TIMEOUT_MS = 10000;
5074
5250
  const WALLET_OVERLAY_FALLBACK_Z_INDEX = '2147483647';
@@ -5148,6 +5324,7 @@ class ExpressCheckoutElementImpl {
5148
5324
  this.googlePayEnvironment = null;
5149
5325
  this.googlePayRequestId = null;
5150
5326
  this.googlePayProcessingRequestId = null;
5327
+ this.googlePayPopupRecovery = null;
5151
5328
  this.googlePayUpdates = new Map();
5152
5329
  this.googlePayAuthorization = null;
5153
5330
  this.googlePayButtonTarget = null;
@@ -5267,6 +5444,14 @@ class ExpressCheckoutElementImpl {
5267
5444
  this.applePaySession !== null ||
5268
5445
  this.googlePayRequestId !== null);
5269
5446
  }
5447
+ hasActiveProviderSubmission() {
5448
+ const googlePayAwaitingMerchantApproval = this.googlePayRequestId !== null &&
5449
+ this.activeAttempt?.requestId === this.googlePayRequestId &&
5450
+ this.activeAttempt.approved === false;
5451
+ return (this.activeAttempt?.approved === true ||
5452
+ this.applePaySession !== null ||
5453
+ (this.googlePayRequestId !== null && !googlePayAwaitingMerchantApproval));
5454
+ }
5270
5455
  handleControllerError(error) {
5271
5456
  if (this.destroyed)
5272
5457
  return;
@@ -5672,6 +5857,7 @@ class ExpressCheckoutElementImpl {
5672
5857
  configurationIdentity: this.group.configurationIdentity,
5673
5858
  appearanceScopeId: this.group.controllerId,
5674
5859
  componentDisplayScopeId: this.componentId,
5860
+ isVisible: () => isElementVisible(this.iframe?.parentElement ?? null),
5675
5861
  isAvailable: () => true,
5676
5862
  isAppearanceAvailable: () => this.isMounted(),
5677
5863
  canPreview: () => this.group.isAppearancePreviewAvailable(),
@@ -5813,7 +5999,9 @@ class ExpressCheckoutElementImpl {
5813
5999
  const settle = (accepted, options) => {
5814
6000
  if (settled || this.destroyed || this.activeAttempt?.requestId !== requestId)
5815
6001
  return;
5816
- const validatedOptions = accepted ? validateClickResolveOptions(options) : undefined;
6002
+ const validatedResolution = accepted ? validateClickResolveOptions(options) : undefined;
6003
+ const { amount, ...checkoutDetails } = validatedResolution ?? {};
6004
+ const validatedOptions = Object.keys(checkoutDetails).length > 0 ? checkoutDetails : undefined;
5817
6005
  settled = true;
5818
6006
  window.clearTimeout(timeout);
5819
6007
  if (accepted && this.activeAttempt?.requestId === requestId) {
@@ -5823,11 +6011,23 @@ class ExpressCheckoutElementImpl {
5823
6011
  ...(validatedOptions ?? {}),
5824
6012
  });
5825
6013
  }
5826
- this.group.resolveWalletClick(this.componentId, requestId, accepted, validatedOptions);
6014
+ if (amount === undefined) {
6015
+ this.group.resolveWalletClick(this.componentId, requestId, accepted, validatedOptions);
6016
+ }
6017
+ else {
6018
+ this.group.resolveWalletClick(this.componentId, requestId, accepted, validatedOptions, amount);
6019
+ }
5827
6020
  if (!accepted) {
5828
6021
  this.group.endWalletAttempt(this.componentId, requestId);
5829
- this.activeAttempt = null;
5830
- this.activeOptions = null;
6022
+ // A top-level Google Pay sheet is already open before the async
6023
+ // merchant click decision returns. Keep the request identity until the
6024
+ // controller's wallet_cancel arrives so integrations receive their
6025
+ // normal cancel lifecycle and can release their own attempt lock.
6026
+ if (wallet !== 'google_pay' ||
6027
+ this.googlePayRequestId !== requestId) {
6028
+ this.activeAttempt = null;
6029
+ this.activeOptions = null;
6030
+ }
5831
6031
  }
5832
6032
  };
5833
6033
  // Woo and other commerce adapters may need to validate their checkout and
@@ -6190,10 +6390,22 @@ class ExpressCheckoutElementImpl {
6190
6390
  this.googlePayClient = this.createGooglePayClient(environment, Object.keys(paymentDataCallbacks).length > 0 ? paymentDataCallbacks : undefined);
6191
6391
  // Keep the browser launch synchronous with the relayed click. Awaiting
6192
6392
  // script or merchant work here loses mobile popup/user-activation state.
6193
- const payment = this.googlePayClient.loadPaymentData(request);
6393
+ const popupRecovery = launchWithProviderPopupRecovery(() => this.googlePayClient.loadPaymentData(request), () => {
6394
+ if (this.googlePayRequestId !== requestId || this.destroyed)
6395
+ return;
6396
+ try {
6397
+ this.group.sendGooglePayCanceled(this.componentId, requestId);
6398
+ }
6399
+ finally {
6400
+ this.clearGooglePayAttempt(requestId);
6401
+ }
6402
+ });
6403
+ this.googlePayPopupRecovery = popupRecovery;
6404
+ const payment = popupRecovery.result;
6194
6405
  void Promise.resolve(payment).then((data) => {
6195
6406
  if (this.googlePayRequestId !== requestId || this.destroyed)
6196
6407
  return;
6408
+ this.clearGooglePayPopupRecovery();
6197
6409
  // Google has returned control to the merchant document at this
6198
6410
  // boundary. Keep blocking duplicate checkout interactions, but stop
6199
6411
  // telling the customer that the provider window is still open while
@@ -6204,13 +6416,17 @@ class ExpressCheckoutElementImpl {
6204
6416
  }, (error) => {
6205
6417
  if (this.googlePayRequestId !== requestId || this.destroyed)
6206
6418
  return;
6207
- if (isGooglePayCancellation(error)) {
6208
- this.group.sendGooglePayCanceled(this.componentId, requestId);
6419
+ try {
6420
+ if (isGooglePayCancellation(error)) {
6421
+ this.group.sendGooglePayCanceled(this.componentId, requestId);
6422
+ }
6423
+ else {
6424
+ this.group.sendGooglePayError(this.componentId, requestId, googlePayErrorCode(error), googlePayErrorMessage(error));
6425
+ }
6209
6426
  }
6210
- else {
6211
- this.group.sendGooglePayError(this.componentId, requestId, googlePayErrorCode(error), googlePayErrorMessage(error));
6427
+ finally {
6428
+ this.clearGooglePayAttempt(requestId);
6212
6429
  }
6213
- this.clearGooglePayAttempt(requestId);
6214
6430
  });
6215
6431
  }
6216
6432
  catch (error) {
@@ -6297,6 +6513,7 @@ class ExpressCheckoutElementImpl {
6297
6513
  clearGooglePayAttempt(requestId) {
6298
6514
  if (requestId && this.googlePayRequestId !== requestId)
6299
6515
  return;
6516
+ this.clearGooglePayPopupRecovery();
6300
6517
  this.googlePayRequestId = null;
6301
6518
  this.googlePayProcessingRequestId = null;
6302
6519
  for (const pending of this.googlePayUpdates.values()) {
@@ -6311,6 +6528,10 @@ class ExpressCheckoutElementImpl {
6311
6528
  }
6312
6529
  this.positionGooglePayButton();
6313
6530
  }
6531
+ clearGooglePayPopupRecovery() {
6532
+ this.googlePayPopupRecovery?.stop();
6533
+ this.googlePayPopupRecovery = null;
6534
+ }
6314
6535
  startApplePay(requestId, request) {
6315
6536
  this.abortApplePay();
6316
6537
  const ApplePayAPI = window.ApplePaySession;
@@ -6661,6 +6882,7 @@ function validateClickResolveOptions(options) {
6661
6882
  if (options === undefined)
6662
6883
  return undefined;
6663
6884
  const allowed = new Set([
6885
+ 'amount',
6664
6886
  'lineItems',
6665
6887
  'emailRequired',
6666
6888
  'phoneNumberRequired',
@@ -6672,6 +6894,12 @@ function validateClickResolveOptions(options) {
6672
6894
  if (!isRecord(options) || Object.keys(options).some((key) => !allowed.has(key))) {
6673
6895
  throw invalidOptions();
6674
6896
  }
6897
+ if (options.amount !== undefined &&
6898
+ (typeof options.amount !== 'number' ||
6899
+ !Number.isSafeInteger(options.amount) ||
6900
+ options.amount < 0)) {
6901
+ throw invalidOptions();
6902
+ }
6675
6903
  validateRows(options.lineItems, 'name');
6676
6904
  validateRows(options.shippingRates, 'displayName', true);
6677
6905
  for (const flag of [
@@ -6699,7 +6927,7 @@ function validateClickResolveOptions(options) {
6699
6927
  });
6700
6928
  }
6701
6929
  function validateElementUpdateOptions(options) {
6702
- if (!isRecord(options) || Object.keys(options).length === 0) {
6930
+ if (!isRecord(options) || Object.keys(options).length === 0 || 'amount' in options) {
6703
6931
  throw new Error('[Paypercut Elements] Express Checkout update options must contain checkout details.');
6704
6932
  }
6705
6933
  return validateClickResolveOptions(options);
@@ -8262,6 +8490,9 @@ class CardFieldElementImpl {
8262
8490
  isMounted() {
8263
8491
  return this.mounted && !this.destroyed;
8264
8492
  }
8493
+ isVisible() {
8494
+ return isElementVisible(this.surface?.root ?? null);
8495
+ }
8265
8496
  destroy() {
8266
8497
  if (this.destroyed)
8267
8498
  return;
@@ -11302,9 +11533,6 @@ class ElementsGroupImpl {
11302
11533
  return element;
11303
11534
  }
11304
11535
  if (type === 'expressCheckout') {
11305
- if (this.elementsOptions.mode !== 'payment') {
11306
- throw createElementsError('elements_component_configuration_invalid', 'Express Checkout is currently supported only in payment mode.', false);
11307
- }
11308
11536
  const element = new ExpressCheckoutElementImpl(this, options);
11309
11537
  this.elements.set(element.componentId, element);
11310
11538
  return element;
@@ -11751,7 +11979,9 @@ class ElementsGroupImpl {
11751
11979
  };
11752
11980
  this.postControl(control);
11753
11981
  }
11754
- resolveWalletClick(componentId, requestId, accepted, options) {
11982
+ resolveWalletClick(componentId, requestId, accepted, options, amount) {
11983
+ if (accepted && amount !== undefined)
11984
+ this.commitAmountUpdate(amount);
11755
11985
  const snapshot = this.getUpdateSnapshot().options;
11756
11986
  const message = {
11757
11987
  channel: ELEMENTS_COMPONENT_CHANNEL,
@@ -11970,13 +12200,17 @@ class ElementsGroupImpl {
11970
12200
  if (this.destroyed) {
11971
12201
  throw new Error('[Paypercut Elements] Cannot update a destroyed group.');
11972
12202
  }
12203
+ const activeElementSubmission = Array.from(this.elements.values()).some((element) => element.hasActiveSubmission());
12204
+ const activeProviderSubmission = Array.from(this.elements.values()).some((element) => element.componentType === 'express_checkout'
12205
+ ? element.hasActiveProviderSubmission()
12206
+ : element.hasActiveSubmission());
11973
12207
  if (this.pendingValidation !== null ||
11974
12208
  this.paymentMethodSubmission.hasActiveSubmission() ||
11975
- Array.from(this.elements.values()).some((element) => element.hasActiveSubmission())) {
12209
+ (options.appearance !== undefined ? activeElementSubmission : activeProviderSubmission)) {
11976
12210
  if (options.appearance !== undefined) {
11977
12211
  throw new AppearancePreviewError('elements_appearance_preview_refused', 'Appearance Preview is unavailable while payment validation, Card authentication, or a wallet attempt is active.');
11978
12212
  }
11979
- throw new Error('[Paypercut Elements] Cannot update Elements while payment details are being submitted.');
12213
+ throw createElementsError('elements_submission_in_progress', '[Paypercut Elements] Cannot update Elements while payment details are being submitted.', true);
11980
12214
  }
11981
12215
  const update = normalizeUpdateOptions(options, this.appearance, this.amount);
11982
12216
  const appearanceWasRequested = options.appearance !== undefined;
@@ -12001,6 +12235,10 @@ class ElementsGroupImpl {
12001
12235
  if (update.amount === this.amount && !appearanceChanged) {
12002
12236
  return Promise.resolve();
12003
12237
  }
12238
+ if (!appearanceChanged) {
12239
+ this.commitAmountUpdate(update.amount);
12240
+ return Promise.resolve();
12241
+ }
12004
12242
  if (this.updateRevision === Number.MAX_SAFE_INTEGER) {
12005
12243
  throw new Error('[Paypercut Elements] The update revision limit has been reached.');
12006
12244
  }
@@ -12032,6 +12270,26 @@ class ElementsGroupImpl {
12032
12270
  this.postControl(message);
12033
12271
  return Promise.resolve();
12034
12272
  }
12273
+ commitAmountUpdate(amount) {
12274
+ if (amount === this.amount)
12275
+ return;
12276
+ if (this.updateRevision === Number.MAX_SAFE_INTEGER) {
12277
+ throw new Error('[Paypercut Elements] The update revision limit has been reached.');
12278
+ }
12279
+ this.amount = amount;
12280
+ this.invalidateSubmissionValidation();
12281
+ this.updateRevision += 1;
12282
+ if (!this.controllerInitialized)
12283
+ return;
12284
+ const snapshot = this.getUpdateSnapshot();
12285
+ this.postControl({
12286
+ channel: ELEMENTS_COMPONENT_CHANNEL,
12287
+ type: ElementsControllerCommandType.UpdateOptions,
12288
+ controllerId: this.controllerId,
12289
+ updateRevision: snapshot.updateRevision,
12290
+ options: snapshot.options,
12291
+ });
12292
+ }
12035
12293
  startAppearancePreview(appearance, deferCommit = false) {
12036
12294
  const generation = ++this.appearancePreviewGeneration;
12037
12295
  const previous = cloneElementsAppearance(this.appearance);
@@ -12193,6 +12451,9 @@ class ElementsGroupImpl {
12193
12451
  hasMountedCardFields() {
12194
12452
  return Array.from(this.cardFields.values()).some((field) => field.isMounted());
12195
12453
  }
12454
+ hasVisibleCardFields() {
12455
+ return Array.from(this.cardFields.values()).some((field) => field.isVisible());
12456
+ }
12196
12457
  warnAppearancePreview(error) {
12197
12458
  if (error.code === 'elements_appearance_preview_superseded')
12198
12459
  return;
@@ -12289,6 +12550,7 @@ class ElementsGroupImpl {
12289
12550
  configurationIdentity: this.configurationIdentity,
12290
12551
  appearanceScopeId: this.controllerId,
12291
12552
  presetSource: 'split-card',
12553
+ isVisible: () => !this.destroyed && this.hasVisibleCardFields(),
12292
12554
  isAvailable: () => !this.destroyed && this.cardCollectionRuntime.canApplyDeveloperPreset(),
12293
12555
  isAppearanceAvailable: () => !this.destroyed && this.hasMountedCardFields(),
12294
12556
  appearancePreviewClearsTestData: () => true,