@payrails/web-sdk 5.29.0 → 5.29.1-rc.1

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;
@@ -742,6 +1094,13 @@ declare class CardList extends PayrailsElement {
742
1094
  reset(): void;
743
1095
  }
744
1096
 
1097
+ declare enum RequestMethod {
1098
+ GET = "GET",
1099
+ POST = "POST",
1100
+ DELETE = "DELETE",
1101
+ PATCH = "PATCH"
1102
+ }
1103
+
745
1104
  interface SdkConfiguration {
746
1105
  token: string;
747
1106
  amount: PayrailsAmount;
@@ -763,6 +1122,7 @@ interface SdkConfiguration {
763
1122
  links: {
764
1123
  saveInstrument: {
765
1124
  href: string;
1125
+ method: RequestMethod;
766
1126
  };
767
1127
  };
768
1128
  };
@@ -865,6 +1225,7 @@ interface LoadingScreenStyles {
865
1225
  [StyleKeys.loader]?: Partial<CSSStyleDeclaration>;
866
1226
  }
867
1227
 
1228
+ type GooglePayConfigInput = google.payments.api.IsReadyToPayPaymentMethodSpecification[] | GooglePayConfig;
868
1229
  interface GooglePayButtonOptions extends StoreInstrumentElementOptions {
869
1230
  environment?: PayrailsEnvironment;
870
1231
  merchantInfo?: google.payments.api.MerchantInfo;
@@ -887,8 +1248,9 @@ declare class GooglePayButton extends PayrailsElementWithStoreInstrumentCheckbox
887
1248
  private static googleSDKClient;
888
1249
  private sdkLoadedCalled;
889
1250
  private buttonElement;
1251
+ private static getGooglePayConfigAsArray;
890
1252
  private static getSDKClient;
891
- 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>;
892
1254
  constructor(options: GooglePayButtonOptions);
893
1255
  private sdkLoaded;
894
1256
  private onLoadPaymentData;
@@ -913,6 +1275,7 @@ interface ApplePayDropinOptions extends ApplePayButtonOptions {
913
1275
  labels?: {
914
1276
  label?: string;
915
1277
  storeInstrument?: string;
1278
+ paymentScreenLabel?: string;
916
1279
  };
917
1280
  };
918
1281
  events?: ApplePayButtonOptions['events'] & DropinElementEvents;
@@ -1080,7 +1443,7 @@ declare class Dropin extends PayrailsElement {
1080
1443
  private loadingScreen;
1081
1444
  constructor(collectContainer: PayrailsCollectContainer, clientConfig: PayrailsClientOptions, dropinConfig: DropinOptions);
1082
1445
  private isHppIntegration;
1083
- private isGenericDirect;
1446
+ private isEmbeddedElement;
1084
1447
  private createStoredInstrumentElement;
1085
1448
  private createInstallmentsDropdown;
1086
1449
  private getInstallmentOptionsForInstrument;
@@ -1092,7 +1455,7 @@ declare class Dropin extends PayrailsElement {
1092
1455
  private createCardForm;
1093
1456
  private createApplePayButton;
1094
1457
  private createCardPaymentButton;
1095
- private createGenericDirectElement;
1458
+ private createEmbeddedElement;
1096
1459
  private onAuthorizeSuccess;
1097
1460
  private getElementEvents;
1098
1461
  private onAuthorizePending;
@@ -1158,519 +1521,74 @@ interface DropinOptions {
1158
1521
  applePayButton?: ApplePayButtonOptions['styles'];
1159
1522
  cardForm?: CardFormOptions['styles'];
1160
1523
  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
- };
1524
+ authSuccess?: Partial<CSSStyleDeclaration>;
1525
+ authFailed?: Partial<CSSStyleDeclaration>;
1526
+ loadingScreen?: LoadingScreenStyles;
1527
+ addressSelector?: AddressSelectorElementOptions['styles'];
1528
+ mercadoPago?: GenericRedirectDropinOptions['styles'];
1529
+ };
1530
+ configuration?: {
1531
+ authFailMsg?: AuthFailedMsgOptions['configuration'];
1652
1532
  };
1653
1533
  }
1654
- declare enum PAYMENT_CLIENT_FLOW {
1655
- 'REDIRECT' = "redirect",
1656
- 'DIRECT' = "direct"
1534
+ interface ContainerStyles {
1535
+ styles?: Partial<CSSStyleDeclaration>;
1657
1536
  }
1658
- declare enum INTEGRATION_TYPE {
1659
- API = "api",
1660
- HPP = "hpp"
1537
+
1538
+ interface DynamicElementOptions {
1539
+ styles?: DynamicElementStyles;
1540
+ translations?: DynamicElementTranslations;
1541
+ events?: PaymentEvents;
1542
+ paymentMethod: BasePaymentMethodConfig;
1543
+ }
1544
+ interface FormConfig {
1545
+ schema: JSONSchemaType;
1546
+ }
1547
+ declare class DynamicElementForm extends Tokenizable {
1548
+ protected options: DynamicElementOptions;
1549
+ protected readonly formConfig: FormConfig;
1550
+ private readonly returnInfo?;
1551
+ private formFields;
1552
+ private formData;
1553
+ private __schema;
1554
+ constructor(options: DynamicElementOptions, formConfig: FormConfig, returnInfo?: ReturnInfo | undefined);
1555
+ collect(): Promise<Record<string, any>>;
1556
+ protected constructSaveInstrumentBody(tokens: any, opts?: TokenizeOptions): Promise<any>;
1557
+ private isFormValid;
1558
+ mount(location: string): Promise<void>;
1559
+ private makeForm;
1560
+ private createField;
1561
+ private createFieldSync;
1562
+ private createOneOfField;
1563
+ private createStringField;
1564
+ private createFieldByType;
1565
+ private extractStyles;
1566
+ private makeFieldEvents;
1567
+ private evaluateDependencies;
1661
1568
  }
1662
1569
 
1663
- interface SaveInstrumentResponse {
1570
+ type Operations = {
1571
+ deleteInstrument: OperationConfig<void, DeleteInstrumentResponse>;
1572
+ updateInstrument: OperationConfig<UpdateInstrumentBody, UpdateInstrumentResponse>;
1573
+ };
1574
+ interface UpdateInstrumentBody {
1575
+ status?: 'enabled' | 'disabled';
1576
+ networkTransactionReference?: string;
1577
+ merchantReference?: string;
1578
+ paymentMethod?: 'applepay' | 'card' | 'googlepay' | 'paypal';
1579
+ default?: boolean;
1580
+ }
1581
+ interface UpdateInstrumentResponse {
1664
1582
  id: string;
1665
1583
  createdAt: string;
1666
1584
  holderId: string;
1667
- paymentMethod: PAYMENT_METHOD_CODES.CARD;
1585
+ paymentMethod: PAYMENT_METHOD_CODES;
1668
1586
  status: PAYMENT_INSTRUMENT_STATUS;
1669
1587
  data: {
1670
- bin: string;
1588
+ bin?: string;
1671
1589
  binLookup?: {
1672
- bin: string;
1673
- network: string;
1590
+ bin?: string;
1591
+ network?: string;
1674
1592
  issuer?: string;
1675
1593
  issuerCountry?: {
1676
1594
  code?: string;
@@ -1680,14 +1598,228 @@ interface SaveInstrumentResponse {
1680
1598
  type?: string;
1681
1599
  };
1682
1600
  holderName?: string;
1683
- network: string;
1684
- suffix: string;
1601
+ network?: string;
1602
+ suffix?: string;
1685
1603
  expiryMonth?: string;
1686
1604
  expiryYear?: string;
1687
1605
  };
1688
1606
  fingerprint?: string;
1689
1607
  futureUsage?: string;
1690
1608
  }
1609
+ interface DeleteInstrumentResponse {
1610
+ success: boolean;
1611
+ }
1612
+ type RequestCreator<TReq, TOperation extends keyof Operations> = (config: ApiConfig<TReq> & {
1613
+ operation: TOperation;
1614
+ }) => {
1615
+ url: string;
1616
+ body?: TReq;
1617
+ };
1618
+ interface OperationConfig<TReq, TRes> {
1619
+ linkKey: keyof NonNullable<SdkConfiguration['links']>;
1620
+ method: RequestMethod;
1621
+ createRequest: RequestCreator<TReq, keyof Operations>;
1622
+ requestType: TReq;
1623
+ responseType: TRes;
1624
+ }
1625
+ interface ApiConfig<TReq> {
1626
+ operation: keyof Operations;
1627
+ resourceId?: string;
1628
+ body?: TReq;
1629
+ }
1630
+
1631
+ declare class SdkLoader {
1632
+ private static readonly scriptMap;
1633
+ static load<T = void>(sdk: ThirdPartySDK, params?: PayPalScriptConfig): Promise<T>;
1634
+ static reset(): void;
1635
+ static preloadCardForm(): void;
1636
+ private static loadScript;
1637
+ private static loadPayPalScript;
1638
+ private constructor();
1639
+ private static logLoadError;
1640
+ }
1641
+ interface PayPalScriptConfig {
1642
+ clientId: string;
1643
+ currency: string;
1644
+ vault: boolean;
1645
+ intent: 'tokenize' | 'capture' | 'authorize';
1646
+ }
1647
+ declare enum ThirdPartySDK {
1648
+ ApplePay = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",
1649
+ GooglePay = "https://pay.google.com/gp/p/js/pay.js",
1650
+ PayPal = "paypal-sdk"
1651
+ }
1652
+
1653
+ interface QueryDefinition<T> {
1654
+ path: string[];
1655
+ returnType: T;
1656
+ }
1657
+
1658
+ interface ConfigurationQueryTypes {
1659
+ holderReference: QueryDefinition<string>;
1660
+ amount: QueryDefinition<PayrailsAmount>;
1661
+ binLookup: QueryDefinition<Links | undefined>;
1662
+ instrumentDelete: QueryDefinition<Links | undefined>;
1663
+ instrumentUpdate: QueryDefinition<Links | undefined>;
1664
+ executionId: QueryDefinition<string | undefined>;
1665
+ paymentMethodConfig: QueryDefinition<StorablePaymentCompositionOption | undefined>;
1666
+ paymentMethodInstruments: QueryDefinition<StoredPaymentInstrument<CardMetadata | PayPalMetadata>[] | undefined>;
1667
+ }
1668
+
1669
+ interface InitOptions {
1670
+ version: string;
1671
+ data: string;
1672
+ }
1673
+
1674
+ interface PayrailsClientOptions {
1675
+ environment?: PayrailsEnvironment;
1676
+ events?: ClientEvents;
1677
+ redirectFor3DS?: boolean;
1678
+ returnInfo?: ReturnInfo;
1679
+ telemetry?: {
1680
+ enabled?: boolean;
1681
+ logLevel?: LogLevel$1;
1682
+ };
1683
+ }
1684
+ declare class Payrails {
1685
+ private vaultClient;
1686
+ private options?;
1687
+ private __container;
1688
+ private __cardForm;
1689
+ private __cardList;
1690
+ private __cardPaymentButton;
1691
+ private __paypalButton;
1692
+ private __genericRedirectButton;
1693
+ private __dynamicElementForm;
1694
+ private __dropin;
1695
+ static preloadCardForm: typeof SdkLoader.preloadCardForm;
1696
+ static init(initResponse: InitOptions, options?: PayrailsClientOptions): Payrails;
1697
+ update(amount: PayrailsAmount): void;
1698
+ collectContainer(containerOptions: CollectContainerOptions): PayrailsCollectContainer;
1699
+ googlePayButton(options: GooglePayButtonOptions): GooglePayButton;
1700
+ isGooglePayAvailable(merchantInfo: google.payments.api.MerchantInfo): Promise<boolean>;
1701
+ applePayButton(options: ApplePayButtonOptions): ApplePayButton;
1702
+ isApplePayAvailable(): Promise<boolean>;
1703
+ cardList(options?: CardListOptions): CardList;
1704
+ cardForm(options?: CardFormOptions): CardForm;
1705
+ dropin(options: DropinOptions): Dropin;
1706
+ getSavedCreditCards(): StoredPaymentInstrument<CardMetadata>[];
1707
+ getSavedGooglePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
1708
+ getSavedApplePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
1709
+ query<K extends keyof ConfigurationQueryTypes>(key: K, params?: Record<string, any>): ConfigurationQueryTypes[K]['returnType'] | null;
1710
+ api<TOperation extends keyof Operations>(config: ApiConfig<Operations[TOperation]['requestType']> & {
1711
+ operation: TOperation;
1712
+ }): Promise<Operations[TOperation]['responseType']>;
1713
+ getStoredInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
1714
+ getAvailablePaymentMethods(): PAYMENT_METHOD_CODES[];
1715
+ paymentButton(options: CardPaymentButtonOptions): CardPaymentButton;
1716
+ paypalButton(options?: PaypalButtonOptions): PaypalButton;
1717
+ genericRedirectButton(options: GenericRedirectButtonOptions): GenericRedirectButton;
1718
+ dynamicElement(options: DynamicElementOptions): DynamicElementForm;
1719
+ getSavedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
1720
+ private logIntegrationMode;
1721
+ private constructor();
1722
+ private getContainerLayout;
1723
+ binLookup(): Promise<any>;
1724
+ }
1725
+ interface ClientEvents {
1726
+ onClientInitialized?: (execution?: typeof WorkflowExecution) => void;
1727
+ onSessionExpired?: () => Promise<InitOptions>;
1728
+ }
1729
+ interface PaymentEvents {
1730
+ onAuthorizeSuccess?: (e?: any) => void;
1731
+ onAuthorizeFailed?: (e?: any) => void;
1732
+ onAuthorizePending?: (e?: any) => void;
1733
+ onPaymentButtonClicked?: (e?: {
1734
+ bin?: string;
1735
+ }) => Promise<boolean>;
1736
+ onAuthorizeRequestStart?: () => Promise<boolean>;
1737
+ onPaymentSessionExpired?: () => void;
1738
+ onThreeDSecureChallenge?: () => void;
1739
+ }
1740
+ interface UIEvents {
1741
+ onSaveInstrumentCheckboxChanged?: ({ checked }: {
1742
+ checked: boolean;
1743
+ }) => void;
1744
+ onBillingAddressChanged?: (e: {
1745
+ isValid: boolean;
1746
+ billingAddress?: IAddress;
1747
+ }) => void;
1748
+ onDeliveryAddressChanged?: (data?: onDeliveryAddressChangedResponse) => Promise<boolean>;
1749
+ }
1750
+ type onPaymentMethodSelectedParams = {
1751
+ paymentMethod?: StorablePaymentCompositionOption;
1752
+ instrument?: StoredPaymentInstrument<CardMetadata & PayPalMetadata>;
1753
+ };
1754
+ interface DropinEvents {
1755
+ onPaymentOptionSelected?: (e: onPaymentMethodSelectedParams) => void;
1756
+ }
1757
+ type PayrailsSDKEvents = PaymentEvents & UIEvents & DropinEvents;
1758
+ type onDeliveryAddressChangedResponse = {
1759
+ deliveryAddress?: {
1760
+ street?: string;
1761
+ doorNumber?: string;
1762
+ complement?: string;
1763
+ area?: string;
1764
+ city?: string;
1765
+ postalCode?: string;
1766
+ state?: string;
1767
+ country?: {
1768
+ code?: string;
1769
+ iso3?: string;
1770
+ name?: string;
1771
+ };
1772
+ latitude?: number;
1773
+ longitude?: number;
1774
+ phone?: {
1775
+ countryCode?: string;
1776
+ number?: string;
1777
+ };
1778
+ name?: string;
1779
+ lastName?: string;
1780
+ email?: string;
1781
+ };
1782
+ };
1783
+ declare enum PayrailsEnvironment {
1784
+ TEST = "TEST",
1785
+ PRODUCTION = "PRODUCTION"
1786
+ }
1787
+
1788
+ interface ApplePayButtonOptions extends StoreInstrumentElementOptions {
1789
+ clientDomain?: string;
1790
+ showPaymentMethodLogo?: boolean;
1791
+ translations?: {
1792
+ labels?: {
1793
+ storeInstrument?: string;
1794
+ saveInstrument?: string;
1795
+ paymentScreenLabel?: string;
1796
+ };
1797
+ };
1798
+ events?: PaymentEvents & {
1799
+ onApplePayAvailable?: () => void;
1800
+ };
1801
+ styles?: {
1802
+ type?: 'plain' | 'buy' | 'addMoney' | 'book' | 'checkout' | 'continue' | 'contribute' | 'donate' | 'inStore' | 'order' | 'reload' | 'rent' | 'setUp' | 'subscribe' | 'support' | 'tip' | 'topUp';
1803
+ style?: 'white' | 'whiteOutline' | 'black' | 'automatic';
1804
+ } & StoreInstrumentElementOptions['styles'];
1805
+ }
1806
+ declare global {
1807
+ interface Window {
1808
+ ApplePaySession?: ApplePaySession;
1809
+ }
1810
+ }
1811
+ declare class ApplePayButton extends PayrailsElementWithStoreInstrumentCheckbox {
1812
+ protected options: ApplePayButtonOptions;
1813
+ private appleButton;
1814
+ private paymentExecutor;
1815
+ static isApplePayAvailable(): Promise<boolean>;
1816
+ constructor(options: ApplePayButtonOptions);
1817
+ mount(location: string): void;
1818
+ unmount(): void;
1819
+ private mountApplePayButton;
1820
+ private createApplePaySession;
1821
+ private onApplePayAuthorized;
1822
+ }
1691
1823
 
1692
1824
  export { AuthorizationFailureReasons, ElementType, INTEGRATION_TYPE, PAYMENT_METHOD_CODES, Payrails, PayrailsEnvironment };
1693
1825
  export type { ApplePayButtonOptions, CardFormOptions, CardListOptions, CardPaymentButtonOptions, DropinOptions, GooglePayButtonOptions, InitOptions, PaymentEvents, PaypalButtonOptions, PayrailsAmount, PayrailsClientOptions, PayrailsContainerType, PayrailsSecureField, PayrailsSecureFieldEvent, SaveInstrumentResponse, WorkflowExecutionResponse };