@payrails/web-sdk 5.28.0 → 5.29.0-RC.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payrails/web-sdk",
3
- "version": "5.28.0",
3
+ "version": "5.29.0-RC.0",
4
4
  "description": "SDK providing tokenization options on the client for merchants",
5
5
  "main": "index.js",
6
6
  "types": "payrails.d.ts",
@@ -760,12 +760,12 @@ button.payrails-generic-button {
760
760
  min-height: 44px;
761
761
  }
762
762
 
763
- #payrails-container-wrapper {
763
+ .payrails-container-wrapper {
764
764
  width: 100%;
765
765
  min-height: 90px;
766
766
  }
767
767
 
768
- .with-card-holder #payrails-container-wrapper {
768
+ .with-card-holder .payrails-container-wrapper {
769
769
  width: 100%;
770
770
  height: min-content;
771
771
  min-height: 120px;
package/payrails.d.ts CHANGED
@@ -453,6 +453,10 @@ declare class ComposableElement {
453
453
  update: (options: any) => void;
454
454
  }
455
455
 
456
+ /**
457
+ * Configuration interface for creating collect elements
458
+ * Defines the structure and styling options for form input elements
459
+ */
456
460
  interface CollectElementInput {
457
461
  table?: string;
458
462
  column?: string;
@@ -466,23 +470,116 @@ interface CollectElementInput {
466
470
  validations?: IValidationRule[];
467
471
  skyflowID?: string;
468
472
  }
473
+ /**
474
+ * Options interface for the collect operation
475
+ * Controls how data is collected and processed
476
+ */
469
477
  interface ICollectOptions {
470
478
  tokens?: boolean;
471
479
  additionalFields?: IInsertRecordInput;
472
480
  upsert?: Array<IUpsertOptions>;
473
481
  }
482
+ /**
483
+ * ComposableContainer class - Main container for managing secure form elements
484
+ *
485
+ * This class extends the base Container and provides functionality to:
486
+ * - Create and manage secure iframe-based form elements
487
+ * - Handle secure communication between parent and iframe contexts
488
+ * - Collect and tokenize sensitive data while maintaining PCI compliance
489
+ * - Manage element lifecycle (create, mount, validate, collect, destroy)
490
+ */
474
491
  declare class ComposableContainer extends Container {
475
492
  #private;
476
493
  type: string;
477
494
  private bus;
478
495
  private iframe;
496
+ /**
497
+ * Constructor - Initializes the composable container
498
+ *
499
+ * Sets up the secure iframe, establishes communication channels,
500
+ * and prepares the container for element creation and management.
501
+ *
502
+ * @param options - Container configuration (layout, styles, etc.)
503
+ * @param metaData - Client metadata and configuration
504
+ * @param skyflowElements - Global elements registry
505
+ * @param context - Application context with logging and config
506
+ */
479
507
  constructor(options: any, metaData: any, skyflowElements: any, context: any);
508
+ /**
509
+ * Creates a new composable form element
510
+ *
511
+ * This method creates a secure form element (like card number, CVV, etc.)
512
+ * that will be rendered inside the secure iframe. The element is added to
513
+ * the container's element list but not yet mounted to the DOM.
514
+ *
515
+ * @param input - Element configuration (type, styles, validations, etc.)
516
+ * @param options - Additional options like required field validation
517
+ * @returns ComposableElement instance for further configuration
518
+ */
480
519
  create: (input: CollectElementInput, options?: any) => ComposableElement;
520
+ /**
521
+ * Registers an event listener for container events
522
+ *
523
+ * Allows the application to listen for events like form submission,
524
+ * validation errors, or other container-level events.
525
+ *
526
+ * @param eventName - The name of the event to listen for
527
+ * @param handler - The callback function to execute when the event occurs
528
+ */
481
529
  on: (eventName: string, handler: any) => void;
530
+ /**
531
+ * Mounts the container and its elements to a DOM element
532
+ *
533
+ * This method organizes the created elements according to the specified layout,
534
+ * applies styling, and renders them within the provided DOM element.
535
+ * The elements are rendered inside secure iframes for PCI compliance.
536
+ *
537
+ * @param domElement - The DOM element where the form should be mounted
538
+ */
482
539
  mount: (domElement: any) => void;
540
+ /**
541
+ * Mounts the container element to the DOM and triggers a mounted event
542
+ *
543
+ * This method mounts the container element to the specified DOM element
544
+ * and then emits an event to notify the SDK that the container has been mounted.
545
+ *
546
+ * @param domElement - The DOM element where the container should be mounted
547
+ */
548
+ mountContainerElement: (domElement: string) => void;
549
+ /**
550
+ * Unmounts the container and cleans up all resources
551
+ *
552
+ * This method removes all elements from the DOM, clears internal state,
553
+ * and removes the iframe to prevent memory leaks.
554
+ */
483
555
  unmount: () => void;
556
+ /**
557
+ * Validates all elements in the container
558
+ *
559
+ * Checks that all elements are mounted and triggers validation
560
+ * in the secure iframe. Returns a promise that resolves with
561
+ * validation results.
562
+ *
563
+ * @returns Promise that resolves with validation results
564
+ */
484
565
  validate: () => Promise<unknown>;
566
+ /**
567
+ * Collects data from all elements in the container
568
+ *
569
+ * This method securely collects sensitive data from all mounted elements,
570
+ * validates the data, and optionally tokenizes it. The actual data collection
571
+ * happens within the secure iframe to maintain PCI compliance.
572
+ *
573
+ * @param options - Collection options (tokenization, additional fields, etc.)
574
+ * @returns Promise that resolves with collected/tokenized data
575
+ */
485
576
  collect: (options?: ICollectOptions) => Promise<unknown>;
577
+ /**
578
+ * Resets all form elements to their initial state
579
+ *
580
+ * Clears all input values and resets validation states
581
+ * by sending a reset command to the secure iframe.
582
+ */
486
583
  reset(): void;
487
584
  }
488
585
 
@@ -518,6 +615,7 @@ interface Mountable {
518
615
  }
519
616
  interface ElementOptions {
520
617
  id?: string;
618
+ dataTestId?: string;
521
619
  className?: string | string[];
522
620
  styles?: Partial<CSSStyleDeclaration>;
523
621
  }
@@ -525,8 +623,9 @@ declare class PayrailsElement implements Mountable {
525
623
  protected element: HTMLElement;
526
624
  protected subElements: Array<Mountable>;
527
625
  readonly id: string | undefined;
626
+ readonly dataTestId: string | undefined;
528
627
  protected eventBus: _payrails_iframe_event_bus.IframeEventBus;
529
- constructor(elementType: string, { id, className }?: ElementOptions);
628
+ constructor(elementType: string, { id, className, dataTestId }?: ElementOptions);
530
629
  get parentElement(): HTMLElement | null;
531
630
  get selector(): string;
532
631
  mount(location: string): void;
@@ -562,6 +661,11 @@ interface CollectElementOptions {
562
661
  errorTextStyles?: object;
563
662
  required?: boolean;
564
663
  enableCardIcon?: boolean;
664
+ translations?: {
665
+ error?: {
666
+ default?: string;
667
+ };
668
+ };
565
669
  }
566
670
  type PayrailsContainerType = 'COLLECT' | 'COMPOSABLE';
567
671
  interface CollectContainerOptions {
@@ -593,11 +697,14 @@ interface PayrailsSecureField {
593
697
  resetError?: () => void;
594
698
  setValue?: (elementValue: string) => void;
595
699
  clearValue?: () => void;
700
+ update: (data: CollectElementOptions) => void;
596
701
  }
597
702
  declare class PayrailsCollectContainer implements Mountable {
598
703
  bin: string;
599
704
  isBinLookupEnabled: boolean;
600
705
  readonly id = "payrails-container-wrapper";
706
+ readonly dataTestId = "payrails-container-wrapper";
707
+ readonly className = "payrails-container-wrapper";
601
708
  private static instance;
602
709
  private readonly __container;
603
710
  private element;
@@ -677,6 +784,7 @@ declare const regexes: {
677
784
  hipercard: RegExp;
678
785
  unionpay: RegExp;
679
786
  maestro: RegExp;
787
+ elo: RegExp;
680
788
  };
681
789
  type CardNetwork = keyof typeof regexes;
682
790
 
@@ -811,9 +919,14 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
811
919
  private throttledFetchBinLookup;
812
920
  private lastBin;
813
921
  private lastBinLookup;
922
+ private defaultStyles;
923
+ private defaultTranslations;
814
924
  constructor(collectContainer: PayrailsCollectContainer, options?: CardFormOptions | undefined);
815
925
  private initializeFormFields;
816
926
  getErrorTextStyles(errorTextStyles: any): any;
927
+ private updateStyles;
928
+ private updateTranslations;
929
+ update(options: Partial<Pick<CardFormOptions, 'styles' | 'translations'>>): void;
817
930
  private createFormField;
818
931
  private initializeCustomLayout;
819
932
  private hasFieldBeenUsed;
@@ -826,14 +939,15 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
826
939
  reset?: boolean;
827
940
  }): void;
828
941
  private triggerOnReady;
942
+ private prepareErrorStyles;
829
943
  private prepareLabelStyles;
830
- private prepareInputStyles;
944
+ prepareInputStyles(styles: CardFieldStyles, type: ElementType): CardFieldStyles;
831
945
  validate(): Promise<{
832
946
  isValid: boolean;
833
947
  errors: string;
834
948
  }>;
835
949
  get isValid(): boolean;
836
- get cardNetwork(): "" | "visa" | "mastercard" | "amex" | "diners" | "discover" | "jcb" | "hipercard" | "unionpay" | "maestro";
950
+ get cardNetwork(): "" | "visa" | "mastercard" | "amex" | "diners" | "discover" | "jcb" | "hipercard" | "unionpay" | "maestro" | "elo";
837
951
  onChange(): void;
838
952
  private updateInstallments;
839
953
  private reset;
@@ -851,6 +965,8 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
851
965
  bin: string;
852
966
  }>;
853
967
  private getinstallmentOptions;
968
+ unmount(): void;
969
+ mount(selector: string): void;
854
970
  }
855
971
  interface LabelStyles {
856
972
  base?: Partial<CSSStyleDeclaration>;
@@ -946,6 +1062,7 @@ declare class CardPaymentButton extends PayrailsElement {
946
1062
  private readonly returnInfo?;
947
1063
  selectedInstrument: StoredPaymentInstrument | null;
948
1064
  paymentInstallmentElement: PayrailsElementWithPaymentInstallmentsDropdown | null;
1065
+ private isLoading;
949
1066
  get bin(): string | undefined;
950
1067
  private readonly paymentExecutor;
951
1068
  private cardForm;
@@ -963,6 +1080,9 @@ declare class CardPaymentButton extends PayrailsElement {
963
1080
  private onAuthorizationFailed;
964
1081
  private onPay;
965
1082
  private constructEncryptedPayment;
1083
+ private updateStyles;
1084
+ private updateTranslations;
1085
+ update(options: Partial<Pick<CardPaymentButtonOptions, 'styles' | 'translations'>>): void;
966
1086
  private handleAuthorizationResult;
967
1087
  }
968
1088
  declare enum AuthorizationFailureReasons {
@@ -1010,9 +1130,10 @@ interface GooglePayButtonOptions extends StoreInstrumentElementOptions {
1010
1130
  }
1011
1131
  declare class GooglePayButton extends PayrailsElementWithStoreInstrumentCheckbox {
1012
1132
  protected options: GooglePayButtonOptions;
1013
- private static instance;
1014
1133
  private readonly paymentExecutor;
1015
1134
  private static googleSDKClient;
1135
+ private sdkLoadedCalled;
1136
+ private buttonElement;
1016
1137
  private static getSDKClient;
1017
1138
  static isGooglePayAvailable(allowedPaymentMethods: google.payments.api.IsReadyToPayPaymentMethodSpecification[], environment?: PayrailsEnvironment, merchantInfo?: google.payments.api.MerchantInfo): Promise<boolean>;
1018
1139
  constructor(options: GooglePayButtonOptions);
@@ -1070,7 +1191,6 @@ interface ButtonOptions {
1070
1191
  hover?: Partial<CSSStyleDeclaration>;
1071
1192
  };
1072
1193
  }
1073
-
1074
1194
  interface GenericRedirectButtonOptions {
1075
1195
  styles?: ButtonOptions['styles'];
1076
1196
  translations?: {
@@ -1082,14 +1202,24 @@ interface GenericRedirectButtonOptions {
1082
1202
  declare class GenericRedirectButton extends PayrailsElement {
1083
1203
  protected options: GenericRedirectButtonOptions;
1084
1204
  private readonly returnInfo?;
1085
- constructor(options: GenericRedirectButtonOptions, returnInfo?: ReturnInfo | undefined);
1086
1205
  private popup;
1087
- private buildRedirectButton;
1088
1206
  private readonly paymentExecutor;
1207
+ private isDisabled;
1208
+ private isLoading;
1209
+ constructor(options: GenericRedirectButtonOptions, returnInfo?: ReturnInfo | undefined);
1210
+ private setStyles;
1211
+ private removeStyles;
1212
+ private triggerLoading;
1089
1213
  private onClick;
1090
1214
  private handleAuthorizationResult;
1091
1215
  private createPopupWithTimeout;
1092
1216
  private redirectToPaymentLink;
1217
+ private updateStyles;
1218
+ private updateTranslations;
1219
+ update(options: {
1220
+ styles?: ButtonOptions['styles'];
1221
+ translations?: ButtonOptions['translations'];
1222
+ }): void;
1093
1223
  }
1094
1224
 
1095
1225
  interface GenericRedirectDropinOptions {
@@ -1228,6 +1358,7 @@ interface DropinOptions {
1228
1358
  [key: string]: any;
1229
1359
  mercadoPago?: GenericRedirectDropinOptions['config'];
1230
1360
  preselectFirstPaymentOption?: boolean;
1361
+ showPaymentMethodLogo?: boolean;
1231
1362
  cards?: {
1232
1363
  showCardHolderName?: boolean;
1233
1364
  showExistingCards?: boolean;
@@ -1538,4 +1669,5 @@ declare class ApplePayButton extends PayrailsElementWithStoreInstrumentCheckbox
1538
1669
  private onApplePayAuthorized;
1539
1670
  }
1540
1671
 
1541
- export { ApplePayButtonOptions, AuthorizationFailureReasons, CardFormOptions, CardListOptions, CardPaymentButtonOptions, DropinOptions, ElementType, GooglePayButtonOptions, INTEGRATION_TYPE, InitOptions, PAYMENT_METHOD_CODES, PaymentEvents, PaypalButtonOptions, Payrails, PayrailsAmount, PayrailsClientOptions, PayrailsContainerType, PayrailsEnvironment, PayrailsSecureField, PayrailsSecureFieldEvent, SaveInstrumentResponse, WorkflowExecutionResponse };
1672
+ export { AuthorizationFailureReasons, ElementType, INTEGRATION_TYPE, PAYMENT_METHOD_CODES, Payrails, PayrailsEnvironment };
1673
+ export type { ApplePayButtonOptions, CardFormOptions, CardListOptions, CardPaymentButtonOptions, DropinOptions, GooglePayButtonOptions, InitOptions, PaymentEvents, PaypalButtonOptions, PayrailsAmount, PayrailsClientOptions, PayrailsContainerType, PayrailsSecureField, PayrailsSecureFieldEvent, SaveInstrumentResponse, WorkflowExecutionResponse };