@foxy.io/elements 1.53.3 → 1.54.0

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 (73) hide show
  1. package/dist/cdn/foxy-address-form.js +1 -1
  2. package/dist/cdn/foxy-admin-subscription-form.js +1 -1
  3. package/dist/cdn/foxy-api-browser.js +1 -1
  4. package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
  5. package/dist/cdn/foxy-attribute-form.js +1 -1
  6. package/dist/cdn/foxy-cart-form.js +1 -1
  7. package/dist/cdn/foxy-client-form.js +1 -1
  8. package/dist/cdn/foxy-coupon-code-form.js +1 -1
  9. package/dist/cdn/foxy-coupon-codes-form.js +1 -1
  10. package/dist/cdn/foxy-coupon-form.js +1 -1
  11. package/dist/cdn/foxy-custom-field-form.js +1 -1
  12. package/dist/cdn/foxy-customer-form.js +1 -1
  13. package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
  14. package/dist/cdn/foxy-customer-portal.js +11 -11
  15. package/dist/cdn/foxy-customer.js +1 -1
  16. package/dist/cdn/foxy-downloadable-form.js +1 -1
  17. package/dist/cdn/foxy-email-template-form.js +1 -1
  18. package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -1
  19. package/dist/cdn/foxy-filter-attribute-form.js +1 -1
  20. package/dist/cdn/foxy-generate-codes-form.js +1 -1
  21. package/dist/cdn/foxy-gift-card-code-form.js +1 -1
  22. package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
  23. package/dist/cdn/foxy-gift-card-form.js +1 -1
  24. package/dist/cdn/foxy-integration-form.js +1 -1
  25. package/dist/cdn/foxy-item-category-form.js +1 -1
  26. package/dist/cdn/foxy-item-form.js +1 -1
  27. package/dist/cdn/foxy-item-option-form.js +1 -1
  28. package/dist/cdn/foxy-native-integration-form.js +1 -1
  29. package/dist/cdn/foxy-passkey-form.js +1 -1
  30. package/dist/cdn/foxy-payment-method-card.js +1 -1
  31. package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
  32. package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
  33. package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
  34. package/dist/cdn/foxy-payments-api.js +1 -1
  35. package/dist/cdn/foxy-report-form.js +1 -1
  36. package/dist/cdn/foxy-store-form.js +1 -1
  37. package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
  38. package/dist/cdn/foxy-store-transaction-folder-form.js +1 -1
  39. package/dist/cdn/foxy-subscription-form.js +1 -1
  40. package/dist/cdn/foxy-subscription-settings-form.js +1 -1
  41. package/dist/cdn/foxy-tax-form.js +1 -1
  42. package/dist/cdn/foxy-template-config-form.js +1 -1
  43. package/dist/cdn/foxy-template-form.js +1 -1
  44. package/dist/cdn/foxy-template-set-form.js +1 -1
  45. package/dist/cdn/foxy-transaction.js +1 -1
  46. package/dist/cdn/foxy-update-payment-method-form.js +1 -1
  47. package/dist/cdn/foxy-user-form.js +1 -1
  48. package/dist/cdn/foxy-user-invitation-form.js +1 -1
  49. package/dist/cdn/foxy-users-table.js +1 -1
  50. package/dist/cdn/foxy-webhook-form.js +1 -1
  51. package/dist/cdn/{shared-ad26f72d.js → shared-13fed57b.js} +1 -1
  52. package/dist/cdn/{shared-e44d4a56.js → shared-6418bbb8.js} +1 -1
  53. package/dist/cdn/{shared-842078ca.js → shared-db8913cf.js} +1 -1
  54. package/dist/cdn/translations/payments-api-payment-method-form/en.json +51 -1
  55. package/dist/elements/internal/InternalForm/InternalForm.js +5 -3
  56. package/dist/elements/internal/InternalForm/InternalForm.js.map +1 -1
  57. package/dist/elements/internal/InternalForm/types.d.ts +2 -0
  58. package/dist/elements/internal/InternalForm/types.js.map +1 -1
  59. package/dist/elements/public/PaymentsApi/api/composers/payment_method.js +11 -5
  60. package/dist/elements/public/PaymentsApi/api/composers/payment_method.js.map +1 -1
  61. package/dist/elements/public/PaymentsApi/api/composers/payment_methods.js +1 -0
  62. package/dist/elements/public/PaymentsApi/api/composers/payment_methods.js.map +1 -1
  63. package/dist/elements/public/PaymentsApi/api/composers/payment_preset.js +1 -0
  64. package/dist/elements/public/PaymentsApi/api/composers/payment_preset.js.map +1 -1
  65. package/dist/elements/public/PaymentsApi/api/types.d.ts +3 -0
  66. package/dist/elements/public/PaymentsApi/api/types.js.map +1 -1
  67. package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.d.ts +14 -0
  68. package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js +197 -16
  69. package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js.map +1 -1
  70. package/dist/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.d.ts +2 -0
  71. package/dist/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.js +4 -0
  72. package/dist/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.js.map +1 -1
  73. package/package.json +4 -2
@@ -8,6 +8,8 @@ import Fuse from 'fuse.js';
8
8
  import has from 'lodash-es/has';
9
9
  import get from 'lodash-es/get';
10
10
  import set from 'lodash-es/set';
11
+ /** OAuth gateways that connect through fx:connect_gateway. Other OAuth gateways show a notice. */
12
+ const connectableGateways = ['paypal_platform'];
11
13
  const NS = 'payments-api-payment-method-form';
12
14
  const Base = TranslatableMixin(InternalForm, NS);
13
15
  /**
@@ -28,6 +30,12 @@ export class PaymentsApiPaymentMethodForm extends Base {
28
30
  this.paymentPreset = null;
29
31
  /** A function that returns a URL of a payment method icon based on the given type. */
30
32
  this.getImageSrc = null;
33
+ /**
34
+ * Returns the URL the gateway sends the merchant back to after a connection.
35
+ * Receives the `payment-preset` URL. The API appends a `status` query parameter.
36
+ * Defaults to the current page URL.
37
+ */
38
+ this.getConnectRedirectUrl = null;
31
39
  /** URL of the linked `fx:store` resource. */
32
40
  this.store = null;
33
41
  this.__availablePaymentMethodsLoaderId = 'availablePaymentMethodsLoader';
@@ -75,6 +83,9 @@ export class PaymentsApiPaymentMethodForm extends Base {
75
83
  { label: 'option_enabled_override', value: 'enabled_override' },
76
84
  ];
77
85
  this.__search = '';
86
+ this.__connectState = 'idle';
87
+ /** Key of the connect choice whose connection URL is being fetched. */
88
+ this.__connectKey = '';
78
89
  }
79
90
  static get defaultImageSrc() {
80
91
  return "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='m29.3 14 14-14H32.1l-14 14h11.2Zm2.7 9.9 12-12V.7L30.62 14.1A2 2 0 0 1 32 16v7.9ZM13.31 44h11.18L44 24.5V13.3l-12 12V28a2 2 0 0 1-2 2h-2.69l-14 14Zm-1.41 0H.7l14-14h11.2l-14 14Zm14 0h11.2l6.9-6.9V25.9L25.9 44Zm12.6 0H44v-5.5L38.5 44Z'/%3E%3Cpath fill='%23fff' d='M30 28H14v-6h16v6Zm0-10v-2H14v2h16ZM0 43.3l13.4-13.4A2 2 0 0 1 12 28v-7.9L0 32.12V43.3Z'/%3E%3Cpath fill='%23fff' d='M16.7 14H14c-1.11 0-1.99.89-1.99 2v2.7L0 30.7V19.52L19.52 0H30.7l-14 14Zm1.4-14H6.92L0 6.92V18.1L18.1 0ZM5.5 0H0v5.5L5.5 0Z'/%3E%3C/svg%3E";
@@ -84,8 +95,11 @@ export class PaymentsApiPaymentMethodForm extends Base {
84
95
  ...super.properties,
85
96
  paymentPreset: { attribute: 'payment-preset' },
86
97
  getImageSrc: { attribute: false },
98
+ getConnectRedirectUrl: { attribute: false },
87
99
  store: {},
88
100
  __search: { attribute: false },
101
+ __connectState: { attribute: false },
102
+ __connectKey: { attribute: false },
89
103
  };
90
104
  }
91
105
  static get v8n() {
@@ -219,11 +233,14 @@ export class PaymentsApiPaymentMethodForm extends Base {
219
233
  const isSpecialCharacter = !/\w/.test(firstChar);
220
234
  const name = isSpecialCharacter ? '#' : firstChar;
221
235
  const group = groups.find(group => group.name === name);
236
+ const items = connectableGateways.includes(type)
237
+ ? this.__getConnectChoices(type).map(choice => ({ type, helper, choice }))
238
+ : [{ type, helper }];
222
239
  if (group) {
223
- group.items.push({ type, helper });
240
+ group.items.push(...items);
224
241
  }
225
242
  else {
226
- groups.push({ name, items: [{ type, helper }] });
243
+ groups.push({ name, items });
227
244
  }
228
245
  return groups;
229
246
  }, []);
