data里面的參數信息,需要從后台接口中調取,點擊查看微信支付詳情,https://docs.apicloud.com/Client-API/Open-SDK/wxPay
首先,需要在config.xml中配置
<!-- 支付微信 -->
<feature name="wxPay">
<param name="urlScheme" value="wxd0d84bbf23b4a0e4"/>
<param name="apiKey" value="wxd0d84bbf23b4a0e4"/>
<param name="apiSecret" value="a354f72aa1b4c2b8eaad137ac81434cd"/>
</feature>
<!-- 支付支付寶 -->
<feature name="aliPayPlus"> <param name="urlScheme" value="AliPayPlusA000000011"/> </feature>
var data = { description: ret.info.wx_pay_data.po_body, totalFee: ret.info.wx_pay_data.po_total_fee * 100, tradeNo: ret.info.wx_pay_data.po_order_no, spbillCreateIP: '', deviceInfo: '', detail: ret.info.wx_pay_data.po_body, attach: '', feeType: 'CNY', timeStart: '', timeExpire: '', goodsTag: '', productId: '', } var wxPay = api.require('wxPay'); wxPay.config({ apiKey: '', // mchId: '', partnerKey: '', notifyUrl: $app + '/Pay/wxNotify' }, function(ret, err) { if (ret.status) { wxPay.pay(data, function(ret, err) { if (ret.status) { api.alert({ title: '系統提示', msg: '打賞成功', }, function(ret, err) { if (ret) { api.closeWin(); } }); } else { if (err.code == '-2') { api.toast({ msg: '用戶取消' }); } else { api.toast({ msg: '打賞失敗' }); } } }); } else { api.toast({ msg: '打賞失敗' }); api.toast({ msg: '傳輸錯誤' }) } })
data里面的參數信息,需要從后台接口中調取,點擊查看微信支付詳情,https://docs.apicloud.com/Client-API/Open-SDK/wxPay
var aliPayPlus = api.require('aliPayPlus'); aliPayPlus.payOrder({ orderInfo: ret.info.pay_url, }, function(ret, err) { if (ret.code == '9000') { api.alert({ title: '系統提示', msg: '打賞成功', }, function(ret, err) { if (ret) { api.closeWin(); } }); } else if (ret.code == '8000') { api.alert({ msg: '正在處理中,支付結果未知', buttons: ['確定'] }); } else if (ret.code == '4000') { $("#alert-sign-fail").show(); } else if (ret.code == '5000') { api.alert({ msg: '重復請求', buttons: ['確定'] }); } else if (ret.code == '6001') { api.alert({ msg: '用戶中途取消支付操作', buttons: ['確定'] }); } else if (ret.code == '6002') { api.alert({ msg: '網絡連接出錯', buttons: ['確定'] }); } else if (ret.code == '6004') { api.alert({ msg: '支付結果未知', buttons: ['確定'] }); } }); } else { if (ret.info == '金額過大') { api.toast({ msg: '充值金額已達上限,請重新輸入金額' }); } else { api.toast({ msg: ret.info }); } } })
