W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
cloud.payment.common.refund 是通用接口的交易退款接口。
字段名 | 類型 | 必填 | 說(shuō)明 |
---|---|---|---|
outTradeNo | String | 是 | 交易創(chuàng)建時(shí)傳入的商戶訂單號(hào) |
refundAmount | String | 是 | 需要退款的金額,該金額不能大于訂單金額,單位為元,支持兩位小數(shù) |
appAuthToken | String | 否 | 三方代調(diào)用應(yīng)用訪問(wèn)令牌,詳見(jiàn)應(yīng)用授權(quán)概述,目前僅在云函數(shù)中調(diào)用支持。 |
// 云函數(shù)中使用云調(diào)用無(wú)需引入其他依賴,只需要使用ctx.cloud調(diào)用
module.exports = async function (ctx) {
const res = await ctx.cloud.payment.common.refund({
// 參數(shù)接收自云函數(shù)調(diào)用端傳入的參數(shù)
outTradeNo: ctx.args.outTradeNo,
refundAmount: ctx.args.refundAmount
});
return res;
};
支持傳入appAuthToken進(jìn)行三方代調(diào)用
// 云函數(shù)中使用云調(diào)用無(wú)需引入其他依賴,只需要使用ctx.cloud調(diào)用
module.exports = async function (ctx) {
const res = await ctx.cloud.payment.common.refund({
// 參數(shù)接收自云函數(shù)調(diào)用端傳入的參數(shù)
outTradeNo: ctx.args.outTradeNo,
refundAmount: ctx.args.refundAmount
}, {
// appAuthToken參數(shù)接收自云函數(shù)調(diào)用處傳入的參數(shù)
appAuthToken: ctx.args.appAuthToken
});
return res;
};
alipay-serverless-sdk 版本&=1.0.0
const refundResult = await cloud.payment.common.refund({
outTradeNo: this.data.outTradeNo,
refundAmount: '0.01'
});
alipay-serverless-sdk 版本<1.0.0
const refundResult = await cloud.payment.common.refund(this.data.outTradeNo, '0.01');
{
"code":"10000",
"msg":"Success",
"trade_no":"支付寶交易號(hào)",
"out_trade_no":"6823789339978248",
"buyer_logon_id":"159****5620",
"fund_change":"Y",
"refund_fee":88.88,
"refund_currency":"USD",
"gmt_refund_pay":"2014-11-27 15:45:57",
"refund_detail_item_list":[
{
"fund_channel":"ALIPAYACCOUNT",
"bank_code":"CEB",
"amount":10,
"real_amount":11.21,
"fund_type":"DEBIT_CARD"
}
],
"store_name":"望湘園聯(lián)洋店",
"buyer_user_id":"2088101117955611",
"refund_preset_paytool_list":{
"amount":[
12.21
],
"assert_type_code":"盒馬禮品卡:HEMA;抓貓貓紅包:T_CAT_COUPON"
},
"refund_settlement_id":"2018101610032004620239146945",
"present_refund_buyer_amount":"88.88",
"present_refund_discount_amount":"88.88",
"present_refund_mdiscount_amount":"88.88"
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: