-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.js
70 lines (63 loc) · 1.35 KB
/
interface.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// @flow
export type IAny = any
export type IPaymentSystemDefinition = {
key: string;
name: {
short?: string;
nice: string;
aliases?: string[];
org?: string;
};
pan: {
pattern: RegExp;
prefixPattern: RegExp;
lengths: number[];
algorithm?: string;
};
code: {
name: string;
length: number;
}
}
export type IPaymentSystemDefinitions = IPaymentSystemDefinition[]
export type IBinDefinition = {
}
export type ICardInfo = {
paymentSystem: string;
valid?: boolean;
type?: string;
brand?: string;
category?: string;
issuer?: {
name?: string;
country?: string;
address?: string;
url?: string;
phone?: string;
svg?: string;
}
}
export type IPaymentSystem = string
export type IServiceKeys = 'getPaymentSystem' | 'getCardInfo'
export type IServiceOpts = {
url? :string;
headers?: IAny;
transport?: IAny;
skipError?: boolean;
}
export interface IService {
opts: IServiceOpts;
constructor(IServiceOpts): IService;
getPaymentSystem(pan: string): Promise<?IPaymentSystem>;
getCardInfo(pan: string): Promise<?ICardInfo>;
[key: IServiceKeys]: (pan: string) => Promise<?ICardInfo | ?IPaymentSystem>;
}
export interface IServiceResponse {
json(): IAny
}
export type IHttpOpts = {
url: string;
} & RequestOptions;
export type IHttpTransport = {
(opts: IHttpOpts): Promise<IAny>
}