@payrails/web-sdk 5.11.0 → 5.12.0-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payrails/web-sdk",
3
- "version": "5.11.0",
3
+ "version": "5.12.0-RC.1",
4
4
  "description": "SDK providing tokenization options on the client for merchants",
5
5
  "main": "index.js",
6
6
  "types": "payrails.d.ts",
@@ -8,6 +8,7 @@
8
8
  "author": "Payrails GitHub Bot <github@payrails.com>",
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
+ "@payrails/fraud-sdk": "1.0.0",
11
12
  "@payrails/web-cse": "1.2.3",
12
13
  "@types/applepayjs": "14.0.4",
13
14
  "@types/googlepay": "0.7.5"
@@ -122,6 +122,41 @@
122
122
  margin-bottom: 4px;
123
123
  }
124
124
 
125
+ .payrails-payment-installments-dropdown {
126
+ display: flex;
127
+ flex-wrap: wrap;
128
+ flex-direction: row;
129
+ justify-content: space-between;
130
+ align-items: center;
131
+ }
132
+
133
+ .payrails-payment-installments-dropdown select {
134
+ width: 100%;
135
+ padding: 10px 15px;
136
+ border: 1px solid #eae8ee;
137
+ border-radius: 4px;
138
+ appearance: none;
139
+ -webkit-appearance: none;
140
+ -moz-appearance: none;
141
+ cursor: pointer;
142
+ }
143
+
144
+ .payrails-payment-installments-dropdown::after {
145
+ content: '\25BC';
146
+ position: absolute;
147
+ top: 18px;
148
+ transform: translateY(-50%);
149
+ pointer-events: none;
150
+ color: rgba(25, 25, 25, 1);
151
+ right: 20px;
152
+ }
153
+
154
+ .payrails-card-form-payment-installments-container {
155
+ position: relative;
156
+ width: 100%;
157
+ margin-bottom: 8px;
158
+ }
159
+
125
160
  #payrails-card-list * {
126
161
  line-height: 1;
127
162
  }
package/payrails.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { LogLevel as LogLevel$1 } from '@payrails/logger';
2
+ import { FraudProvider } from '@payrails/fraud-sdk';
2
3
 
