@payrails/web-sdk 5.29.0-RC.0 → 5.29.1-RC.2

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.29.0-RC.0",
3
+ "version": "5.29.1-RC.2",
4
4
  "description": "SDK providing tokenization options on the client for merchants",
5
5
  "main": "index.js",
6
6
  "types": "payrails.d.ts",
@@ -683,6 +683,126 @@
683
683
  }
684
684
  }
685
685
 
686
+ .payrails-dynamic-element-form {
687
+ display: flex;
688
+ flex-direction: column;
689
+ gap: 16px;
690
+ width: 100%;
691
+ }
692
+
693
+ .payrails-dynamic-element-form-field {
694
+ display: flex;
695
+ flex-direction: column;
696
+ gap: 4px;
697
+ width: 100%;
698
+ }
699
+
700
+ .payrails-dynamic-element-form-field-label {
701
+ font-size: 14px;
702
+ font-weight: 500;
703
+ color: #000000;
704
+ margin-bottom: 4px;
705
+ }
706
+
707
+ .payrails-dynamic-element-form-field-component {
708
+ width: 100%;
709
+ }
710
+
711
+ .payrails-dynamic-element-form-field-error {
712
+ font-size: 12px;
713
+ color: #ff0000;
714
+ margin-top: 4px;
715
+ display: none;
716
+ }
717
+
718
+ .payrails-dynamic-element-form-field.error
719
+ .payrails-dynamic-element-form-field-error {
720
+ display: block;
721
+ }
722
+
723
+ .payrails-dynamic-element-input {
724
+ width: 100%;
725
+ padding: 10px 16px;
726
+ border: 1px solid #eae8ee;
727
+ font-size: 14px;
728
+ color: #1d1d1d;
729
+ background-color: #fff;
730
+ box-sizing: border-box;
731
+ transition: border-color 0.2s ease;
732
+ }
733
+
734
+ .payrails-dynamic-element-input:focus {
735
+ outline: none;
736
+ border-color: #007bff;
737
+ box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
738
+ }
739
+
740
+ .payrails-dynamic-element-input:invalid {
741
+ border-color: #f25226;
742
+ background-color: #f9e1e1;
743
+ }
744
+
745
+ .payrails-dynamic-element-form-field.error .payrails-dynamic-element-input {
746
+ border-color: #f25226;
747
+ background-color: #f9e1e1;
748
+ }
749
+
750
+ .payrails-dynamic-element-input::placeholder {
751
+ color: grey;
752
+ opacity: 1;
753
+ }
754
+
755
+ .payrails-dynamic-element-select {
756
+ appearance: none;
757
+ -webkit-appearance: none;
758
+ -moz-appearance: none;
759
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
760
+ background-repeat: no-repeat;
761
+ background-position: right 8px center;
762
+ width: 100%;
763
+ font-size: 14px;
764
+ color: #1d1d1d;
765
+ background-color: #fff;
766
+ box-sizing: border-box;
767
+ transition: border-color 0.2s ease;
768
+ padding: 10px 16px;
769
+ margin: 0;
770
+ border: 1px solid #eae8ee;
771
+ box-shadow: none;
772
+ cursor: pointer;
773
+ }
774
+
775
+ .payrails-dynamic-element-tabs {
776
+ display: flex;
777
+ flex-direction: row;
778
+ border: 1px solid #eae8ee;
779
+ padding: 4px;
780
+ background: transparent;
781
+ }
782
+
783
+ .payrails-dynamic-element-tabs button.payrails-dynamic-element-tab {
784
+ border-radius: 0;
785
+ flex: 1;
786
+ background: white;
787
+ border: none;
788
+ outline: none;
789
+ font-size: 16px;
790
+ font-weight: 500;
791
+ color: #000000;
792
+ padding: 4px;
793
+ text-transform: unset;
794
+ cursor: pointer;
795
+ }
796
+
797
+ .payrails-dynamic-element-tabs button.payrails-dynamic-element-tab.active {
798
+ background-color: #e0e5ed;
799
+ }
800
+
801
+ .payrails-dynamic-element-tabs button.payrails-dynamic-element-tab:hover {
802
+ background-color: unset;
803
+ color: unset;
804
+ }
805
+
686
806
  button.payrails-generic-button {
687
807
  border: none;
688
808
  outline: none;
package/payrails.d.ts CHANGED
@@ -2,6 +2,85 @@ import * as _payrails_iframe_event_bus from '@payrails/iframe-event-bus';
2
2
  import { LogLevel as LogLevel$1 } from '@payrails/logger';
3
3
  import { FraudProvider } from '@payrails/fraud-sdk';
4
4
 
5
+ type JSONSchemaType = JSONSchemaProperty & {
6
+ required?: string[];
7
+ dependentSchemas?: Record<string, JSONSchemaDependentSchema>;
8
+ };
9
+ interface JSONSchemaDependentSchema {
10
+ oneOf: Array<{
11
+ properties: Record<string, {
12
+ const: string | number;
13
+ }>;
14
+ required: string[];
15
+ }>;
16
+ }
17
+ interface JSONSchemaProperty {
18
+ type?: 'string' | 'number' | 'boolean' | 'array' | 'object';
19
+ title?: string;
20
+ oneOf?: JSONSchemaOneOfOption[];
21
+ pattern?: string;
22
+ minLength?: number;
23
+ maxLength?: number;
24
+ errorMessage?: Record<string, string>;
25
+ $ref?: string;
26
+ properties?: Record<string, JSONSchemaType>;
27
+ }
28
+ interface JSONSchemaOneOfOption {
29
+ const: string | number;
30
+ title: string;
31
+ }
32
+ interface JSONSchemaOneOfOption {
33
+ const: string | number;
34
+ title: string;
35
+ }
36
+ interface DynamicElementFieldTranslation {
37
+ label?: string;
38
+ placeholder?: string;
39
+ errors?: Partial<DynamicElementErrorTranslation>;
40
+ }
41
+ interface DynamicElementErrorTranslation {
42
+ required: string;
43
+ minLength: string;
44
+ maxLength: string;
45
+ pattern: string;
46
+ oneOf: string;
47
+ }
48
+ type DynamicElementTranslations = {
49
+ labels?: {
50
+ submitButton?: string;
51
+ };
52
+ fields?: Record<string, DynamicElementFieldTranslation>;
53
+ errors?: Partial<DynamicElementErrorTranslation>;
54
+ };
55
+ interface DynamicElementElementStyles {
56
+ base?: Partial<CSSStyleDeclaration>;
57
+ complete?: Partial<CSSStyleDeclaration>;
58
+ empty?: Partial<CSSStyleDeclaration>;
59
+ focus?: Partial<CSSStyleDeclaration>;
60
+ invalid?: Partial<CSSStyleDeclaration>;
61
+ }
62
+ type DynamicElementInputFieldStyles = DynamicElementElementStyles;
63
+ type DynamicElementSelectFieldStyles = DynamicElementElementStyles;
64
+ interface DynamicElementTabsFieldStyles {
65
+ tab: {
66
+ base?: Partial<CSSStyleDeclaration>;
67
+ active?: Partial<CSSStyleDeclaration>;
68
+ };
69
+ container?: DynamicElementElementStyles;
70
+ }
71
+ interface DynamicElementFieldStyles {
72
+ base?: Partial<CSSStyleDeclaration>;
73
+ label?: Partial<CSSStyleDeclaration>;
74
+ errors?: Partial<CSSStyleDeclaration>;
75
+ input?: DynamicElementInputFieldStyles;
76
+ select?: DynamicElementSelectFieldStyles;
77
+ tabs?: DynamicElementTabsFieldStyles;
78
+ }
79
+ interface DynamicElementStyles {
80
+ all: Omit<DynamicElementFieldStyles, 'label'>;
81
+ fields?: Record<string, DynamicElementFieldStyles>;
82
+ }
83
+
5
84
  declare enum PAYMENT_METHOD_CODES {
6
85
  'CARD' = "card",
7
86
  'GOOGLE_PAY' = "googlePay",
@@ -9,7 +88,8 @@ declare enum PAYMENT_METHOD_CODES {
9
88
  'APPLE_PAY' = "applePay",
10
89
  'GENERIC_REDIRECT' = "genericRedirect",
11
90
  'MERCADO_PAGO' = "mercadoPago",
12
- 'PIX' = "pix"
91
+ 'PIX' = "pix",
92
+ 'BANK_ACCOUNT' = "bankAccount"
13
93
  }
14
94
  declare enum PAYMENT_INSTRUMENT_STATUS {
15
95
  'ENABLED' = "enabled",
@@ -45,7 +125,7 @@ declare class WorkflowExecution {
45
125
  static get savedGooglePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
46
126
  static get savedApplePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
47
127
  static get paypalConfig(): PayPalConfig;
48
- static get googlePayConfig(): GooglePayConfig[];
128
+ static get googlePayConfig(): any;
49
129
  static isPaymentMethodAvailable(paymentMethod: PAYMENT_METHOD_CODES): boolean;
50
130
  static get applePayConfig(): {
51
131
  merchantIdentifier: string;
@@ -90,6 +170,8 @@ declare class WorkflowExecution {
90
170
  supportsInstallments?: boolean;
91
171
  installments?: PaymentInstallmentsConfig;
92
172
  supportsBillingInfo?: boolean;
173
+ schema?: JSONSchemaType;
174
+ additionalConfig?: any;
93
175
  };
94
176
  paymentMethodCode: PAYMENT_METHOD_CODES;
95
177
  } | undefined;
@@ -104,6 +186,8 @@ declare class WorkflowExecution {
104
186
  supportsInstallments?: boolean;
105
187
  installments?: PaymentInstallmentsConfig;
106
188
  supportsBillingInfo?: boolean;
189
+ schema?: JSONSchemaType;
190
+ additionalConfig?: any;
107
191
  };
108
192
  paymentMethodCode: PAYMENT_METHOD_CODES;
109
193
  };
@@ -191,6 +275,8 @@ interface StorablePaymentCompositionOption<I = CardMetadata | PayPalMetadata, C
191
275
  supportsInstallments?: boolean;
192
276
  installments?: PaymentInstallmentsConfig;
193
277
  supportsBillingInfo?: boolean;
278
+ schema?: JSONSchemaType;
279
+ additionalConfig?: any;
194
280
  };
195
281
  paymentInstruments?: Array<StoredPaymentInstrument<I>>;
196
282
  }
@@ -198,9 +284,21 @@ interface GooglePayConfig {
198
284
  parameters: {
199
285
  allowedAuthMethods: google.payments.api.CardAuthMethod[];
200
286
  allowedCardNetworks: google.payments.api.CardNetwork[];
287
+ billingAddressParameters?: {
288
+ format?: string;
289
+ };
290
+ billingAddressRequired?: boolean;
201
291
  };
202
292
  tokenizationSpecification: google.payments.api.PaymentMethodTokenizationSpecification;
203
293
  type: google.payments.api.PaymentMethodType;
294
+ apiVersion?: number;
295
+ apiVersionMinor?: number;
296
+ allowedPaymentMethods?: google.payments.api.PaymentMethodSpecification[];
297
+ emailRequired?: boolean;
298
+ shippingAddressRequired?: boolean;
299
+ shippingAddressParameters?: google.payments.api.ShippingAddressParameters;
300
+ merchantInfo?: google.payments.api.MerchantInfo;
301
+ existingPaymentMethodRequired?: boolean;
204
302
  }
205
303
  interface PayPalConfig {
206
304
  clientId: string;
@@ -242,7 +340,8 @@ interface CardMetadata {
242
340
  }
243
341
  declare enum PAYMENT_CLIENT_FLOW {
244
342
  'REDIRECT' = "redirect",
245
- 'DIRECT' = "direct"
343
+ 'DIRECT' = "direct",
344
+ 'EMBEDDED' = "embedded"
246
345
  }
247
346
  declare enum INTEGRATION_TYPE {
248
347
  API = "api",
@@ -633,6 +732,16 @@ declare class PayrailsElement implements Mountable {
633
732
  unmount(): void;
634
733
  }
635
734
 
735
+ interface TokenizeOptions {
736
+ futureUsage?: 'CardOnFile' | 'Subscription' | 'UnscheduledCardOnFile';
737
+ storeInstrument?: boolean;
738
+ }
739
+ declare abstract class Tokenizable extends PayrailsElement {
740
+ abstract collect(): Promise<any>;
741
+ protected abstract constructSaveInstrumentBody(tokens: any, opts?: TokenizeOptions): Promise<any>;
742
+ tokenize(_opts?: TokenizeOptions): Promise<any>;
743
+ }
744
+
636
745
  declare enum ElementType {
637
746
  CARD_NUMBER = "CARD_NUMBER",
638
747
  CARDHOLDER_NAME = "CARDHOLDER_NAME",
@@ -697,7 +806,7 @@ interface PayrailsSecureField {
697
806
  resetError?: () => void;
698
807
  setValue?: (elementValue: string) => void;
699
808
  clearValue?: () => void;
700
- update: (data: CollectElementOptions) => void;
809
+ update?: (data: Partial<CollectElementOptions>) => void;
701
810
  }
702
811
  declare class PayrailsCollectContainer implements Mountable {
703
812
  bin: string;
@@ -728,10 +837,6 @@ declare class PayrailsCollectContainer implements Mountable {
728
837
  bin: string;
729
838
  }>;
730
839
  }
731
- interface TokenizeOptions {
732
- futureUsage?: 'CardOnFile' | 'Subscription' | 'UnscheduledCardOnFile';
733
- storeInstrument?: boolean;
734
- }
735
840
 
736
841
  interface IAddress {
737
842
  country?: {
@@ -921,12 +1026,14 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
921
1026
  private lastBinLookup;
922
1027
  private defaultStyles;
923
1028
  private defaultTranslations;
1029
+ private eventsRef?;
924
1030
  constructor(collectContainer: PayrailsCollectContainer, options?: CardFormOptions | undefined);
925
1031
  private initializeFormFields;
926
1032
  getErrorTextStyles(errorTextStyles: any): any;
927
1033
  private updateStyles;
928
1034
  private updateTranslations;
929
- update(options: Partial<Pick<CardFormOptions, 'styles' | 'translations'>>): void;
1035
+ private updateEvents;
1036
+ update(options: Partial<Pick<CardFormOptions, 'styles' | 'translations' | 'events'>>): void;
930
1037
  private createFormField;
931
1038
  private initializeCustomLayout;
932
1039
  private hasFieldBeenUsed;
@@ -989,6 +1096,13 @@ declare class CardList extends PayrailsElement {
989
1096
  reset(): void;
990
1097
  }
991
1098
 
1099
+ declare enum RequestMethod {
1100
+ GET = "GET",
1101
+ POST = "POST",
1102
+ DELETE = "DELETE",
1103
+ PATCH = "PATCH"
1104
+ }
1105
+
992
1106
  interface SdkConfiguration {
993
1107
  token: string;
994
1108
  amount: PayrailsAmount;
@@ -1010,6 +1124,7 @@ interface SdkConfiguration {
1010
1124
  links: {
1011
1125
  saveInstrument: {
1012
1126
  href: string;
1127
+ method: RequestMethod;
1013
1128
  };
1014
1129
  };
1015
1130
  };
@@ -1082,7 +1197,8 @@ declare class CardPaymentButton extends PayrailsElement {
1082
1197
  private constructEncryptedPayment;
1083
1198
  private updateStyles;
1084
1199
  private updateTranslations;
1085
- update(options: Partial<Pick<CardPaymentButtonOptions, 'styles' | 'translations'>>): void;
1200
+ private updateEvents;
1201
+ update(options: Partial<Pick<CardPaymentButtonOptions, 'styles' | 'translations' | 'events'>>): void;
1086
1202
  private handleAuthorizationResult;
1087
1203
  }
1088
1204
  declare enum AuthorizationFailureReasons {
@@ -1112,6 +1228,7 @@ interface LoadingScreenStyles {
1112
1228
  [StyleKeys.loader]?: Partial<CSSStyleDeclaration>;
1113
1229
  }
1114
1230
 
1231
+ type GooglePayConfigInput = google.payments.api.IsReadyToPayPaymentMethodSpecification[] | GooglePayConfig;
1115
1232
  interface GooglePayButtonOptions extends StoreInstrumentElementOptions {
1116
1233
  environment?: PayrailsEnvironment;
1117
1234
  merchantInfo?: google.payments.api.MerchantInfo;
@@ -1134,8 +1251,9 @@ declare class GooglePayButton extends PayrailsElementWithStoreInstrumentCheckbox
1134
1251
  private static googleSDKClient;
1135
1252
  private sdkLoadedCalled;
1136
1253
  private buttonElement;
1254
+ private static getGooglePayConfigAsArray;
1137
1255
  private static getSDKClient;
1138
- static isGooglePayAvailable(allowedPaymentMethods: google.payments.api.IsReadyToPayPaymentMethodSpecification[], environment?: PayrailsEnvironment, merchantInfo?: google.payments.api.MerchantInfo): Promise<boolean>;
1256
+ static isGooglePayAvailable(allowedPaymentMethods: GooglePayConfigInput, environment?: PayrailsEnvironment, merchantInfo?: google.payments.api.MerchantInfo): Promise<boolean>;
1139
1257
  constructor(options: GooglePayButtonOptions);
1140
1258
  private sdkLoaded;
1141
1259
  private onLoadPaymentData;
@@ -1160,6 +1278,7 @@ interface ApplePayDropinOptions extends ApplePayButtonOptions {
1160
1278
  labels?: {
1161
1279
  label?: string;
1162
1280
  storeInstrument?: string;
1281
+ paymentScreenLabel?: string;
1163
1282
  };
1164
1283
  };
1165
1284
  events?: ApplePayButtonOptions['events'] & DropinElementEvents;
@@ -1216,9 +1335,11 @@ declare class GenericRedirectButton extends PayrailsElement {
1216
1335
  private redirectToPaymentLink;
1217
1336
  private updateStyles;
1218
1337
  private updateTranslations;
1338
+ private updateEvents;
1219
1339
  update(options: {
1220
1340
  styles?: ButtonOptions['styles'];
1221
1341
  translations?: ButtonOptions['translations'];
1342
+ events?: ButtonOptions['events'];
1222
1343
  }): void;
1223
1344
  }
1224
1345
 
@@ -1327,6 +1448,7 @@ declare class Dropin extends PayrailsElement {
1327
1448
  private loadingScreen;
1328
1449
  constructor(collectContainer: PayrailsCollectContainer, clientConfig: PayrailsClientOptions, dropinConfig: DropinOptions);
1329
1450
  private isHppIntegration;
1451
+ private isEmbeddedElement;
1330
1452
  private createStoredInstrumentElement;
1331
1453
  private createInstallmentsDropdown;
1332
1454
  private getInstallmentOptionsForInstrument;
@@ -1338,6 +1460,7 @@ declare class Dropin extends PayrailsElement {
1338
1460
  private createCardForm;
1339
1461
  private createApplePayButton;
1340
1462
  private createCardPaymentButton;
1463
+ private createEmbeddedElement;
1341
1464
  private onAuthorizeSuccess;
1342
1465
  private getElementEvents;
1343
1466
  private onAuthorizePending;
@@ -1417,11 +1540,36 @@ interface ContainerStyles {
1417
1540
  styles?: Partial<CSSStyleDeclaration>;
1418
1541
  }
1419
1542
 
1420
- declare enum RequestMethod {
1421
- GET = "GET",
1422
- POST = "POST",
1423
- DELETE = "DELETE",
1424
- PATCH = "PATCH"
1543
+ interface DynamicElementOptions {
1544
+ styles?: DynamicElementStyles;
1545
+ translations?: DynamicElementTranslations;
1546
+ events?: PaymentEvents;
1547
+ paymentMethod: BasePaymentMethodConfig;
1548
+ }
1549
+ interface FormConfig {
1550
+ schema: JSONSchemaType;
1551
+ }
1552
+ declare class DynamicElementForm extends Tokenizable {
1553
+ protected options: DynamicElementOptions;
1554
+ protected readonly formConfig: FormConfig;
1555
+ private readonly returnInfo?;
1556
+ private formFields;
1557
+ private formData;
1558
+ private __schema;
1559
+ constructor(options: DynamicElementOptions, formConfig: FormConfig, returnInfo?: ReturnInfo | undefined);
1560
+ collect(): Promise<Record<string, any>>;
1561
+ protected constructSaveInstrumentBody(tokens: any, opts?: TokenizeOptions): Promise<any>;
1562
+ private isFormValid;
1563
+ mount(location: string): Promise<void>;
1564
+ private makeForm;
1565
+ private createField;
1566
+ private createFieldSync;
1567
+ private createOneOfField;
1568
+ private createStringField;
1569
+ private createFieldByType;
1570
+ private extractStyles;
1571
+ private makeFieldEvents;
1572
+ private evaluateDependencies;
1425
1573
  }
1426
1574
 
1427
1575
  type Operations = {
@@ -1547,6 +1695,7 @@ declare class Payrails {
1547
1695
  private __cardPaymentButton;
1548
1696
  private __paypalButton;
1549
1697
  private __genericRedirectButton;
1698
+ private __dynamicElementForm;
1550
1699
  private __dropin;
1551
1700
  static preloadCardForm: typeof SdkLoader.preloadCardForm;
1552
1701
  static init(initResponse: InitOptions, options?: PayrailsClientOptions): Payrails;
@@ -1571,6 +1720,7 @@ declare class Payrails {
1571
1720
  paymentButton(options: CardPaymentButtonOptions): CardPaymentButton;
1572
1721
  paypalButton(options?: PaypalButtonOptions): PaypalButton;
1573
1722
  genericRedirectButton(options: GenericRedirectButtonOptions): GenericRedirectButton;
1723
+ dynamicElement(options: DynamicElementOptions): DynamicElementForm;
1574
1724
  getSavedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
1575
1725
  private logIntegrationMode;
1576
1726
  private constructor();
@@ -1588,7 +1738,7 @@ interface PaymentEvents {
1588
1738
  onPaymentButtonClicked?: (e?: {
1589
1739
  bin?: string;
1590
1740
  }) => Promise<boolean>;
1591
- onAuthorizeRequestStart?: () => void;
1741
+ onAuthorizeRequestStart?: () => Promise<boolean>;
1592
1742
  onPaymentSessionExpired?: () => void;
1593
1743
  onThreeDSecureChallenge?: () => void;
1594
1744
  }
@@ -1643,6 +1793,13 @@ declare enum PayrailsEnvironment {
1643
1793
  interface ApplePayButtonOptions extends StoreInstrumentElementOptions {
1644
1794
  clientDomain?: string;
1645
1795
  showPaymentMethodLogo?: boolean;
1796
+ translations?: {
1797
+ labels?: {
1798
+ storeInstrument?: string;
1799
+ saveInstrument?: string;
1800
+ paymentScreenLabel?: string;
1801
+ };
1802
+ };
1646
1803
  events?: PaymentEvents & {
1647
1804
  onApplePayAvailable?: () => void;
1648
1805
  };