@payrails/web-sdk 3.0.0-RC.8 → 3.0.0

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.
Files changed (3) hide show
  1. package/index.js +4 -4
  2. package/package.json +8 -8
  3. package/payrails.d.ts +172 -165
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@payrails/web-sdk",
3
- "version": "3.0.0-RC.8",
3
+ "version": "3.0.0",
4
4
  "description": "SDK providing tokenization options on the client for merchants",
5
5
  "main": "index.js",
6
6
  "types": "payrails.d.ts",
7
7
  "type": "commonjs",
8
- "scripts": {},
9
- "author": "Petr Prchal <petr@payrails.com>",
8
+ "author": "Payrails GitHub Bot <github@payrails.com>",
10
9
  "license": "MIT",
11
10
  "dependencies": {
12
- "@payrails/web-cse": "1.2.2",
13
- "@types/applepayjs": "3.0.4",
14
- "@types/googlepay": "0.7.1"
15
- }
16
- }
11
+ "@payrails/web-cse": "1.2.2-RC.1",
12
+ "@types/applepayjs": "14.0.4",
13
+ "@types/googlepay": "0.7.5"
14
+ },
15
+ "scripts": {}
16
+ }
package/payrails.d.ts CHANGED
@@ -1,11 +1,174 @@
1
1
  /// <reference types="applepayjs" />
2
2
  /// <reference types="googlepay" />
