发放小程序红包
红包金额大于200或者小于1元时,请求参数scene_id必传,参数说明见下文。◆ 根据监管要求,新申请商户号使用小程序红包需要满足两个条件:1、入驻时间超过90天 2、连续正常交易30天。◆ 移动应用的appid无法使用红包接口。 官方文档 官方文档
js
const { Formatter, Hash, Transformer } = require('wechatpay-axios-plugin')
wxpay.v2.mmpaymkttransfers.sendminiprogramhb.post({
nonce_str,
mch_billno,
mch_id,
wxappid,
send_name,
re_openid,
total_amount,
total_num,
wishing,
act_name,
remark,
notify_way,
scene_id,
}, { security, transformResponse: [Transformer.toObject], })
.then(
({
data: {
return_code,
return_msg,
result_code,
err_code,
err_code_des,
mch_billno,
mch_id,
wxappid,
re_openid,
total_amount,
send_listid,
package: packageStr,
},
}) => {
const nonceStr = Formatter.nonce();
const timeStamp = '' + Formatter.timestamp();
const signType = 'MD5';
return {
appId,
timeStamp,
nonceStr,
package: encodeURIComponent(packageStr),
signType,
paySign: Hash.sign(
signType,
{ appId, timeStamp, nonceStr, package: packageStr },
apiv2Secret
)
}
}
)