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

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",
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?: {
@@ -989,6 +1094,13 @@ declare class CardList extends PayrailsElement {
989
1094
  reset(): void;
990
1095
  }
991
1096
 
1097
+ declare enum RequestMethod {
1098
+ GET = "GET",
1099
+ POST = "POST",
1100
+ DELETE = "DELETE",
1101
+ PATCH = "PATCH"
1102
+ }
1103
+
992
1104
  interface SdkConfiguration {
993
1105
  token: string;
994
1106
  amount: PayrailsAmount;
@@ -1010,6 +1122,7 @@ interface SdkConfiguration {
1010
1122
  links: {
1011
1123
  saveInstrument: {
1012
1124
  href: string;
1125
+ method: RequestMethod;
1013
1126
  };
1014
1127
  };
1015
1128
  };
@@ -1112,6 +1225,7 @@ interface LoadingScreenStyles {
1112
1225
  [StyleKeys.loader]?: Partial<CSSStyleDeclaration>;
1113
1226
  }
1114
1227
 
1228
+ type GooglePayConfigInput = google.payments.api.IsReadyToPayPaymentMethodSpecification[] | GooglePayConfig;
1115
1229
  interface GooglePayButtonOptions extends StoreInstrumentElementOptions {
1116
1230
  environment?: PayrailsEnvironment;
1117
1231
  merchantInfo?: google.payments.api.MerchantInfo;
@@ -1134,8 +1248,9 @@ declare class GooglePayButton extends PayrailsElementWithStoreInstrumentCheckbox
1134
1248
  private static googleSDKClient;
1135
1249
  private sdkLoadedCalled;
1136
1250
  private buttonElement;
1251
+ private static getGooglePayConfigAsArray;
1137
1252
  private static getSDKClient;
1138
- static isGooglePayAvailable(allowedPaymentMethods: google.payments.api.IsReadyToPayPaymentMethodSpecification[], environment?: PayrailsEnvironment, merchantInfo?: google.payments.api.MerchantInfo): Promise<boolean>;
1253
+ static isGooglePayAvailable(allowedPaymentMethods: GooglePayConfigInput, environment?: PayrailsEnvironment, merchantInfo?: google.payments.api.MerchantInfo): Promise<boolean>;
1139
1254
  constructor(options: GooglePayButtonOptions);
1140
1255
  private sdkLoaded;
1141
1256
  private onLoadPaymentData;
@@ -1327,6 +1442,7 @@ declare class Dropin extends PayrailsElement {
1327
1442
  private loadingScreen;
1328
1443
  constructor(collectContainer: PayrailsCollectContainer, clientConfig: PayrailsClientOptions, dropinConfig: DropinOptions);
1329
1444
  private isHppIntegration;
1445
+ private isEmbeddedElement;
1330
1446
  private createStoredInstrumentElement;
1331
1447
  private createInstallmentsDropdown;
1332
1448
  private getInstallmentOptionsForInstrument;
@@ -1338,6 +1454,7 @@ declare class Dropin extends PayrailsElement {
1338
1454
  private createCardForm;
1339
1455
  private createApplePayButton;
1340
1456
  private createCardPaymentButton;
1457
+ private createEmbeddedElement;
1341
1458
  private onAuthorizeSuccess;
1342
1459
  private getElementEvents;
1343
1460
  private onAuthorizePending;
@@ -1417,11 +1534,36 @@ interface ContainerStyles {
1417
1534
  styles?: Partial<CSSStyleDeclaration>;
1418
1535
  }
1419
1536
 
1420
- declare enum RequestMethod {
1421
- GET = "GET",
1422
- POST = "POST",
1423
- DELETE = "DELETE",
1424
- PATCH = "PATCH"
1537
+ interface DynamicElementOptions {
1538
+ styles?: DynamicElementStyles;
1539
+ translations?: DynamicElementTranslations;
1540
+ events?: PaymentEvents;
1541
+ paymentMethod: BasePaymentMethodConfig;
1542
+ }
1543
+ interface FormConfig {
1544
+ schema: JSONSchemaType;
1545
+ }
1546
+ declare class DynamicElementForm extends Tokenizable {
1547
+ protected options: DynamicElementOptions;
1548
+ protected readonly formConfig: FormConfig;
1549
+ private readonly returnInfo?;
1550
+ private formFields;
1551
+ private formData;
1552
+ private __schema;
1553
+ constructor(options: DynamicElementOptions, formConfig: FormConfig, returnInfo?: ReturnInfo | undefined);
1554
+ collect(): Promise<Record<string, any>>;
1555
+ protected constructSaveInstrumentBody(tokens: any, opts?: TokenizeOptions): Promise<any>;
1556
+ private isFormValid;
1557
+ mount(location: string): Promise<void>;
1558
+ private makeForm;
1559
+ private createField;
1560
+ private createFieldSync;
1561
+ private createOneOfField;
1562
+ private createStringField;
1563
+ private createFieldByType;
1564
+ private extractStyles;
1565
+ private makeFieldEvents;
1566
+ private evaluateDependencies;
1425
1567
  }
1426
1568
 
1427
1569
  type Operations = {
@@ -1547,6 +1689,7 @@ declare class Payrails {
1547
1689
  private __cardPaymentButton;
1548
1690
  private __paypalButton;
1549
1691
  private __genericRedirectButton;
1692
+ private __dynamicElementForm;
1550
1693
  private __dropin;
1551
1694
  static preloadCardForm: typeof SdkLoader.preloadCardForm;
1552
1695
  static init(initResponse: InitOptions, options?: PayrailsClientOptions): Payrails;
@@ -1571,6 +1714,7 @@ declare class Payrails {
1571
1714
  paymentButton(options: CardPaymentButtonOptions): CardPaymentButton;
1572
1715
  paypalButton(options?: PaypalButtonOptions): PaypalButton;
1573
1716
  genericRedirectButton(options: GenericRedirectButtonOptions): GenericRedirectButton;
1717
+ dynamicElement(options: DynamicElementOptions): DynamicElementForm;
1574
1718
  getSavedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
1575
1719
  private logIntegrationMode;
1576
1720
  private constructor();
@@ -1588,7 +1732,7 @@ interface PaymentEvents {
1588
1732
  onPaymentButtonClicked?: (e?: {
1589
1733
  bin?: string;
1590
1734
  }) => Promise<boolean>;
1591
- onAuthorizeRequestStart?: () => void;
1735
+ onAuthorizeRequestStart?: () => Promise<boolean>;
1592
1736
  onPaymentSessionExpired?: () => void;
1593
1737
  onThreeDSecureChallenge?: () => void;
1594
1738
  }