@@ -283,8 +300,145 @@ export class PaymentsApiPaymentMethodForm extends Base {
283
300
  </div>
284
301
  `;
285
302
  }
303
+ __redirect(url) {
304
+ window.location.assign(url);
305
+ }
306
+ __getConnectChoices(type) {
307
+ if (type === 'paypal_platform') {
308
+ return [
309
+ { key: 'paypal_platform.ppcp', options: { paypal_product_type: 'ppcp' } },
310
+ {
311
+ key: 'paypal_platform.express_checkout',
312
+ options: { paypal_product_type: 'express_checkout' },
313
+ },
314
+ ];
315
+ }
316
+ return [{ key: 'default' }];
317
+ }
318
+ __getReconnectChoice(thirdPartyKey) {
319
+ if (this.form.type === 'paypal_platform') {
320
+ // An empty third-party key means the account is connected for PayPal only, without cards.
321
+ const key = thirdPartyKey ? 'reconnect' : 'reconnect_with_cards';
322
+ return { key: `paypal_platform.${key}`, options: { paypal_product_type: 'ppcp' } };
323
+ }
324
+ return { key: 'reconnect' };
325
+ }
326
+ async __connect(choice, type) {
327
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
328
+ const presetLink = (_b = (_a = this.__paymentPresetLoader) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b._links['fx:connect_gateway'];
329
+ const href = (_e = (_d = (_c = this.data) === null || _c === void 0 ? void 0 : _c._links['fx:connect_gateway']) === null || _d === void 0 ? void 0 : _d.href) !== null && _e !== void 0 ? _e : presetLink === null || presetLink === void 0 ? void 0 : presetLink.href;
330
+ if (!href || !this.paymentPreset || this.__connectState === 'busy')
331
+ return;
332
+ this.__connectState = 'busy';
333
+ this.__connectKey = choice.key;
334
+ this.status = null;
335
+ try {
336
+ const body = {
337
+ type,
338
+ final_redirect: (_g = (_f = this.getConnectRedirectUrl) === null || _f === void 0 ? void 0 : _f.call(this, this.paymentPreset)) !== null && _g !== void 0 ? _g : window.location.href,
339
+ };
340
+ if (choice.options)
341
+ body.options = choice.options;
342
+ const response = await this._fetch(href, {
343
+ method: 'POST',
344
+ body: JSON.stringify(body),
345
+ });
346
+ // The API answers 201 with a null URL when the gateway itself fails to create one.
347
+ if (!response.connection_url)
348
+ throw new Error('No connection_url in the response.');
349
+ // State stays busy on purpose: the spinner keeps going until the browser leaves the page.
350
+ this.__redirect(response.connection_url);
351
+ }
352
+ catch (err) {
353
+ let message = '';
354
+ if (err instanceof Response) {
355
+ try {
356
+ const json = await err.json();
357
+ message = (_l = (_k = (_j = (_h = json === null || json === void 0 ? void 0 : json._embedded) === null || _h === void 0 ? void 0 : _h['fx:errors']) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.message) !== null && _l !== void 0 ? _l : '';
358
+ }
359
+ catch (_o) {
360
+ // not a vnd.error response
361
+ }
362
+ }
363
+ // The API's country error names raw option values ('ppcp', 'express_checkout'), so we
364
+ // replace it with our own text. It's the only 403 our requests can get that mentions 'ppcp'.
365
+ const isPpcpUnsupported = err instanceof Response &&
366
+ err.status === 403 &&
367
+ ((_m = choice.options) === null || _m === void 0 ? void 0 : _m.paypal_product_type) === 'ppcp' &&
368
+ message.includes("'ppcp'");
369
+ if (isPpcpUnsupported) {
370
+ this.status = { key: 'connect_error_ppcp_unsupported', type: 'error' };
371
+ }
372
+ else if (message) {
373
+ this.status = { key: 'connect_error', options: { message }, type: 'error' };
374
+ }
375
+ else {
376
+ this.status = { key: 'connect_error_unknown', type: 'error' };
377
+ }
378
+ this.__connectState = 'idle';
379
+ }
380
+ }
381
+ __renderConnection() {
382
+ var _a, _b, _c, _d;
383
+ const preset = (_a = this.__paymentPresetLoader) === null || _a === void 0 ? void 0 : _a.data;
384
+ if (!preset)
385
+ return html ``;
386
+ const prefix = preset.is_live ? '' : 'test_';
387
+ const email = (_b = this.data) === null || _b === void 0 ? void 0 : _b[`${prefix}account_id`];
388
+ const thirdPartyKey = (_d = (_c = this.data) === null || _c === void 0 ? void 0 : _c[`${prefix}third_party_key`]) !== null && _d !== void 0 ? _d : '';
389
+ const type = this.form.type;
390
+ const choices = email
391
+ ? [this.__getReconnectChoice(thirdPartyKey)]
392
+ : this.__getConnectChoices(type);
393
+ const isBusy = this.__connectState === 'busy';
394
+ const isReadonly = this.readonlySelector.matches('connection', true);
395
+ const isDisabled = isBusy || this.disabledSelector.matches('connection', true);
396
+ return html `
397
+ <foxy-internal-summary-control infer="connection">
398
+ ${email
399
+ ? html `
400
+ <p class="font-medium">
401
+ <foxy-i18n infer="" key="status_connected" .options=${{ email }}></foxy-i18n>
402
+ </p>
403
+ `
404
+ : ''}
405
+ ${(isReadonly ? [] : choices).map(choice => html `
406
+ <div class="leading-xs">
407
+ <p class="font-medium">
408
+ <foxy-i18n infer="" key="${choice.key}.label"></foxy-i18n>
409
+ </p>
410
+ <p class="text-s text-secondary">
411
+ <foxy-i18n infer="" key="${choice.key}.description"></foxy-i18n>
412
+ </p>
413
+ </div>
414
+ <div>
415
+ <vaadin-button
416
+ data-testid="connect-${choice.key}"
417
+ theme="tertiary-inline"
418
+ ?disabled=${isDisabled}
419
+ @click=${() => this.__connect(choice, type)}
420
+ >
421
+ ${isBusy && this.__connectKey === choice.key
422
+ ? html `<foxy-spinner layout="no-label" infer="connect-spinner"></foxy-spinner>`
423
+ : html `<foxy-i18n infer="" key="${choice.key}.button"></foxy-i18n>`}
424
+ </vaadin-button>
425
+ </div>
426
+ `)}
427
+ </foxy-internal-summary-control>
428
+ `;
429
+ }
286
430
  __renderPaymentMethodConfig() {
287
431
  var _a, _b;
432
+ if (this.form.type && connectableGateways.includes(this.form.type)) {
433
+ return html `
434
+ <foxy-internal-summary-control infer="general">
435
+ <foxy-internal-text-control layout="summary-item" infer="description">
436
+ </foxy-internal-text-control>
437
+ </foxy-internal-summary-control>
438
+
439
+ ${this.__renderConnection()} ${super.renderBody()}
440
+ `;
441
+ }
288
442
  const oauthGateways = [
289
443
  'stripe_connect',
290
444
  'stripe_v2',
@@ -461,11 +615,14 @@ export class PaymentsApiPaymentMethodForm extends Base {
461
615
  ${super.renderBody()}
462
616
  `;
463
617
  }
