@payrails/web-sdk 5.29.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/payrails.d.ts CHANGED
@@ -1,144 +1,381 @@
1
- import { LogLevel as LogLevel$1 } from '@payrails/logger';
2
1
  import * as _payrails_iframe_event_bus from '@payrails/iframe-event-bus';
2
+ import { LogLevel as LogLevel$1 } from '@payrails/logger';
3
3
  import { FraudProvider } from '@payrails/fraud-sdk';
4
4
 
5
- interface Mountable {
6
- mount(selector: string | PayrailsElement): void;
7
- unmount(): void;
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
+ }>;
8
16
  }
9
- interface ElementOptions {
10
- id?: string;
11
- dataTestId?: string;
12
- className?: string | string[];
13
- styles?: Partial<CSSStyleDeclaration>;
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>;
14
27
  }
15
- declare class PayrailsElement implements Mountable {
16
- protected element: HTMLElement;
17
- protected subElements: Array<Mountable>;
18
- readonly id: string | undefined;
19
- readonly dataTestId: string | undefined;
20
- protected eventBus: _payrails_iframe_event_bus.IframeEventBus;
21
- constructor(elementType: string, { id, className, dataTestId }?: ElementOptions);
22
- get parentElement(): HTMLElement | null;
23
- get selector(): string;
24
- mount(location: string): void;
25
- protected clean(): void;
26
- unmount(): void;
28
+ interface JSONSchemaOneOfOption {
29
+ const: string | number;
30
+ title: string;
27
31
  }
28
-
29
- interface IAddress {
30
- country?: {
31
- code?: string;
32
- fullName?: string;
33
- iso3?: string;
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;
34
51
  };
35
- postalCode?: string;
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>;
36
61
  }
37
- interface IOnChange {
38
- isValid: boolean;
39
- billingAddress?: IAddress;
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;
40
70
  }
41
- interface AddressSelectorElementOptions extends ElementOptions {
42
- translations?: {
43
- labels?: {
44
- countrySelector?: string;
45
- postalCodeInput?: string;
46
- };
47
- placeholders?: {
48
- postalCodeInput?: string;
49
- countrySelector?: string;
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
+
84
+ declare enum PAYMENT_METHOD_CODES {
85
+ 'CARD' = "card",
86
+ 'GOOGLE_PAY' = "googlePay",
87
+ 'PAYPAL' = "payPal",
88
+ 'APPLE_PAY' = "applePay",
89
+ 'GENERIC_REDIRECT' = "genericRedirect",
90
+ 'MERCADO_PAGO' = "mercadoPago",
91
+ 'PIX' = "pix",
92
+ 'BANK_ACCOUNT' = "bankAccount"
93
+ }
94
+ declare enum PAYMENT_INSTRUMENT_STATUS {
95
+ 'ENABLED' = "enabled",
96
+ 'CREATED' = "created",
97
+ 'DELETED' = "deleted",
98
+ 'DISABLED' = "disabled",
99
+ 'INVALID' = "invalid",
100
+ 'TRANSIENT' = "transient"
101
+ }
102
+ declare class WorkflowExecution {
103
+ private static _response;
104
+ static get response(): WorkflowExecutionResponse;
105
+ static setResponse(response: WorkflowExecutionResponse): typeof WorkflowExecution;
106
+ static get lookup(): {
107
+ httpCode: number;
108
+ body: {
109
+ data: {
110
+ paymentCompositionOptions: Array<StorablePaymentCompositionOption>;
111
+ };
112
+ links: {
113
+ authorize: {
114
+ href: string;
115
+ method: "POST";
116
+ };
117
+ execution: string;
118
+ };
119
+ name: "lookup";
50
120
  };
121
+ } | undefined;
122
+ static get holderReference(): string;
123
+ static get savedCreditCards(): StoredPaymentInstrument<CardMetadata>[];
124
+ static get savedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
125
+ static get savedGooglePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
126
+ static get savedApplePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
127
+ static get paypalConfig(): PayPalConfig;
128
+ static get googlePayConfig(): any;
129
+ static isPaymentMethodAvailable(paymentMethod: PAYMENT_METHOD_CODES): boolean;
130
+ static get applePayConfig(): {
131
+ merchantIdentifier: string;
132
+ supportedNetworks: string[];
133
+ countryCode: string;
134
+ merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
135
+ requiredBillingContactFields?: ApplePayJS.ApplePayContactField[];
51
136
  };
52
- styles?: {
53
- wrapper?: Partial<CSSStyleDeclaration>;
54
- countrySelector?: {
55
- wrapper?: Partial<CSSStyleDeclaration>;
56
- element?: Partial<CSSStyleDeclaration>;
57
- label?: Partial<CSSStyleDeclaration>;
137
+ static get url(): string;
138
+ static get meta(): {
139
+ customer?: {
140
+ country?: {
141
+ code?: string;
142
+ };
58
143
  };
59
- postalCodeInput?: {
60
- wrapper?: Partial<CSSStyleDeclaration>;
61
- element?: Partial<CSSStyleDeclaration>;
62
- label?: Partial<CSSStyleDeclaration>;
144
+ order?: {
145
+ billingAddress?: {
146
+ country?: {
147
+ code?: string;
148
+ };
149
+ };
63
150
  };
64
151
  };
65
- events?: {
66
- onBillingAddressChanged?: (e: IOnChange) => void;
152
+ static get availablePaymentMethods(): StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined>[];
153
+ static get authorizeLink(): string | undefined;
154
+ static get createSessionLink(): string | undefined;
155
+ static get storedPaymentInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
156
+ static get storedDropinInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
157
+ static getFullPaymentMethodConfig(paymentMethod: PAYMENT_METHOD_CODES): StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined> | undefined;
158
+ static isAddressSelectorEnabled(paymentMethod: PAYMENT_METHOD_CODES): boolean | undefined;
159
+ static isPaymentInstallmentsEnabled(paymentMethod: PAYMENT_METHOD_CODES): boolean | undefined;
160
+ static getPaymentInstallmentOptions(paymentMethod: PAYMENT_METHOD_CODES): PaymentInstallmentsConfig;
161
+ static getStoredInstrumentForPaymentMethod<T = CardMetadata | PayPalMetadata>(paymentMethod: PAYMENT_METHOD_CODES): Array<StoredPaymentInstrument<T>>;
162
+ static getPaymentMethodForStoredInstrument<T extends CardMetadata | PayPalMetadata>(instrument: StoredPaymentInstrument<T>): {
163
+ id: string;
164
+ description?: string;
165
+ status: PAYMENT_INSTRUMENT_STATUS;
166
+ integrationType: INTEGRATION_TYPE;
167
+ config: ApplePayConfig | PayPalConfig | GooglePayConfig | undefined;
168
+ clientConfig?: {
169
+ flow?: PAYMENT_CLIENT_FLOW;
170
+ supportsInstallments?: boolean;
171
+ installments?: PaymentInstallmentsConfig;
172
+ supportsBillingInfo?: boolean;
173
+ schema?: JSONSchemaType;
174
+ additionalConfig?: any;
175
+ };
176
+ paymentMethodCode: PAYMENT_METHOD_CODES;
177
+ } | undefined;
178
+ static getPaymentMethodConfig(paymentMethod: StorablePaymentCompositionOption): {
179
+ id: string;
180
+ description?: string;
181
+ status: PAYMENT_INSTRUMENT_STATUS;
182
+ integrationType: INTEGRATION_TYPE;
183
+ config: ApplePayConfig | PayPalConfig | GooglePayConfig | undefined;
184
+ clientConfig?: {
185
+ flow?: PAYMENT_CLIENT_FLOW;
186
+ supportsInstallments?: boolean;
187
+ installments?: PaymentInstallmentsConfig;
188
+ supportsBillingInfo?: boolean;
189
+ schema?: JSONSchemaType;
190
+ additionalConfig?: any;
191
+ };
192
+ paymentMethodCode: PAYMENT_METHOD_CODES;
67
193
  };
68
194
  }
69
-
70
- interface StoreInstrumentElementOptions extends ElementOptions {
71
- showStoreInstrumentCheckbox?: boolean;
72
- alwaysStoreInstrument?: boolean;
73
- defaultStoreInstrumentState?: 'checked' | 'unchecked';
74
- translations?: {
75
- labels?: {
76
- storeInstrument?: string;
77
- saveInstrument?: string;
195
+ interface WorkflowExecutionResponse {
196
+ id: string;
197
+ merchantReference: string;
198
+ holderReference: string;
199
+ actionRequired?: string;
200
+ meta: {
201
+ customer?: {
202
+ country?: {
203
+ code?: string;
204
+ };
205
+ };
206
+ order?: {
207
+ billingAddress?: {
208
+ country?: {
209
+ code?: string;
210
+ };
211
+ };
78
212
  };
79
213
  };
80
- styles?: {
81
- storeInstrumentCheckbox?: Partial<CSSStyleDeclaration>;
214
+ status: Array<{
215
+ code: string;
216
+ time: string;
217
+ }>;
218
+ initialResults: Array<{
219
+ httpCode: number;
220
+ body: {
221
+ data: {
222
+ paymentCompositionOptions: Array<StorablePaymentCompositionOption>;
223
+ };
224
+ links: {
225
+ authorize: {
226
+ href: string;
227
+ method: 'POST';
228
+ };
229
+ execution: string;
230
+ };
231
+ name: 'lookup';
232
+ };
233
+ }>;
234
+ links: {
235
+ startPaymentSession?: {
236
+ href: string;
237
+ method: 'POST';
238
+ };
239
+ confirm?: {
240
+ href: string;
241
+ action?: {
242
+ parameters?: {
243
+ orderId?: string;
244
+ tokenId?: string;
245
+ };
246
+ };
247
+ };
248
+ redirect?: string;
249
+ '3ds'?: string;
250
+ self: string;
251
+ };
252
+ workflow: {
253
+ code: string;
254
+ version: number;
82
255
  };
83
- events?: PayrailsSDKEvents;
84
256
  }
85
- declare class StoreInstrumentCheckbox extends PayrailsElement {
86
- private options;
87
- constructor(options: StoreInstrumentElementOptions);
88
- get isChecked(): boolean;
89
- private createHTML;
90
- private applyStyles;
91
- private addListeners;
257
+ interface BasePaymentMethodConfig {
258
+ paymentMethodCode: PAYMENT_METHOD_CODES;
92
259
  }
93
- declare abstract class PayrailsElementWithStoreInstrumentCheckbox extends PayrailsElement {
94
- protected options?: StoreInstrumentElementOptions | undefined;
95
- protected storeInstrumentCheckbox: StoreInstrumentCheckbox | null;
96
- protected constructor(elementType: string, options?: StoreInstrumentElementOptions | undefined);
97
- protected get shouldStoreInstrument(): boolean;
260
+ interface BaseInstallmentOption {
261
+ count: number;
262
+ amount: number;
98
263
  }
99
-
100
- interface ApplePayButtonOptions extends StoreInstrumentElementOptions {
101
- clientDomain?: string;
102
- showPaymentMethodLogo?: boolean;
103
- events?: PaymentEvents & {
104
- onApplePayAvailable?: () => void;
264
+ interface PaymentInstallmentsConfig {
265
+ [key: string]: BaseInstallmentOption[];
266
+ }
267
+ interface StorablePaymentCompositionOption<I = CardMetadata | PayPalMetadata, C = undefined | ApplePayConfig | PayPalConfig | GooglePayConfig> extends BasePaymentMethodConfig {
268
+ id: string;
269
+ description?: string;
270
+ status: PAYMENT_INSTRUMENT_STATUS;
271
+ integrationType: INTEGRATION_TYPE;
272
+ config: C;
273
+ clientConfig?: {
274
+ flow?: PAYMENT_CLIENT_FLOW;
275
+ supportsInstallments?: boolean;
276
+ installments?: PaymentInstallmentsConfig;
277
+ supportsBillingInfo?: boolean;
278
+ schema?: JSONSchemaType;
279
+ additionalConfig?: any;
105
280
  };
106
- styles?: {
107
- type?: 'plain' | 'buy' | 'addMoney' | 'book' | 'checkout' | 'continue' | 'contribute' | 'donate' | 'inStore' | 'order' | 'reload' | 'rent' | 'setUp' | 'subscribe' | 'support' | 'tip' | 'topUp';
108
- style?: 'white' | 'whiteOutline' | 'black' | 'automatic';
109
- } & StoreInstrumentElementOptions['styles'];
281
+ paymentInstruments?: Array<StoredPaymentInstrument<I>>;
110
282
  }
111
- declare global {
112
- interface Window {
113
- ApplePaySession?: ApplePaySession;
114
- }
283
+ interface GooglePayConfig {
284
+ parameters: {
285
+ allowedAuthMethods: google.payments.api.CardAuthMethod[];
286
+ allowedCardNetworks: google.payments.api.CardNetwork[];
287
+ billingAddressParameters?: {
288
+ format?: string;
289
+ };
290
+ billingAddressRequired?: boolean;
291
+ };
292
+ tokenizationSpecification: google.payments.api.PaymentMethodTokenizationSpecification;
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;
115
302
  }
116
- declare class ApplePayButton extends PayrailsElementWithStoreInstrumentCheckbox {
117
- protected options: ApplePayButtonOptions;
118
- private appleButton;
119
- private paymentExecutor;
120
- static isApplePayAvailable(): Promise<boolean>;
121
- constructor(options: ApplePayButtonOptions);
122
- mount(location: string): void;
123
- unmount(): void;
124
- private mountApplePayButton;
125
- private createApplePaySession;
126
- private onApplePayAuthorized;
303
+ interface PayPalConfig {
304
+ clientId: string;
305
+ merchantId: string;
306
+ captureMode: 'Delayed' | 'Instant' | 'Manual';
307
+ integrationMode: 'express' | 'normal';
308
+ }
309
+ interface ApplePayConfig {
310
+ parameters: {
311
+ merchantIdentifier: string;
312
+ supportedNetworks: string[];
313
+ countryCode: string;
314
+ merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
315
+ requiredBillingContactFields?: ApplePayJS.ApplePayContactField[];
316
+ };
317
+ type: string;
318
+ }
319
+ interface StoredPaymentInstrument<T = CardMetadata | PayPalMetadata> {
320
+ id: string;
321
+ status: PAYMENT_INSTRUMENT_STATUS;
322
+ paymentMethod: PAYMENT_METHOD_CODES;
323
+ displayName?: string;
324
+ data?: T;
325
+ }
326
+ interface PayPalMetadata {
327
+ email?: string;
328
+ }
329
+ interface CardMetadata {
330
+ bin?: string;
331
+ suffix?: string;
332
+ network?: string;
333
+ binLookup?: {
334
+ issuerCountry: {
335
+ code: string;
336
+ name: string;
337
+ iso3: string;
338
+ };
339
+ };
340
+ }
341
+ declare enum PAYMENT_CLIENT_FLOW {
342
+ 'REDIRECT' = "redirect",
343
+ 'DIRECT' = "direct",
344
+ 'EMBEDDED' = "embedded"
345
+ }
346
+ declare enum INTEGRATION_TYPE {
347
+ API = "api",
348
+ HPP = "hpp"
127
349
  }
128
350
 
129
- declare const regexes: {
130
- visa: RegExp;
131
- mastercard: RegExp;
132
- amex: RegExp;
133
- diners: RegExp;
134
- discover: RegExp;
135
- jcb: RegExp;
136
- hipercard: RegExp;
137
- unionpay: RegExp;
138
- maestro: RegExp;
139
- elo: RegExp;
140
- };
141
- type CardNetwork = keyof typeof regexes;
351
+ interface SaveInstrumentResponse {
352
+ id: string;
353
+ createdAt: string;
354
+ holderId: string;
355
+ paymentMethod: PAYMENT_METHOD_CODES.CARD;
356
+ status: PAYMENT_INSTRUMENT_STATUS;
357
+ data: {
358
+ bin: string;
359
+ binLookup?: {
360
+ bin: string;
361
+ network: string;
362
+ issuer?: string;
363
+ issuerCountry?: {
364
+ code?: string;
365
+ name?: string;
366
+ iso3?: string;
367
+ };
368
+ type?: string;
369
+ };
370
+ holderName?: string;
371
+ network: string;
372
+ suffix: string;
373
+ expiryMonth?: string;
374
+ expiryYear?: string;
375
+ };
376
+ fingerprint?: string;
377
+ futureUsage?: string;
378
+ }
142
379
 
143
380
  interface BinLookupResponse {
144
381
  bin: string;
@@ -471,6 +708,40 @@ declare class Skyflow {
471
708
  static get ValidationRuleType(): typeof ValidationRuleType;
472
709
  }
473
710
 
711
+ interface Mountable {
712
+ mount(selector: string | PayrailsElement): void;
713
+ unmount(): void;
714
+ }
715
+ interface ElementOptions {
716
+ id?: string;
717
+ dataTestId?: string;
718
+ className?: string | string[];
719
+ styles?: Partial<CSSStyleDeclaration>;
720
+ }
721
+ declare class PayrailsElement implements Mountable {
722
+ protected element: HTMLElement;
723
+ protected subElements: Array<Mountable>;
724
+ readonly id: string | undefined;
725
+ readonly dataTestId: string | undefined;
726
+ protected eventBus: _payrails_iframe_event_bus.IframeEventBus;
727
+ constructor(elementType: string, { id, className, dataTestId }?: ElementOptions);
728
+ get parentElement(): HTMLElement | null;
729
+ get selector(): string;
730
+ mount(location: string): void;
731
+ protected clean(): void;
732
+ unmount(): void;
733
+ }
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
+
474
745
  declare enum ElementType {
475
746
  CARD_NUMBER = "CARD_NUMBER",
476
747
  CARDHOLDER_NAME = "CARDHOLDER_NAME",
@@ -566,10 +837,61 @@ declare class PayrailsCollectContainer implements Mountable {
566
837
  bin: string;
567
838
  }>;
568
839
  }
569
- interface TokenizeOptions {
570
- futureUsage?: 'CardOnFile' | 'Subscription' | 'UnscheduledCardOnFile';
571
- storeInstrument?: boolean;
840
+
841
+ interface IAddress {
842
+ country?: {
843
+ code?: string;
844
+ fullName?: string;
845
+ iso3?: string;
846
+ };
847
+ postalCode?: string;
848
+ }
849
+ interface IOnChange {
850
+ isValid: boolean;
851
+ billingAddress?: IAddress;
572
852
  }
853
+ interface AddressSelectorElementOptions extends ElementOptions {
854
+ translations?: {
855
+ labels?: {
856
+ countrySelector?: string;
857
+ postalCodeInput?: string;
858
+ };
859
+ placeholders?: {
860
+ postalCodeInput?: string;
861
+ countrySelector?: string;
862
+ };
863
+ };
864
+ styles?: {
865
+ wrapper?: Partial<CSSStyleDeclaration>;
866
+ countrySelector?: {
867
+ wrapper?: Partial<CSSStyleDeclaration>;
868
+ element?: Partial<CSSStyleDeclaration>;
869
+ label?: Partial<CSSStyleDeclaration>;
870
+ };
871
+ postalCodeInput?: {
872
+ wrapper?: Partial<CSSStyleDeclaration>;
873
+ element?: Partial<CSSStyleDeclaration>;
874
+ label?: Partial<CSSStyleDeclaration>;
875
+ };
876
+ };
877
+ events?: {
878
+ onBillingAddressChanged?: (e: IOnChange) => void;
879
+ };
880
+ }
881
+
882
+ declare const regexes: {
883
+ visa: RegExp;
884
+ mastercard: RegExp;
885
+ amex: RegExp;
886
+ diners: RegExp;
887
+ discover: RegExp;
888
+ jcb: RegExp;
889
+ hipercard: RegExp;
890
+ unionpay: RegExp;
891
+ maestro: RegExp;
892
+ elo: RegExp;
893
+ };
894
+ type CardNetwork = keyof typeof regexes;
573
895
 
574
896
  interface PaymentInstallmentsElementOptions extends ElementOptions {
575
897
  showPaymentInstallmentsDropdown?: boolean;
@@ -608,26 +930,56 @@ declare class PayrailsElementWithPaymentInstallmentsDropdown extends PayrailsEle
608
930
  setDisabled(state: boolean): void;
609
931
  }
610
932
 
611
- interface OnChange {
612
- isValid: boolean;
613
- cardNetwork: CardNetwork | '';
614
- bin?: string;
615
- billingAddress?: IAddress;
616
- }
617
- type cardFormField = keyof typeof ElementType;
618
- type CardFormLayout = cardFormField[][];
619
- interface CardFormOptions extends StoreInstrumentElementOptions {
620
- showCardHolderName?: boolean;
621
- showSingleExpiryDateField?: boolean;
622
- enrollInstrumentToNetworkOffers?: boolean;
623
- layout?: CardFormLayout;
933
+ interface StoreInstrumentElementOptions extends ElementOptions {
934
+ showStoreInstrumentCheckbox?: boolean;
935
+ alwaysStoreInstrument?: boolean;
936
+ defaultStoreInstrumentState?: 'checked' | 'unchecked';
624
937
  translations?: {
625
- placeholders?: {
626
- [key in ElementType]?: string;
627
- };
628
938
  labels?: {
629
- [key in ElementType | 'saveCreditCard']?: string;
630
- } & {
939
+ storeInstrument?: string;
940
+ saveInstrument?: string;
941
+ };
942
+ };
943
+ styles?: {
944
+ storeInstrumentCheckbox?: Partial<CSSStyleDeclaration>;
945
+ };
946
+ events?: PayrailsSDKEvents;
947
+ }
948
+ declare class StoreInstrumentCheckbox extends PayrailsElement {
949
+ private options;
950
+ constructor(options: StoreInstrumentElementOptions);
951
+ get isChecked(): boolean;
952
+ private createHTML;
953
+ private applyStyles;
954
+ private addListeners;
955
+ }
956
+ declare abstract class PayrailsElementWithStoreInstrumentCheckbox extends PayrailsElement {
957
+ protected options?: StoreInstrumentElementOptions | undefined;
958
+ protected storeInstrumentCheckbox: StoreInstrumentCheckbox | null;
959
+ protected constructor(elementType: string, options?: StoreInstrumentElementOptions | undefined);
960
+ protected get shouldStoreInstrument(): boolean;
961
+ }
962
+
963
+ interface OnChange {
964
+ isValid: boolean;
965
+ cardNetwork: CardNetwork | '';
966
+ bin?: string;
967
+ billingAddress?: IAddress;
968
+ }
969
+ type cardFormField = keyof typeof ElementType;
970
+ type CardFormLayout = cardFormField[][];
971
+ interface CardFormOptions extends StoreInstrumentElementOptions {
972
+ showCardHolderName?: boolean;
973
+ showSingleExpiryDateField?: boolean;
974
+ enrollInstrumentToNetworkOffers?: boolean;
975
+ layout?: CardFormLayout;
976
+ translations?: {
977
+ placeholders?: {
978
+ [key in ElementType]?: string;
979
+ };
980
+ labels?: {
981
+ [key in ElementType | 'saveCreditCard']?: string;
982
+ } & {
631
983
  saveInstrument?: string;
632
984
  storeInstrument?: string;
633
985
  paymentInstallments?: string;
@@ -674,12 +1026,14 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
674
1026
  private lastBinLookup;
675
1027
  private defaultStyles;
676
1028
  private defaultTranslations;
1029
+ private eventsRef?;
677
1030
  constructor(collectContainer: PayrailsCollectContainer, options?: CardFormOptions | undefined);
678
1031
  private initializeFormFields;
679
1032
  getErrorTextStyles(errorTextStyles: any): any;
680
1033
  private updateStyles;
681
1034
  private updateTranslations;
682
- update(options: Partial<Pick<CardFormOptions, 'styles' | 'translations'>>): void;
1035
+ private updateEvents;
1036
+ update(options: Partial<Pick<CardFormOptions, 'styles' | 'translations' | 'events'>>): void;
683
1037
  private createFormField;
684
1038
  private initializeCustomLayout;
685
1039
  private hasFieldBeenUsed;
@@ -742,6 +1096,13 @@ declare class CardList extends PayrailsElement {
742
1096
  reset(): void;
743
1097
  }
744
1098
 
1099
+ declare enum RequestMethod {
1100
+ GET = "GET",
1101
+ POST = "POST",
1102
+ DELETE = "DELETE",
1103
+ PATCH = "PATCH"
1104
+ }
1105
+
745
1106
  interface SdkConfiguration {
746
1107
  token: string;
747
1108
  amount: PayrailsAmount;
@@ -763,6 +1124,7 @@ interface SdkConfiguration {
763
1124
  links: {
764
1125
  saveInstrument: {
765
1126
  href: string;
1127
+ method: RequestMethod;
766
1128
  };
767
1129
  };
768
1130
  };
@@ -835,7 +1197,8 @@ declare class CardPaymentButton extends PayrailsElement {
835
1197
  private constructEncryptedPayment;
836
1198
  private updateStyles;
837
1199
  private updateTranslations;
838
- update(options: Partial<Pick<CardPaymentButtonOptions, 'styles' | 'translations'>>): void;
1200
+ private updateEvents;
1201
+ update(options: Partial<Pick<CardPaymentButtonOptions, 'styles' | 'translations' | 'events'>>): void;
839
1202
  private handleAuthorizationResult;
840
1203
  }
841
1204
  declare enum AuthorizationFailureReasons {
@@ -865,6 +1228,7 @@ interface LoadingScreenStyles {
865
1228
  [StyleKeys.loader]?: Partial<CSSStyleDeclaration>;
866
1229
  }
867
1230
 
1231
+ type GooglePayConfigInput = google.payments.api.IsReadyToPayPaymentMethodSpecification[] | GooglePayConfig;
868
1232
  interface GooglePayButtonOptions extends StoreInstrumentElementOptions {
869
1233
  environment?: PayrailsEnvironment;
870
1234
  merchantInfo?: google.payments.api.MerchantInfo;
@@ -887,8 +1251,9 @@ declare class GooglePayButton extends PayrailsElementWithStoreInstrumentCheckbox
887
1251
  private static googleSDKClient;
888
1252
  private sdkLoadedCalled;
889
1253
  private buttonElement;
1254
+ private static getGooglePayConfigAsArray;
890
1255
  private static getSDKClient;
891
- 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>;
892
1257
  constructor(options: GooglePayButtonOptions);
893
1258
  private sdkLoaded;
894
1259
  private onLoadPaymentData;
@@ -913,6 +1278,7 @@ interface ApplePayDropinOptions extends ApplePayButtonOptions {
913
1278
  labels?: {
914
1279
  label?: string;
915
1280
  storeInstrument?: string;
1281
+ paymentScreenLabel?: string;
916
1282
  };
917
1283
  };
918
1284
  events?: ApplePayButtonOptions['events'] & DropinElementEvents;
@@ -969,9 +1335,11 @@ declare class GenericRedirectButton extends PayrailsElement {
969
1335
  private redirectToPaymentLink;
970
1336
  private updateStyles;
971
1337
  private updateTranslations;
1338
+ private updateEvents;
972
1339
  update(options: {
973
1340
  styles?: ButtonOptions['styles'];
974
1341
  translations?: ButtonOptions['translations'];
1342
+ events?: ButtonOptions['events'];
975
1343
  }): void;
976
1344
  }
977
1345
 
@@ -1080,7 +1448,7 @@ declare class Dropin extends PayrailsElement {
1080
1448
  private loadingScreen;
1081
1449
  constructor(collectContainer: PayrailsCollectContainer, clientConfig: PayrailsClientOptions, dropinConfig: DropinOptions);
1082
1450
  private isHppIntegration;
1083
- private isGenericDirect;
1451
+ private isEmbeddedElement;
1084
1452
  private createStoredInstrumentElement;
1085
1453
  private createInstallmentsDropdown;
1086
1454
  private getInstallmentOptionsForInstrument;
@@ -1092,7 +1460,7 @@ declare class Dropin extends PayrailsElement {
1092
1460
  private createCardForm;
1093
1461
  private createApplePayButton;
1094
1462
  private createCardPaymentButton;
1095
- private createGenericDirectElement;
1463
+ private createEmbeddedElement;
1096
1464
  private onAuthorizeSuccess;
1097
1465
  private getElementEvents;
1098
1466
  private onAuthorizePending;
@@ -1158,519 +1526,74 @@ interface DropinOptions {
1158
1526
  applePayButton?: ApplePayButtonOptions['styles'];
1159
1527
  cardForm?: CardFormOptions['styles'];
1160
1528
  cardPaymentButton?: CardPaymentButtonOptions['styles'];
1161
- authSuccess?: Partial<CSSStyleDeclaration>;
1162
- authFailed?: Partial<CSSStyleDeclaration>;
1163
- loadingScreen?: LoadingScreenStyles;
1164
- addressSelector?: AddressSelectorElementOptions['styles'];
1165
- mercadoPago?: GenericRedirectDropinOptions['styles'];
1166
- };
1167
- configuration?: {
1168
- authFailMsg?: AuthFailedMsgOptions['configuration'];
1169
- };
1170
- }
1171
- interface ContainerStyles {
1172
- styles?: Partial<CSSStyleDeclaration>;
1173
- }
1174
-
1175
- declare enum RequestMethod {
1176
- GET = "GET",
1177
- POST = "POST",
1178
- DELETE = "DELETE",
1179
- PATCH = "PATCH"
1180
- }
1181
-
1182
- type Operations = {
1183
- deleteInstrument: OperationConfig<void, DeleteInstrumentResponse>;
1184
- updateInstrument: OperationConfig<UpdateInstrumentBody, UpdateInstrumentResponse>;
1185
- };
1186
- interface UpdateInstrumentBody {
1187
- status?: 'enabled' | 'disabled';
1188
- networkTransactionReference?: string;
1189
- merchantReference?: string;
1190
- paymentMethod?: 'applepay' | 'card' | 'googlepay' | 'paypal';
1191
- default?: boolean;
1192
- }
1193
- interface UpdateInstrumentResponse {
1194
- id: string;
1195
- createdAt: string;
1196
- holderId: string;
1197
- paymentMethod: PAYMENT_METHOD_CODES;
1198
- status: PAYMENT_INSTRUMENT_STATUS;
1199
- data: {
1200
- bin?: string;
1201
- binLookup?: {
1202
- bin?: string;
1203
- network?: string;
1204
- issuer?: string;
1205
- issuerCountry?: {
1206
- code?: string;
1207
- name?: string;
1208
- iso3?: string;
1209
- };
1210
- type?: string;
1211
- };
1212
- holderName?: string;
1213
- network?: string;
1214
- suffix?: string;
1215
- expiryMonth?: string;
1216
- expiryYear?: string;
1217
- };
1218
- fingerprint?: string;
1219
- futureUsage?: string;
1220
- }
1221
- interface DeleteInstrumentResponse {
1222
- success: boolean;
1223
- }
1224
- type RequestCreator<TReq, TOperation extends keyof Operations> = (config: ApiConfig<TReq> & {
1225
- operation: TOperation;
1226
- }) => {
1227
- url: string;
1228
- body?: TReq;
1229
- };
1230
- interface OperationConfig<TReq, TRes> {
1231
- linkKey: keyof NonNullable<SdkConfiguration['links']>;
1232
- method: RequestMethod;
1233
- createRequest: RequestCreator<TReq, keyof Operations>;
1234
- requestType: TReq;
1235
- responseType: TRes;
1236
- }
1237
- interface ApiConfig<TReq> {
1238
- operation: keyof Operations;
1239
- resourceId?: string;
1240
- body?: TReq;
1241
- }
1242
-
1243
- declare class SdkLoader {
1244
- private static readonly scriptMap;
1245
- static load<T = void>(sdk: ThirdPartySDK, params?: PayPalScriptConfig): Promise<T>;
1246
- static reset(): void;
1247
- static preloadCardForm(): void;
1248
- private static loadScript;
1249
- private static loadPayPalScript;
1250
- private constructor();
1251
- private static logLoadError;
1252
- }
1253
- interface PayPalScriptConfig {
1254
- clientId: string;
1255
- currency: string;
1256
- vault: boolean;
1257
- intent: 'tokenize' | 'capture' | 'authorize';
1258
- }
1259
- declare enum ThirdPartySDK {
1260
- ApplePay = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",
1261
- GooglePay = "https://pay.google.com/gp/p/js/pay.js",
1262
- PayPal = "paypal-sdk"
1263
- }
1264
-
1265
- interface QueryDefinition<T> {
1266
- path: string[];
1267
- returnType: T;
1268
- }
1269
-
1270
- interface ConfigurationQueryTypes {
1271
- holderReference: QueryDefinition<string>;
1272
- amount: QueryDefinition<PayrailsAmount>;
1273
- binLookup: QueryDefinition<Links | undefined>;
1274
- instrumentDelete: QueryDefinition<Links | undefined>;
1275
- instrumentUpdate: QueryDefinition<Links | undefined>;
1276
- executionId: QueryDefinition<string | undefined>;
1277
- paymentMethodConfig: QueryDefinition<StorablePaymentCompositionOption | undefined>;
1278
- paymentMethodInstruments: QueryDefinition<StoredPaymentInstrument<CardMetadata | PayPalMetadata>[] | undefined>;
1279
- }
1280
-
1281
- interface InitOptions {
1282
- version: string;
1283
- data: string;
1284
- }
1285
-
1286
- interface PayrailsClientOptions {
1287
- environment?: PayrailsEnvironment;
1288
- events?: ClientEvents;
1289
- redirectFor3DS?: boolean;
1290
- returnInfo?: ReturnInfo;
1291
- telemetry?: {
1292
- enabled?: boolean;
1293
- logLevel?: LogLevel$1;
1294
- };
1295
- }
1296
- declare class Payrails {
1297
- private vaultClient;
1298
- private options?;
1299
- private __container;
1300
- private __cardForm;
1301
- private __cardList;
1302
- private __cardPaymentButton;
1303
- private __paypalButton;
1304
- private __genericRedirectButton;
1305
- private __dropin;
1306
- static preloadCardForm: typeof SdkLoader.preloadCardForm;
1307
- static init(initResponse: InitOptions, options?: PayrailsClientOptions): Payrails;
1308
- update(amount: PayrailsAmount): void;
1309
- collectContainer(containerOptions: CollectContainerOptions): PayrailsCollectContainer;
1310
- googlePayButton(options: GooglePayButtonOptions): GooglePayButton;
1311
- isGooglePayAvailable(merchantInfo: google.payments.api.MerchantInfo): Promise<boolean>;
1312
- applePayButton(options: ApplePayButtonOptions): ApplePayButton;
1313
- isApplePayAvailable(): Promise<boolean>;
1314
- cardList(options?: CardListOptions): CardList;
1315
- cardForm(options?: CardFormOptions): CardForm;
1316
- dropin(options: DropinOptions): Dropin;
1317
- getSavedCreditCards(): StoredPaymentInstrument<CardMetadata>[];
1318
- getSavedGooglePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
1319
- getSavedApplePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
1320
- query<K extends keyof ConfigurationQueryTypes>(key: K, params?: Record<string, any>): ConfigurationQueryTypes[K]['returnType'] | null;
1321
- api<TOperation extends keyof Operations>(config: ApiConfig<Operations[TOperation]['requestType']> & {
1322
- operation: TOperation;
1323
- }): Promise<Operations[TOperation]['responseType']>;
1324
- getStoredInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
1325
- getAvailablePaymentMethods(): PAYMENT_METHOD_CODES[];
1326
- paymentButton(options: CardPaymentButtonOptions): CardPaymentButton;
1327
- paypalButton(options?: PaypalButtonOptions): PaypalButton;
1328
- genericRedirectButton(options: GenericRedirectButtonOptions): GenericRedirectButton;
1329
- getSavedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
1330
- private logIntegrationMode;
1331
- private constructor();
1332
- private getContainerLayout;
1333
- binLookup(): Promise<any>;
1334
- }
1335
- interface ClientEvents {
1336
- onClientInitialized?: (execution?: typeof WorkflowExecution) => void;
1337
- onSessionExpired?: () => Promise<InitOptions>;
1338
- }
1339
- interface PaymentEvents {
1340
- onAuthorizeSuccess?: (e?: any) => void;
1341
- onAuthorizeFailed?: (e?: any) => void;
1342
- onAuthorizePending?: (e?: any) => void;
1343
- onPaymentButtonClicked?: (e?: {
1344
- bin?: string;
1345
- }) => Promise<boolean>;
1346
- onAuthorizeRequestStart?: () => void;
1347
- onPaymentSessionExpired?: () => void;
1348
- onThreeDSecureChallenge?: () => void;
1349
- }
1350
- interface UIEvents {
1351
- onSaveInstrumentCheckboxChanged?: ({ checked }: {
1352
- checked: boolean;
1353
- }) => void;
1354
- onBillingAddressChanged?: (e: {
1355
- isValid: boolean;
1356
- billingAddress?: IAddress;
1357
- }) => void;
1358
- onDeliveryAddressChanged?: (data?: onDeliveryAddressChangedResponse) => Promise<boolean>;
1359
- }
1360
- type onPaymentMethodSelectedParams = {
1361
- paymentMethod?: StorablePaymentCompositionOption;
1362
- instrument?: StoredPaymentInstrument<CardMetadata & PayPalMetadata>;
1363
- };
1364
- interface DropinEvents {
1365
- onPaymentOptionSelected?: (e: onPaymentMethodSelectedParams) => void;
1366
- }
1367
- type PayrailsSDKEvents = PaymentEvents & UIEvents & DropinEvents;
1368
- type onDeliveryAddressChangedResponse = {
1369
- deliveryAddress?: {
1370
- street?: string;
1371
- doorNumber?: string;
1372
- complement?: string;
1373
- area?: string;
1374
- city?: string;
1375
- postalCode?: string;
1376
- state?: string;
1377
- country?: {
1378
- code?: string;
1379
- iso3?: string;
1380
- name?: string;
1381
- };
1382
- latitude?: number;
1383
- longitude?: number;
1384
- phone?: {
1385
- countryCode?: string;
1386
- number?: string;
1387
- };
1388
- name?: string;
1389
- lastName?: string;
1390
- email?: string;
1391
- };
1392
- };
1393
- declare enum PayrailsEnvironment {
1394
- TEST = "TEST",
1395
- PRODUCTION = "PRODUCTION"
1396
- }
1397
-
1398
- type JSONSchemaType = JSONSchemaProperty & {
1399
- required?: string[];
1400
- };
1401
- interface JSONSchemaProperty {
1402
- type?: 'string' | 'number' | 'boolean' | 'array' | 'object';
1403
- title?: string;
1404
- enum?: any[];
1405
- pattern?: string;
1406
- minLength?: number;
1407
- maxLength?: number;
1408
- errorMessage?: Record<string, string>;
1409
- properties?: Record<string, JSONSchemaType>;
1410
- }
1411
-
1412
- declare enum PAYMENT_METHOD_CODES {
1413
- 'CARD' = "card",
1414
- 'GOOGLE_PAY' = "googlePay",
1415
- 'PAYPAL' = "payPal",
1416
- 'APPLE_PAY' = "applePay",
1417
- 'GENERIC_REDIRECT' = "genericRedirect",
1418
- 'MERCADO_PAGO' = "mercadoPago",
1419
- 'PIX' = "pix",
1420
- 'BANK_ACCOUNT' = "bankAccount"
1421
- }
1422
- declare enum PAYMENT_INSTRUMENT_STATUS {
1423
- 'ENABLED' = "enabled",
1424
- 'CREATED' = "created",
1425
- 'DELETED' = "deleted",
1426
- 'DISABLED' = "disabled",
1427
- 'INVALID' = "invalid",
1428
- 'TRANSIENT' = "transient"
1429
- }
1430
- declare class WorkflowExecution {
1431
- private static _response;
1432
- static get response(): WorkflowExecutionResponse;
1433
- static setResponse(response: WorkflowExecutionResponse): typeof WorkflowExecution;
1434
- static get lookup(): {
1435
- httpCode: number;
1436
- body: {
1437
- data: {
1438
- paymentCompositionOptions: Array<StorablePaymentCompositionOption>;
1439
- };
1440
- links: {
1441
- authorize: {
1442
- href: string;
1443
- method: "POST";
1444
- };
1445
- execution: string;
1446
- };
1447
- name: "lookup";
1448
- };
1449
- } | undefined;
1450
- static get holderReference(): string;
1451
- static get savedCreditCards(): StoredPaymentInstrument<CardMetadata>[];
1452
- static get savedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
1453
- static get savedGooglePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
1454
- static get savedApplePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
1455
- static get paypalConfig(): PayPalConfig;
1456
- static get googlePayConfig(): GooglePayConfig[];
1457
- static isPaymentMethodAvailable(paymentMethod: PAYMENT_METHOD_CODES): boolean;
1458
- static get applePayConfig(): {
1459
- merchantIdentifier: string;
1460
- supportedNetworks: string[];
1461
- countryCode: string;
1462
- merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
1463
- requiredBillingContactFields?: ApplePayJS.ApplePayContactField[];
1464
- };
1465
- static get url(): string;
1466
- static get meta(): {
1467
- customer?: {
1468
- country?: {
1469
- code?: string;
1470
- };
1471
- };
1472
- order?: {
1473
- billingAddress?: {
1474
- country?: {
1475
- code?: string;
1476
- };
1477
- };
1478
- };
1479
- };
1480
- static get availablePaymentMethods(): StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined>[];
1481
- static get authorizeLink(): string | undefined;
1482
- static get createSessionLink(): string | undefined;
1483
- static get storedPaymentInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
1484
- static get storedDropinInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
1485
- static getFullPaymentMethodConfig(paymentMethod: PAYMENT_METHOD_CODES): StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined> | undefined;
1486
- static isAddressSelectorEnabled(paymentMethod: PAYMENT_METHOD_CODES): boolean | undefined;
1487
- static isPaymentInstallmentsEnabled(paymentMethod: PAYMENT_METHOD_CODES): boolean | undefined;
1488
- static getPaymentInstallmentOptions(paymentMethod: PAYMENT_METHOD_CODES): PaymentInstallmentsConfig;
1489
- static getStoredInstrumentForPaymentMethod<T = CardMetadata | PayPalMetadata>(paymentMethod: PAYMENT_METHOD_CODES): Array<StoredPaymentInstrument<T>>;
1490
- static getPaymentMethodForStoredInstrument<T extends CardMetadata | PayPalMetadata>(instrument: StoredPaymentInstrument<T>): {
1491
- id: string;
1492
- description?: string;
1493
- status: PAYMENT_INSTRUMENT_STATUS;
1494
- integrationType: INTEGRATION_TYPE;
1495
- config: ApplePayConfig | PayPalConfig | GooglePayConfig | undefined;
1496
- clientConfig?: {
1497
- flow?: PAYMENT_CLIENT_FLOW;
1498
- supportsInstallments?: boolean;
1499
- installments?: PaymentInstallmentsConfig;
1500
- supportsBillingInfo?: boolean;
1501
- schema?: JSONSchemaType;
1502
- };
1503
- paymentMethodCode: PAYMENT_METHOD_CODES;
1504
- } | undefined;
1505
- static getPaymentMethodConfig(paymentMethod: StorablePaymentCompositionOption): {
1506
- id: string;
1507
- description?: string;
1508
- status: PAYMENT_INSTRUMENT_STATUS;
1509
- integrationType: INTEGRATION_TYPE;
1510
- config: ApplePayConfig | PayPalConfig | GooglePayConfig | undefined;
1511
- clientConfig?: {
1512
- flow?: PAYMENT_CLIENT_FLOW;
1513
- supportsInstallments?: boolean;
1514
- installments?: PaymentInstallmentsConfig;
1515
- supportsBillingInfo?: boolean;
1516
- schema?: JSONSchemaType;
1517
- };
1518
- paymentMethodCode: PAYMENT_METHOD_CODES;
1519
- };
1520
- }
1521
- interface WorkflowExecutionResponse {
1522
- id: string;
1523
- merchantReference: string;
1524
- holderReference: string;
1525
- actionRequired?: string;
1526
- meta: {
1527
- customer?: {
1528
- country?: {
1529
- code?: string;
1530
- };
1531
- };
1532
- order?: {
1533
- billingAddress?: {
1534
- country?: {
1535
- code?: string;
1536
- };
1537
- };
1538
- };
1539
- };
1540
- status: Array<{
1541
- code: string;
1542
- time: string;
1543
- }>;
1544
- initialResults: Array<{
1545
- httpCode: number;
1546
- body: {
1547
- data: {
1548
- paymentCompositionOptions: Array<StorablePaymentCompositionOption>;
1549
- };
1550
- links: {
1551
- authorize: {
1552
- href: string;
1553
- method: 'POST';
1554
- };
1555
- execution: string;
1556
- };
1557
- name: 'lookup';
1558
- };
1559
- }>;
1560
- links: {
1561
- startPaymentSession?: {
1562
- href: string;
1563
- method: 'POST';
1564
- };
1565
- confirm?: {
1566
- href: string;
1567
- action?: {
1568
- parameters?: {
1569
- orderId?: string;
1570
- tokenId?: string;
1571
- };
1572
- };
1573
- };
1574
- redirect?: string;
1575
- '3ds'?: string;
1576
- self: string;
1577
- };
1578
- workflow: {
1579
- code: string;
1580
- version: number;
1581
- };
1582
- }
1583
- interface BasePaymentMethodConfig {
1584
- paymentMethodCode: PAYMENT_METHOD_CODES;
1585
- }
1586
- interface BaseInstallmentOption {
1587
- count: number;
1588
- amount: number;
1589
- }
1590
- interface PaymentInstallmentsConfig {
1591
- [key: string]: BaseInstallmentOption[];
1592
- }
1593
- interface StorablePaymentCompositionOption<I = CardMetadata | PayPalMetadata, C = undefined | ApplePayConfig | PayPalConfig | GooglePayConfig> extends BasePaymentMethodConfig {
1594
- id: string;
1595
- description?: string;
1596
- status: PAYMENT_INSTRUMENT_STATUS;
1597
- integrationType: INTEGRATION_TYPE;
1598
- config: C;
1599
- clientConfig?: {
1600
- flow?: PAYMENT_CLIENT_FLOW;
1601
- supportsInstallments?: boolean;
1602
- installments?: PaymentInstallmentsConfig;
1603
- supportsBillingInfo?: boolean;
1604
- schema?: JSONSchemaType;
1605
- };
1606
- paymentInstruments?: Array<StoredPaymentInstrument<I>>;
1607
- }
1608
- interface GooglePayConfig {
1609
- parameters: {
1610
- allowedAuthMethods: google.payments.api.CardAuthMethod[];
1611
- allowedCardNetworks: google.payments.api.CardNetwork[];
1612
- };
1613
- tokenizationSpecification: google.payments.api.PaymentMethodTokenizationSpecification;
1614
- type: google.payments.api.PaymentMethodType;
1615
- }
1616
- interface PayPalConfig {
1617
- clientId: string;
1618
- merchantId: string;
1619
- captureMode: 'Delayed' | 'Instant' | 'Manual';
1620
- integrationMode: 'express' | 'normal';
1621
- }
1622
- interface ApplePayConfig {
1623
- parameters: {
1624
- merchantIdentifier: string;
1625
- supportedNetworks: string[];
1626
- countryCode: string;
1627
- merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
1628
- requiredBillingContactFields?: ApplePayJS.ApplePayContactField[];
1629
- };
1630
- type: string;
1631
- }
1632
- interface StoredPaymentInstrument<T = CardMetadata | PayPalMetadata> {
1633
- id: string;
1634
- status: PAYMENT_INSTRUMENT_STATUS;
1635
- paymentMethod: PAYMENT_METHOD_CODES;
1636
- displayName?: string;
1637
- data?: T;
1638
- }
1639
- interface PayPalMetadata {
1640
- email?: string;
1641
- }
1642
- interface CardMetadata {
1643
- bin?: string;
1644
- suffix?: string;
1645
- network?: string;
1646
- binLookup?: {
1647
- issuerCountry: {
1648
- code: string;
1649
- name: string;
1650
- iso3: string;
1651
- };
1529
+ authSuccess?: Partial<CSSStyleDeclaration>;
1530
+ authFailed?: Partial<CSSStyleDeclaration>;
1531
+ loadingScreen?: LoadingScreenStyles;
1532
+ addressSelector?: AddressSelectorElementOptions['styles'];
1533
+ mercadoPago?: GenericRedirectDropinOptions['styles'];
1534
+ };
1535
+ configuration?: {
1536
+ authFailMsg?: AuthFailedMsgOptions['configuration'];
1652
1537
  };
1653
1538
  }
1654
- declare enum PAYMENT_CLIENT_FLOW {
1655
- 'REDIRECT' = "redirect",
1656
- 'DIRECT' = "direct"
1539
+ interface ContainerStyles {
1540
+ styles?: Partial<CSSStyleDeclaration>;
1657
1541
  }
1658
- declare enum INTEGRATION_TYPE {
1659
- API = "api",
1660
- HPP = "hpp"
1542
+
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;
1661
1573
  }
1662
1574
 
1663
- interface SaveInstrumentResponse {
1575
+ type Operations = {
1576
+ deleteInstrument: OperationConfig<void, DeleteInstrumentResponse>;
1577
+ updateInstrument: OperationConfig<UpdateInstrumentBody, UpdateInstrumentResponse>;
1578
+ };
1579
+ interface UpdateInstrumentBody {
1580
+ status?: 'enabled' | 'disabled';
1581
+ networkTransactionReference?: string;
1582
+ merchantReference?: string;
1583
+ paymentMethod?: 'applepay' | 'card' | 'googlepay' | 'paypal';
1584
+ default?: boolean;
1585
+ }
1586
+ interface UpdateInstrumentResponse {
1664
1587
  id: string;
1665
1588
  createdAt: string;
1666
1589
  holderId: string;
1667
- paymentMethod: PAYMENT_METHOD_CODES.CARD;
1590
+ paymentMethod: PAYMENT_METHOD_CODES;
1668
1591
  status: PAYMENT_INSTRUMENT_STATUS;
1669
1592
  data: {
1670
- bin: string;
1593
+ bin?: string;
1671
1594
  binLookup?: {
1672
- bin: string;
1673
- network: string;
1595
+ bin?: string;
1596
+ network?: string;
1674
1597
  issuer?: string;
1675
1598
  issuerCountry?: {
1676
1599
  code?: string;
@@ -1680,14 +1603,228 @@ interface SaveInstrumentResponse {
1680
1603
  type?: string;
1681
1604
  };
1682
1605
  holderName?: string;
1683
- network: string;
1684
- suffix: string;
1606
+ network?: string;
1607
+ suffix?: string;
1685
1608
  expiryMonth?: string;
1686
1609
  expiryYear?: string;
1687
1610
  };
1688
1611
  fingerprint?: string;
1689
1612
  futureUsage?: string;
1690
1613
  }
1614
+ interface DeleteInstrumentResponse {
1615
+ success: boolean;
1616
+ }
1617
+ type RequestCreator<TReq, TOperation extends keyof Operations> = (config: ApiConfig<TReq> & {
1618
+ operation: TOperation;
1619
+ }) => {
1620
+ url: string;
1621
+ body?: TReq;
1622
+ };
1623
+ interface OperationConfig<TReq, TRes> {
1624
+ linkKey: keyof NonNullable<SdkConfiguration['links']>;
1625
+ method: RequestMethod;
1626
+ createRequest: RequestCreator<TReq, keyof Operations>;
1627
+ requestType: TReq;
1628
+ responseType: TRes;
1629
+ }
1630
+ interface ApiConfig<TReq> {
1631
+ operation: keyof Operations;
1632
+ resourceId?: string;
1633
+ body?: TReq;
1634
+ }
1635
+
1636
+ declare class SdkLoader {
1637
+ private static readonly scriptMap;
1638
+ static load<T = void>(sdk: ThirdPartySDK, params?: PayPalScriptConfig): Promise<T>;
1639
+ static reset(): void;
1640
+ static preloadCardForm(): void;
1641
+ private static loadScript;
1642
+ private static loadPayPalScript;
1643
+ private constructor();
1644
+ private static logLoadError;
1645
+ }
1646
+ interface PayPalScriptConfig {
1647
+ clientId: string;
1648
+ currency: string;
1649
+ vault: boolean;
1650
+ intent: 'tokenize' | 'capture' | 'authorize';
1651
+ }
1652
+ declare enum ThirdPartySDK {
1653
+ ApplePay = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",
1654
+ GooglePay = "https://pay.google.com/gp/p/js/pay.js",
1655
+ PayPal = "paypal-sdk"
1656
+ }
1657
+
1658
+ interface QueryDefinition<T> {
1659
+ path: string[];
1660
+ returnType: T;
1661
+ }
1662
+
1663
+ interface ConfigurationQueryTypes {
1664
+ holderReference: QueryDefinition<string>;
1665
+ amount: QueryDefinition<PayrailsAmount>;
1666
+ binLookup: QueryDefinition<Links | undefined>;
1667
+ instrumentDelete: QueryDefinition<Links | undefined>;
1668
+ instrumentUpdate: QueryDefinition<Links | undefined>;
1669
+ executionId: QueryDefinition<string | undefined>;
1670
+ paymentMethodConfig: QueryDefinition<StorablePaymentCompositionOption | undefined>;
1671
+ paymentMethodInstruments: QueryDefinition<StoredPaymentInstrument<CardMetadata | PayPalMetadata>[] | undefined>;
1672
+ }
1673
+
1674
+ interface InitOptions {
1675
+ version: string;
1676
+ data: string;
1677
+ }
1678
+
1679
+ interface PayrailsClientOptions {
1680
+ environment?: PayrailsEnvironment;
1681
+ events?: ClientEvents;
1682
+ redirectFor3DS?: boolean;
1683
+ returnInfo?: ReturnInfo;
1684
+ telemetry?: {
1685
+ enabled?: boolean;
1686
+ logLevel?: LogLevel$1;
1687
+ };
1688
+ }
1689
+ declare class Payrails {
1690
+ private vaultClient;
1691
+ private options?;
1692
+ private __container;
1693
+ private __cardForm;
1694
+ private __cardList;
1695
+ private __cardPaymentButton;
1696
+ private __paypalButton;
1697
+ private __genericRedirectButton;
1698
+ private __dynamicElementForm;
1699
+ private __dropin;
1700
+ static preloadCardForm: typeof SdkLoader.preloadCardForm;
1701
+ static init(initResponse: InitOptions, options?: PayrailsClientOptions): Payrails;
1702
+ update(amount: PayrailsAmount): void;
1703
+ collectContainer(containerOptions: CollectContainerOptions): PayrailsCollectContainer;
1704
+ googlePayButton(options: GooglePayButtonOptions): GooglePayButton;
1705
+ isGooglePayAvailable(merchantInfo: google.payments.api.MerchantInfo): Promise<boolean>;
1706
+ applePayButton(options: ApplePayButtonOptions): ApplePayButton;
1707
+ isApplePayAvailable(): Promise<boolean>;
1708
+ cardList(options?: CardListOptions): CardList;
1709
+ cardForm(options?: CardFormOptions): CardForm;
1710
+ dropin(options: DropinOptions): Dropin;
1711
+ getSavedCreditCards(): StoredPaymentInstrument<CardMetadata>[];
1712
+ getSavedGooglePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
1713
+ getSavedApplePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
1714
+ query<K extends keyof ConfigurationQueryTypes>(key: K, params?: Record<string, any>): ConfigurationQueryTypes[K]['returnType'] | null;
1715
+ api<TOperation extends keyof Operations>(config: ApiConfig<Operations[TOperation]['requestType']> & {
1716
+ operation: TOperation;
1717
+ }): Promise<Operations[TOperation]['responseType']>;
1718
+ getStoredInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
1719
+ getAvailablePaymentMethods(): PAYMENT_METHOD_CODES[];
1720
+ paymentButton(options: CardPaymentButtonOptions): CardPaymentButton;
1721
+ paypalButton(options?: PaypalButtonOptions): PaypalButton;
1722
+ genericRedirectButton(options: GenericRedirectButtonOptions): GenericRedirectButton;
1723
+ dynamicElement(options: DynamicElementOptions): DynamicElementForm;
1724
+ getSavedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
1725
+ private logIntegrationMode;
1726
+ private constructor();
1727
+ private getContainerLayout;
1728
+ binLookup(): Promise<any>;
1729
+ }
1730
+ interface ClientEvents {
1731
+ onClientInitialized?: (execution?: typeof WorkflowExecution) => void;
1732
+ onSessionExpired?: () => Promise<InitOptions>;
1733
+ }
1734
+ interface PaymentEvents {
1735
+ onAuthorizeSuccess?: (e?: any) => void;
1736
+ onAuthorizeFailed?: (e?: any) => void;
1737
+ onAuthorizePending?: (e?: any) => void;
1738
+ onPaymentButtonClicked?: (e?: {
1739
+ bin?: string;
1740
+ }) => Promise<boolean>;
1741
+ onAuthorizeRequestStart?: () => Promise<boolean>;
1742
+ onPaymentSessionExpired?: () => void;
1743
+ onThreeDSecureChallenge?: () => void;
1744
+ }
1745
+ interface UIEvents {
1746
+ onSaveInstrumentCheckboxChanged?: ({ checked }: {
1747
+ checked: boolean;
1748
+ }) => void;
1749
+ onBillingAddressChanged?: (e: {
1750
+ isValid: boolean;
1751
+ billingAddress?: IAddress;
1752
+ }) => void;
1753
+ onDeliveryAddressChanged?: (data?: onDeliveryAddressChangedResponse) => Promise<boolean>;
1754
+ }
1755
+ type onPaymentMethodSelectedParams = {
1756
+ paymentMethod?: StorablePaymentCompositionOption;
1757
+ instrument?: StoredPaymentInstrument<CardMetadata & PayPalMetadata>;
1758
+ };
1759
+ interface DropinEvents {
1760
+ onPaymentOptionSelected?: (e: onPaymentMethodSelectedParams) => void;
1761
+ }
1762
+ type PayrailsSDKEvents = PaymentEvents & UIEvents & DropinEvents;
1763
+ type onDeliveryAddressChangedResponse = {
1764
+ deliveryAddress?: {
1765
+ street?: string;
1766
+ doorNumber?: string;
1767
+ complement?: string;
1768
+ area?: string;
1769
+ city?: string;
1770
+ postalCode?: string;
1771
+ state?: string;
1772
+ country?: {
1773
+ code?: string;
1774
+ iso3?: string;
1775
+ name?: string;
1776
+ };
1777
+ latitude?: number;
1778
+ longitude?: number;
1779
+ phone?: {
1780
+ countryCode?: string;
1781
+ number?: string;
1782
+ };
1783
+ name?: string;
1784
+ lastName?: string;
1785
+ email?: string;
1786
+ };
1787
+ };
1788
+ declare enum PayrailsEnvironment {
1789
+ TEST = "TEST",
1790
+ PRODUCTION = "PRODUCTION"
1791
+ }
1792
+
1793
+ interface ApplePayButtonOptions extends StoreInstrumentElementOptions {
1794
+ clientDomain?: string;
1795
+ showPaymentMethodLogo?: boolean;
1796
+ translations?: {
1797
+ labels?: {
1798
+ storeInstrument?: string;
1799
+ saveInstrument?: string;
1800
+ paymentScreenLabel?: string;
1801
+ };
1802
+ };
1803
+ events?: PaymentEvents & {
1804
+ onApplePayAvailable?: () => void;
1805
+ };
1806
+ styles?: {
1807
+ type?: 'plain' | 'buy' | 'addMoney' | 'book' | 'checkout' | 'continue' | 'contribute' | 'donate' | 'inStore' | 'order' | 'reload' | 'rent' | 'setUp' | 'subscribe' | 'support' | 'tip' | 'topUp';
1808
+ style?: 'white' | 'whiteOutline' | 'black' | 'automatic';
1809
+ } & StoreInstrumentElementOptions['styles'];
1810
+ }
1811
+ declare global {
1812
+ interface Window {
1813
+ ApplePaySession?: ApplePaySession;
1814
+ }
1815
+ }
1816
+ declare class ApplePayButton extends PayrailsElementWithStoreInstrumentCheckbox {
1817
+ protected options: ApplePayButtonOptions;
1818
+ private appleButton;
1819
+ private paymentExecutor;
1820
+ static isApplePayAvailable(): Promise<boolean>;
1821
+ constructor(options: ApplePayButtonOptions);
1822
+ mount(location: string): void;
1823
+ unmount(): void;
1824
+ private mountApplePayButton;
1825
+ private createApplePaySession;
1826
+ private onApplePayAuthorized;
1827
+ }
1691
1828
 
1692
1829
  export { AuthorizationFailureReasons, ElementType, INTEGRATION_TYPE, PAYMENT_METHOD_CODES, Payrails, PayrailsEnvironment };
1693
1830
  export type { ApplePayButtonOptions, CardFormOptions, CardListOptions, CardPaymentButtonOptions, DropinOptions, GooglePayButtonOptions, InitOptions, PaymentEvents, PaypalButtonOptions, PayrailsAmount, PayrailsClientOptions, PayrailsContainerType, PayrailsSecureField, PayrailsSecureFieldEvent, SaveInstrumentResponse, WorkflowExecutionResponse };