1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| const partnerid = "160*****39" const key = "53E12F838************5A43C5DC3"
const appid = wechatOrder.orderInfo.appid const timeStamp = Math.floor(new Date().getTime() / 1000) + "" const sign = `appid=${appid}&noncestr=${wechatOrder.orderInfo.nonce_str}&package=Sign=WXPay&partnerid=${partnerid}&prepayid=${wechatOrder.orderInfo.prepay_id}×tamp=${timeStamp}&key=${key}`
const orderInfo = { appid: appid, noncestr: wechatOrder.orderInfo.nonce_str, package: "Sign=WXPay", partnerid: partnerid, prepayid: wechatOrder.orderInfo.prepay_id, timestamp: timeStamp, sign: crypto.enc.Hex.stringify(crypto.HmacSHA256(sign, key)), } uni.requestPayment({ provider: "wxpay", orderInfo: orderInfo, success: (res) => { console.log("调用微信支付", res) }, fail: (err) => { console.log("调用支付失败", err) }, complete(complete) { console.log("complete", complete) }, })
|