@payrails/web-sdk 5.29.0 → 5.29.1-RC.3

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,383 @@
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[];
136
+ requiredShippingContactFields?: ApplePayJS.ApplePayContactField[];
51
137
  };
52
- styles?: {
53
- wrapper?: Partial<CSSStyleDeclaration>;
54
- countrySelector?: {
55
- wrapper?: Partial<CSSStyleDeclaration>;
56
- element?: Partial<CSSStyleDeclaration>;
57
- label?: Partial<CSSStyleDeclaration>;
138
+ static get url(): string;
139
+ static get meta(): {
140
+ customer?: {
141
+ country?: {
142
+ code?: string;
143
+ };
58
144
  };
59
- postalCodeInput?: {
60
- wrapper?: Partial<CSSStyleDeclaration>;
61
- element?: Partial<CSSStyleDeclaration>;
62
- label?: Partial<CSSStyleDeclaration>;
145
+ order?: {
146
+ billingAddress?: {
147
+ country?: {
148
+ code?: string;
149
+ };
150
+ };
63
151
  };
64
152
  };
65
- events?: {
66
- onBillingAddressChanged?: (e: IOnChange) => void;
153
+ static get availablePaymentMethods(): StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined>[];
154
+ static get authorizeLink(): string | undefined;
155
+ static get createSessionLink(): string | undefined;
156
+ static get storedPaymentInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
157
+ static get storedDropinInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
158
+ static getFullPaymentMethodConfig(paymentMethod: PAYMENT_METHOD_CODES): StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined> | undefined;
159
+ static isAddressSelectorEnabled(paymentMethod: PAYMENT_METHOD_CODES): boolean | undefined;
160
+ static isPaymentInstallmentsEnabled(paymentMethod: PAYMENT_METHOD_CODES): boolean | undefined;
161
+ static getPaymentInstallmentOptions(paymentMethod: PAYMENT_METHOD_CODES): PaymentInstallmentsConfig;
162
+ static getStoredInstrumentForPaymentMethod<T = CardMetadata | PayPalMetadata>(paymentMethod: PAYMENT_METHOD_CODES): Array<StoredPaymentInstrument<T>>;
163
+ static getPaymentMethodForStoredInstrument<T extends CardMetadata | PayPalMetadata>(instrument: StoredPaymentInstrument<T>): {
164
+ id: string;
165
+ description?: string;
166
+ status: PAYMENT_INSTRUMENT_STATUS;
167
+ integrationType: INTEGRATION_TYPE;
168
+ config: ApplePayConfig | PayPalConfig | GooglePayConfig | undefined;
169
+ clientConfig?: {
170
+ flow?: PAYMENT_CLIENT_FLOW;
171
+ supportsInstallments?: boolean;
172
+ installments?: PaymentInstallmentsConfig;
173
+ supportsBillingInfo?: boolean;
174
+ schema?: JSONSchemaType;
175
+ additionalConfig?: any;
176
+ };
177
+ paymentMethodCode: PAYMENT_METHOD_CODES;
178
+ } | undefined;
179
+ static getPaymentMethodConfig(paymentMethod: StorablePaymentCompositionOption): {
180
+ id: string;
181
+ description?: string;
182
+ status: PAYMENT_INSTRUMENT_STATUS;
183
+ integrationType: INTEGRATION_TYPE;
184
+ config: ApplePayConfig | PayPalConfig | GooglePayConfig | undefined;
185
+ clientConfig?: {
186
+ flow?: PAYMENT_CLIENT_FLOW;
187
+ supportsInstallments?: boolean;
188
+ installments?: PaymentInstallmentsConfig;
189
+ supportsBillingInfo?: boolean;
190
+ schema?: JSONSchemaType;
191
+ additionalConfig?: any;
192
+ };
193
+ paymentMethodCode: PAYMENT_METHOD_CODES;
67
194
  };
68
195
  }
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;
196
+ interface WorkflowExecutionResponse {
197
+ id: string;
198
+ merchantReference: string;
199
+ holderReference: string;
200
+ actionRequired?: string;
201
+ meta: {
202
+ customer?: {
203
+ country?: {
204
+ code?: string;
205
+ };
206
+ };
207
+ order?: {
208
+ billingAddress?: {
209
+ country?: {
210
+ code?: string;
211
+ };
212
+ };
78
213
  };
79
214
  };
80
- styles?: {
81
- storeInstrumentCheckbox?: Partial<CSSStyleDeclaration>;
215
+ status: Array<{
216
+ code: string;
217
+ time: string;
218
+ }>;
219
+ initialResults: Array<{
220
+ httpCode: number;
221
+ body: {
222
+ data: {
223
+ paymentCompositionOptions: Array<StorablePaymentCompositionOption>;
224
+ };
225
+ links: {
226
+ authorize: {
227
+ href: string;
228
+ method: 'POST';
229
+ };
230
+ execution: string;
231
+ };
232
+ name: 'lookup';
233
+ };
234
+ }>;
235
+ links: {
236
+ startPaymentSession?: {
237
+ href: string;
238
+ method: 'POST';
239
+ };
240
+ confirm?: {
241
+ href: string;
242
+ action?: {
243
+ parameters?: {
244
+ orderId?: string;
245
+ tokenId?: string;
246
+ };
247
+ };
248
+ };
249
+ redirect?: string;
250
+ '3ds'?: string;
251
+ self: string;
252
+ };
253
+ workflow: {
254
+ code: string;
255
+ version: number;
82
256
  };
83
- events?: PayrailsSDKEvents;
84
257
  }
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;
258
+ interface BasePaymentMethodConfig {
259
+ paymentMethodCode: PAYMENT_METHOD_CODES;
92
260
  }
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;
261
+ interface BaseInstallmentOption {
262
+ count: number;
263
+ amount: number;
98
264
  }
99
-
100
- interface ApplePayButtonOptions extends StoreInstrumentElementOptions {
101
- clientDomain?: string;
102
- showPaymentMethodLogo?: boolean;
103
- events?: PaymentEvents & {
104
- onApplePayAvailable?: () => void;
265
+ interface PaymentInstallmentsConfig {
266
+ [key: string]: BaseInstallmentOption[];
267
+ }
268
+ interface StorablePaymentCompositionOption<I = CardMetadata | PayPalMetadata, C = undefined | ApplePayConfig | PayPalConfig | GooglePayConfig> extends BasePaymentMethodConfig {
269
+ id: string;
270
+ description?: string;
271
+ status: PAYMENT_INSTRUMENT_STATUS;
272
+ integrationType: INTEGRATION_TYPE;
273
+ config: C;
274
+ clientConfig?: {
275
+ flow?: PAYMENT_CLIENT_FLOW;
276
+ supportsInstallments?: boolean;
277
+ installments?: PaymentInstallmentsConfig;
278
+ supportsBillingInfo?: boolean;
279
+ schema?: JSONSchemaType;
280
+ additionalConfig?: any;
105
281
  };
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'];
282
+ paymentInstruments?: Array<StoredPaymentInstrument<I>>;
110
283
  }
111
- declare global {
112
- interface Window {
113
- ApplePaySession?: ApplePaySession;
114
- }
284
+ interface GooglePayConfig {
285
+ parameters: {
286
+ allowedAuthMethods: google.payments.api.CardAuthMethod[];
287
+ allowedCardNetworks: google.payments.api.CardNetwork[];
288
+ billingAddressParameters?: {
289
+ format?: string;
290
+ };
291
+ billingAddressRequired?: boolean;
292
+ };
293
+ tokenizationSpecification: google.payments.api.PaymentMethodTokenizationSpecification;
294
+ type: google.payments.api.PaymentMethodType;
295
+ apiVersion?: number;
296
+ apiVersionMinor?: number;
297
+ allowedPaymentMethods?: google.payments.api.PaymentMethodSpecification[];
298
+ emailRequired?: boolean;
299
+ shippingAddressRequired?: boolean;
300
+ shippingAddressParameters?: google.payments.api.ShippingAddressParameters;
301
+ merchantInfo?: google.payments.api.MerchantInfo;
302
+ existingPaymentMethodRequired?: boolean;
115
303
  }
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;
304
+ interface PayPalConfig {
305
+ clientId: string;
306
+ merchantId: string;
307
+ captureMode: 'Delayed' | 'Instant' | 'Manual';
308
+ integrationMode: 'express' | 'normal';
309
+ }
310
+ interface ApplePayConfig {
311
+ parameters: {
312
+ merchantIdentifier: string;
313
+ supportedNetworks: string[];
314
+ countryCode: string;
315
+ merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
316
+ requiredBillingContactFields?: ApplePayJS.ApplePayContactField[];
317
+ requiredShippingContactFields?: ApplePayJS.ApplePayContactField[];
318
+ };
319
+ type: string;
320
+ }
321
+ interface StoredPaymentInstrument<T = CardMetadata | PayPalMetadata> {
322
+ id: string;
323
+ status: PAYMENT_INSTRUMENT_STATUS;
324
+ paymentMethod: PAYMENT_METHOD_CODES;
325
+ displayName?: string;
326
+ data?: T;
327
+ }
328
+ interface PayPalMetadata {
329
+ email?: string;
330
+ }
331
+ interface CardMetadata {
332
+ bin?: string;
333
+ suffix?: string;
334
+ network?: string;
335
+ binLookup?: {
336
+ issuerCountry: {
337
+ code: string;
338
+ name: string;
339
+ iso3: string;
340
+ };
341
+ };
342
+ }
343
+ declare enum PAYMENT_CLIENT_FLOW {
344
+ 'REDIRECT' = "redirect",
345
+ 'DIRECT' = "direct",
346
+ 'EMBEDDED' = "embedded"
347
+ }
348
+ declare enum INTEGRATION_TYPE {
349
+ API = "api",
350
+ HPP = "hpp"
127
351
  }
128
352
 
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;
353
+ interface SaveInstrumentResponse {
354
+ id: string;
355
+ createdAt: string;
356
+ holderId: string;
357
+ paymentMethod: PAYMENT_METHOD_CODES.CARD;
358
+ status: PAYMENT_INSTRUMENT_STATUS;
359
+ data: {
360
+ bin: string;
361
+ binLookup?: {
362
+ bin: string;
363
+ network: string;
364
+ issuer?: string;
365
+ issuerCountry?: {
366
+ code?: string;
367
+ name?: string;
368
+ iso3?: string;
369
+ };
370
+ type?: string;
371
+ };
372
+ holderName?: string;
373
+ network: string;
374
+ suffix: string;
375
+ expiryMonth?: string;
376
+ expiryYear?: string;
377
+ };
378
+ fingerprint?: string;
379
+ futureUsage?: string;
380
+ }
142
381
 
143
382
  interface BinLookupResponse {
144
383
  bin: string;
@@ -471,6 +710,40 @@ declare class Skyflow {
471
710
  static get ValidationRuleType(): typeof ValidationRuleType;
472
711
  }
473
712
 
713
+ interface Mountable {
714
+ mount(selector: string | PayrailsElement): void;
715
+ unmount(): void;
716
+ }
717
+ interface ElementOptions {
718
+ id?: string;
719
+ dataTestId?: string;
720
+ className?: string | string[];
721
+ styles?: Partial<CSSStyleDeclaration>;
722
+ }
723
+ declare class PayrailsElement implements Mountable {
724
+ protected element: HTMLElement;
725
+ protected subElements: Array<Mountable>;
726
+ readonly id: string | undefined;
727
+ readonly dataTestId: string | undefined;
728
+ protected eventBus: _payrails_iframe_event_bus.IframeEventBus;
729
+ constructor(elementType: string, { id, className, dataTestId }?: ElementOptions);
730
+ get parentElement(): HTMLElement | null;
731
+ get selector(): string;
732
+ mount(location: string): void;
733
+ protected clean(): void;
734
+ unmount(): void;
735
+ }
736
+
737
+ interface TokenizeOptions {
738
+ futureUsage?: 'CardOnFile' | 'Subscription' | 'UnscheduledCardOnFile';
739
+ storeInstrument?: boolean;
740
+ }
741
+ declare abstract class Tokenizable extends PayrailsElement {
742
+ abstract collect(): Promise<any>;
743
+ protected abstract constructSaveInstrumentBody(tokens: any, opts?: TokenizeOptions): Promise<any>;
744
+ tokenize(_opts?: TokenizeOptions): Promise<any>;
745
+ }
746
+
474
747
  declare enum ElementType {
475
748
  CARD_NUMBER = "CARD_NUMBER",
476
749
  CARDHOLDER_NAME = "CARDHOLDER_NAME",
@@ -566,10 +839,61 @@ declare class PayrailsCollectContainer implements Mountable {
566
839
  bin: string;
567
840
  }>;
568
841
  }
569
- interface TokenizeOptions {
570
- futureUsage?: 'CardOnFile' | 'Subscription' | 'UnscheduledCardOnFile';
571
- storeInstrument?: boolean;
842
+
843
+ interface IAddress {
844
+ country?: {
845
+ code?: string;
846
+ fullName?: string;
847
+ iso3?: string;
848
+ };
849
+ postalCode?: string;
850
+ }
851
+ interface IOnChange {
852
+ isValid: boolean;
853
+ billingAddress?: IAddress;
572
854
  }
855
+ interface AddressSelectorElementOptions extends ElementOptions {
856
+ translations?: {
857
+ labels?: {
858
+ countrySelector?: string;
859
+ postalCodeInput?: string;
860
+ };
861
+ placeholders?: {
862
+ postalCodeInput?: string;
863
+ countrySelector?: string;
864
+ };
865
+ };
866
+ styles?: {
867
+ wrapper?: Partial<CSSStyleDeclaration>;
868
+ countrySelector?: {
869
+ wrapper?: Partial<CSSStyleDeclaration>;
870
+ element?: Partial<CSSStyleDeclaration>;
871
+ label?: Partial<CSSStyleDeclaration>;
872
+ };
873
+ postalCodeInput?: {
874
+ wrapper?: Partial<CSSStyleDeclaration>;
875
+ element?: Partial<CSSStyleDeclaration>;
876
+ label?: Partial<CSSStyleDeclaration>;
877
+ };
878
+ };
879
+ events?: {
880
+ onBillingAddressChanged?: (e: IOnChange) => void;
881
+ };
882
+ }
883
+
884
+ declare const regexes: {
885
+ visa: RegExp;
886
+ mastercard: RegExp;
887
+ amex: RegExp;
888
+ diners: RegExp;
889
+ discover: RegExp;
890
+ jcb: RegExp;
891
+ hipercard: RegExp;
892
+ unionpay: RegExp;
893
+ maestro: RegExp;
894
+ elo: RegExp;
895
+ };
896
+ type CardNetwork = keyof typeof regexes;
573
897
 
574
898
  interface PaymentInstallmentsElementOptions extends ElementOptions {
575
899
  showPaymentInstallmentsDropdown?: boolean;
@@ -608,26 +932,56 @@ declare class PayrailsElementWithPaymentInstallmentsDropdown extends PayrailsEle
608
932
  setDisabled(state: boolean): void;
609
933
  }
610
934
 
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;
935
+ interface StoreInstrumentElementOptions extends ElementOptions {
936
+ showStoreInstrumentCheckbox?: boolean;
937
+ alwaysStoreInstrument?: boolean;
938
+ defaultStoreInstrumentState?: 'checked' | 'unchecked';
624
939
  translations?: {
625
- placeholders?: {
626
- [key in ElementType]?: string;
627
- };
628
940
  labels?: {
629
- [key in ElementType | 'saveCreditCard']?: string;
630
- } & {
941
+ storeInstrument?: string;
942
+ saveInstrument?: string;
943
+ };
944
+ };
945
+ styles?: {
946
+ storeInstrumentCheckbox?: Partial<CSSStyleDeclaration>;
947
+ };
948
+ events?: PayrailsSDKEvents;
949
+ }
950
+ declare class StoreInstrumentCheckbox extends PayrailsElement {
951
+ private options;
952
+ constructor(options: StoreInstrumentElementOptions);
953
+ get isChecked(): boolean;
954
+ private createHTML;
955
+ private applyStyles;
956
+ private addListeners;
957
+ }
958
+ declare abstract class PayrailsElementWithStoreInstrumentCheckbox extends PayrailsElement {
959
+ protected options?: StoreInstrumentElementOptions | undefined;
960
+ protected storeInstrumentCheckbox: StoreInstrumentCheckbox | null;
961
+ protected constructor(elementType: string, options?: StoreInstrumentElementOptions | undefined);
962
+ protected get shouldStoreInstrument(): boolean;
963
+ }
964
+
965
+ interface OnChange {
966
+ isValid: boolean;
967
+ cardNetwork: CardNetwork | '';
968
+ bin?: string;
969
+ billingAddress?: IAddress;
970
+ }
971
+ type cardFormField = keyof typeof ElementType;
972
+ type CardFormLayout = cardFormField[][];
973
+ interface CardFormOptions extends StoreInstrumentElementOptions {
974
+ showCardHolderName?: boolean;
975
+ showSingleExpiryDateField?: boolean;
976
+ enrollInstrumentToNetworkOffers?: boolean;
977
+ layout?: CardFormLayout;
978
+ translations?: {
979
+ placeholders?: {
980
+ [key in ElementType]?: string;
981
+ };
982
+ labels?: {
983
+ [key in ElementType | 'saveCreditCard']?: string;
984
+ } & {
631
985
  saveInstrument?: string;
632
986
  storeInstrument?: string;
633
987
  paymentInstallments?: string;
@@ -674,12 +1028,14 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
674
1028
  private lastBinLookup;
675
1029
  private defaultStyles;
676
1030
  private defaultTranslations;
1031
+ private eventsRef?;
677
1032
  constructor(collectContainer: PayrailsCollectContainer, options?: CardFormOptions | undefined);
678
1033
  private initializeFormFields;
679
1034
  getErrorTextStyles(errorTextStyles: any): any;
680
1035
  private updateStyles;
681
1036
  private updateTranslations;
682
- update(options: Partial<Pick<CardFormOptions, 'styles' | 'translations'>>): void;
1037
+ private updateEvents;
1038
+ update(options: Partial<Pick<CardFormOptions, 'styles' | 'translations' | 'events'>>): void;
683
1039
  private createFormField;
684
1040
  private initializeCustomLayout;
685
1041
  private hasFieldBeenUsed;
@@ -742,6 +1098,13 @@ declare class CardList extends PayrailsElement {
742
1098
  reset(): void;
743
1099
  }
744
1100
 
1101
+ declare enum RequestMethod {
1102
+ GET = "GET",
1103
+ POST = "POST",
1104
+ DELETE = "DELETE",
1105
+ PATCH = "PATCH"
1106
+ }
1107
+
745
1108
  interface SdkConfiguration {
746
1109
  token: string;
747
1110
  amount: PayrailsAmount;
@@ -763,6 +1126,7 @@ interface SdkConfiguration {
763
1126
  links: {
764
1127
  saveInstrument: {
765
1128
  href: string;
1129
+ method: RequestMethod;
766
1130
  };
767
1131
  };
768
1132
  };
@@ -835,7 +1199,8 @@ declare class CardPaymentButton extends PayrailsElement {
835
1199
  private constructEncryptedPayment;
836
1200
  private updateStyles;
837
1201
  private updateTranslations;
838
- update(options: Partial<Pick<CardPaymentButtonOptions, 'styles' | 'translations'>>): void;
1202
+ private updateEvents;
1203
+ update(options: Partial<Pick<CardPaymentButtonOptions, 'styles' | 'translations' | 'events'>>): void;
839
1204
  private handleAuthorizationResult;
840
1205
  }
841
1206
  declare enum AuthorizationFailureReasons {
@@ -865,6 +1230,7 @@ interface LoadingScreenStyles {
865
1230
  [StyleKeys.loader]?: Partial<CSSStyleDeclaration>;
866
1231
  }
867
1232
 
1233
+ type GooglePayConfigInput = google.payments.api.IsReadyToPayPaymentMethodSpecification[] | GooglePayConfig;
868
1234
  interface GooglePayButtonOptions extends StoreInstrumentElementOptions {
869
1235
  environment?: PayrailsEnvironment;
870
1236
  merchantInfo?: google.payments.api.MerchantInfo;
@@ -887,8 +1253,9 @@ declare class GooglePayButton extends PayrailsElementWithStoreInstrumentCheckbox
887
1253
  private static googleSDKClient;
888
1254
  private sdkLoadedCalled;
889
1255
  private buttonElement;
1256
+ private static getGooglePayConfigAsArray;
890
1257
  private static getSDKClient;
891
- static isGooglePayAvailable(allowedPaymentMethods: google.payments.api.IsReadyToPayPaymentMethodSpecification[], environment?: PayrailsEnvironment, merchantInfo?: google.payments.api.MerchantInfo): Promise<boolean>;
1258
+ static isGooglePayAvailable(allowedPaymentMethods: GooglePayConfigInput, environment?: PayrailsEnvironment, merchantInfo?: google.payments.api.MerchantInfo): Promise<boolean>;
892
1259
  constructor(options: GooglePayButtonOptions);
893
1260
  private sdkLoaded;
894
1261
  private onLoadPaymentData;
@@ -913,6 +1280,7 @@ interface ApplePayDropinOptions extends ApplePayButtonOptions {
913
1280
  labels?: {
914
1281
  label?: string;
915
1282
  storeInstrument?: string;
1283
+ paymentScreenLabel?: string;
916
1284
  };
917
1285
  };
918
1286
  events?: ApplePayButtonOptions['events'] & DropinElementEvents;
@@ -969,9 +1337,11 @@ declare class GenericRedirectButton extends PayrailsElement {
969
1337
  private redirectToPaymentLink;
970
1338
  private updateStyles;
971
1339
  private updateTranslations;
1340
+ private updateEvents;
972
1341
  update(options: {
973
1342
  styles?: ButtonOptions['styles'];
974
1343
  translations?: ButtonOptions['translations'];
1344
+ events?: ButtonOptions['events'];
975
1345
  }): void;
976
1346
  }
977
1347
 
@@ -1080,7 +1450,7 @@ declare class Dropin extends PayrailsElement {
1080
1450
  private loadingScreen;
1081
1451
  constructor(collectContainer: PayrailsCollectContainer, clientConfig: PayrailsClientOptions, dropinConfig: DropinOptions);
1082
1452
  private isHppIntegration;
1083
- private isGenericDirect;
1453
+ private isEmbeddedElement;
1084
1454
  private createStoredInstrumentElement;
1085
1455
  private createInstallmentsDropdown;
1086
1456
  private getInstallmentOptionsForInstrument;
@@ -1092,7 +1462,7 @@ declare class Dropin extends PayrailsElement {
1092
1462
  private createCardForm;
1093
1463
  private createApplePayButton;
1094
1464
  private createCardPaymentButton;
1095
- private createGenericDirectElement;
1465
+ private createEmbeddedElement;
1096
1466
  private onAuthorizeSuccess;
1097
1467
  private getElementEvents;
1098
1468
  private onAuthorizePending;
@@ -1158,519 +1528,74 @@ interface DropinOptions {
1158
1528
  applePayButton?: ApplePayButtonOptions['styles'];
1159
1529
  cardForm?: CardFormOptions['styles'];
1160
1530
  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
- };
1531
+ authSuccess?: Partial<CSSStyleDeclaration>;
1532
+ authFailed?: Partial<CSSStyleDeclaration>;
1533
+ loadingScreen?: LoadingScreenStyles;
1534
+ addressSelector?: AddressSelectorElementOptions['styles'];
1535
+ mercadoPago?: GenericRedirectDropinOptions['styles'];
1536
+ };
1537
+ configuration?: {
1538
+ authFailMsg?: AuthFailedMsgOptions['configuration'];
1652
1539
  };
1653
1540
  }
1654
- declare enum PAYMENT_CLIENT_FLOW {
1655
- 'REDIRECT' = "redirect",
1656
- 'DIRECT' = "direct"
1541
+ interface ContainerStyles {
1542
+ styles?: Partial<CSSStyleDeclaration>;
1657
1543
  }
1658
- declare enum INTEGRATION_TYPE {
1659
- API = "api",
1660
- HPP = "hpp"
1544
+
1545
+ interface DynamicElementOptions {
1546
+ styles?: DynamicElementStyles;
1547
+ translations?: DynamicElementTranslations;
1548
+ events?: PaymentEvents;
1549
+ paymentMethod: BasePaymentMethodConfig;
1550
+ }
1551
+ interface FormConfig {
1552
+ schema: JSONSchemaType;
1553
+ }
1554
+ declare class DynamicElementForm extends Tokenizable {
1555
+ protected options: DynamicElementOptions;
1556
+ protected readonly formConfig: FormConfig;
1557
+ private readonly returnInfo?;
1558
+ private formFields;
1559
+ private formData;
1560
+ private __schema;
1561
+ constructor(options: DynamicElementOptions, formConfig: FormConfig, returnInfo?: ReturnInfo | undefined);
1562
+ collect(): Promise<Record<string, any>>;
1563
+ protected constructSaveInstrumentBody(tokens: any, opts?: TokenizeOptions): Promise<any>;
1564
+ private isFormValid;
1565
+ mount(location: string): Promise<void>;
1566
+ private makeForm;
1567
+ private createField;
1568
+ private createFieldSync;
1569
+ private createOneOfField;
1570
+ private createStringField;
1571
+ private createFieldByType;
1572
+ private extractStyles;
1573
+ private makeFieldEvents;
1574
+ private evaluateDependencies;
1661
1575
  }
1662
1576
 
1663
- interface SaveInstrumentResponse {
1577
+ type Operations = {
1578
+ deleteInstrument: OperationConfig<void, DeleteInstrumentResponse>;
1579
+ updateInstrument: OperationConfig<UpdateInstrumentBody, UpdateInstrumentResponse>;
1580
+ };
1581
+ interface UpdateInstrumentBody {
1582
+ status?: 'enabled' | 'disabled';
1583
+ networkTransactionReference?: string;
1584
+ merchantReference?: string;
1585
+ paymentMethod?: 'applepay' | 'card' | 'googlepay' | 'paypal';
1586
+ default?: boolean;
1587
+ }
1588
+ interface UpdateInstrumentResponse {
1664
1589
  id: string;
1665
1590
  createdAt: string;
1666
1591
  holderId: string;
1667
- paymentMethod: PAYMENT_METHOD_CODES.CARD;
1592
+ paymentMethod: PAYMENT_METHOD_CODES;
1668
1593
  status: PAYMENT_INSTRUMENT_STATUS;
1669
1594
  data: {
1670
- bin: string;
1595
+ bin?: string;
1671
1596
  binLookup?: {
1672
- bin: string;
1673
- network: string;
1597
+ bin?: string;
1598
+ network?: string;
1674
1599
  issuer?: string;
1675
1600
  issuerCountry?: {
1676
1601
  code?: string;
@@ -1680,14 +1605,228 @@ interface SaveInstrumentResponse {
1680
1605
  type?: string;
1681
1606
  };
1682
1607
  holderName?: string;
1683
- network: string;
1684
- suffix: string;
1608
+ network?: string;
1609
+ suffix?: string;
1685
1610
  expiryMonth?: string;
1686
1611
  expiryYear?: string;
1687
1612
  };
1688
1613
  fingerprint?: string;
1689
1614
  futureUsage?: string;
1690
1615
  }
1616
+ interface DeleteInstrumentResponse {
1617
+ success: boolean;
1618
+ }
1619
+ type RequestCreator<TReq, TOperation extends keyof Operations> = (config: ApiConfig<TReq> & {
1620
+ operation: TOperation;
1621
+ }) => {
1622
+ url: string;
1623
+ body?: TReq;
1624
+ };
1625
+ interface OperationConfig<TReq, TRes> {
1626
+ linkKey: keyof NonNullable<SdkConfiguration['links']>;
1627
+ method: RequestMethod;
1628
+ createRequest: RequestCreator<TReq, keyof Operations>;
1629
+ requestType: TReq;
1630
+ responseType: TRes;
1631
+ }
1632
+ interface ApiConfig<TReq> {
1633
+ operation: keyof Operations;
1634
+ resourceId?: string;
1635
+ body?: TReq;
1636
+ }
1637
+
1638
+ declare class SdkLoader {
1639
+ private static readonly scriptMap;
1640
+ static load<T = void>(sdk: ThirdPartySDK, params?: PayPalScriptConfig): Promise<T>;
1641
+ static reset(): void;
1642
+ static preloadCardForm(): void;
1643
+ private static loadScript;
1644
+ private static loadPayPalScript;
1645
+ private constructor();
1646
+ private static logLoadError;
1647
+ }
1648
+ interface PayPalScriptConfig {
1649
+ clientId: string;
1650
+ currency: string;
1651
+ vault: boolean;
1652
+ intent: 'tokenize' | 'capture' | 'authorize';
1653
+ }
1654
+ declare enum ThirdPartySDK {
1655
+ ApplePay = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",
1656
+ GooglePay = "https://pay.google.com/gp/p/js/pay.js",
1657
+ PayPal = "paypal-sdk"
1658
+ }
1659
+
1660
+ interface QueryDefinition<T> {
1661
+ path: string[];
1662
+ returnType: T;
1663
+ }
1664
+
1665
+ interface ConfigurationQueryTypes {
1666
+ holderReference: QueryDefinition<string>;
1667
+ amount: QueryDefinition<PayrailsAmount>;
1668
+ binLookup: QueryDefinition<Links | undefined>;
1669
+ instrumentDelete: QueryDefinition<Links | undefined>;
1670
+ instrumentUpdate: QueryDefinition<Links | undefined>;
1671
+ executionId: QueryDefinition<string | undefined>;
1672
+ paymentMethodConfig: QueryDefinition<StorablePaymentCompositionOption | undefined>;
1673
+ paymentMethodInstruments: QueryDefinition<StoredPaymentInstrument<CardMetadata | PayPalMetadata>[] | undefined>;
1674
+ }
1675
+
1676
+ interface InitOptions {
1677
+ version: string;
1678
+ data: string;
1679
+ }
1680
+
1681
+ interface PayrailsClientOptions {
1682
+ environment?: PayrailsEnvironment;
1683
+ events?: ClientEvents;
1684
+ redirectFor3DS?: boolean;
1685
+ returnInfo?: ReturnInfo;
1686
+ telemetry?: {
1687
+ enabled?: boolean;
1688
+ logLevel?: LogLevel$1;
1689
+ };
1690
+ }
1691
+ declare class Payrails {
1692
+ private vaultClient;
1693
+ private options?;
1694
+ private __container;
1695
+ private __cardForm;
1696
+ private __cardList;
1697
+ private __cardPaymentButton;
1698
+ private __paypalButton;
1699
+ private __genericRedirectButton;
1700
+ private __dynamicElementForm;
1701
+ private __dropin;
1702
+ static preloadCardForm: typeof SdkLoader.preloadCardForm;
1703
+ static init(initResponse: InitOptions, options?: PayrailsClientOptions): Payrails;
1704
+ update(amount: PayrailsAmount): void;
1705
+ collectContainer(containerOptions: CollectContainerOptions): PayrailsCollectContainer;
1706
+ googlePayButton(options: GooglePayButtonOptions): GooglePayButton;
1707
+ isGooglePayAvailable(merchantInfo: google.payments.api.MerchantInfo): Promise<boolean>;
1708
+ applePayButton(options: ApplePayButtonOptions): ApplePayButton;
1709
+ isApplePayAvailable(): Promise<boolean>;
1710
+ cardList(options?: CardListOptions): CardList;
1711
+ cardForm(options?: CardFormOptions): CardForm;
1712
+ dropin(options: DropinOptions): Dropin;
1713
+ getSavedCreditCards(): StoredPaymentInstrument<CardMetadata>[];
1714
+ getSavedGooglePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
1715
+ getSavedApplePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
1716
+ query<K extends keyof ConfigurationQueryTypes>(key: K, params?: Record<string, any>): ConfigurationQueryTypes[K]['returnType'] | null;
1717
+ api<TOperation extends keyof Operations>(config: ApiConfig<Operations[TOperation]['requestType']> & {
1718
+ operation: TOperation;
1719
+ }): Promise<Operations[TOperation]['responseType']>;
1720
+ getStoredInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
1721
+ getAvailablePaymentMethods(): PAYMENT_METHOD_CODES[];
1722
+ paymentButton(options: CardPaymentButtonOptions): CardPaymentButton;
1723
+ paypalButton(options?: PaypalButtonOptions): PaypalButton;
1724
+ genericRedirectButton(options: GenericRedirectButtonOptions): GenericRedirectButton;
1725
+ dynamicElement(options: DynamicElementOptions): DynamicElementForm;
1726
+ getSavedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
1727
+ private logIntegrationMode;
1728
+ private constructor();
1729
+ private getContainerLayout;
1730
+ binLookup(): Promise<any>;
1731
+ }
1732
+ interface ClientEvents {
1733
+ onClientInitialized?: (execution?: typeof WorkflowExecution) => void;
1734
+ onSessionExpired?: () => Promise<InitOptions>;
1735
+ }
1736
+ interface PaymentEvents {
1737
+ onAuthorizeSuccess?: (e?: any) => void;
1738
+ onAuthorizeFailed?: (e?: any) => void;
1739
+ onAuthorizePending?: (e?: any) => void;
1740
+ onPaymentButtonClicked?: (e?: {
1741
+ bin?: string;
1742
+ }) => Promise<boolean>;
1743
+ onAuthorizeRequestStart?: () => Promise<boolean>;
1744
+ onPaymentSessionExpired?: () => void;
1745
+ onThreeDSecureChallenge?: () => void;
1746
+ }
1747
+ interface UIEvents {
1748
+ onSaveInstrumentCheckboxChanged?: ({ checked }: {
1749
+ checked: boolean;
1750
+ }) => void;
1751
+ onBillingAddressChanged?: (e: {
1752
+ isValid: boolean;
1753
+ billingAddress?: IAddress;
1754
+ }) => void;
1755
+ onDeliveryAddressChanged?: (data?: onDeliveryAddressChangedResponse) => Promise<boolean>;
1756
+ }
1757
+ type onPaymentMethodSelectedParams = {
1758
+ paymentMethod?: StorablePaymentCompositionOption;
1759
+ instrument?: StoredPaymentInstrument<CardMetadata & PayPalMetadata>;
1760
+ };
1761
+ interface DropinEvents {
1762
+ onPaymentOptionSelected?: (e: onPaymentMethodSelectedParams) => void;
1763
+ }
1764
+ type PayrailsSDKEvents = PaymentEvents & UIEvents & DropinEvents;
1765
+ type onDeliveryAddressChangedResponse = {
1766
+ deliveryAddress?: {
1767
+ street?: string;
1768
+ doorNumber?: string;
1769
+ complement?: string;
1770
+ area?: string;
1771
+ city?: string;
1772
+ postalCode?: string;
1773
+ state?: string;
1774
+ country?: {
1775
+ code?: string;
1776
+ iso3?: string;
1777
+ name?: string;
1778
+ };
1779
+ latitude?: number;
1780
+ longitude?: number;
1781
+ phone?: {
1782
+ countryCode?: string;
1783
+ number?: string;
1784
+ };
1785
+ name?: string;
1786
+ lastName?: string;
1787
+ email?: string;
1788
+ };
1789
+ };
1790
+ declare enum PayrailsEnvironment {
1791
+ TEST = "TEST",
1792
+ PRODUCTION = "PRODUCTION"
1793
+ }
1794
+
1795
+ interface ApplePayButtonOptions extends StoreInstrumentElementOptions {
1796
+ clientDomain?: string;
1797
+ showPaymentMethodLogo?: boolean;
1798
+ translations?: {
1799
+ labels?: {
1800
+ storeInstrument?: string;
1801
+ saveInstrument?: string;
1802
+ paymentScreenLabel?: string;
1803
+ };
1804
+ };
1805
+ events?: PaymentEvents & {
1806
+ onApplePayAvailable?: () => void;
1807
+ };
1808
+ styles?: {
1809
+ type?: 'plain' | 'buy' | 'addMoney' | 'book' | 'checkout' | 'continue' | 'contribute' | 'donate' | 'inStore' | 'order' | 'reload' | 'rent' | 'setUp' | 'subscribe' | 'support' | 'tip' | 'topUp';
1810
+ style?: 'white' | 'whiteOutline' | 'black' | 'automatic';
1811
+ } & StoreInstrumentElementOptions['styles'];
1812
+ }
1813
+ declare global {
1814
+ interface Window {
1815
+ ApplePaySession?: ApplePaySession;
1816
+ }
1817
+ }
1818
+ declare class ApplePayButton extends PayrailsElementWithStoreInstrumentCheckbox {
1819
+ protected options: ApplePayButtonOptions;
1820
+ private appleButton;
1821
+ private paymentExecutor;
1822
+ static isApplePayAvailable(): Promise<boolean>;
1823
+ constructor(options: ApplePayButtonOptions);
1824
+ mount(location: string): void;
1825
+ unmount(): void;
1826
+ private mountApplePayButton;
1827
+ private createApplePaySession;
1828
+ private onApplePayAuthorized;
1829
+ }
1691
1830
 
1692
1831
  export { AuthorizationFailureReasons, ElementType, INTEGRATION_TYPE, PAYMENT_METHOD_CODES, Payrails, PayrailsEnvironment };
1693
1832
  export type { ApplePayButtonOptions, CardFormOptions, CardListOptions, CardPaymentButtonOptions, DropinOptions, GooglePayButtonOptions, InitOptions, PaymentEvents, PaypalButtonOptions, PayrailsAmount, PayrailsClientOptions, PayrailsContainerType, PayrailsSecureField, PayrailsSecureFieldEvent, SaveInstrumentResponse, WorkflowExecutionResponse };