Skip to content

Commit 31a4bd9

Browse files
committed
doc: Add type document.
1 parent e83aa44 commit 31a4bd9

File tree

4 files changed

+144
-111
lines changed

4 files changed

+144
-111
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
# node.js
66
#
7+
typedoc
78
node_modules/
89
npm-debug.log
910
yarn-error.log
11+
yarn.lock
1012

1113
# Xcode
1214
#

index.d.ts

Lines changed: 125 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,164 @@
1+
/// <reference no-default-lib="true" />
2+
/// <reference lib="esnext" />
13

24
/**
3-
* 支付宝端支付
4-
* 支付宝回调结果, 详情见 https://docs.open.alipay.com/204/105301
5+
* 支付宝支付,基于 React Native 的支付宝插件,支持Android/iOS。
56
*/
6-
export interface AliOrderResult {
7-
alipay_trade_app_pay_response: {
8-
/**
9-
* 长度:64,商户网站唯一订单号 70501111111S001111119
10-
*/
11-
out_trade_no: string;
12-
/**
13-
* 长度:64,该交易在支付宝系统中的交易流水号。最长64位。 2014112400001000340011111118
14-
*/
15-
trade_no: string;
16-
/**
17-
* 长度:32,支付宝分配给开发者的应用Id。 2014072300007148
18-
*/
19-
app_id: string;
7+
declare namespace Alipay {
8+
9+
/**
10+
* 支付宝端支付
11+
* 支付宝回调结果, 详情见 https://docs.open.alipay.com/204/105301
12+
*/
13+
export interface OrderResultStr {
14+
alipay_trade_app_pay_response: {
15+
/**
16+
* 长度:64,商户网站唯一订单号 70501111111S001111119
17+
*/
18+
out_trade_no: string;
19+
/**
20+
* 长度:64,该交易在支付宝系统中的交易流水号。最长64位。 2014112400001000340011111118
21+
*/
22+
trade_no: string;
23+
/**
24+
* 长度:32,支付宝分配给开发者的应用Id。 2014072300007148
25+
*/
26+
app_id: string;
27+
/**
28+
* 长度:9 ,该笔订单的资金总额,单位为RMB-Yuan。取值范围为[0.01,100000000.00],精确到小数点后两位。 9.00
29+
*/
30+
total_amount: number;
31+
/**
32+
* 长度:16,收款支付宝账号对应的支付宝唯一用户号。以2088开头的纯16位数字 20886894
33+
*/
34+
seller_id: string;
35+
/**
36+
* 长度:16,处理结果的描述,信息来自于code返回结果的描述 success
37+
*/
38+
msg: string;
39+
/**
40+
* 长度:16,编码格式 utf-8
41+
*/
42+
charset: string;
43+
/**
44+
* 长度:32,时间 2016-10-11 17:43:36
45+
*/
46+
timestamp: string;
47+
/**
48+
* 长度:16,结果码 具体见公共错误码
49+
*/
50+
code: string;
51+
},
52+
sign: string;
53+
sign_type: 'RSA2' | 'RSA';
54+
}
55+
56+
/**
57+
* 支付订单返回结果
58+
* @returns 成功返回
59+
*
60+
* ```json
61+
* {
62+
* result: '{"alipay_trade_app_pay_response":{"code":"10000","msg":"Success","app_id":"2021001172656340","auth_app_id":"2021001172656340","charset":"UTF-8","timestamp":"2020-07-08 21:30:14","out_trade_no":"123123213123214","total_amount":"0.01","trade_no":"2020070822001414841426413774","seller_id":"2088421915791034"},"sign":"LY7wCsNLp+QnDqCq6VelY/RvyK7ZGY8wsXoKvS+Or7JjONLDUx5P6lDgqRKkpkng7br3y6GZzfGKaZ88Tf4eMnBMKyqU+huR2Um47xUxP383njvHlxuQZsSTLQZRswy4wmb/fPkFfvyH6Or6+oj0eboePOTu63bNr+h03w0QnP4znuHpfRuoVgWpsYh/6B1DL+4xfWRKJ21zm1SV9Feo9RWqnyTaGZyFVi6IKge0dUCYs9hXju95fOUVUOx5YflOFtSEnZafY9Ls4FCRQE1ANkjaKiKIE0+c4c4sEVEf/9Dwh88N+aSQOoLT+AV4RpjMoA8hF2k+vv2OKNeqr6SYGQ==","sign_type":"RSA2"}',
63+
* resultStatus: '9000',
64+
* memo: ''
65+
* }
66+
* ```
67+
*
68+
* @returns 错误返回
69+
*
70+
* ```json
71+
* {
72+
* memo: "Error Domain=系统繁忙,请稍后再试 Code=1000 \"(null)\"",
73+
* result: "",
74+
* resultStatus: "4000",
75+
* }
76+
* ```
77+
*/
78+
export interface OrderResult {
2079
/**
21-
* 长度:9 ,该笔订单的资金总额,单位为RMB-Yuan。取值范围为[0.01,100000000.00],精确到小数点后两位。 9.00
80+
* 支付返回结果:
81+
* 支付宝支付返回结果,[支付宝文档地址](https://opendocs.alipay.com/open/204/105301#%E8%BF%94%E5%9B%9E%E7%BB%93%E6%9E%9C%E7%A4%BA%E4%BE%8B%EF%BC%88iOS%7CAndroid%EF%BC%89)
82+
* 支付返回结果字符串通过 `JSON.parse` 进行转换为对象 {@link OrderResultStr}
83+
* @typeParam OrderResultStr
84+
* @example
85+
*
86+
* ```json
87+
* '{"alipay_trade_app_pay_response":{"code":"10000","msg":"Success","app_id":"2021001172656340","auth_app_id":"2021001172656340","charset":"UTF-8","timestamp":"2020-07-08 21:30:14","out_trade_no":"123123213123214","total_amount":"0.01","trade_no":"2020070822001414841426413774","seller_id":"2088421915791034"},"sign":"LY7wCsNLp+QnDqCq6VelY/RvyK7ZGY8wsXoKvS+Or7JjONLDUx5P6lDgqRKkpkng7br3y6GZzfGKaZ88Tf4eMnBMKyqU+huR2Um47xUxP383njvHlxuQZsSTLQZRswy4wmb/fPkFfvyH6Or6+oj0eboePOTu63bNr+h03w0QnP4znuHpfRuoVgWpsYh/6B1DL+4xfWRKJ21zm1SV9Feo9RWqnyTaGZyFVi6IKge0dUCYs9hXju95fOUVUOx5YflOFtSEnZafY9Ls4FCRQE1ANkjaKiKIE0+c4c4sEVEf/9Dwh88N+aSQOoLT+AV4RpjMoA8hF2k+vv2OKNeqr6SYGQ==","sign_type":"RSA2"}'
88+
* ```
89+
*
2290
*/
23-
total_amount: number;
91+
result?: string;
2492
/**
25-
* 长度:16,收款支付宝账号对应的支付宝唯一用户号。以2088开头的纯16位数字 20886894
93+
* 错误状态码
94+
* - 9000 订单支付成功
95+
* - 8000 正在处理中,支付结果未知(有可能已经支付成功),请查询商户订单列表中订单的支付状态
96+
* - 4000 订单支付失败
97+
* - 5000 重复请求
98+
* - 6001 用户中途取消
99+
* - 6002 网络连接出错
100+
* - 6004 支付结果未知(有可能已经支付成功),请查询商户订单列表中订单的支付状态
101+
* - 其它 其它支付错误
26102
*/
27-
seller_id: string;
103+
resultStatus?: '9000' | '8000' | '4000' | '5000' | '6001' | '6002' | '6004' | string;
28104
/**
29-
* 长度:16,处理结果的描述,信息来自于code返回结果的描述 success
105+
* 优惠券备注信息
106+
* "Error Domain=系统繁忙,请稍后再试 Code=1000 "(null)""
30107
*/
31-
msg: string;
108+
memo: string;
109+
}
110+
/**
111+
* 快速登录授权,[支付宝文档](https://opendocs.alipay.com/open/218/105327#%E8%BF%94%E5%9B%9E%E7%BB%93%E6%9E%9C%E8%AF%B4%E6%98%8E)
112+
*
113+
*/
114+
export interface AuthResult {
32115
/**
33-
* 长度:16,编码格式 utf-8
116+
* 长度:144,本次操作返回的结果数据。
117+
* - `result_code` 具体状态码值请参见“result_code状态代码”。仅当resultStatus为“9000”且result_code为“200”时,代表授权成功。
118+
* - `auth_code` 表示授权成功的授码。
119+
* @example `success=true&auth_code=9c11732de44f4f1790b63978b6fbOX53&result_code=200&alipay_open_id=20881001757376426161095132517425&user_id=2088003646494707`
34120
*/
35-
charset: string;
121+
result: string;
36122
/**
37-
* 长度:32,时间 2016-10-11 17:43:36
123+
* 长度:5,本次操作的状态返回值,标识本次调用的结果,参见“resultStatus状态代码”。
124+
* - 9000 请求处理成功
125+
* - 4000 系统异常
126+
* - 6001 用户中途取消
127+
* - 6002 网络连接出错
38128
*/
39-
timestamp: string;
129+
resultStatus: '9000' | '4000' | '6001' | '6002';
40130
/**
41-
* 长度:16,结果码 具体见公共错误码
131+
* 长度:无,保留参数,一般无内容。 处理成功
42132
*/
43-
code: string;
44-
},
45-
sign: string;
46-
sign_type: 'RSA2' | 'RSA';
47-
}
48-
49-
50-
interface OrderResult {
51-
/**
52-
* @callback AliOrderResult
53-
* 支付返回结果:
54-
* 支付宝支付返回结果文档地址:https://opendocs.alipay.com/open/204/105301#%E8%BF%94%E5%9B%9E%E7%BB%93%E6%9E%9C%E7%A4%BA%E4%BE%8B%EF%BC%88iOS%7CAndroid%EF%BC%89
55-
* '{"alipay_trade_app_pay_response":{"code":"10000","msg":"Success","app_id":"2021001172656340","auth_app_id":"2021001172656340","charset":"UTF-8","timestamp":"2020-07-08 21:30:14","out_trade_no":"123123213123214","total_amount":"0.01","trade_no":"2020070822001414841426413774","seller_id":"2088421915791034"},"sign":"LY7wCsNLp+QnDqCq6VelY/RvyK7ZGY8wsXoKvS+Or7JjONLDUx5P6lDgqRKkpkng7br3y6GZzfGKaZ88Tf4eMnBMKyqU+huR2Um47xUxP383njvHlxuQZsSTLQZRswy4wmb/fPkFfvyH6Or6+oj0eboePOTu63bNr+h03w0QnP4znuHpfRuoVgWpsYh/6B1DL+4xfWRKJ21zm1SV9Feo9RWqnyTaGZyFVi6IKge0dUCYs9hXju95fOUVUOx5YflOFtSEnZafY9Ls4FCRQE1ANkjaKiKIE0+c4c4sEVEf/9Dwh88N+aSQOoLT+AV4RpjMoA8hF2k+vv2OKNeqr6SYGQ==","sign_type":"RSA2"}'
56-
*/
57-
result?: string;
58-
/**
59-
* 9000 订单支付成功
60-
* 8000 正在处理中,支付结果未知(有可能已经支付成功),请查询商户订单列表中订单的支付状态
61-
* 4000 订单支付失败
62-
* 5000 重复请求
63-
* 6001 用户中途取消
64-
* 6002 网络连接出错
65-
* 6004 支付结果未知(有可能已经支付成功),请查询商户订单列表中订单的支付状态
66-
* 其它 其它支付错误
67-
*/
68-
resultStatus?: '9000' | '8000' | '4000' | '5000' | '6001' | '6002' | '6004' | string;
69-
/**
70-
* "Error Domain=系统繁忙,请稍后再试 Code=1000 "(null)""
71-
* 优惠券备注信息
72-
*/
73-
memo: string;
74-
}
75-
76-
// 错误返回
77-
// {
78-
// memo: "Error Domain=系统繁忙,请稍后再试 Code=1000 \"(null)\"",
79-
// result: "",
80-
// resultStatus: "4000",
81-
// }
82-
// 成功返回
83-
// {
84-
// result: '{"alipay_trade_app_pay_response":{"code":"10000","msg":"Success","app_id":"2021001172656340","auth_app_id":"2021001172656340","charset":"UTF-8","timestamp":"2020-07-08 21:30:14","out_trade_no":"123123213123214","total_amount":"0.01","trade_no":"2020070822001414841426413774","seller_id":"2088421915791034"},"sign":"LY7wCsNLp+QnDqCq6VelY/RvyK7ZGY8wsXoKvS+Or7JjONLDUx5P6lDgqRKkpkng7br3y6GZzfGKaZ88Tf4eMnBMKyqU+huR2Um47xUxP383njvHlxuQZsSTLQZRswy4wmb/fPkFfvyH6Or6+oj0eboePOTu63bNr+h03w0QnP4znuHpfRuoVgWpsYh/6B1DL+4xfWRKJ21zm1SV9Feo9RWqnyTaGZyFVi6IKge0dUCYs9hXju95fOUVUOx5YflOFtSEnZafY9Ls4FCRQE1ANkjaKiKIE0+c4c4sEVEf/9Dwh88N+aSQOoLT+AV4RpjMoA8hF2k+vv2OKNeqr6SYGQ==","sign_type":"RSA2"}',
85-
// resultStatus: '9000',
86-
// memo: ''
87-
// }
88-
89-
/**
90-
* 快速登录授权
91-
* https://opendocs.alipay.com/open/218/105327#%E8%BF%94%E5%9B%9E%E7%BB%93%E6%9E%9C%E8%AF%B4%E6%98%8E
92-
*/
93-
interface AuthResult {
94-
/**
95-
* 长度:144,本次操作返回的结果数据。
96-
* - `result_code` 具体状态码值请参见“result_code状态代码”。仅当resultStatus为“9000”且result_code为“200”时,代表授权成功。
97-
* - `auth_code` 表示授权成功的授码。
98-
* @example `success=true&auth_code=9c11732de44f4f1790b63978b6fbOX53&result_code=200&alipay_open_id=20881001757376426161095132517425&user_id=2088003646494707`
99-
*/
100-
result: string;
101-
/**
102-
* 长度:5,本次操作的状态返回值,标识本次调用的结果,参见“resultStatus状态代码”。
103-
* - 9000 请求处理成功
104-
* - 4000 系统异常
105-
* - 6001 用户中途取消
106-
* - 6002 网络连接出错
107-
*/
108-
resultStatus: '9000' | '4000' | '6001' | '6002';
109-
/**
110-
* 长度:无,保留参数,一般无内容。 处理成功
111-
*/
112-
memo: string;
113-
}
114-
115-
116-
export const Alipay: {
133+
memo: string;
134+
}
117135
/**
118136
* 支付
119137
* @param payInfo 支付详情
120138
* @returns result 支付宝回调结果 https://docs.open.alipay.com/204/105301
121139
*/
122-
alipay: (payInfo: string) => Promise<OrderResult>;
140+
export function alipay(payInfo: string): Promise<OrderResult>;
123141
/**
124142
* 快速登录授权
125143
* @param authInfoStr 验证详情
126144
* @returns result 支付宝回调结果 https://opendocs.alipay.com/open/218/105327
127145
*/
128-
authInfo: (authInfoStr: string) => Promise<AuthResult>;
146+
export function authInfo(authInfoStr: string): Promise<AuthResult>;
129147
/**
130148
* 获取当前 SDK 版本号
131149
* @return 当前 SDK 版本字符串
132150
*/
133-
getVersion: () => Promise<string>;
151+
export function getVersion(): Promise<string>;
134152
/**
135153
* 设置支付宝跳转Scheme,仅 iOS
136154
* @param scheme scheme = `ap` + `APPID`
137155
* @platform ios
138156
*/
139-
setAlipayScheme: (scheme: string) => void;
157+
export function setAlipayScheme(scheme: string): void;
140158
/**
141159
* 设置支付宝沙箱环境,仅 Android
142160
* @param isSandBox
143161
* @platform android
144162
*/
145-
setAlipaySandbox: (isSandbox: boolean) => void;
146-
};
147-
148-
export default Alipay;
163+
export function setAlipaySandbox(isSandbox: boolean): void;
164+
}

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "2.0.7",
44
"description": "基于 React Native 的支付宝插件,支持Android/iOS。",
55
"main": "index.js",
6+
"typings": "index.d.ts",
67
"files": [
78
"README.md",
89
"android",
@@ -11,7 +12,7 @@
1112
"ios"
1213
],
1314
"scripts": {
14-
"test": "echo \"Error: no test specified\" && exit 1"
15+
"build": "typedoc"
1516
},
1617
"repository": {
1718
"type": "git",
@@ -40,6 +41,8 @@
4041
},
4142
"devDependencies": {
4243
"react": "^16.9.0",
43-
"react-native": "^0.61.5"
44+
"react-native": "^0.61.5",
45+
"typedoc": "^0.17.8",
46+
"typescript": "^3.9.7"
4447
}
4548
}

typedoc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"inputFiles": "./index.d.ts",
3+
"out": "typedoc",
4+
"entryPoint": "Alipay",
5+
"name": "React Native Alipay",
6+
"mode": "file",
7+
"includeDeclarations": true,
8+
"excludeExternals": true,
9+
"ignoreCompilerErrors": true,
10+
"excludePrivate": true,
11+
"excludeProtected": true
12+
}

0 commit comments

Comments
 (0)