小程序中调用微信支付接口
wx.request({
url:'xxxxxx',
method:'POST',
data: { },
header:{"Authorization": wx.getStorageSync('token')},
success(res){
if(res.data.message == "success"){
let list = res.data.data;
wx.requestPayment({
appId: list.appId,
timeStamp: list.timeStamp + '', // 时间戳必须是字符串才可以成功调起支付接口,否则会失败
nonceStr: list.nonceStr,
package: list.package,
signType: list.signType,
paySign: list.paySign,
success (res) {
wx.redirectTo({
url: '/pages/successPay/successPay',
})
},
fail(err){
wx.redirectTo({
url: '/pages/failPay/failPay',
})
}
})
}
}
})