464
- __renderPaymentMethodButton({ type, helper }, index, total) {
618
+ __renderPaymentMethodButton({ type, helper, choice }, index, total) {
465
619
  var _a, _b;
466
620
  const defaultSrc = PaymentsApiPaymentMethodForm.defaultImageSrc;
467
621
  const src = (_b = (_a = this.getImageSrc) === null || _a === void 0 ? void 0 : _a.call(this, type)) !== null && _b !== void 0 ? _b : defaultSrc;
468
622
  const onError = (evt) => (evt.currentTarget.src = defaultSrc);
623
+ const isBusy = this.__connectState === 'busy';
624
+ const isConnecting = isBusy && !!choice && this.__connectKey === choice.key;
625
+ const hasChoiceLabel = !!choice && choice.key !== 'default';
469
626
  return html `
470
627
  <button
471
628
  class=${classMap({
@@ -476,33 +633,57 @@ export class PaymentsApiPaymentMethodForm extends Base {
476
633
  'rounded-t': index === 0,
477
634
  'rounded-b': index === total - 1,
478
635
  })}
479
- ?disabled=${!!helper.conflict}
636
+ data-testid=${ifDefined(choice ? `connect-${choice.key}` : undefined)}
637
+ ?disabled=${!!helper.conflict || isBusy}
480
638
  style="padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
481
- @click=${() => this.edit({ type, helper })}
639
+ @click=${() => (choice ? this.__connect(choice, type) : this.edit({ type, helper }))}
482
640
  >
483
641
  <figure
484
642
  class="relative flex items-center"
485
643
  style="gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
486
644
  >
487
- <img
488
- class=${classMap({
489
- 'h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs': true,
490
- 'filter grayscale': !!helper.conflict,
491
- })}
492
- src=${src}
493
- alt=""
494
- @error=${onError}
495
- />
645
+ ${isConnecting
646
+ ? html `
647
+ <foxy-spinner
648
+ data-testid="connect-spinner"
649
+ class="h-m w-m flex items-center justify-center flex-shrink-0"
650
+ layout="no-label"
651
+ infer="connect-spinner"
652
+ >
653
+ </foxy-spinner>
654
+ `
655
+ : html `
656
+ <img
657
+ class=${classMap({
658
+ 'h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs': true,
659
+ 'filter grayscale': !!helper.conflict,
660
+ })}
661
+ src=${src}
662
+ alt=""
663
+ @error=${onError}
664
+ />
665
+ `}
496
666
  <figcaption
497
667
  class=${classMap({
498
668
  'min-w-0 flex-1 grid leading-xs': true,
499
669
  'text-disabled': !!helper.conflict,
500
670
  })}
501
671
  >
502
- <span class="font-medium">${helper.name}&ZeroWidthSpace;</span>
672
+ <span class="font-medium">
673
+ ${hasChoiceLabel
674
+ ? this.t(`connection.${choice.key}.label`)
675
+ : helper.name}&ZeroWidthSpace;
676
+ </span>
503
677
  ${helper.conflict
504
678
  ? html `<span class="text-xs"> ${this.t('conflict_message', helper.conflict)}</span>`
505
- : ''}
679
+ : choice
680
+ ? html `
681
+ <span class="text-xs text-secondary">
682
+ ${hasChoiceLabel ? this.t(`connection.${choice.key}.description`) : ''}
683
+ ${this.t('connection.redirect_notice')}
684
+ </span>
685
+ `
686
+ : ''}
506
687
  </figcaption>
507
688
  </figure>
508
689
  </button>
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentsApiPaymentMethodForm.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,QAAQ,E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E7B,KAAK,CAAC,IAAI;wBACV,KAAK;2BACF,OAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;4BAC1D,QAAQ;4BACR,QAAQ;;;aAGvB;oBACH,CAAC,CAAC,IAAI,CAAA;;8BAEc,MAAA,KAAK,CAAC,WAAW,mCAAI,EAAE;8BACvB,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC;;wBAE3E,KAAK,CAAC,IAAI;wBACV,KAAK;4BACD,QAAQ;4BACR,QAAQ;;;aAGvB;OACN,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF","sourcesContent":["import type { AvailablePaymentMethods, PaymentPreset } from '../PaymentsApi/api/types';\nimport type { Block, Data } from './types';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { BooleanSelector, getResourceId } from '@foxy.io/sdk/core';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html, svg } from 'lit-html';\nimport { classMap } from '../../../utils/class-map';\n\nimport Fuse from 'fuse.js';\nimport has from 'lodash-es/has';\nimport get from 'lodash-es/get';\nimport set from 'lodash-es/set';\n\ntype PaymentMethod = {\n helper: AvailablePaymentMethods['values'][string];\n type: string;\n};\n\nconst NS = 'payments-api-payment-method-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for the `fx:payment_method` resource of Payments API.\n *\n * _Payments API is a client-side virtual API layer built on top of hAPI\n * in an attempt to streamline access to stores' payment method settings\n * that is currently a bit quirky due to the legacy functionality. To use\n * this element with hAPI, wrap it into a foxy-payments-api node._\n *\n * @element foxy-payments-api-payment-method-form\n * @since 1.21.0\n */\nexport class PaymentsApiPaymentMethodForm extends Base<Data> {\n static get defaultImageSrc(): string {\n return \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='m29.3 14 14-14H32.1l-14 14h11.2Zm2.7 9.9 12-12V.7L30.62 14.1A2 2 0 0 1 32 16v7.9ZM13.31 44h11.18L44 24.5V13.3l-12 12V28a2 2 0 0 1-2 2h-2.69l-14 14Zm-1.41 0H.7l14-14h11.2l-14 14Zm14 0h11.2l6.9-6.9V25.9L25.9 44Zm12.6 0H44v-5.5L38.5 44Z'/%3E%3Cpath fill='%23fff' d='M30 28H14v-6h16v6Zm0-10v-2H14v2h16ZM0 43.3l13.4-13.4A2 2 0 0 1 12 28v-7.9L0 32.12V43.3Z'/%3E%3Cpath fill='%23fff' d='M16.7 14H14c-1.11 0-1.99.89-1.99 2v2.7L0 30.7V19.52L19.52 0H30.7l-14 14Zm1.4-14H6.92L0 6.92V18.1L18.1 0ZM5.5 0H0v5.5L5.5 0Z'/%3E%3C/svg%3E\";\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n paymentPreset: { attribute: 'payment-preset' },\n getImageSrc: { attribute: false },\n store: {},\n __search: { attribute: false },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ description: v }) => !v || v.length <= 100 || 'description:v8n_too_long',\n ({ type: v }) => !!v || 'type:v8n_required',\n\n form => {\n const blocks = form.helper?.additional_fields?.blocks ?? [];\n let additionalFields: Record<string, unknown>;\n\n try {\n additionalFields = JSON.parse(form.additional_fields ?? '{}');\n } catch {\n additionalFields = {};\n }\n\n for (const block of blocks) {\n for (const field of block.fields) {\n if ('optional' in (field as Record<string, unknown>)) {\n if (!(field as Record<string, unknown>).optional) {\n if (!has(additionalFields, field.id)) {\n if (field.type !== 'checkbox') {\n return 'additional-fields:v8n_invalid';\n }\n }\n }\n }\n }\n }\n\n return true;\n },\n ];\n }\n\n /** URL of the linked `fx:payment_preset` resource from the virtual Payments API. */\n paymentPreset: string | null = null;\n\n /** A function that returns a URL of a payment method icon based on the given type. */\n getImageSrc: ((type: string) => string) | null = null;\n\n /** URL of the linked `fx:store` resource. */\n store: string | null = null;\n\n private readonly __availablePaymentMethodsLoaderId = 'availablePaymentMethodsLoader';\n\n private readonly __paymentPresetLoaderId = 'paymentPresetLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n private readonly __threeDSecureResponseGetValue = () => {\n return this.form.config_3d_secure?.endsWith('require_valid_response');\n };\n\n private readonly __threeDSecureResponseSetValue = (newValue: boolean) => {\n const postfix = newValue ? '_require_valid_response' : '';\n const config = this.form.config_3d_secure;\n const type = config?.startsWith('all_cards') ? 'all_cards' : 'maestro_only';\n\n this.edit({ config_3d_secure: `${type}${postfix}` as Data['config_3d_secure'] });\n };\n\n private readonly __threeDSecureToggleGetValue = () => {\n const config = this.form.config_3d_secure;\n\n if (config?.startsWith('all_cards')) return 'all_cards';\n if (config?.startsWith('maestro_only')) return 'maestro_only';\n\n return 'off';\n };\n\n private readonly __threeDSecureToggleSetValue = (\n newValue: 'off' | 'all_cards' | 'maestro_only'\n ) => {\n let newFormValue = '';\n\n if (newValue === 'all_cards' || newValue === 'maestro_only') {\n if (this.form.config_3d_secure?.endsWith('require_valid_response')) {\n newFormValue = `${newValue}_require_valid_response`;\n } else {\n newFormValue = newValue;\n }\n }\n\n this.edit({ config_3d_secure: newFormValue as Data['config_3d_secure'] });\n };\n\n private readonly __threeDSecureToggleOptions = [\n { value: 'off', label: 'option_off' },\n { value: 'all_cards', label: 'option_all_cards' },\n { value: 'maestro_only', label: 'option_maestro_only' },\n ];\n\n private readonly __cardVerificationOptions = [\n { label: 'option_disabled', value: 'disabled' },\n { label: 'option_enabled_automatically', value: 'enabled_automatically' },\n { label: 'option_enabled_override', value: 'enabled_override' },\n ];\n\n private __search = '';\n\n get hiddenSelector(): BooleanSelector {\n return new BooleanSelector(`header:copy-json ${super.hiddenSelector}`.trimEnd());\n }\n\n renderHeader(...params: Parameters<InternalForm<Data>['renderHeader']>): TemplateResult {\n return html`\n <div>\n ${super.renderHeader(...params)}\n ${this.data?.type || !this.form.type\n ? html``\n : html`\n <vaadin-button\n data-testid=\"select-another-button\"\n theme=\"tertiary-inline\"\n @click=${() => this.undo()}\n >\n <foxy-i18n infer=\"\" key=\"select_another_button_label\"></foxy-i18n>\n </vaadin-button>\n `}\n </div>\n `;\n }\n\n get headerTitleOptions(): Record<string, unknown> {\n return {\n context: this.form.type ? 'selected' : 'new',\n name: this.form.helper?.name,\n };\n }\n\n get headerSubtitleOptions(): Record<string, unknown> {\n if (this.href) {\n const vId = getResourceId(this.href) as string;\n const id = this.headerCopyIdValue;\n if (vId.startsWith('R')) return { context: 'regular', id };\n return { context: 'hosted', id };\n }\n\n return {};\n }\n\n get headerCopyIdValue(): string | number {\n if (this.href) {\n const id = getResourceId(this.href) as string;\n return id.startsWith('R') ? id.slice(1) : id.slice(1).split('C')[0];\n } else {\n return '';\n }\n }\n\n renderBody(): TemplateResult {\n const paymentPreset = this.__paymentPresetLoader?.data;\n\n const loaders = html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(paymentPreset?._links['fx:available_payment_methods'].href)}\n id=${this.__availablePaymentMethodsLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.store)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.paymentPreset)}\n id=${this.__paymentPresetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n\n return html`${this.renderHeader()}${this.form.type\n ? this.__renderPaymentMethodConfig()\n : this.__renderPaymentMethodSelector()}${loaders}`;\n }\n\n private get __groupedAvailablePaymentMethods() {\n const allMethods = Object.entries(this.__availablePaymentMethods ?? {});\n const filteredMethods = this.__search\n ? new Fuse(allMethods, { keys: ['1.name'], threshold: 0.25 })\n .search(this.__search)\n .map(v => v.item)\n : allMethods;\n\n return filteredMethods\n .sort((a, b) => a[1].name.localeCompare(b[1].name, 'en'))\n .reduce((groups, [type, helper]) => {\n if (helper.is_deprecated) return groups;\n\n const firstChar = helper.name.charAt(0).toUpperCase();\n const isSpecialCharacter = !/\\w/.test(firstChar);\n const name = isSpecialCharacter ? '#' : firstChar;\n const group = groups.find(group => group.name === name);\n\n if (group) {\n group.items.push({ type, helper });\n } else {\n groups.push({ name, items: [{ type, helper }] });\n }\n\n return groups;\n }, [] as { name: string; items: PaymentMethod[] }[]);\n }\n\n private get __availablePaymentMethodsLoader() {\n type Loader = NucleonElement<AvailablePaymentMethods>;\n return this.renderRoot.querySelector<Loader>(`#${this.__availablePaymentMethodsLoaderId}`);\n }\n\n private get __availablePaymentMethods() {\n return this.__availablePaymentMethodsLoader?.data?.values;\n }\n\n private get __paymentPresetLoader() {\n type Loader = NucleonElement<PaymentPreset>;\n return this.renderRoot.querySelector<Loader>(`#${this.__paymentPresetLoaderId}`);\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n\n private get __liveBlocks() {\n return this.form.helper?.additional_fields?.blocks.filter(block => block.is_live) ?? [];\n }\n\n private get __testBlocks() {\n return this.form.helper?.additional_fields?.blocks.filter(block => !block.is_live) ?? [];\n }\n\n private __renderPaymentMethodSelector() {\n const loader = this.__availablePaymentMethodsLoader;\n\n if (!loader?.data) {\n return html`\n <foxy-spinner infer=\"list-spinner\" state=${loader?.in('fail') ? 'error' : 'busy'}>\n </foxy-spinner>\n `;\n }\n\n return html`\n <div>\n <input\n placeholder=${this.t('search_placeholder')}\n class=\"w-full leading-m font-medium bg-contrast-5 rounded text-body transition-colors hover-bg-contrast-10 focus-bg-contrast-10 focus-outline-none focus-ring-2 focus-ring-primary-50\"\n style=\"padding: var(--lumo-space-xs) calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n type=\"search\"\n .value=${this.__search}\n @input=${(evt: Event) => {\n this.__search = (evt.currentTarget as HTMLInputElement).value;\n }}\n />\n\n <section data-testid=\"select-method-list\">\n ${this.__groupedAvailablePaymentMethods.map(({ name, items }) => {\n return html`\n <p class=\"font-medium text-tertiary py-m\">${name}</p>\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${items.map((item, index) =>\n this.__renderPaymentMethodButton(item, index, items.length)\n )}\n </foxy-internal-summary-control>\n `;\n })}\n </section>\n </div>\n `;\n }\n\n private __renderPaymentMethodConfig() {\n const oauthGateways = [\n 'stripe_connect',\n 'stripe_v2',\n 'square_up',\n 'quickbook_payments',\n 'amazon_mws',\n 'paypal_platform',\n ];\n\n if (this.form.type && oauthGateways.includes(this.form.type)) {\n return html`\n <div\n class=\"flex items-start rounded border border-primary\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px); padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" class=\"flex-shrink-0 text-primary\" style=\"width: 1.25em\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\" clip-rule=\"evenodd\"></path></svg>`}\n <p>\n <foxy-i18n infer=\"\" key=\"no_oauth_support_message\"></foxy-i18n>\n <br />\n <a\n target=\"_blank\"\n class=\"mt-xs inline-block rounded font-medium text-primary transition-colors cursor-pointer hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50\"\n href=\"https://admin.foxycart.com\"\n >\n admin.foxycart.com\n </a>\n </p>\n </div>\n `;\n }\n\n return html`\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"description\">\n </foxy-internal-text-control>\n\n ${this.form.helper?.supports_auth_only\n ? html`\n <foxy-internal-switch-control infer=\"use-auth-only\" helper-text-as-tooltip>\n </foxy-internal-switch-control>\n `\n : ''}\n ${this.form.helper?.supports_3d_secure\n ? html`\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"three-d-secure-toggle\"\n .getValue=${this.__threeDSecureToggleGetValue}\n .setValue=${this.__threeDSecureToggleSetValue}\n .options=${this.__threeDSecureToggleOptions}\n >\n </foxy-internal-select-control>\n\n ${this.form.config_3d_secure\n ? html`\n <foxy-internal-switch-control\n layout=\"summary-item\"\n infer=\"three-d-secure-response\"\n .getValue=${this.__threeDSecureResponseGetValue}\n .setValue=${this.__threeDSecureResponseSetValue}\n >\n </foxy-internal-switch-control>\n `\n : ''}\n `\n : ''}\n </foxy-internal-summary-control>\n\n ${['live', 'test'].map((type, index) => {\n const propertyPrefix = index === 0 ? '' : (`${type}_` as '' | 'test_');\n const inferPrefix = index === 0 ? '' : `${type}-`;\n const blocks = index === 0 ? this.__liveBlocks : this.__testBlocks;\n const scope = `${type}-group`;\n\n if (type === 'live' && !this.__storeLoader?.data) return html``;\n if (type === 'live' && !this.__storeLoader?.data?.is_active) {\n return html`\n <foxy-internal-summary-control infer=\"${type}-group\">\n <div\n class=\"flex items-start\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" class=\"flex-shrink-0 text-primary\" style=\"width: 1.25em\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\" clip-rule=\"evenodd\"></path></svg>`}\n <p><foxy-i18n infer=\"\" key=\"inactive_message\"></foxy-i18n></p>\n </div>\n </foxy-internal-summary-control>\n `;\n }\n\n const showInactiveSetText =\n this.__storeLoader?.data?.is_active === true &&\n ((type === 'test' && this.__paymentPresetLoader?.data?.is_live === true) ||\n (type === 'live' && this.__paymentPresetLoader?.data?.is_live === false));\n\n return html`\n <foxy-internal-summary-control\n helper-text=${ifDefined(\n showInactiveSetText ? this.t(`${scope}.helper_text_inactive`) : void 0\n )}\n layout=\"section\"\n label=${ifDefined(showInactiveSetText ? this.t(`${scope}.label_inactive`) : void 0)}\n infer=${scope}\n >\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${this.form.helper?.id_description\n ? html`\n <foxy-internal-text-control\n placeholder=${this.t('default_additional_field_placeholder')}\n helper-text=\"\"\n layout=\"summary-item\"\n label=${this.form.helper.id_description}\n infer=\"${inferPrefix}account-id\"\n >\n </foxy-internal-text-control>\n `\n : ''}\n ${this.form.helper?.third_party_key_description\n ? html`\n <foxy-internal-password-control\n placeholder=${this.t('default_additional_field_placeholder')}\n helper-text=\"\"\n layout=\"summary-item\"\n label=${this.form.helper.third_party_key_description}\n infer=\"${inferPrefix}third-party-key\"\n >\n </foxy-internal-password-control>\n `\n : ''}\n ${this.form.helper?.key_description\n ? html`\n <foxy-internal-password-control\n placeholder=${this.t('default_additional_field_placeholder')}\n layout=\"summary-item\"\n helper-text=\"\"\n label=${this.form.helper.key_description}\n infer=\"${inferPrefix}account-key\"\n >\n </foxy-internal-password-control>\n `\n : ''}\n ${blocks.map(block => this.__renderBlock(block))}\n ${this.form.helper?.supports_card_verification\n ? html`\n <foxy-internal-select-control\n helper-text=${this.t(\n `${scope}.${inferPrefix}card-verification.helper_text_${\n this.form[`${propertyPrefix}card_verification` as const] || 'disabled'\n }`\n )}\n layout=\"summary-item\"\n infer=\"${inferPrefix}card-verification\"\n .options=${this.__cardVerificationOptions}\n .getValue=${() => {\n return (\n this.form[`${propertyPrefix}card_verification` as const] || 'disabled'\n );\n }}\n >\n </foxy-internal-select-control>\n `\n : ''}\n </foxy-internal-summary-control>\n\n ${this.form.helper?.supports_card_verification &&\n this.form[`${propertyPrefix}card_verification` as const]?.startsWith('enabled_')\n ? html`\n <foxy-internal-summary-control\n layout=\"details\"\n class=\"mt-s\"\n infer=\"${inferPrefix}card-verification-config\"\n >\n ${['visa', 'mastercard', 'american-express', 'discover', 'default'].map(\n type => {\n return html`\n <foxy-internal-number-control\n json-template=${ifDefined(this.form.helper?.card_verification_config)}\n json-path=\"verification_amounts.${type.replace(/-/g, '_')}\"\n property=\"${propertyPrefix}card_verification_config\"\n layout=\"summary-item\"\n infer=\"${inferPrefix}card-verification-config-verification-amounts-${type}\"\n step=\"0.01\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n `;\n }\n )}\n </foxy-internal-summary-control>\n `\n : ''}\n </foxy-internal-summary-control>\n `;\n })}\n ${super.renderBody()}\n `;\n }\n\n private __renderPaymentMethodButton(\n { type, helper }: PaymentMethod,\n index: number,\n total: number\n ) {\n const defaultSrc = PaymentsApiPaymentMethodForm.defaultImageSrc;\n const src = this.getImageSrc?.(type) ?? defaultSrc;\n const onError = (evt: Event) => ((evt.currentTarget as HTMLImageElement).src = defaultSrc);\n\n return html`\n <button\n class=${classMap({\n 'relative w-full block text-left bg-contrast-5 overflow-hidden': true,\n 'focus-outline-none focus-ring-inset focus-ring-2 focus-ring-primary-50': true,\n 'transition-colors hover-bg-contrast-10': !helper.conflict,\n 'cursor-default': !!helper.conflict,\n 'rounded-t': index === 0,\n 'rounded-b': index === total - 1,\n })}\n ?disabled=${!!helper.conflict}\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n @click=${() => this.edit({ type, helper })}\n >\n <figure\n class=\"relative flex items-center\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n <img\n class=${classMap({\n 'h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs': true,\n 'filter grayscale': !!helper.conflict,\n })}\n src=${src}\n alt=\"\"\n @error=${onError}\n />\n <figcaption\n class=${classMap({\n 'min-w-0 flex-1 grid leading-xs': true,\n 'text-disabled': !!helper.conflict,\n })}\n >\n <span class=\"font-medium\">${helper.name}&ZeroWidthSpace;</span>\n ${helper.conflict\n ? html`<span class=\"text-xs\"> ${this.t('conflict_message', helper.conflict)}</span>`\n : ''}\n </figcaption>\n </figure>\n </button>\n `;\n }\n\n private __renderBlock(block: Block) {\n return html`${block.fields.map(field => {\n if (field.type === 'hidden') return;\n const scope = ['additional-fields', field.id].join('-').replace(/_/g, '-');\n\n const getValue = () => {\n try {\n const config = JSON.parse(this.form.additional_fields ?? '{}');\n return get(config, field.id) ?? config.default_value;\n } catch {\n return field.default_value;\n }\n };\n\n const setValue = (newValue: unknown) => {\n let config: Record<string, unknown> = {};\n\n try {\n config = JSON.parse(this.form.additional_fields ?? '');\n } catch {\n // ignore\n }\n\n this.edit({ additional_fields: JSON.stringify(set(config, field.id, newValue)) });\n };\n\n type Option = { name: string; value: string };\n const options = (field as { options?: Option[] }).options;\n\n return html`\n ${field.type === 'checkbox'\n ? html`\n <foxy-internal-switch-control\n helper-text=${field.description ?? ''}\n label=${field.name}\n infer=${scope}\n helper-text-as-tooltip\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-switch-control>\n `\n : field.type === 'select'\n ? html`\n <foxy-internal-select-control\n placeholder=${this.t('default_additional_field_select_placeholder')}\n helper-text=${field.description ?? ''}\n layout=\"summary-item\"\n label=${field.name}\n infer=${scope}\n .options=${options!.map(({ name, value }) => ({ label: name, value }))}\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-select-control>\n `\n : html`\n <foxy-internal-text-control\n helper-text=${field.description ?? ''}\n placeholder=${field.default_value || this.t('default_additional_field_placeholder')}\n layout=\"summary-item\"\n label=${field.name}\n infer=${scope}\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-text-control>\n `}\n `;\n })}`;\n }\n}\n"]}
1
+ {"version":3,"file":"PaymentsApiPaymentMethodForm.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,GAAG,MAAM,eAAe,CAAC;AAahC,kGAAkG;AAClG,MAAM,mBAAmB,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAEhD,MAAM,EAAE,GAAG,kCAAkC,CAAC;AAC9C,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,4BAA6B,SAAQ,IAAU;IAA5D;;QAoDE,oFAAoF;QACpF,kBAAa,GAAkB,IAAI,CAAC;QAEpC,sFAAsF;QACtF,gBAAW,GAAsC,IAAI,CAAC;QAEtD;;;;WAIG;QACH,0BAAqB,GAA+C,IAAI,CAAC;QAEzE,6CAA6C;QAC7C,UAAK,GAAkB,IAAI,CAAC;QAEX,sCAAiC,GAAG,+BAA+B,CAAC;QAEpE,4BAAuB,GAAG,qBAAq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C;iBACxD;gBAAC,WAAM;oBACN,SAAS;iBACV;gBAED,IAAI,CAAC,IAAI,CAAC,EAAE,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;YACpF,CAAC,CAAC;YAGF,MAAM,OAAO,GAAI,KAAgC,CAAC,OAAO,CAAC;YAE1D,OAAO,IAAI,CAAA;UACP,KAAK,CAAC,IAAI,KAAK,UAAU;gBACzB,CAAC,CAAC,IAAI,CAAA;;8BAEc,MAAA,KAAK,CAAC,WAAW,mCAAI,EAAE;wBAC7B,KAAK,CAAC,IAAI;wBACV,KAAK;;4BAED,QAAQ;4BACR,QAAQ;;;aAGvB;gBACH,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ;oBACzB,CAAC,CAAC,IAAI,CAAA;;8BAEc,IAAI,CAAC,CAAC,CAAC,6CAA6C,CAAC;8BACrD,MAAA,KAAK,CAAC,WAAW,mCAAI,EAAE;;wBAE7B,KAAK,CAAC,IAAI;wBACV,KAAK;2BACF,OAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;4BAC1D,QAAQ;4BACR,QAAQ;;;aAGvB;oBACH,CAAC,CAAC,IAAI,CAAA;;8BAEc,MAAA,KAAK,CAAC,WAAW,mCAAI,EAAE;8BACvB,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC;;wBAE3E,KAAK,CAAC,IAAI;wBACV,KAAK;4BACD,QAAQ;4BACR,QAAQ;;;aAGvB;OACN,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF","sourcesContent":["import type { AvailablePaymentMethods, PaymentPreset } from '../PaymentsApi/api/types';\nimport type { Block, Data } from './types';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { BooleanSelector, getResourceId } from '@foxy.io/sdk/core';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html, svg } from 'lit-html';\nimport { classMap } from '../../../utils/class-map';\n\nimport Fuse from 'fuse.js';\nimport has from 'lodash-es/has';\nimport get from 'lodash-es/get';\nimport set from 'lodash-es/set';\n\ntype ConnectChoice = {\n key: string;\n options?: Rels.ConnectGateway['props']['options'];\n};\n\ntype PaymentMethod = {\n helper: AvailablePaymentMethods['values'][string];\n choice?: ConnectChoice;\n type: string;\n};\n\n/** OAuth gateways that connect through fx:connect_gateway. Other OAuth gateways show a notice. */\nconst connectableGateways = ['paypal_platform'];\n\nconst NS = 'payments-api-payment-method-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for the `fx:payment_method` resource of Payments API.\n *\n * _Payments API is a client-side virtual API layer built on top of hAPI\n * in an attempt to streamline access to stores' payment method settings\n * that is currently a bit quirky due to the legacy functionality. To use\n * this element with hAPI, wrap it into a foxy-payments-api node._\n *\n * @element foxy-payments-api-payment-method-form\n * @since 1.21.0\n */\nexport class PaymentsApiPaymentMethodForm extends Base<Data> {\n static get defaultImageSrc(): string {\n return \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='m29.3 14 14-14H32.1l-14 14h11.2Zm2.7 9.9 12-12V.7L30.62 14.1A2 2 0 0 1 32 16v7.9ZM13.31 44h11.18L44 24.5V13.3l-12 12V28a2 2 0 0 1-2 2h-2.69l-14 14Zm-1.41 0H.7l14-14h11.2l-14 14Zm14 0h11.2l6.9-6.9V25.9L25.9 44Zm12.6 0H44v-5.5L38.5 44Z'/%3E%3Cpath fill='%23fff' d='M30 28H14v-6h16v6Zm0-10v-2H14v2h16ZM0 43.3l13.4-13.4A2 2 0 0 1 12 28v-7.9L0 32.12V43.3Z'/%3E%3Cpath fill='%23fff' d='M16.7 14H14c-1.11 0-1.99.89-1.99 2v2.7L0 30.7V19.52L19.52 0H30.7l-14 14Zm1.4-14H6.92L0 6.92V18.1L18.1 0ZM5.5 0H0v5.5L5.5 0Z'/%3E%3C/svg%3E\";\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n paymentPreset: { attribute: 'payment-preset' },\n getImageSrc: { attribute: false },\n getConnectRedirectUrl: { attribute: false },\n store: {},\n __search: { attribute: false },\n __connectState: { attribute: false },\n __connectKey: { attribute: false },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ description: v }) => !v || v.length <= 100 || 'description:v8n_too_long',\n ({ type: v }) => !!v || 'type:v8n_required',\n\n form => {\n const blocks = form.helper?.additional_fields?.blocks ?? [];\n let additionalFields: Record<string, unknown>;\n\n try {\n additionalFields = JSON.parse(form.additional_fields ?? '{}');\n } catch {\n additionalFields = {};\n }\n\n for (const block of blocks) {\n for (const field of block.fields) {\n if ('optional' in (field as Record<string, unknown>)) {\n if (!(field as Record<string, unknown>).optional) {\n if (!has(additionalFields, field.id)) {\n if (field.type !== 'checkbox') {\n return 'additional-fields:v8n_invalid';\n }\n }\n }\n }\n }\n }\n\n return true;\n },\n ];\n }\n\n /** URL of the linked `fx:payment_preset` resource from the virtual Payments API. */\n paymentPreset: string | null = null;\n\n /** A function that returns a URL of a payment method icon based on the given type. */\n getImageSrc: ((type: string) => string) | null = null;\n\n /**\n * Returns the URL the gateway sends the merchant back to after a connection.\n * Receives the `payment-preset` URL. The API appends a `status` query parameter.\n * Defaults to the current page URL.\n */\n getConnectRedirectUrl: ((paymentPreset: string) => string) | null = null;\n\n /** URL of the linked `fx:store` resource. */\n store: string | null = null;\n\n private readonly __availablePaymentMethodsLoaderId = 'availablePaymentMethodsLoader';\n\n private readonly __paymentPresetLoaderId = 'paymentPresetLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n private readonly __threeDSecureResponseGetValue = () => {\n return this.form.config_3d_secure?.endsWith('require_valid_response');\n };\n\n private readonly __threeDSecureResponseSetValue = (newValue: boolean) => {\n const postfix = newValue ? '_require_valid_response' : '';\n const config = this.form.config_3d_secure;\n const type = config?.startsWith('all_cards') ? 'all_cards' : 'maestro_only';\n\n this.edit({ config_3d_secure: `${type}${postfix}` as Data['config_3d_secure'] });\n };\n\n private readonly __threeDSecureToggleGetValue = () => {\n const config = this.form.config_3d_secure;\n\n if (config?.startsWith('all_cards')) return 'all_cards';\n if (config?.startsWith('maestro_only')) return 'maestro_only';\n\n return 'off';\n };\n\n private readonly __threeDSecureToggleSetValue = (\n newValue: 'off' | 'all_cards' | 'maestro_only'\n ) => {\n let newFormValue = '';\n\n if (newValue === 'all_cards' || newValue === 'maestro_only') {\n if (this.form.config_3d_secure?.endsWith('require_valid_response')) {\n newFormValue = `${newValue}_require_valid_response`;\n } else {\n newFormValue = newValue;\n }\n }\n\n this.edit({ config_3d_secure: newFormValue as Data['config_3d_secure'] });\n };\n\n private readonly __threeDSecureToggleOptions = [\n { value: 'off', label: 'option_off' },\n { value: 'all_cards', label: 'option_all_cards' },\n { value: 'maestro_only', label: 'option_maestro_only' },\n ];\n\n private readonly __cardVerificationOptions = [\n { label: 'option_disabled', value: 'disabled' },\n { label: 'option_enabled_automatically', value: 'enabled_automatically' },\n { label: 'option_enabled_override', value: 'enabled_override' },\n ];\n\n private __search = '';\n\n private __connectState: 'idle' | 'busy' = 'idle';\n\n /** Key of the connect choice whose connection URL is being fetched. */\n private __connectKey = '';\n\n get hiddenSelector(): BooleanSelector {\n return new BooleanSelector(`header:copy-json ${super.hiddenSelector}`.trimEnd());\n }\n\n renderHeader(...params: Parameters<InternalForm<Data>['renderHeader']>): TemplateResult {\n return html`\n <div>\n ${super.renderHeader(...params)}\n ${this.data?.type || !this.form.type\n ? html``\n : html`\n <vaadin-button\n data-testid=\"select-another-button\"\n theme=\"tertiary-inline\"\n @click=${() => this.undo()}\n >\n <foxy-i18n infer=\"\" key=\"select_another_button_label\"></foxy-i18n>\n </vaadin-button>\n `}\n </div>\n `;\n }\n\n get headerTitleOptions(): Record<string, unknown> {\n return {\n context: this.form.type ? 'selected' : 'new',\n name: this.form.helper?.name,\n };\n }\n\n get headerSubtitleOptions(): Record<string, unknown> {\n if (this.href) {\n const vId = getResourceId(this.href) as string;\n const id = this.headerCopyIdValue;\n if (vId.startsWith('R')) return { context: 'regular', id };\n return { context: 'hosted', id };\n }\n\n return {};\n }\n\n get headerCopyIdValue(): string | number {\n if (this.href) {\n const id = getResourceId(this.href) as string;\n return id.startsWith('R') ? id.slice(1) : id.slice(1).split('C')[0];\n } else {\n return '';\n }\n }\n\n renderBody(): TemplateResult {\n const paymentPreset = this.__paymentPresetLoader?.data;\n\n const loaders = html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(paymentPreset?._links['fx:available_payment_methods'].href)}\n id=${this.__availablePaymentMethodsLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.store)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.paymentPreset)}\n id=${this.__paymentPresetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n\n return html`${this.renderHeader()}${this.form.type\n ? this.__renderPaymentMethodConfig()\n : this.__renderPaymentMethodSelector()}${loaders}`;\n }\n\n private get __groupedAvailablePaymentMethods() {\n const allMethods = Object.entries(this.__availablePaymentMethods ?? {});\n const filteredMethods = this.__search\n ? new Fuse(allMethods, { keys: ['1.name'], threshold: 0.25 })\n .search(this.__search)\n .map(v => v.item)\n : allMethods;\n\n return filteredMethods\n .sort((a, b) => a[1].name.localeCompare(b[1].name, 'en'))\n .reduce((groups, [type, helper]) => {\n if (helper.is_deprecated) return groups;\n\n const firstChar = helper.name.charAt(0).toUpperCase();\n const isSpecialCharacter = !/\\w/.test(firstChar);\n const name = isSpecialCharacter ? '#' : firstChar;\n const group = groups.find(group => group.name === name);\n\n const items: PaymentMethod[] = connectableGateways.includes(type)\n ? this.__getConnectChoices(type).map(choice => ({ type, helper, choice }))\n : [{ type, helper }];\n\n if (group) {\n group.items.push(...items);\n } else {\n groups.push({ name, items });\n }\n\n return groups;\n }, [] as { name: string; items: PaymentMethod[] }[]);\n }\n\n private get __availablePaymentMethodsLoader() {\n type Loader = NucleonElement<AvailablePaymentMethods>;\n return this.renderRoot.querySelector<Loader>(`#${this.__availablePaymentMethodsLoaderId}`);\n }\n\n private get __availablePaymentMethods() {\n return this.__availablePaymentMethodsLoader?.data?.values;\n }\n\n private get __paymentPresetLoader() {\n type Loader = NucleonElement<PaymentPreset>;\n return this.renderRoot.querySelector<Loader>(`#${this.__paymentPresetLoaderId}`);\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n\n private get __liveBlocks() {\n return this.form.helper?.additional_fields?.blocks.filter(block => block.is_live) ?? [];\n }\n\n private get __testBlocks() {\n return this.form.helper?.additional_fields?.blocks.filter(block => !block.is_live) ?? [];\n }\n\n private __renderPaymentMethodSelector() {\n const loader = this.__availablePaymentMethodsLoader;\n\n if (!loader?.data) {\n return html`\n <foxy-spinner infer=\"list-spinner\" state=${loader?.in('fail') ? 'error' : 'busy'}>\n </foxy-spinner>\n `;\n }\n\n return html`\n <div>\n <input\n placeholder=${this.t('search_placeholder')}\n class=\"w-full leading-m font-medium bg-contrast-5 rounded text-body transition-colors hover-bg-contrast-10 focus-bg-contrast-10 focus-outline-none focus-ring-2 focus-ring-primary-50\"\n style=\"padding: var(--lumo-space-xs) calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n type=\"search\"\n .value=${this.__search}\n @input=${(evt: Event) => {\n this.__search = (evt.currentTarget as HTMLInputElement).value;\n }}\n />\n\n <section data-testid=\"select-method-list\">\n ${this.__groupedAvailablePaymentMethods.map(({ name, items }) => {\n return html`\n <p class=\"font-medium text-tertiary py-m\">${name}</p>\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${items.map((item, index) =>\n this.__renderPaymentMethodButton(item, index, items.length)\n )}\n </foxy-internal-summary-control>\n `;\n })}\n </section>\n </div>\n `;\n }\n\n private __redirect(url: string) {\n window.location.assign(url);\n }\n\n private __getConnectChoices(type: string): ConnectChoice[] {\n if (type === 'paypal_platform') {\n return [\n { key: 'paypal_platform.ppcp', options: { paypal_product_type: 'ppcp' } },\n {\n key: 'paypal_platform.express_checkout',\n options: { paypal_product_type: 'express_checkout' },\n },\n ];\n }\n\n return [{ key: 'default' }];\n }\n\n private __getReconnectChoice(thirdPartyKey: string): ConnectChoice {\n if (this.form.type === 'paypal_platform') {\n // An empty third-party key means the account is connected for PayPal only, without cards.\n const key = thirdPartyKey ? 'reconnect' : 'reconnect_with_cards';\n return { key: `paypal_platform.${key}`, options: { paypal_product_type: 'ppcp' } };\n }\n\n return { key: 'reconnect' };\n }\n\n private async __connect(choice: ConnectChoice, type: string) {\n const presetLink = this.__paymentPresetLoader?.data?._links['fx:connect_gateway'];\n const href = this.data?._links['fx:connect_gateway']?.href ?? presetLink?.href;\n if (!href || !this.paymentPreset || this.__connectState === 'busy') return;\n\n this.__connectState = 'busy';\n this.__connectKey = choice.key;\n this.status = null;\n\n try {\n const body: Rels.ConnectGateway['props'] = {\n type,\n final_redirect: this.getConnectRedirectUrl?.(this.paymentPreset) ?? window.location.href,\n };\n\n if (choice.options) body.options = choice.options;\n\n const response = await this._fetch<{ connection_url: string | null }>(href, {\n method: 'POST',\n body: JSON.stringify(body),\n });\n\n // The API answers 201 with a null URL when the gateway itself fails to create one.\n if (!response.connection_url) throw new Error('No connection_url in the response.');\n\n // State stays busy on purpose: the spinner keeps going until the browser leaves the page.\n this.__redirect(response.connection_url);\n } catch (err) {\n let message = '';\n\n if (err instanceof Response) {\n try {\n const json = await err.json();\n message = json?._embedded?.['fx:errors']?.[0]?.message ?? '';\n } catch {\n // not a vnd.error response\n }\n }\n\n // The API's country error names raw option values ('ppcp', 'express_checkout'), so we\n // replace it with our own text. It's the only 403 our requests can get that mentions 'ppcp'.\n const isPpcpUnsupported =\n err instanceof Response &&\n err.status === 403 &&\n choice.options?.paypal_product_type === 'ppcp' &&\n message.includes(\"'ppcp'\");\n\n if (isPpcpUnsupported) {\n this.status = { key: 'connect_error_ppcp_unsupported', type: 'error' };\n } else if (message) {\n this.status = { key: 'connect_error', options: { message }, type: 'error' };\n } else {\n this.status = { key: 'connect_error_unknown', type: 'error' };\n }\n\n this.__connectState = 'idle';\n }\n }\n\n private __renderConnection() {\n const preset = this.__paymentPresetLoader?.data;\n if (!preset) return html``;\n\n const prefix = preset.is_live ? '' : 'test_';\n const email = this.data?.[`${prefix}account_id` as const];\n const thirdPartyKey = this.data?.[`${prefix}third_party_key` as const] ?? '';\n const type = this.form.type as string;\n const choices = email\n ? [this.__getReconnectChoice(thirdPartyKey)]\n : this.__getConnectChoices(type);\n const isBusy = this.__connectState === 'busy';\n const isReadonly = this.readonlySelector.matches('connection', true);\n const isDisabled = isBusy || this.disabledSelector.matches('connection', true);\n\n return html`\n <foxy-internal-summary-control infer=\"connection\">\n ${email\n ? html`\n <p class=\"font-medium\">\n <foxy-i18n infer=\"\" key=\"status_connected\" .options=${{ email }}></foxy-i18n>\n </p>\n `\n : ''}\n ${(isReadonly ? [] : choices).map(\n choice => html`\n <div class=\"leading-xs\">\n <p class=\"font-medium\">\n <foxy-i18n infer=\"\" key=\"${choice.key}.label\"></foxy-i18n>\n </p>\n <p class=\"text-s text-secondary\">\n <foxy-i18n infer=\"\" key=\"${choice.key}.description\"></foxy-i18n>\n </p>\n </div>\n <div>\n <vaadin-button\n data-testid=\"connect-${choice.key}\"\n theme=\"tertiary-inline\"\n ?disabled=${isDisabled}\n @click=${() => this.__connect(choice, type)}\n >\n ${isBusy && this.__connectKey === choice.key\n ? html`<foxy-spinner layout=\"no-label\" infer=\"connect-spinner\"></foxy-spinner>`\n : html`<foxy-i18n infer=\"\" key=\"${choice.key}.button\"></foxy-i18n>`}\n </vaadin-button>\n </div>\n `\n )}\n </foxy-internal-summary-control>\n `;\n }\n\n private __renderPaymentMethodConfig() {\n if (this.form.type && connectableGateways.includes(this.form.type)) {\n return html`\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"description\">\n </foxy-internal-text-control>\n </foxy-internal-summary-control>\n\n ${this.__renderConnection()} ${super.renderBody()}\n `;\n }\n\n const oauthGateways = [\n 'stripe_connect',\n 'stripe_v2',\n 'square_up',\n 'quickbook_payments',\n 'amazon_mws',\n 'paypal_platform',\n ];\n\n if (this.form.type && oauthGateways.includes(this.form.type)) {\n return html`\n <div\n class=\"flex items-start rounded border border-primary\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px); padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" class=\"flex-shrink-0 text-primary\" style=\"width: 1.25em\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\" clip-rule=\"evenodd\"></path></svg>`}\n <p>\n <foxy-i18n infer=\"\" key=\"no_oauth_support_message\"></foxy-i18n>\n <br />\n <a\n target=\"_blank\"\n class=\"mt-xs inline-block rounded font-medium text-primary transition-colors cursor-pointer hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50\"\n href=\"https://admin.foxycart.com\"\n >\n admin.foxycart.com\n </a>\n </p>\n </div>\n `;\n }\n\n return html`\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"description\">\n </foxy-internal-text-control>\n\n ${this.form.helper?.supports_auth_only\n ? html`\n <foxy-internal-switch-control infer=\"use-auth-only\" helper-text-as-tooltip>\n </foxy-internal-switch-control>\n `\n : ''}\n ${this.form.helper?.supports_3d_secure\n ? html`\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"three-d-secure-toggle\"\n .getValue=${this.__threeDSecureToggleGetValue}\n .setValue=${this.__threeDSecureToggleSetValue}\n .options=${this.__threeDSecureToggleOptions}\n >\n </foxy-internal-select-control>\n\n ${this.form.config_3d_secure\n ? html`\n <foxy-internal-switch-control\n layout=\"summary-item\"\n infer=\"three-d-secure-response\"\n .getValue=${this.__threeDSecureResponseGetValue}\n .setValue=${this.__threeDSecureResponseSetValue}\n >\n </foxy-internal-switch-control>\n `\n : ''}\n `\n : ''}\n </foxy-internal-summary-control>\n\n ${['live', 'test'].map((type, index) => {\n const propertyPrefix = index === 0 ? '' : (`${type}_` as '' | 'test_');\n const inferPrefix = index === 0 ? '' : `${type}-`;\n const blocks = index === 0 ? this.__liveBlocks : this.__testBlocks;\n const scope = `${type}-group`;\n\n if (type === 'live' && !this.__storeLoader?.data) return html``;\n if (type === 'live' && !this.__storeLoader?.data?.is_active) {\n return html`\n <foxy-internal-summary-control infer=\"${type}-group\">\n <div\n class=\"flex items-start\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" class=\"flex-shrink-0 text-primary\" style=\"width: 1.25em\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\" clip-rule=\"evenodd\"></path></svg>`}\n <p><foxy-i18n infer=\"\" key=\"inactive_message\"></foxy-i18n></p>\n </div>\n </foxy-internal-summary-control>\n `;\n }\n\n const showInactiveSetText =\n this.__storeLoader?.data?.is_active === true &&\n ((type === 'test' && this.__paymentPresetLoader?.data?.is_live === true) ||\n (type === 'live' && this.__paymentPresetLoader?.data?.is_live === false));\n\n return html`\n <foxy-internal-summary-control\n helper-text=${ifDefined(\n showInactiveSetText ? this.t(`${scope}.helper_text_inactive`) : void 0\n )}\n layout=\"section\"\n label=${ifDefined(showInactiveSetText ? this.t(`${scope}.label_inactive`) : void 0)}\n infer=${scope}\n >\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${this.form.helper?.id_description\n ? html`\n <foxy-internal-text-control\n placeholder=${this.t('default_additional_field_placeholder')}\n helper-text=\"\"\n layout=\"summary-item\"\n label=${this.form.helper.id_description}\n infer=\"${inferPrefix}account-id\"\n >\n </foxy-internal-text-control>\n `\n : ''}\n ${this.form.helper?.third_party_key_description\n ? html`\n <foxy-internal-password-control\n placeholder=${this.t('default_additional_field_placeholder')}\n helper-text=\"\"\n layout=\"summary-item\"\n label=${this.form.helper.third_party_key_description}\n infer=\"${inferPrefix}third-party-key\"\n >\n </foxy-internal-password-control>\n `\n : ''}\n ${this.form.helper?.key_description\n ? html`\n <foxy-internal-password-control\n placeholder=${this.t('default_additional_field_placeholder')}\n layout=\"summary-item\"\n helper-text=\"\"\n label=${this.form.helper.key_description}\n infer=\"${inferPrefix}account-key\"\n >\n </foxy-internal-password-control>\n `\n : ''}\n ${blocks.map(block => this.__renderBlock(block))}\n ${this.form.helper?.supports_card_verification\n ? html`\n <foxy-internal-select-control\n helper-text=${this.t(\n `${scope}.${inferPrefix}card-verification.helper_text_${\n this.form[`${propertyPrefix}card_verification` as const] || 'disabled'\n }`\n )}\n layout=\"summary-item\"\n infer=\"${inferPrefix}card-verification\"\n .options=${this.__cardVerificationOptions}\n .getValue=${() => {\n return (\n this.form[`${propertyPrefix}card_verification` as const] || 'disabled'\n );\n }}\n >\n </foxy-internal-select-control>\n `\n : ''}\n </foxy-internal-summary-control>\n\n ${this.form.helper?.supports_card_verification &&\n this.form[`${propertyPrefix}card_verification` as const]?.startsWith('enabled_')\n ? html`\n <foxy-internal-summary-control\n layout=\"details\"\n class=\"mt-s\"\n infer=\"${inferPrefix}card-verification-config\"\n >\n ${['visa', 'mastercard', 'american-express', 'discover', 'default'].map(\n type => {\n return html`\n <foxy-internal-number-control\n json-template=${ifDefined(this.form.helper?.card_verification_config)}\n json-path=\"verification_amounts.${type.replace(/-/g, '_')}\"\n property=\"${propertyPrefix}card_verification_config\"\n layout=\"summary-item\"\n infer=\"${inferPrefix}card-verification-config-verification-amounts-${type}\"\n step=\"0.01\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n `;\n }\n )}\n </foxy-internal-summary-control>\n `\n : ''}\n </foxy-internal-summary-control>\n `;\n })}\n ${super.renderBody()}\n `;\n }\n\n private __renderPaymentMethodButton(\n { type, helper, choice }: PaymentMethod,\n index: number,\n total: number\n ) {\n const defaultSrc = PaymentsApiPaymentMethodForm.defaultImageSrc;\n const src = this.getImageSrc?.(type) ?? defaultSrc;\n const onError = (evt: Event) => ((evt.currentTarget as HTMLImageElement).src = defaultSrc);\n const isBusy = this.__connectState === 'busy';\n const isConnecting = isBusy && !!choice && this.__connectKey === choice.key;\n const hasChoiceLabel = !!choice && choice.key !== 'default';\n\n return html`\n <button\n class=${classMap({\n 'relative w-full block text-left bg-contrast-5 overflow-hidden': true,\n 'focus-outline-none focus-ring-inset focus-ring-2 focus-ring-primary-50': true,\n 'transition-colors hover-bg-contrast-10': !helper.conflict,\n 'cursor-default': !!helper.conflict,\n 'rounded-t': index === 0,\n 'rounded-b': index === total - 1,\n })}\n data-testid=${ifDefined(choice ? `connect-${choice.key}` : undefined)}\n ?disabled=${!!helper.conflict || isBusy}\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n @click=${() => (choice ? this.__connect(choice, type) : this.edit({ type, helper }))}\n >\n <figure\n class=\"relative flex items-center\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${isConnecting\n ? html`\n <foxy-spinner\n data-testid=\"connect-spinner\"\n class=\"h-m w-m flex items-center justify-center flex-shrink-0\"\n layout=\"no-label\"\n infer=\"connect-spinner\"\n >\n </foxy-spinner>\n `\n : html`\n <img\n class=${classMap({\n 'h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs':\n true,\n 'filter grayscale': !!helper.conflict,\n })}\n src=${src}\n alt=\"\"\n @error=${onError}\n />\n `}\n <figcaption\n class=${classMap({\n 'min-w-0 flex-1 grid leading-xs': true,\n 'text-disabled': !!helper.conflict,\n })}\n >\n <span class=\"font-medium\">\n ${hasChoiceLabel\n ? this.t(`connection.${choice!.key}.label`)\n : helper.name}&ZeroWidthSpace;\n </span>\n ${helper.conflict\n ? html`<span class=\"text-xs\"> ${this.t('conflict_message', helper.conflict)}</span>`\n : choice\n ? html`\n <span class=\"text-xs text-secondary\">\n ${hasChoiceLabel ? this.t(`connection.${choice.key}.description`) : ''}\n ${this.t('connection.redirect_notice')}\n </span>\n `\n : ''}\n </figcaption>\n </figure>\n </button>\n `;\n }\n\n private __renderBlock(block: Block) {\n return html`${block.fields.map(field => {\n if (field.type === 'hidden') return;\n const scope = ['additional-fields', field.id].join('-').replace(/_/g, '-');\n\n const getValue = () => {\n try {\n const config = JSON.parse(this.form.additional_fields ?? '{}');\n return get(config, field.id) ?? config.default_value;\n } catch {\n return field.default_value;\n }\n };\n\n const setValue = (newValue: unknown) => {\n let config: Record<string, unknown> = {};\n\n try {\n config = JSON.parse(this.form.additional_fields ?? '');\n } catch {\n // ignore\n }\n\n this.edit({ additional_fields: JSON.stringify(set(config, field.id, newValue)) });\n };\n\n type Option = { name: string; value: string };\n const options = (field as { options?: Option[] }).options;\n\n return html`\n ${field.type === 'checkbox'\n ? html`\n <foxy-internal-switch-control\n helper-text=${field.description ?? ''}\n label=${field.name}\n infer=${scope}\n helper-text-as-tooltip\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-switch-control>\n `\n : field.type === 'select'\n ? html`\n <foxy-internal-select-control\n placeholder=${this.t('default_additional_field_select_placeholder')}\n helper-text=${field.description ?? ''}\n layout=\"summary-item\"\n label=${field.name}\n infer=${scope}\n .options=${options!.map(({ name, value }) => ({ label: name, value }))}\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-select-control>\n `\n : html`\n <foxy-internal-text-control\n helper-text=${field.description ?? ''}\n placeholder=${field.default_value || this.t('default_additional_field_placeholder')}\n layout=\"summary-item\"\n label=${field.name}\n infer=${scope}\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-text-control>\n `}\n `;\n })}`;\n }\n}\n"]}
@@ -21,6 +21,8 @@ declare const Base: typeof InternalForm & import("lit-element").Constructor<impo
21
21
  export declare class PaymentsApiPaymentPresetForm extends Base<Data> {
22
22
  static get properties(): PropertyDeclarations;
23
23
  static get v8n(): NucleonV8N<Data>;
24
+ /** Passed to the payment method form. See `PaymentsApiPaymentMethodForm.getConnectRedirectUrl`. */
25
+ getConnectRedirectUrl: ((paymentPreset: string) => string) | null;
24
26
  /** A function that returns image URL for given fraud protection `type`. */
25
27
  getFraudProtectionImageSrc: ((type: string) => string) | null;
26
28
  /** A function that returns image URL for given payment method `type`. */
@@ -19,6 +19,8 @@ const Base = TranslatableMixin(InternalForm, NS);
19
19
  export class PaymentsApiPaymentPresetForm extends Base {
20
20
  constructor() {
21
21
  super(...arguments);
22
+ /** Passed to the payment method form. See `PaymentsApiPaymentMethodForm.getConnectRedirectUrl`. */
23
+ this.getConnectRedirectUrl = null;
22
24
  /** A function that returns image URL for given fraud protection `type`. */
23
25
  this.getFraudProtectionImageSrc = null;
24
26
  /** A function that returns image URL for given payment method `type`. */
@@ -36,6 +38,7 @@ export class PaymentsApiPaymentPresetForm extends Base {
36
38
  static get properties() {
37
39
  return {
38
40
  ...super.properties,
41
+ getConnectRedirectUrl: { attribute: false },
39
42
  getFraudProtectionImageSrc: { attribute: false },
40
43
  getPaymentMethodImageSrc: { attribute: false },
41
44
  };
@@ -102,6 +105,7 @@ export class PaymentsApiPaymentPresetForm extends Base {
102
105
  wide
103
106
  .itemProps=${{ '.getImageSrc': this.getPaymentMethodImageSrc }}
104
107
  .formProps=${{
108
+ '.getConnectRedirectUrl': this.getConnectRedirectUrl,
105
109
  '.getImageSrc': this.getPaymentMethodImageSrc,
106
110
  'payment-preset': this.href,
107
111
  'store': (_d = this.data) === null || _d === void 0 ? void 0 : _d._links['fx:store'].href,
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentsApiPaymentPresetForm.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,kCAAkC,CAAC;AAC9C,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,4BAA6B,SAAQ,IAAU;IAA5D;;QAgBE,2EAA2E;QAC3E,+BAA0B,GAAsC,IAAI,CAAC;QAErE,yEAAyE;QACzE,6BAAwB,GAAsC,IAAI,CAAC;QAElD,qCAAgC,GAA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C,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI;SAC5C;;;;;;gBAMO,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,sBAAsB,EAAE,IAAI,CAAC;;;;;qBAKpD,EAAE,cAAc,EAAE,IAAI,CAAC,0BAA0B,EAAE;qBACnD,EAAE,cAAc,EAAE,IAAI,CAAC,0BAA0B,EAAE;;;;QAIhE,KAAK,CAAC,UAAU,EAAE;;;;;eAKX,SAAS,OAAC,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC;aAC/C,IAAI,CAAC,eAAe;kBACf,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;;;KAGvC,CAAC;IACJ,CAAC;IAED,IAAY,aAAa;QAEvB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAS,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Data } from './types';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'payments-api-payment-preset-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for the `fx:payment_preset` resource of Payments API.\n *\n * _Payments API is a client-side virtual API layer built on top of hAPI\n * in an attempt to streamline access to stores' payment method settings\n * that is currently a bit quirky due to the legacy functionality. To use\n * this element with hAPI, wrap it into a foxy-payments-api node._\n *\n * @element foxy-payments-api-payment-preset-form\n * @since 1.21.0\n */\nexport class PaymentsApiPaymentPresetForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n getFraudProtectionImageSrc: { attribute: false },\n getPaymentMethodImageSrc: { attribute: false },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ description: v }) => !!v || 'description:v8n_required',\n ({ description: v }) => (v && v.length <= 100) || 'description:v8n_too_long',\n ];\n }\n\n /** A function that returns image URL for given fraud protection `type`. */\n getFraudProtectionImageSrc: ((type: string) => string) | null = null;\n\n /** A function that returns image URL for given payment method `type`. */\n getPaymentMethodImageSrc: ((type: string) => string) | null = null;\n\n private readonly __isPurchaseOrderEnabledGetValue = () => {\n return this.__storeLoader?.data?.is_active ? this.form.is_purchase_order_enabled : false;\n };\n\n private readonly __isLiveGetValue = () => {\n return this.__storeLoader?.data?.is_active ? this.form.is_live : false;\n };\n\n private readonly __storeLoaderId = 'storeLoader';\n\n get readonlySelector(): BooleanSelector {\n const alwaysMatch = [super.hiddenSelector.toString()];\n\n if (!this.__storeLoader?.data?.is_active) {\n alwaysMatch.unshift('general:is-live', 'general:is-purchase-order-enabled');\n }\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = ['header:copy-json', super.hiddenSelector.toString()];\n const isStoreActive = !!this.__storeLoader?.data?.is_active;\n\n if (!this.data) alwaysMatch.unshift('payment-methods', 'fraud-protections');\n if (!isStoreActive) alwaysMatch.unshift('general:is-live', 'general:is-purchase-order-enabled');\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n renderBody(): TemplateResult {\n const isStoreActive = !!this.__storeLoader?.data?.is_active;\n const helperTextSuffix = isStoreActive ? '' : '_inactive_store';\n\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"description\">\n </foxy-internal-text-control>\n\n <foxy-internal-switch-control\n helper-text=${this.t(`general.is-live.helper_text${helperTextSuffix}`)}\n infer=\"is-live\"\n helper-text-as-tooltip\n .getValue=${this.__isLiveGetValue}\n >\n </foxy-internal-switch-control>\n\n <foxy-internal-switch-control\n helper-text=${this.t(`general.is-purchase-order-enabled.helper_text${helperTextSuffix}`)}\n infer=\"is-purchase-order-enabled\"\n helper-text-as-tooltip\n .getValue=${this.__isPurchaseOrderEnabledGetValue}\n >\n </foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-list-control\n infer=\"payment-methods\"\n first=${ifDefined(this.data?._links['fx:payment_methods'].href)}\n limit=\"5\"\n item=\"foxy-payments-api-payment-method-card\"\n form=\"foxy-payments-api-payment-method-form\"\n alert\n wide\n .itemProps=${{ '.getImageSrc': this.getPaymentMethodImageSrc }}\n .formProps=${{\n '.getImageSrc': this.getPaymentMethodImageSrc,\n 'payment-preset': this.href,\n 'store': this.data?._links['fx:store'].href,\n }}\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-async-list-control\n infer=\"fraud-protections\"\n first=${ifDefined(this.data?._links['fx:fraud_protections'].href)}\n limit=\"5\"\n item=\"foxy-payments-api-fraud-protection-card\"\n form=\"foxy-payments-api-fraud-protection-form\"\n alert\n .itemProps=${{ '.getImageSrc': this.getFraudProtectionImageSrc }}\n .formProps=${{ '.getImageSrc': this.getFraudProtectionImageSrc }}\n >\n </foxy-internal-async-list-control>\n\n ${super.renderBody()}\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.data?._links['fx:store'].href)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n}\n"]}
1
+ {"version":3,"file":"PaymentsApiPaymentPresetForm.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.ts"],"names":[],"mappings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,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Data } from './types';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'payments-api-payment-preset-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for the `fx:payment_preset` resource of Payments API.\n *\n * _Payments API is a client-side virtual API layer built on top of hAPI\n * in an attempt to streamline access to stores' payment method settings\n * that is currently a bit quirky due to the legacy functionality. To use\n * this element with hAPI, wrap it into a foxy-payments-api node._\n *\n * @element foxy-payments-api-payment-preset-form\n * @since 1.21.0\n */\nexport class PaymentsApiPaymentPresetForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n getConnectRedirectUrl: { attribute: false },\n getFraudProtectionImageSrc: { attribute: false },\n getPaymentMethodImageSrc: { attribute: false },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ description: v }) => !!v || 'description:v8n_required',\n ({ description: v }) => (v && v.length <= 100) || 'description:v8n_too_long',\n ];\n }\n\n /** Passed to the payment method form. See `PaymentsApiPaymentMethodForm.getConnectRedirectUrl`. */\n getConnectRedirectUrl: ((paymentPreset: string) => string) | null = null;\n\n /** A function that returns image URL for given fraud protection `type`. */\n getFraudProtectionImageSrc: ((type: string) => string) | null = null;\n\n /** A function that returns image URL for given payment method `type`. */\n getPaymentMethodImageSrc: ((type: string) => string) | null = null;\n\n private readonly __isPurchaseOrderEnabledGetValue = () => {\n return this.__storeLoader?.data?.is_active ? this.form.is_purchase_order_enabled : false;\n };\n\n private readonly __isLiveGetValue = () => {\n return this.__storeLoader?.data?.is_active ? this.form.is_live : false;\n };\n\n private readonly __storeLoaderId = 'storeLoader';\n\n get readonlySelector(): BooleanSelector {\n const alwaysMatch = [super.hiddenSelector.toString()];\n\n if (!this.__storeLoader?.data?.is_active) {\n alwaysMatch.unshift('general:is-live', 'general:is-purchase-order-enabled');\n }\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = ['header:copy-json', super.hiddenSelector.toString()];\n const isStoreActive = !!this.__storeLoader?.data?.is_active;\n\n if (!this.data) alwaysMatch.unshift('payment-methods', 'fraud-protections');\n if (!isStoreActive) alwaysMatch.unshift('general:is-live', 'general:is-purchase-order-enabled');\n\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n renderBody(): TemplateResult {\n const isStoreActive = !!this.__storeLoader?.data?.is_active;\n const helperTextSuffix = isStoreActive ? '' : '_inactive_store';\n\n return html`\n ${this.renderHeader()}\n\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"description\">\n </foxy-internal-text-control>\n\n <foxy-internal-switch-control\n helper-text=${this.t(`general.is-live.helper_text${helperTextSuffix}`)}\n infer=\"is-live\"\n helper-text-as-tooltip\n .getValue=${this.__isLiveGetValue}\n >\n </foxy-internal-switch-control>\n\n <foxy-internal-switch-control\n helper-text=${this.t(`general.is-purchase-order-enabled.helper_text${helperTextSuffix}`)}\n infer=\"is-purchase-order-enabled\"\n helper-text-as-tooltip\n .getValue=${this.__isPurchaseOrderEnabledGetValue}\n >\n </foxy-internal-switch-control>\n </foxy-internal-summary-control>\n\n <foxy-internal-async-list-control\n infer=\"payment-methods\"\n first=${ifDefined(this.data?._links['fx:payment_methods'].href)}\n limit=\"5\"\n item=\"foxy-payments-api-payment-method-card\"\n form=\"foxy-payments-api-payment-method-form\"\n alert\n wide\n .itemProps=${{ '.getImageSrc': this.getPaymentMethodImageSrc }}\n .formProps=${{\n '.getConnectRedirectUrl': this.getConnectRedirectUrl,\n '.getImageSrc': this.getPaymentMethodImageSrc,\n 'payment-preset': this.href,\n 'store': this.data?._links['fx:store'].href,\n }}\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-async-list-control\n infer=\"fraud-protections\"\n first=${ifDefined(this.data?._links['fx:fraud_protections'].href)}\n limit=\"5\"\n item=\"foxy-payments-api-fraud-protection-card\"\n form=\"foxy-payments-api-fraud-protection-form\"\n alert\n .itemProps=${{ '.getImageSrc': this.getFraudProtectionImageSrc }}\n .formProps=${{ '.getImageSrc': this.getFraudProtectionImageSrc }}\n >\n </foxy-internal-async-list-control>\n\n ${super.renderBody()}\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.data?._links['fx:store'].href)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n}\n"]}