微信支付報錯問題解決
支付回調各類報錯,openID、APPID等等緣由,打印 console.log(typeof(res.jsApiParameters));
重點把string轉化爲Object就ok了。
每次支付請求會生成訂單,根據對應訂單號,修改數據庫訂單狀態才能夠完成。html
{ "appId":"wx1b35c*********3", "nonceStr":"nam97dundxjiisasumrevju*******", "package":"prepay_id=wx***", "signType":"MD5", "timeStamp":"1**", "paySign":"7CD01*****9" }
//獲取充值套餐 $.ajax({ type: 'post', url: api.domain + api.recharge_package, data: { "access_token": access }, success : function(res) { if (res.status == 1) { var n = res.data.length; var menu = []; if(n < 1){ return false; } for(var i = 0;i < n;i++){ menu.push(res.data[i].id); var selected; //設置默認套餐與價格 if(i == 0){ selected = ' btn-active'; $('#money').html(res.data[i].price); } else { selected = ''; } var $list = $('<span class="weui-btn btn-check js-pay ' + selected + '" title="' + res.data[i].id + '" price="' + res.data[i].price + '">' + res.data[i].name + '</span>'); $list.appendTo($('#parent')); } $('#count').val(menu); } else { $.toptip(res.msg,'cancel'); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { console.log('XMLHttpRequest.status = ' + XMLHttpRequest.status); console.log('XMLHttpRequest.readyState = ' + XMLHttpRequest.readyState); console.log('textStatus = ' + textStatus); }