interface.uts 2.5 KB
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
export interface Uni {
	/**
	 * @description 请求支付
	 * @param {RequestPaymentOptions} options
	 * @example
	 * ```typescript
	 *	 uni.requestPayment({
	 *		provider: "alipay",
	 *		orderInfo: "",
	 *		success: function (res) {
	 *			 console.log("支付成功"+JSON.stringify(res))
	 *		}
	 *	});
	 * ```
	 * @tutorial [](https://uniapp.dcloud.net.cn/api/plugins/payment.html)
	 * @uniPlatform {
	 *    "app": {
	 *        "android": {
	 *            "osVer": "5.0",
	 *            "uniVer": "√",
	 *            "unixVer": "4.02"
	 *        },
	 *        "ios": {
	 *            "osVer": "9.0",
	 *            "uniVer": "√",
	 *            "unixVer": "x"
	 *        }
	 *    },
	 *    "web": {
	 *        "uniVer": "x",
	 *        "unixVer": "x"
	 *    }
	 * }
	 */
	requestPayment : RequestPayment;
}
/**
 * 错误码
 * - 700710  正在处理中,支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态
 * - 700711  订单支付失败。
 * - 700712  重复请求。
 * - 700713  用户中途取消。
 * - 700714  网络连接出错。
 * - 700715  支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态。
 * - 700716  其它支付错误。
 */
export type RequestPaymentErrorCode = 700710 | 700711 | 700712 | 700713 | 700714 | 700715 | 700716;

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 = {
	/**
	 * 支付服务提供商,目前仅支持支付宝(alipay)
	 */
	provider : string,
	/**
	 * 订单数据
	 */
	orderInfo : string,
	/**
	 * 接口调用成功的回调函数
	 */
	success : RequestPaymentSuccessCallback | null,
	/**
	 * 接口调用失败的回调函数
	 */
	fail : RequestPaymentFailCallback | null,
	/**
	 * 接口调用结束的回调函数(调用成功、失败都会执行)
	 */
	complete ?: RequestPaymentCompleteCallback | null
};