1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

doc: Add type document.

This commit is contained in:
jaywcjlove 2020-07-24 01:19:11 +08:00
parent e83aa446c7
commit 31a4bd9c3e
4 changed files with 150 additions and 117 deletions

2
.gitignore vendored
View File

@ -4,9 +4,11 @@
# node.js
#
typedoc
node_modules/
npm-debug.log
yarn-error.log
yarn.lock
# Xcode
#

108
index.d.ts vendored
View File

@ -1,9 +1,16 @@
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/**
* React Native Android/iOS
*/
declare namespace Alipay {
/**
*
* , https://docs.open.alipay.com/204/105301
*/
export interface AliOrderResult {
export interface OrderResultStr {
alipay_trade_app_pay_response: {
/**
* 64 70501111111S001111119
@ -44,53 +51,67 @@ export interface AliOrderResult {
},
sign: string;
sign_type: 'RSA2' | 'RSA';
}
}
interface OrderResult {
/**
* @callback AliOrderResult
*
* @returns
*
* ```json
* {
* 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"}',
* resultStatus: '9000',
* memo: ''
* }
* ```
*
* @returns
*
* ```json
* {
* memo: "Error Domain=系统繁忙,请稍后再试 Code=1000 \"(null)\"",
* result: "",
* resultStatus: "4000",
* }
* ```
*/
export interface OrderResult {
/**
*
* 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
* [](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)
* `JSON.parse` {@link OrderResultStr}
* @typeParam OrderResultStr
* @example
*
* ```json
* '{"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"}'
* ```
*
*/
result?: string;
/**
* 9000
* 8000
* 4000
* 5000
* 6001
* 6002
* 6004
*
*
* - 9000
* - 8000
* - 4000
* - 5000
* - 6001
* - 6002
* - 6004
* -
*/
resultStatus?: '9000' | '8000' | '4000' | '5000' | '6001' | '6002' | '6004' | string;
/**
* "Error Domain=系统繁忙,请稍后再试 Code=1000 "(null)""
*
* "Error Domain=系统繁忙,请稍后再试 Code=1000 "(null)""
*/
memo: string;
}
// 错误返回
// {
// memo: "Error Domain=系统繁忙,请稍后再试 Code=1000 \"(null)\"",
// result: "",
// resultStatus: "4000",
// }
// 成功返回
// {
// 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"}',
// resultStatus: '9000',
// memo: ''
// }
/**
*
* 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
}
/**
* [](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)
*
*/
interface AuthResult {
export interface AuthResult {
/**
* 144
* - `result_code` result_code状态代码resultStatus为9000result_code为200
@ -110,39 +131,34 @@ interface AuthResult {
*
*/
memo: string;
}
export const Alipay: {
}
/**
*
* @param payInfo
* @returns result https://docs.open.alipay.com/204/105301
*/
alipay: (payInfo: string) => Promise<OrderResult>;
export function alipay(payInfo: string): Promise<OrderResult>;
/**
*
* @param authInfoStr
* @returns result https://opendocs.alipay.com/open/218/105327
*/
authInfo: (authInfoStr: string) => Promise<AuthResult>;
export function authInfo(authInfoStr: string): Promise<AuthResult>;
/**
* SDK
* @return SDK
*/
getVersion: () => Promise<string>;
export function getVersion(): Promise<string>;
/**
* Scheme iOS
* @param scheme scheme = `ap` + `APPID`
* @platform ios
*/
setAlipayScheme: (scheme: string) => void;
export function setAlipayScheme(scheme: string): void;
/**
* Android
* @param isSandBox
* @platform android
*/
setAlipaySandbox: (isSandbox: boolean) => void;
};
export default Alipay;
export function setAlipaySandbox(isSandbox: boolean): void;
}

View File

@ -3,6 +3,7 @@
"version": "2.0.7",
"description": "基于 React Native 的支付宝插件支持Android/iOS。",
"main": "index.js",
"typings": "index.d.ts",
"files": [
"README.md",
"android",
@ -11,7 +12,7 @@
"ios"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "typedoc"
},
"repository": {
"type": "git",
@ -40,6 +41,8 @@
},
"devDependencies": {
"react": "^16.9.0",
"react-native": "^0.61.5"
"react-native": "^0.61.5",
"typedoc": "^0.17.8",
"typescript": "^3.9.7"
}
}

12
typedoc.json Normal file
View File

@ -0,0 +1,12 @@
{
"inputFiles": "./index.d.ts",
"out": "typedoc",
"entryPoint": "Alipay",
"name": "React Native Alipay",
"mode": "file",
"includeDeclarations": true,
"excludeExternals": true,
"ignoreCompilerErrors": true,
"excludePrivate": true,
"excludeProtected": true
}