3
4
  declare enum PAYMENT_METHOD_CODES {
4
5
  'CARD' = "card",
@@ -68,6 +69,8 @@ declare class WorkflowExecution {
68
69
  get authorizeLink(): string | undefined;
69
70
  get createSessionLink(): string | undefined;
70
71
  get storedPaymentInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
72
+ isPaymentInstallmentsEnabled(paymentMethod: PAYMENT_METHOD_CODES): boolean | undefined;
73
+ getPaymentInstallmentOptions(paymentMethod: PAYMENT_METHOD_CODES): PaymentInstallmentsConfig;
71
74
  private getStoredInstrumentForPaymentMethod;
72
75
  getPaymentMethodForStoredInstrument<T extends CardMetadata | PayPalMetadata>(instrument: StoredPaymentInstrument<T>): {
73
76
  id: string;
@@ -77,6 +80,8 @@ declare class WorkflowExecution {
77
80
  config: ApplePayConfig | PayPalConfig | GooglePayConfig | undefined;
78
81
  clientConfig?: {
79
82
  flow?: PAYMENT_CLIENT_FLOW;
83
+ supportsInstallments?: boolean;
84
+ installments?: PaymentInstallmentsConfig;
80
85
  };
81
86
  paymentMethodCode: PAYMENT_METHOD_CODES;
82
87
  } | undefined;
@@ -88,6 +93,8 @@ declare class WorkflowExecution {
88
93
  config: ApplePayConfig | PayPalConfig | GooglePayConfig | undefined;
89
94
  clientConfig?: {
90
95
  flow?: PAYMENT_CLIENT_FLOW;
96
+ supportsInstallments?: boolean;
97
+ installments?: PaymentInstallmentsConfig;
91
98
  };
92
99
  paymentMethodCode: PAYMENT_METHOD_CODES;
93
100
  };
@@ -157,6 +164,13 @@ interface WorkflowExecutionResponse {
157
164
  interface BasePaymentMethodConfig {
158
165
  paymentMethodCode: PAYMENT_METHOD_CODES;
159
166
  }
167
+ interface BaseInstallmentOption {
168
+ count: number;
169
+ amount: number;
170
+ }
171
+ interface PaymentInstallmentsConfig {
172
+ [key: string]: BaseInstallmentOption[];
173
+ }
160
174
  interface StorablePaymentCompositionOption<I = CardMetadata | PayPalMetadata, C = undefined | ApplePayConfig | PayPalConfig | GooglePayConfig> extends BasePaymentMethodConfig {
161
175
  id: string;
162
176
  description?: string;
@@ -165,6 +179,8 @@ interface StorablePaymentCompositionOption<I = CardMetadata | PayPalMetadata, C
165
179
  config: C;
166
180
  clientConfig?: {
167
181
  flow?: PAYMENT_CLIENT_FLOW;
182
+ supportsInstallments?: boolean;
183
+ installments?: PaymentInstallmentsConfig;
168
184
  };
169
185
  paymentInstruments?: Array<StoredPaymentInstrument<I>>;
170
186
  }
@@ -204,6 +220,13 @@ interface CardMetadata {
204
220
  bin?: string;
205
221
  suffix?: string;
206
222
  network?: string;
223
+ binLookup?: {
224
+ issuerCountry: {
225
+ code: string;
226
+ name: string;
227
+ iso3: string;
228
+ };
229
+ };
207
230
  }
208
231
  declare enum PAYMENT_CLIENT_FLOW {
209
232
  'REDIRECT' = "redirect",
@@ -243,6 +266,18 @@ interface SaveInstrumentResponse {
243
266
  futureUsage?: string;
244
267
  }
245
268
 
269
+ interface BinLookupResponse {
270
+ bin: string;
271
+ network: string;
272
+ issuer?: string;
273
+ issuerCountry?: {
274
+ code?: string;
275
+ name?: string;
276
+ iso3?: string;
277
+ };
278
+ type?: string;
279
+ }
280
+
246
281
  declare enum ElementType$1 {
247
282
  CVV = "CVV",
248
283
  EXPIRATION_DATE = "EXPIRATION_DATE",
@@ -562,6 +597,40 @@ declare const regexes: {
562
597
  };
563
598
  type CardNetwork = keyof typeof regexes;
564
599
 
600
+ interface PaymentInstallmentsElementOptions extends ElementOptions {
601
+ showPaymentInstallmentsDropdown?: boolean;
602
+ installmentOptions?: BaseInstallmentOption[] | null;
603
+ installmentCurrency?: string;
604
+ translations?: {
605
+ labels?: {
606
+ paymentInstallments?: string;
607
+ };
608
+ };
609
+ styles?: {
610
+ paymentInstallmentsDropdown?: Partial<CSSStyleDeclaration>;
611
+ };
612
+ events?: PayrailsSDKEvents;
613
+ }
614
+ declare class PaymentInstallmentsDropdown extends PayrailsElement {
615
+ private options;
616
+ constructor(options: PaymentInstallmentsElementOptions);
617
+ private generateOptionsHTML;
618
+ updateOptions(installmentOptions: BaseInstallmentOption[]): void;
619
+ private createHTML;
620
+ private applyStyles;
621
+ private addListeners;
622
+ get selectedInstallmentValue(): string | undefined;
623
+ setDisabled(state: boolean): void;
624
+ }
625
+ declare class PayrailsElementWithPaymentInstallmentsDropdown extends PayrailsElement {
626
+ protected options?: PaymentInstallmentsElementOptions | undefined;
627
+ protected paymentInstallmentsDropdown: PaymentInstallmentsDropdown | null;
628
+ constructor(elementType: string, options?: PaymentInstallmentsElementOptions | undefined);
629
+ get selectedInstallmentValue(): number;
630
+ updateInstallmentOptions(installmentOptions: BaseInstallmentOption[]): void;
631
+ setDisabled(state: boolean): void;
632
+ }
633
+
565
634
  interface OnChange {
566
635
  isValid: boolean;
567
636
  cardNetwork: CardNetwork | '';
@@ -570,6 +639,7 @@ interface OnChange {
570
639
  interface CardFormOptions extends StoreInstrumentElementOptions {
571
640
  showCardHolderName?: boolean;
572
641
  enrollInstrumentToNetworkOffers?: boolean;
642
+ execution?: WorkflowExecution;
573
643
  translations?: {
574
644
  placeholders?: {
575
645
  [key in ElementType]?: string;
@@ -579,6 +649,7 @@ interface CardFormOptions extends StoreInstrumentElementOptions {
579
649
  } & {
580
650
  saveInstrument?: string;
581
651
  storeInstrument?: string;
652
+ paymentInstallments?: string;
582
653
  };
583
654
  };
584
655
  events?: {
@@ -600,14 +671,20 @@ interface CardFormOptions extends StoreInstrumentElementOptions {
600
671
  labels?: {
601
672
  [key in ElementType | 'all']?: Partial<CSSStyleDeclaration>;
602
673
  };
603
- } & StoreInstrumentElementOptions['styles'];
674
+ } & StoreInstrumentElementOptions['styles'] & PaymentInstallmentsElementOptions['styles'];
604
675
  }
605
676
  declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
606
677
  private readonly collectContainer;
607
678
  protected readonly options?: CardFormOptions | undefined;
608
679
  get bin(): string;
680
+ get isBinLookupEnabled(): boolean;
609
681
  private readonly formFields;
682
+ private readonly paymentInstallmentsDropdown;
683
+ private throttledFetchBinLookup;
684
+ private lastBin;
685
+ private lastBinLookup;
610
686
  constructor(collectContainer: PayrailsCollectContainer, options?: CardFormOptions | undefined);
687
+ throttledFetchBinLookupIfChanged(): Promise<BinLookupResponse | null>;
611
688
  tokenize(opts: TokenizeOptions): Promise<SaveInstrumentResponse>;
612
689
  show(): void;
613
690
  hide(): void;
@@ -617,12 +694,18 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
617
694
  get isValid(): boolean;
618
695
  get cardNetwork(): "" | "visa" | "mastercard" | "amex" | "diners" | "discover" | "jcb" | "hipercard" | "unionpay" | "maestro";
619
696
  onChange(): void;
697
+ private updateInstallments;
620
698
  collectValues(): Promise<{
621
699
  cardData: EncryptedCollectResult | TokenizedCollectResult;
622
700
  storeInstrument: boolean;
701
+ selectedInstallment: number | undefined;
623
702
  enrollInstrumentToNetworkOffers: boolean;
624
703
  }>;
704
+ protected get selectedInstallment(): number | undefined;
625
705
  private enforceEnrollInstrumentToNetworkOffersForMasterCard;
706
+ fetchBinLookup(): Promise<string | BinLookupResponse>;
707
+ get isPaymentInstallmentsEnabled(): boolean | undefined;
708
+ private getinstallmentOptions;
626
709
  }
627
710
  interface LabelStyles {
628
711
  base?: Partial<CSSStyleDeclaration>;
@@ -651,6 +734,15 @@ interface ReturnInfo {
651
734
  cancel?: string;
652
735
  error?: string;
653
736
  }
737
+ declare global {
738
+ interface Window {
739
+ Payrails: {
740
+ riskIds: {
741
+ [key in FraudProvider]?: string;
742
+ };
743
+ };
744
+ }
745
+ }
654
746
 
655
747
  interface CardPaymentButtonOptions {
656
748
  events?: PayrailsSDKEvents & {
@@ -673,6 +765,7 @@ declare class CardPaymentButton extends PayrailsElement {
673
765
  private readonly options;
674
766
  private readonly returnInfo?;
675
767
  selectedInstrument: StoredPaymentInstrument | null;
768
+ paymentInstallmentElement: PayrailsElementWithPaymentInstallmentsDropdown | null;
676
769
  get bin(): string | undefined;
677
770
  private paymentExecutor;
678
771
  private cardForm;
@@ -684,6 +777,7 @@ declare class CardPaymentButton extends PayrailsElement {
684
777
  private removeStyles;
685
778
  setLabel(label: string): void;
686
779
  setCardForm(cardForm: CardForm): void;
780
+ setPaymentInstallmentsDropdown(paymentInsallmentsDropdown: PayrailsElementWithPaymentInstallmentsDropdown): void;
687
781
  triggerLoading(isLoading: boolean): void;
688
782
  private onAuthorizationFailed;
689
783
  private onPay;
@@ -769,9 +863,13 @@ declare class GenericRedirectButton extends PayrailsElement {
769
863
  protected options: GenericRedirectButtonOptions;
770
864
  private readonly returnInfo?;
771
865
  constructor(sdkConfig: SdkConfiguration, execution: WorkflowExecution, options: GenericRedirectButtonOptions, returnInfo?: ReturnInfo | undefined);
866
+ private popup;
772
867
  private buildRedirectButton;
773
- private paymentExecutor;
868
+ private readonly paymentExecutor;
774
869
  private onClick;
870
+ private handleAuthorizationResult;
871
+ private createPopupWithTimeout;
872
+ private redirectToPaymentLink;
775
873
  }
776
874
 
777
875
  interface GenericRedirectDropinOptions {
@@ -858,9 +956,12 @@ declare class Dropin extends PayrailsElement {
858
956
  private applePay;
859
957
  private cardForm;
860
958
  private paypal;
959
+ private paymentInstallmentsDropdown;
861
960
  constructor(collectContainer: PayrailsCollectContainer, clientConfig: PayrailsClientOptions, dropinConfig: DropinOptions, execution: WorkflowExecution, sdkConfig: SdkConfiguration);
862
961
  private isHppIntegration;
863
962
  private createStoredInstrumentElement;
963
+ private createInstallmentsDropdown;
964
+ private getInstallmentOptionsForInstrument;
864
965
  private createHppIntegrationElement;
865
966
  private get totalPaymentOptions();
866
967
  private createCreditCardButton;
@@ -874,6 +975,7 @@ declare class Dropin extends PayrailsElement {
874
975
  private onAuthorizeFailed;
875
976
  private isStoredInstrumentEnabled;
876
977
  private applyStyles;
978
+ fetchBinLookup(): Promise<string | BinLookupResponse | undefined>;
877
979
  }
878
980
  interface StorablePaymentMethodConfiguration extends StoreInstrumentElementOptions {
879
981
  showStoredInstruments?: boolean;
@@ -1014,6 +1116,7 @@ declare class Payrails {
1014
1116
  private logIntegrationMode;
1015
1117
  private constructor();
1016
1118
  private getContainerLayout;
1119
+ binLookup(): Promise<any>;
1017
1120
  }
1018
1121
  interface InitOptions {
1019
1122
  version: string;
@@ -1046,6 +1149,12 @@ interface SdkConfiguration {
1046
1149
  amount: PayrailsAmount;
1047
1150
  holderReference: string;
1048
1151
  usePayrailsFrames: boolean;
1152
+ links?: {
1153
+ binLookup: {
1154
+ method: 'GET' | 'POST';
1155
+ href: string;
1156
+ };
1157
+ };
1049
1158
  vaultConfiguration: {
1050
1159
  cardTableName: string;
1051
1160
  token: string;
@@ -1131,6 +1240,7 @@ interface PayrailsSecureField {
1131
1240
  declare class PayrailsCollectContainer implements Mountable {
1132
1241
  private sdkConfig;
1133
1242
  bin: string;
1243
+ isBinLookupEnabled: boolean;
1134
1244
  readonly id = "payrails-container-wrapper";
1135
1245
  private static instance;
1136
1246
  private readonly __container;
@@ -1150,6 +1260,7 @@ declare class PayrailsCollectContainer implements Mountable {
1150
1260
  private attachCustomEventHandler;
1151
1261
  private formatBin;
1152
1262
  private get elementToFieldMap();
1263
+ fetchBinLookup: (bin: string) => Promise<string | BinLookupResponse>;
1153
1264
  }
1154
1265
  interface TokenizeOptions {
1155
1266
  futureUsage?: 'CardOnFile' | 'Subscription' | 'UnscheduledCardOnFile';