@payrails/web-sdk 5.28.1 → 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.1",
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
 
@@ -564,6 +661,11 @@ interface CollectElementOptions {
564
661
  errorTextStyles?: object;
565
662
  required?: boolean;
566
663
  enableCardIcon?: boolean;
664
+ translations?: {
665
+ error?: {
666
+ default?: string;
667
+ };
668
+ };
567
669
  }
568
670
  type PayrailsContainerType = 'COLLECT' | 'COMPOSABLE';
569
671
  interface CollectContainerOptions {
@@ -595,11 +697,14 @@ interface PayrailsSecureField {
595
697
  resetError?: () => void;
596
698
  setValue?: (elementValue: string) => void;
597
699
  clearValue?: () => void;
700
+ update: (data: CollectElementOptions) => void;
598
701
  }
599
702
  declare class PayrailsCollectContainer implements Mountable {
600
703
  bin: string;
601
704
  isBinLookupEnabled: boolean;
602
705
  readonly id = "payrails-container-wrapper";
706
+ readonly dataTestId = "payrails-container-wrapper";
707
+ readonly className = "payrails-container-wrapper";
603
708
  private static instance;
604
709
  private readonly __container;
605
710
  private element;
@@ -814,9 +919,14 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
814
919
  private throttledFetchBinLookup;
815
920
  private lastBin;
816
921
  private lastBinLookup;
922
+ private defaultStyles;
923
+ private defaultTranslations;
817
924
  constructor(collectContainer: PayrailsCollectContainer, options?: CardFormOptions | undefined);
818
925
  private initializeFormFields;
819
926
  getErrorTextStyles(errorTextStyles: any): any;
927
+ private updateStyles;
928
+ private updateTranslations;
929
+ update(options: Partial<Pick<CardFormOptions, 'styles' | 'translations'>>): void;
820
930
  private createFormField;
821
931
  private initializeCustomLayout;
822
932
  private hasFieldBeenUsed;
@@ -829,8 +939,9 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
829
939
  reset?: boolean;
830
940
  }): void;
831
941
  private triggerOnReady;
942
+ private prepareErrorStyles;
832
943
  private prepareLabelStyles;
833
- private prepareInputStyles;
944
+ prepareInputStyles(styles: CardFieldStyles, type: ElementType): CardFieldStyles;
834
945
  validate(): Promise<{
835
946
  isValid: boolean;
836
947
  errors: string;
@@ -854,6 +965,8 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
854
965
  bin: string;
855
966
  }>;
856
967
  private getinstallmentOptions;
968
+ unmount(): void;
969
+ mount(selector: string): void;
857
970
  }
858
971
  interface LabelStyles {
859
972
  base?: Partial<CSSStyleDeclaration>;
@@ -949,6 +1062,7 @@ declare class CardPaymentButton extends PayrailsElement {
949
1062
  private readonly returnInfo?;
950
1063
  selectedInstrument: StoredPaymentInstrument | null;
951
1064
  paymentInstallmentElement: PayrailsElementWithPaymentInstallmentsDropdown | null;
1065
+ private isLoading;
952
1066
  get bin(): string | undefined;
953
1067
  private readonly paymentExecutor;
954
1068
  private cardForm;
@@ -966,6 +1080,9 @@ declare class CardPaymentButton extends PayrailsElement {
966
1080
  private onAuthorizationFailed;
967
1081
  private onPay;
968
1082
  private constructEncryptedPayment;
1083
+ private updateStyles;
1084
+ private updateTranslations;
1085
+ update(options: Partial<Pick<CardPaymentButtonOptions, 'styles' | 'translations'>>): void;
969
1086
  private handleAuthorizationResult;
970
1087
  }
971
1088
  declare enum AuthorizationFailureReasons {
@@ -1074,7 +1191,6 @@ interface ButtonOptions {
1074
1191
  hover?: Partial<CSSStyleDeclaration>;
1075
1192
  };
1076
1193
  }
1077
-
1078
1194
  interface GenericRedirectButtonOptions {
1079
1195
  styles?: ButtonOptions['styles'];
1080
1196
  translations?: {
@@ -1086,14 +1202,24 @@ interface GenericRedirectButtonOptions {
1086
1202
  declare class GenericRedirectButton extends PayrailsElement {
1087
1203
  protected options: GenericRedirectButtonOptions;
1088
1204
  private readonly returnInfo?;
1089
- constructor(options: GenericRedirectButtonOptions, returnInfo?: ReturnInfo | undefined);
1090
1205
  private popup;
1091
- private buildRedirectButton;
1092
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;
1093
1213
  private onClick;
1094
1214
  private handleAuthorizationResult;
1095
1215
  private createPopupWithTimeout;
1096
1216
  private redirectToPaymentLink;
1217
+ private updateStyles;
1218
+ private updateTranslations;
1219
+ update(options: {
1220
+ styles?: ButtonOptions['styles'];
1221
+ translations?: ButtonOptions['translations'];
1222
+ }): void;
1097
1223
  }
1098
1224
 
1099
1225
  interface GenericRedirectDropinOptions {
@@ -1543,4 +1669,5 @@ declare class ApplePayButton extends PayrailsElementWithStoreInstrumentCheckbox
1543
1669
  private onApplePayAuthorized;
1544
1670
  }
1545
1671
 
1546
- 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 };