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 # node.js
# #
typedoc
node_modules/ node_modules/
npm-debug.log npm-debug.log
yarn-error.log yarn-error.log
yarn.lock
# Xcode # 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 * , https://docs.open.alipay.com/204/105301
*/ */
export interface AliOrderResult { export interface OrderResultStr {
alipay_trade_app_pay_response: { alipay_trade_app_pay_response: {
/** /**
* 64 70501111111S001111119 * 64 70501111111S001111119
@ -44,53 +51,67 @@ export interface AliOrderResult {
}, },
sign: string; sign: string;
sign_type: 'RSA2' | 'RSA'; 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"}' * '{"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; result?: string;
/** /**
* 9000 *
* 8000 * - 9000
* 4000 * - 8000
* 5000 * - 4000
* 6001 * - 5000
* 6002 * - 6001
* 6004 * - 6002
* * - 6004
* -
*/ */
resultStatus?: '9000' | '8000' | '4000' | '5000' | '6001' | '6002' | '6004' | string; resultStatus?: '9000' | '8000' | '4000' | '5000' | '6001' | '6002' | '6004' | string;
/** /**
* "Error Domain=系统繁忙,请稍后再试 Code=1000 "(null)""
* *
* "Error Domain=系统繁忙,请稍后再试 Code=1000 "(null)""
*/ */
memo: string; memo: string;
} }
/**
// 错误返回 * [](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)
// { *
// 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
*/ */
interface AuthResult { export interface AuthResult {
/** /**
* 144 * 144
* - `result_code` result_code状态代码resultStatus为9000result_code为200 * - `result_code` result_code状态代码resultStatus为9000result_code为200
@ -110,39 +131,34 @@ interface AuthResult {
* *
*/ */
memo: string; memo: string;
} }
export const Alipay: {
/** /**
* *
* @param payInfo * @param payInfo
* @returns result https://docs.open.alipay.com/204/105301 * @returns result https://docs.open.alipay.com/204/105301
*/ */
alipay: (payInfo: string) => Promise<OrderResult>; export function alipay(payInfo: string): Promise<OrderResult>;
/** /**
* *
* @param authInfoStr * @param authInfoStr
* @returns result https://opendocs.alipay.com/open/218/105327 * @returns result https://opendocs.alipay.com/open/218/105327
*/ */
authInfo: (authInfoStr: string) => Promise<AuthResult>; export function authInfo(authInfoStr: string): Promise<AuthResult>;
/** /**
* SDK * SDK
* @return SDK * @return SDK
*/ */
getVersion: () => Promise<string>; export function getVersion(): Promise<string>;
/** /**
* Scheme iOS * Scheme iOS
* @param scheme scheme = `ap` + `APPID` * @param scheme scheme = `ap` + `APPID`
* @platform ios * @platform ios
*/ */
setAlipayScheme: (scheme: string) => void; export function setAlipayScheme(scheme: string): void;
/** /**
* Android * Android
* @param isSandBox * @param isSandBox
* @platform android * @platform android
*/ */
setAlipaySandbox: (isSandbox: boolean) => void; export function setAlipaySandbox(isSandbox: boolean): void;
}; }
export default Alipay;

View File

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