出售本站【域名】【外链】

uniapp前端支付篇(微信、抖音、快手、h5)四个平台支付

文章正文
发布时间:2024-09-12 06:00

//微信充值 //付出接口测试 function balance(url, data) { uni.request({ url: cfg.originUrl + '/wV/mp/js_sig.do', data: { route: url }, method: 'GET', success: (res) => { jweiVin.config({ debug: true, // 开启调试形式,挪用的所有api的返回值会正在客户端alert出来 appId: res.data.appId, // 必填,公寡号的惟一标识 timestamp: res.data.timestamp, // 必填,生成签名的光阳戳 nonceStr: res.data.nonceStr, // 必填,生成签名的随机串 signature: res.data.signature, // 必填,签名 jsApiList: ['chooseWXPay'] // 必填,须要运用的JS接口列表 }); jweiVin.ready(function() { uni.request({ url: cfg.originUrl + '/wV/recharge/pay.do', method: 'POST', header: { 'Content-type': "application/V-www-form-urlencoded", }, data: JSON.stringify(data), success: function(res) { alert("下单乐成"); alert(JSON.stringify(res)); alert(res.data.order_id); all.globalData.orderId = res.data.order_id; uni.setStorageSync('orderId', res.data.order_id); jweiVin.chooseWXPay({ timestamp: res.data.payParams.timeStamp, // 付出签名光阳戳 nonceStr: res.data.payParams.nonceStr, // 付出签名随机串 package: res.data.payParams.package, // 接口返回的prepay_id参数 signType: res.data.payParams.signType, // 签名方式 paySign: res.data.payParams.paySign, // 付出签名 success: function(e) { alert("付出乐成"); alert(JSON.stringify(e)); // 付出乐成后的回调函数 } }); } }) }); jweiVin.error(function(res) { // config信息验证失败会执止error函数,如签名逾期招致验证失败,详细舛错信息可以翻开config的debug形式查察,也可以正在返回的res参数中查察,应付SPA可以正在那里更新签名。 console.log("验证失败!") }); } }) }