@payrails/web-sdk 5.11.0 → 5.12.0-RC.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.
- package/index.js +4 -4
- package/package.json +2 -1
- package/payrails-styles.css +35 -0
- package/payrails.d.ts +108 -1
- package/payrails.js +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payrails/web-sdk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0-RC.0",
|
|
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"
|
package/payrails-styles.css
CHANGED
|
@@ -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;
|
|
@@ -858,9 +952,12 @@ declare class Dropin extends PayrailsElement {
|
|
|
858
952
|
private applePay;
|
|
859
953
|
private cardForm;
|
|
860
954
|
private paypal;
|
|
955
|
+
private paymentInstallmentsDropdown;
|
|
861
956
|
constructor(collectContainer: PayrailsCollectContainer, clientConfig: PayrailsClientOptions, dropinConfig: DropinOptions, execution: WorkflowExecution, sdkConfig: SdkConfiguration);
|
|
862
957
|
private isHppIntegration;
|
|
863
958
|
private createStoredInstrumentElement;
|
|
959
|
+
private createInstallmentsDropdown;
|
|
960
|
+
private getInstallmentOptionsForInstrument;
|
|
864
961
|
private createHppIntegrationElement;
|
|
865
962
|
private get totalPaymentOptions();
|
|
866
963
|
private createCreditCardButton;
|
|
@@ -874,6 +971,7 @@ declare class Dropin extends PayrailsElement {
|
|
|
874
971
|
private onAuthorizeFailed;
|
|
875
972
|
private isStoredInstrumentEnabled;
|
|
876
973
|
private applyStyles;
|
|
974
|
+
fetchBinLookup(): Promise<string | BinLookupResponse | undefined>;
|
|
877
975
|
}
|
|
878
976
|
interface StorablePaymentMethodConfiguration extends StoreInstrumentElementOptions {
|
|
879
977
|
showStoredInstruments?: boolean;
|
|
@@ -1014,6 +1112,7 @@ declare class Payrails {
|
|
|
1014
1112
|
private logIntegrationMode;
|
|
1015
1113
|
private constructor();
|
|
1016
1114
|
private getContainerLayout;
|
|
1115
|
+
binLookup(): Promise<any>;
|
|
1017
1116
|
}
|
|
1018
1117
|
interface InitOptions {
|
|
1019
1118
|
version: string;
|
|
@@ -1046,6 +1145,12 @@ interface SdkConfiguration {
|
|
|
1046
1145
|
amount: PayrailsAmount;
|
|
1047
1146
|
holderReference: string;
|
|
1048
1147
|
usePayrailsFrames: boolean;
|
|
1148
|
+
links?: {
|
|
1149
|
+
binLookup: {
|
|
1150
|
+
method: 'GET' | 'POST';
|
|
1151
|
+
href: string;
|
|
1152
|
+
};
|
|
1153
|
+
};
|
|
1049
1154
|
vaultConfiguration: {
|
|
1050
1155
|
cardTableName: string;
|
|
1051
1156
|
token: string;
|
|
@@ -1131,6 +1236,7 @@ interface PayrailsSecureField {
|
|
|
1131
1236
|
declare class PayrailsCollectContainer implements Mountable {
|
|
1132
1237
|
private sdkConfig;
|
|
1133
1238
|
bin: string;
|
|
1239
|
+
isBinLookupEnabled: boolean;
|
|
1134
1240
|
readonly id = "payrails-container-wrapper";
|
|
1135
1241
|
private static instance;
|
|
1136
1242
|
private readonly __container;
|
|
@@ -1150,6 +1256,7 @@ declare class PayrailsCollectContainer implements Mountable {
|
|
|
1150
1256
|
private attachCustomEventHandler;
|
|
1151
1257
|
private formatBin;
|
|
1152
1258
|
private get elementToFieldMap();
|
|
1259
|
+
fetchBinLookup: (bin: string) => Promise<string | BinLookupResponse>;
|
|
1153
1260
|
}
|
|
1154
1261
|
interface TokenizeOptions {
|
|
1155
1262
|
futureUsage?: 'CardOnFile' | 'Subscription' | 'UnscheduledCardOnFile';
|