1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import AliPayForm from './form';
|
7 |
|
8 |
|
9 |
|
10 | export interface AlipaySdkConfig {
|
11 |
|
12 | appId: string;
|
13 |
|
14 | privateKey: string;
|
15 |
|
16 | signType?: 'RSA2' | 'RSA';
|
17 |
|
18 | alipayPublicKey?: string;
|
19 |
|
20 | gateway?: string;
|
21 |
|
22 | timeout?: number;
|
23 |
|
24 | camelcase?: boolean;
|
25 |
|
26 | charset?: 'utf-8';
|
27 |
|
28 | version?: '1.0';
|
29 |
|
30 | urllib?: any;
|
31 |
|
32 | keyType?: 'PKCS1' | 'PKCS8';
|
33 |
|
34 | appCertPath?: string;
|
35 |
|
36 | appCertContent?: string | Buffer;
|
37 |
|
38 | appCertSn?: string;
|
39 |
|
40 | alipayRootCertPath?: string;
|
41 |
|
42 | alipayRootCertContent?: string | Buffer;
|
43 |
|
44 | alipayRootCertSn?: string;
|
45 |
|
46 | alipayPublicCertPath?: string;
|
47 |
|
48 | alipayPublicCertContent?: string | Buffer;
|
49 |
|
50 | alipayCertSn?: string;
|
51 |
|
52 | encryptKey?: string;
|
53 |
|
54 | wsServiceUrl?: string;
|
55 | }
|
56 | export interface AlipaySdkCommonResult {
|
57 |
|
58 | code: string;
|
59 |
|
60 | msg: string;
|
61 |
|
62 | sub_code?: string;
|
63 |
|
64 | sub_msg?: string;
|
65 |
|
66 | [key: string]: any;
|
67 | }
|
68 | export interface IRequestParams {
|
69 | [key: string]: any;
|
70 |
|
71 | bizContent?: Record<string, any>;
|
72 |
|
73 | needEncrypt?: boolean;
|
74 | }
|
75 | export interface IRequestOption {
|
76 | validateSign?: boolean;
|
77 | log?: {
|
78 | info(...args: any[]): any;
|
79 | error(...args: any[]): any;
|
80 | };
|
81 | formData?: AliPayForm;
|
82 | }
|
83 |
|
84 |
|
85 |
|
86 | declare class AlipaySdk {
|
87 | private sdkVersion;
|
88 | config: AlipaySdkConfig;
|
89 | |
90 |
|
91 |
|
92 |
|
93 | constructor(config: AlipaySdkConfig);
|
94 | private formatKey;
|
95 | private formatUrl;
|
96 | private multipartExec;
|
97 | /**
|
98 | * 生成请求字符串,用于客户端进行调用
|
99 | * @param {string} method 方法名
|
100 | * @param {IRequestParams} params 请求参数
|
101 | * @param {object} params.bizContent 业务请求参数
|
102 | * @return {string} 请求字符串
|
103 | */
|
104 | sdkExec(method: string, params: IRequestParams): string;
|
105 | |
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | pageExec(method: string, params: IRequestParams & {
|
114 | method?: 'GET' | 'POST';
|
115 | }): string;
|
116 | private _pageExec;
|
117 | private notifyRSACheck;
|
118 | |
119 |
|
120 |
|
121 |
|
122 |
|
123 | getSignStr(originStr: string, responseKey: string): string;
|
124 | exec<T = {}>(method: string, params?: IRequestParams, option?: Omit<IRequestOption, 'formData'>): Promise<AlipaySdkCommonResult & T>;
|
125 | exec(method: string, params?: IRequestParams, option?: IRequestOption): Promise<AlipaySdkCommonResult | string>;
|
126 | checkResponseSign(signStr: string, responseKey: string): boolean;
|
127 | |
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 | checkNotifySign(postData: any, raw?: boolean): boolean;
|
134 | }
|
135 | export default AlipaySdk;
|