百富门答题小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
1.3 KiB

// #ifdef H5
import jWeixin from './lib/jweixin-module.js'
// #endif
export function wxPay(res, successCallback, failCallback, optionCallback) {
jWeixin.config({
debug: false,
appId: res.result.appId, //必填
jsApiList: ['chooseWXPay']
});
jWeixin.ready(function() {
jWeixin.chooseWXPay({
appId: res.result.appId,
timestamp: res.result
.timeStamp, // 支付签名时间戳,注意微信 jssdk 中的所有使用 timestamp 字段均为小写。但最新版的支付后台生成签名使用的 timeStamp 字段名需大写其中的 S 字符
nonceStr: res.result.nonceStr, // 支付签名随机串,不长于 32 位
package: res.result.packageValue, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
signType: res.result.signType, // 微信支付V3的传入 RSA ,微信支付V2的传入格式与V2统一下单的签名格式保持一致
paySign: res.result.paySign, // 支付签名
success: function() { // 支付成功取消处理
successCallback && successCallback();
},
fail: function(error) { // 支付失败或取消处理
failCallback && failCallback();
},
cancel : function(){
failCallback && failCallback();
}
});
});
jWeixin.error(function(res) {
// 配置失败处理
optionCallback && optionCallback()
});
}