uni-app实现微信小程序支付
var data = {
'out_trade_no': 订单号,
'WIDsubject': 商品名字,
'WIDtotal_fee': 价格,
'openid': openid,
'appid': 'APPID',
'callBackUrl': 'url地址',
};
console.log('支付data',data)
GetServerData('/webservice/wtWebApiH/GetServerData', {
token: token1,
infoType: "",
jsonValue: JSON.stringify(data)
}, {
emulateJSON: true
}).then(res => {
console.log('支付0',res)
var a = "appId=" + appid + "&nonceStr=" + res.noncestr +
"&package=prepay_id=" + res.prepayid +
"&signType=MD5&timeStamp=1414561699&key=密钥";
var b = md(a);
console.log('b',b)
uni.requestPayment({
provider: 'wxpay',
timeStamp: '1414561699',
// timeStamp: String(Date.now()),
nonceStr: res.noncestr,
package: "prepay_id=" + res.prepayid,
signType: 'MD5',
paySign:b,
success: function (res) {
console.log('success:' + JSON.stringify(res));
},
fail: function (err) {
console.log('fail:' + JSON.stringify(err));
}
});
})
|