支付宝小程序Serverless 支付能力API·cloud.payment.common.query
cloud.payment.common.query 是通用接口的查询交易 接口。
入参说明
字段名 | 类型 | 必填 | 说明 |
---|---|---|---|
outTradeNo | String | 是 | 交易创建时传入的商户订单号 |
appAuthToken | String | 否 | 三方代调用应用访问令牌,目前仅在云函数中调用支持。 |
调用示例
在云函数中调用
// 云函数中使用云调用无需引入其他依赖,只需要使用ctx.cloud调用
module.exports = async function (ctx) {
const res = await ctx.cloud.payment.common.query({
// 参数接收自云函数调用端传入的参数
outTradeNo: ctx.args.outTradeNo
});
return res;
};
支持传入appAuthToken进行三方代调用
// 云函数中使用云调用无需引入其他依赖,只需要使用ctx.cloud调用
module.exports = async function (ctx) {
const res = await ctx.cloud.payment.common.query({
// 参数接收自云函数调用端传入的参数
outTradeNo: ctx.args.outTradeNo
}, {
// appAuthToken参数接收自云函数调用处传入的参数
appAuthToken: ctx.args.appAuthToken
});
return res;
};
在小程序页面调用
alipay-serverless-sdk 版本&=1.0.0
const queryResult = await cloud.payment.common.query({
outTradeNo: this.data.outTradeNo,
});
alipay-serverless-sdk 版本<1.0.0
const queryResult = await cloud.payment.common.query(this.data.tradeNO);
返回数据示例
{
"code":"10000",
"msg":"Success",
"trade_no":"2013112011001004330000121536",
"out_trade_no":"6823789339978248",
"buyer_logon_id":"159****5620",
"trade_status":"TRADE_CLOSED",
"total_amount":88.88,
"trans_currency":"TWD",
"settle_currency":"USD",
"settle_amount":2.96,
"pay_currency":1,
"pay_amount":"8.88",
"settle_trans_rate":"30.025",
"trans_pay_rate":"0.264",
"buyer_pay_amount":8.88,
"point_amount":10,
"invoice_amount":12.11,
"send_pay_date":"2014-11-27 15:45:57",
"receipt_amount":"15.25",
"store_id":"NJ_S_001",
"terminal_id":"NJ_T_001",
"fund_bill_list":[
{
"fund_channel":"ALIPAYACCOUNT",
"amount":10,
"real_amount":11.21
}
],
"store_name":"证大五道口店",
"buyer_user_id":"2088101117955611",
"charge_amount":"8.88",
"charge_flags":"bluesea_1",
"settlement_id":"2018101610032004620239146945",
"trade_settle_info":{
"trade_settle_detail_list":[
{
"operation_type":"replenish",
"operation_serial_no":"2321232323232",
"operation_dt":"2019-05-16 09:59:17",
"trans_out":"208811****111111",
"trans_in":"208811****111111",
"amount":10
}
]
},
"auth_trade_pay_mode":"CREDIT_PREAUTH_PAY",
"buyer_user_type":"PRIVATE",
"mdiscount_amount":"88.88",
"discount_amount":"88.88",
"buyer_user_name":"菜鸟网络有限公司",
"subject":"Iphone6 16G",
"body":"Iphone6 16G",
"alipay_sub_merchant_id":"2088301372182171"
}