interface.uts 2.8 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
import { RequestPaymentFailImpl as RequestPaymentFailImplement } from './unierror.uts'

export type RequestPaymentFailImpl = RequestPaymentFailImplement
export type UniPaymentProvider = Uni
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(options : RequestPaymentOptions) : void;
}
/**
 * 错误码
DCloud-yyl's avatar
DCloud-yyl 已提交
43 44 45 46 47 48 49
 * - 700710  正在处理中,支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态
 * - 700711  订单支付失败。
 * - 700712  重复请求。
 * - 700713  用户中途取消。
 * - 700714  网络连接出错。
 * - 700715  支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态。
 * - 700716  其它支付错误。
DCloud-yyl's avatar
DCloud-yyl 已提交
50
 */
DCloud-yyl's avatar
DCloud-yyl 已提交
51
export type RequestPaymentErrorCode = 700710 | 700711 | 700712 | 700713 | 700714 | 700715 | 700716;
DCloud-yyl's avatar
DCloud-yyl 已提交
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 83 84 85 86

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 = {
	/**
	 * 支付服务提供商,通过 [uni.getProvider](https://doc.dcloud.net.cn/uni-app-x/api/get-provider.html) 获取,目前支持支付宝支付(alipay),微信支付(wxpay)
	 */
	provider : string,
	/**
	 * 订单数据
	 */
	orderInfo : string,
	/**
	 * 接口调用成功的回调函数
	 */
	success : RequestPaymentSuccessCallback | null,
	/**
	 * 接口调用失败的回调函数
	 */
	fail : RequestPaymentFailCallback | null,
	/**
	 * 接口调用结束的回调函数(调用成功、失败都会执行)
	 */
	complete ?: RequestPaymentCompleteCallback | null
};