3
+ declare enum PAYMENT_METHOD_CODES {
4
+ 'CARD' = "card",
5
+ 'GOOGLE_PAY' = "googlePay",
6
+ 'PAYPAL' = "payPal",
7
+ 'APPLE_PAY' = "applePay"
8
+ }
9
+ declare enum PAYMENT_INSTRUMENT_STATUS {
10
+ 'ENABLED' = "enabled",
11
+ 'CREATED' = "created",
12
+ 'DELETED' = "deleted",
13
+ 'DISABLED' = "disabled",
14
+ 'INVALID' = "invalid",
15
+ 'TRANSIENT' = "transient"
16
+ }
17
+ declare class WorkflowExecution {
18
+ private executionResponse;
19
+ constructor(executionResponse: WorkflowExecutionResponse);
20
+ get lookup(): {
21
+ httpCode: number;
22
+ body: {
23
+ data: {
24
+ paymentCompositionOptions: StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined>[];
25
+ };
26
+ links: {
27
+ authorize: {
28
+ href: string;
29
+ method: "POST";
30
+ };
31
+ execution: string;
32
+ };
33
+ name: "lookup";
34
+ };
35
+ } | undefined;
36
+ get holderReference(): string;
37
+ get savedCreditCards(): StoredPaymentInstrument<CardMetadata>[];
38
+ get savedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
39
+ get savedGooglePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
40
+ get savedApplePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
41
+ get paypalConfig(): PayPalConfig;
42
+ get googlePayConfig(): GooglePayConfig[];
43
+ isPaymentMethodAvailable(paymentMethod: PAYMENT_METHOD_CODES): boolean;
44
+ get applePayConfig(): {
45
+ merchantIdentifier: string;
46
+ supportedNetworks: string[];
47
+ countryCode: string;
48
+ merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
49
+ };
50
+ get url(): string;
51
+ get response(): WorkflowExecutionResponse;
52
+ get meta(): {
53
+ customer?: {
54
+ country?: {
55
+ code: string;
56
+ } | undefined;
57
+ } | undefined;
58
+ };
59
+ get availablePaymentMethods(): StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined>[];
60
+ get authorizeLink(): string | undefined;
61
+ get createSessionLink(): string | undefined;
62
+ get storedPaymentInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
63
+ private getStoredInstrumentForPaymentMethod;
64
+ }
65
+ interface WorkflowExecutionResponse {
66
+ id: string;
67
+ merchantReference: string;
68
+ holderReference: string;
69
+ actionRequired?: string;
70
+ meta: {
71
+ customer?: {
72
+ country?: {
73
+ code: string;
74
+ };
75
+ };
76
+ };
77
+ status: Array<{
78
+ code: string;
79
+ time: string;
80
+ }>;
81
+ initialResults: Array<{
82
+ httpCode: number;
83
+ body: {
84
+ data: {
85
+ paymentCompositionOptions: Array<StorablePaymentCompositionOption>;
86
+ };
87
+ links: {
88
+ authorize: {
89
+ href: string;
90
+ method: 'POST';
91
+ };
92
+ execution: string;
93
+ };
94
+ name: 'lookup';
95
+ };
96
+ }>;
97
+ links: {
98
+ startPaymentSession?: {
99
+ href: string;
100
+ method: 'POST';
101
+ };
102
+ confirm?: {
103
+ href: string;
104
+ action?: {
105
+ parameters?: {
106
+ orderId?: string;
107
+ tokenId?: string;
108
+ };
109
+ };
110
+ };
111
+ '3ds'?: string;
112
+ self: string;
113
+ };
114
+ }
115
+ interface StorablePaymentCompositionOption<I = CardMetadata | PayPalMetadata, C = undefined | ApplePayConfig | PayPalConfig | GooglePayConfig> {
116
+ paymentMethodCode?: PAYMENT_METHOD_CODES;
117
+ description: string;
118
+ id: string;
119
+ status: PAYMENT_INSTRUMENT_STATUS;
120
+ config: C;
121
+ paymentInstruments?: Array<StoredPaymentInstrument<I>>;
122
+ integrationType: string;
123
+ }
124
+ interface GooglePayConfig {
125
+ parameters: {
126
+ allowedAuthMethods: string[];
127
+ allowedCardNetworks: string[];
128
+ };
129
+ tokenizationSpecification: {
130
+ parameters: {
131
+ gateway: string;
132
+ gatewayMerchantId: string;
133
+ };
134
+ type: string;
135
+ };
136
+ type: string;
137
+ }
138
+ interface PayPalConfig {
139
+ clientId: string;
140
+ merchantId: string;
141
+ captureMode: 'Delayed' | 'Instant' | 'Manual';
142
+ }
143
+ interface ApplePayConfig {
144
+ parameters: {
145
+ merchantIdentifier: string;
146
+ supportedNetworks: string[];
147
+ countryCode: string;
148
+ merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
149
+ };
150
+ type: string;
151
+ }
152
+ interface StoredPaymentInstrument<T = CardMetadata | PayPalMetadata> {
153
+ id: string;
154
+ status: PAYMENT_INSTRUMENT_STATUS;
155
+ paymentMethod: PAYMENT_METHOD_CODES;
156
+ data?: T;
157
+ }
158
+ interface PayPalMetadata {
159
+ email?: string;
160
+ }
161
+ interface CardMetadata {
162
+ bin?: string;
163
+ suffix?: string;
164
+ }
165
+
3
166
  interface SaveInstrumentResponse {
4
167
  id: string;
5
168
  createdAt: string;
6
169
  holderId: string;
7
- paymentMethod: 'card';
8
- status: 'created' | 'deleted' | 'enabled' | 'disabled' | 'invalid' | 'transient';
170
+ paymentMethod: PAYMENT_METHOD_CODES.CARD;
171
+ status: PAYMENT_INSTRUMENT_STATUS;
9
172
  data: {
10
173
  bin: string;
11
174
  binLookup?: {
@@ -312,165 +475,6 @@ declare class PayrailsElement implements Mountable {
312
475
  unmount(): void;
313
476
  }
314
477
 
315
- declare enum PAYMENT_METHOD_CODES {
316
- 'CARD' = "card",
317
- 'GOOGLE_PAY' = "googlePay",
318
- 'PAYPAL' = "payPal",
319
- 'APPLE_PAY' = "applePay"
320
- }
321
- declare enum PAYMENT_INSTRUMENT_STATUS {
322
- 'ENABLED' = "enabled",
323
- 'CREATED' = "created"
324
- }
325
- declare class WorkflowExecution {
326
- private executionResponse;
327
- constructor(executionResponse: WorkflowExecutionResponse);
328
- get lookup(): {
329
- httpCode: number;
330
- body: {
331
- data: {
332
- paymentCompositionOptions: StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined>[];
333
- };
334
- links: {
335
- authorize: {
336
- href: string;
337
- method: "POST";
338
- };
339
- execution: string;
340
- };
341
- name: "lookup";
342
- };
343
- } | undefined;
344
- get holderReference(): string;
345
- get savedCreditCards(): StoredPaymentInstrument<CardMetadata>[];
346
- get savedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
347
- get savedGooglePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
348
- get savedApplePayAccounts(): StoredPaymentInstrument<CardMetadata>[];
349
- get paypalConfig(): PayPalConfig;
350
- get googlePayConfig(): GooglePayConfig[];
351
- isPaymentMethodAvailable(paymentMethod: PAYMENT_METHOD_CODES): boolean;
352
- get applePayConfig(): {
353
- merchantIdentifier: string;
354
- supportedNetworks: string[];
355
- countryCode: string;
356
- merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
357
- };
358
- get url(): string;
359
- get response(): WorkflowExecutionResponse;
360
- get meta(): {
361
- customer?: {
362
- country?: {
363
- code: string;
364
- } | undefined;
365
- } | undefined;
366
- };
367
- get availablePaymentMethods(): StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined>[];
368
- get authorizeLink(): string | undefined;
369
- get createSessionLink(): string | undefined;
370
- get storedPaymentInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
371
- private getStoredInstrumentForPaymentMethod;
372
- }
373
- interface WorkflowExecutionResponse {
374
- id: string;
375
- merchantReference: string;
376
- holderReference: string;
377
- actionRequired?: string;
378
- meta: {
379
- customer?: {
380
- country?: {
381
- code: string;
382
- };
383
- };
384
- };
385
- status: Array<{
386
- code: string;
387
- time: string;
388
- }>;
389
- initialResults: Array<{
390
- httpCode: number;
391
- body: {
392
- data: {
393
- paymentCompositionOptions: Array<StorablePaymentCompositionOption>;
394
- };
395
- links: {
396
- authorize: {
397
- href: string;
398
- method: 'POST';
399
- };
400
- execution: string;
401
- };
402
- name: 'lookup';
403
- };
404
- }>;
405
- links: {
406
- startPaymentSession?: {
407
- href: string;
408
- method: 'POST';
409
- };
410
- confirm?: {
411
- href: string;
412
- action?: {
413
- parameters?: {
414
- orderId?: string;
415
- tokenId?: string;
416
- };
417
- };
418
- };
419
- '3ds'?: string;
420
- self: string;
421
- };
422
- }
423
- interface StorablePaymentCompositionOption<I = CardMetadata | PayPalMetadata, C = undefined | ApplePayConfig | PayPalConfig | GooglePayConfig> {
424
- paymentMethodCode?: PAYMENT_METHOD_CODES;
425
- description: string;
426
- id: string;
427
- status: PAYMENT_INSTRUMENT_STATUS;
428
- config: C;
429
- paymentInstruments?: Array<StoredPaymentInstrument<I>>;
430
- integrationType: string;
431
- }
432
- interface GooglePayConfig {
433
- parameters: {
434
- allowedAuthMethods: string[];
435
- allowedCardNetworks: string[];
436
- };
437
- tokenizationSpecification: {
438
- parameters: {
439
- gateway: string;
440
- gatewayMerchantId: string;
441
- };
442
- type: string;
443
- };
444
- type: string;
445
- }
446
- interface PayPalConfig {
447
- clientId: string;
448
- merchantId: string;
449
- captureMode: 'Delayed' | 'Instant' | 'Manual';
450
- }
451
- interface ApplePayConfig {
452
- parameters: {
453
- merchantIdentifier: string;
454
- supportedNetworks: string[];
455
- countryCode: string;
456
- merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
457
- };
458
- type: string;
459
- }
460
- interface StoredPaymentInstrument<T = CardMetadata | PayPalMetadata> {
461
- id: string;
462
- status: PAYMENT_INSTRUMENT_STATUS;
463
- paymentMethod: PAYMENT_METHOD_CODES;
464
- data?: T;
465
- }
466
- interface PayPalMetadata {
467
- email?: string;
468
- }
469
- interface CardMetadata {
470
- bin?: string;
471
- suffix?: string;
472
- }
473
-
474
478
  interface StoreInstrumentElementOptions extends ElementOptions {
475
479
  showStoreInstrumentCheckbox?: boolean;
476
480
  alwaysStoreInstrument?: boolean;
@@ -591,6 +595,7 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
591
595
  get bin(): string;
592
596
  private readonly formFields;
593
597
  constructor(collectContainer: PayrailsCollectContainer, options?: CardFormOptions | undefined);
598
+ tokenize(opts: TokenizeOptions): Promise<SaveInstrumentResponse>;
594
599
  show(): void;
595
600
  hide(): void;
596
601
  private triggerOnReady;
@@ -600,7 +605,7 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
600
605
  get cardNetwork(): "" | "visa" | "mastercard" | "amex" | "diners" | "discover" | "jcb" | "hipercard" | "unionpay" | "maestro";
601
606
  onChange(): void;
602
607
  collectValues(): Promise<{
603
- cardData: EncryptedCollectResult | TokenizedCollectResult;
608
+ cardData: TokenizedCollectResult | EncryptedCollectResult;
604
609
  storeInstrument: boolean;
605
610
  enrollInstrumentToNetworkOffers: boolean;
606
611
  }>;
@@ -773,6 +778,7 @@ interface PaypalDropinOptions extends PaypalButtonOptions {
773
778
 
774
779
  declare class Dropin extends PayrailsElement {
775
780
  private collectContainer;
781
+ private readonly clientConfig;
776
782
  private readonly dropinConfig;
777
783
  private readonly execution;
778
784
  private readonly sdkConfig;
@@ -783,7 +789,7 @@ declare class Dropin extends PayrailsElement {
783
789
  private applePay;
784
790
  private cardForm;
785
791
  private paypal;
786
- constructor(collectContainer: PayrailsCollectContainer, dropinConfig: DropinOptions, execution: WorkflowExecution, sdkConfig: SdkConfiguration, returnLinks: RedirectReturnLinks);
792
+ constructor(collectContainer: PayrailsCollectContainer, clientConfig: PayrailsClientOptions, dropinConfig: DropinOptions, execution: WorkflowExecution, sdkConfig: SdkConfiguration, returnLinks: RedirectReturnLinks);
787
793
  private createStoredInstrumentElement;
788
794
  private createCreditCardButton;
789
795
  private createGooglePayButton;
@@ -840,7 +846,7 @@ declare class FraudNet implements Mountable {
840
846
  private sdkConfig;
841
847
  private environment;
842
848
  constructor(pageId: FraudNetPageId, sdkConfig: SdkConfiguration, environment: PayrailsClientOptions['environment']);
843
- readonly guid: string;
849
+ readonly guid: any;
844
850
  mount(): void;
845
851
  unmount(): void;
846
852
  private loadFraudnet;
@@ -998,10 +1004,11 @@ declare class PayrailsCollectContainer implements Mountable {
998
1004
  createCollectElement(options: CollectElementOptions): PayrailsSecureField;
999
1005
  mount(selector: string): void;
1000
1006
  unmount(): void;
1001
- collect(): Promise<EncryptedCollectResult | TokenizedCollectResult>;
1007
+ collect(): Promise<TokenizedCollectResult | EncryptedCollectResult>;
1002
1008
  private collectSkyflowData;
1003
1009
  private collectPayrailsData;
1004
1010
  tokenize(opts: TokenizeOptions): Promise<SaveInstrumentResponse>;
1011
+ private constructSaveInstrumentBody;
1005
1012
  private attachCustomEventHandler;
1006
1013
  private formatBin;
1007
1014
  private get elementToFieldMap();