interface.uts 2.9 KB
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
1 2 3 4
import { RequestPaymentFailImpl as RequestPaymentFailImplement } from './unierror.uts'

export type RequestPaymentFailImpl = RequestPaymentFailImplement
export type UniPaymentProvider = Uni
DCloud-yyl's avatar
DCloud-yyl 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18
export interface Uni {
	/**
	 * @description 请求支付
	 * @param {RequestPaymentOptions} options
	 * @example
	 * ```typescript
	 *	 uni.requestPayment({
	 *		provider: "alipay",
	 *		orderInfo: "",
	 *		success: function (res) {
	 *			 console.log("支付成功"+JSON.stringify(res))
	 *		}
	 *	});
	 * ```
DCloud-yyl's avatar
DCloud-yyl 已提交
19
	 * @tutorial https://uniapp.dcloud.net.cn/api/plugins/payment.html
DCloud-yyl's avatar
DCloud-yyl 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
	 * @uniPlatform {
	 *    "app": {
	 *        "android": {
	 *            "osVer": "5.0",
	 *            "uniVer": "√",
	 *            "unixVer": "4.02"
	 *        },
	 *        "ios": {
	 *            "osVer": "9.0",
	 *            "uniVer": "√",
	 *            "unixVer": "x"
	 *        }
	 *    },
	 *    "web": {
	 *        "uniVer": "x",
	 *        "unixVer": "x"
	 *    }
	 * }
	 */
DCloud-yyl's avatar
DCloud-yyl 已提交
39
	requestPayment(options : RequestPaymentOptions) : void;
DCloud-yyl's avatar
DCloud-yyl 已提交
40 41 42
}
/**
 * 错误码
DCloud-yyl's avatar
DCloud-yyl 已提交
43 44 45 46 47 48 49 50 51 52
 * - 700600  正在处理中,支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态
 * - 701100  订单支付失败。
 * - 701110  重复请求。
 * - 700601  用户中途取消。
 * - 700602  网络连接出错。
 * - 700603  支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态。
 * - 700000  其它支付错误。
 * - 700604  微信没有安装。
 * - 700800  没有配置对应的URL Scheme。
 * - 700801  没有配置对应的universal Link。
DCloud-yyl's avatar
DCloud-yyl 已提交
53
 */
DCloud-yyl's avatar
DCloud-yyl 已提交
54
export type RequestPaymentErrorCode = 700600 | 701100 | 701110 | 700601 | 700602 | 700603 | 700000 | 700604 | 700800 | 700801;
DCloud-yyl's avatar
DCloud-yyl 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

export type RequestPayment = (options : RequestPaymentOptions) => void;
export type RequestPaymentSuccess = {
	data : object | null
};
export type RequestPaymentSuccessCallback = (result : RequestPaymentSuccess) => void;
export type RequestPaymentFail = IRequestPaymentFail;
export type RequestPaymentFailCallback = (result : RequestPaymentFail) => void;
export type RequestPaymentComplete = any
export interface IRequestPaymentFail extends IUniError {
	errCode : RequestPaymentErrorCode
};
export type RequestPaymentCompleteCallback = (result : RequestPaymentComplete) => void;
export type RequestPaymentOptions = {
	/**
DCloud-yyl's avatar
DCloud-yyl 已提交
70
	 * 支付服务提供商,通过 [uni.getProvider](https://doc.dcloud.net.cn/uni-app-x/api/get-provider.html) 获取,目前支持支付宝支付(alipay),微信支付(wxpay)
DCloud-yyl's avatar
DCloud-yyl 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
	 */
	provider : string,
	/**
	 * 订单数据
	 */
	orderInfo : string,
	/**
	 * 接口调用成功的回调函数
	 */
	success : RequestPaymentSuccessCallback | null,
	/**
	 * 接口调用失败的回调函数
	 */
	fail : RequestPaymentFailCallback | null,
	/**
	 * 接口调用结束的回调函数(调用成功、失败都会执行)
	 */
	complete ?: RequestPaymentCompleteCallback | null
};