W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
cloud.payment.huabei.create 是花唄分期的創(chuàng)建花唄分期交易接口。
字段名 | 類型 | 必填 | 說(shuō)明 |
---|---|---|---|
subject | String | 是 | 訂單標(biāo)題 |
outTradeNo | String | 是 | 商戶訂單號(hào),64個(gè)字符以內(nèi),可包含字母、數(shù)字、下劃線,需保證在商戶端不重復(fù) |
totalAmount | String | 是 | 訂單總金額,單位為元,精確到小數(shù)點(diǎn)后兩位,取值范圍[0.01,100000000] |
buyerId | String | 否 | 買家的支付寶用戶 ID,如果為空,會(huì)從傳入的碼值信息中獲取買家 ID |
extendParams | HuabeiConfig | 是 | 花唄交易擴(kuò)展參數(shù) |
notify_url | String | 否 | 支付寶服務(wù)器主動(dòng)通知商戶服務(wù)器里指定的頁(yè)面http/https路徑,也可以是云函數(shù)的http觸發(fā)路徑。 |
appAuthToken | String | 否 | 三方代調(diào)用應(yīng)用訪問(wèn)令牌,目前僅在云函數(shù)中調(diào)用支持。 |
HuabeiConfig 對(duì)象說(shuō)明
字段名 | 類型 | 必填 | 說(shuō)明 |
---|---|---|---|
hbFqNum | String | 是 | 花唄分期數(shù),僅支持傳入3、6、12 |
hbFqSellerPercent | String | 是 | 代表賣家承擔(dān)收費(fèi)比例,商家承擔(dān)手續(xù)費(fèi)傳入100,用戶承擔(dān)手續(xù)費(fèi)傳入0,僅支持傳入100、0兩種 |
// 云函數(shù)中使用云調(diào)用無(wú)需引入其他依賴,只需要使用ctx.cloud調(diào)用
module.exports = async function (ctx) {
let huabeiConfig = new Object({
hbFqNum: "3",
hbFqSellerPercent: "100"
});
const res = await ctx.cloud.payment.huabei.create({
// 參數(shù)接收自云函數(shù)調(diào)用端傳入的參數(shù)
subject: ctx.args.subject,
outTradeNo: ctx.args.outTradeNo,
totalAmount: ctx.args.totalAmount,
buyerId: ctx.args.buyerId,
extendParams: huabeiConfig
});
return res;
};
支持傳入notifyUrl接收支付寶服務(wù)器交易通知
// 云函數(shù)中使用云調(diào)用無(wú)需引入其他依賴,只需要使用ctx.cloud調(diào)用
module.exports = async function (ctx) {
let huabeiConfig = new Object({
hbFqNum: "3",
hbFqSellerPercent: "100"
});
const res = await ctx.cloud.payment.huabei.create({
// 參數(shù)接收自云函數(shù)調(diào)用端傳入的參數(shù)
subject: ctx.args.subject,
outTradeNo: ctx.args.outTradeNo,
totalAmount: ctx.args.totalAmount,
buyerId: ctx.args.buyerId,
extendParams: huabeiConfig
}, {
// 傳入接收支付寶服務(wù)器交易通知的http/https路徑,也可以是云函數(shù)的http觸發(fā)路徑
notify: {
url: 'http://api.test.alipay.net/atinterface/receive_notify.htm'
}
});
return res;
};
支持傳入appAuthToken進(jìn)行三方代調(diào)用
// 云函數(shù)中使用云調(diào)用無(wú)需引入其他依賴,只需要使用ctx.cloud調(diào)用
module.exports = async function (ctx) {
let huabeiConfig = new Object({
hbFqNum: "3",
hbFqSellerPercent: "100"
});
const res = await ctx.cloud.payment.huabei.create({
// 參數(shù)接收自云函數(shù)調(diào)用端傳入的參數(shù)
subject: ctx.args.subject,
outTradeNo: ctx.args.outTradeNo,
totalAmount: ctx.args.totalAmount,
buyerId: ctx.args.buyerId,
extendParams: huabeiConfig
}, {
// appAuthToken參數(shù)接收自云函數(shù)調(diào)用處傳入的參數(shù)
appAuthToken: ctx.args.appAuthToken
});
return res;
};
alipay-serverless-sdk 版本&=1.0.0
var huabeiConfig = new Object({
hbFqNum: '3',
hbFqSellerPercent: '100'
});
const createRes = await cloud.payment.huabei.create({
subject: '小程序花唄Serverless支付測(cè)試',
outTradeNo: "demo" + new Date().getTime(),
totalAmount: '0.01',
buyerId: '2088202286335281',
extendParams: huabeiConfig
});
alipay-serverless-sdk 版本<1.0.0
var huabeiConfig = new Object({
hbFqNum: '3',
hbFqSellerPercent: '100'
});
const createRes = await cloud.payment.huabei.create('小程序Serverless支付測(cè)試', "piwei" + new Date().getTime(), '0.03', this.data.userId, huabeiConfig);
{
"code":"10000",
"msg":"Success",
"out_trade_no":"20150423001001",
"trade_no":"2015042321001004720200028594"
}
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)系方式:
更多建議: