说起微信支付呢,api文档上已经讲的很清楚了,今天小编在给大家讲的更直白些
直接上代码了,看注释即可
前台我们只需将后台传递给我们的参数传入即可
wxpay() {
let that = this,
params = {
mid: that.data.mid, //客户ID
order_id: that.data.order_id, // 订单ID
pay_type: that.data.pay_type, // 支付类型
order_sn: that.data.order_sn, //支付订单号
}
app.net.$Api.wxpay(params).then((res) => {
console.log(res)
wx.requestPayment({
timeStamp: res.data.data.timeStamp, //时间戳
nonceStr: res.data.data.nonceStr, //随机字符串
package: res.data.data.package, //prepay_id
signType: 'MD5',
paySign: res.data.data.paySign, //签名
success(res) {
that.paybac() //支付成功回调
},
fail(res) {
console.log(res)
}
})
})
},
到这就支付成功了,有帮助的记得关注小编
喜欢上方小程序,需要源码的,私信小编留下邮箱。