日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

微信支付调用API

發(fā)布時(shí)間:2023/12/14 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 微信支付调用API 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
$.ajax({
contentType: "application/x-www-form-urlencoded", ?
url: URL + "", ? //請求的url地址
dataType: "json", ? //返回格式為json
headers:{"userId":userId},
data:{"url":url1}, ??
async: true, //請求是否異步,默認(rèn)為異步,這也是ajax重要特性
type: "POST",?
success: function(result) {
var m = result.data;
signature = m.signature;
appId = m.appId;
timeStamp = m.timeStamp;
nonceStr = m.nonceStr;
packages = n.packages;
signType = n.signType;
paySign = n.paySign;
}
})*/
wx.config({
? ? //debug: true, // 開啟調(diào)試模式,調(diào)用的所有api的返回值會(huì)在客戶端alert出來,若要查看傳入的參數(shù),可以在pc端打開,參數(shù)信息會(huì)通過log打出,僅在pc端時(shí)才會(huì)打印。
? ? appId: appId, // 必填,公眾號(hào)的唯一標(biāo)識(shí)
? ? timestamp: timeStamp, // 必填,生成簽名的時(shí)間戳
? ? nonceStr: nonceStr, // 必填,生成簽名的隨機(jī)串
? ? signature: signature,// 必填,簽名,見附錄1
? ? jsApiList: ["chooseWXPay"] // 必填,需要使用的JS接口列表,所有JS接口列表見附錄2
});
wx.ready(function(){
wx.chooseWXPay({
appId: appId,
? ? timestamp: timeStamp, // 支付簽名時(shí)間戳,注意微信jssdk中的所有使用timestamp字段均為小寫。但最新版的支付后臺(tái)生成簽名使用的timeStamp字段名需大寫其中的S字符
? ? nonceStr: nonceStr, // 支付簽名隨機(jī)串,不長于 32 位
? ? package: packages, // 統(tǒng)一支付接口返回的prepay_id參數(shù)值,提交格式如:prepay_id=***)
? ? signType: signType, // 簽名方式,默認(rèn)為'SHA1',使用新版支付需傳入'MD5'
? ? paySign: paySign, // 支付簽名 ? ?
? ? success: function (res) {
$.ajax({
? ? contentType: "application/x-www-form-urlencoded", ?
? ? url: URL + "wxpay/notify", ?//請求的url地址
? ? dataType: "json", ? //返回格式為json
headers:{"userId":userId},
data:{"orderId":orderid}, ??
? ? async: true, //請求是否異步,默認(rèn)為異步,這也是ajax重要特性
? ? type: "POST",?
success: function(result) {
/*var m = result.data;
if(m=="PAID")
{ new TipBox({type:'success',str:'支付成功',setTime:2000,hasBtn:true});}
else if(m=="NOPAY")
{new TipBox({type:'error',str:'支付失敗!',clickDomCancel:true,setTime:1000,hasBtn:true});}*/
document.location.href ="order_detail.html?=" + orderid;
}
})
? ? },
error:function(res){
if(res.errMsg == "chooseWXPay:fail" )?
document.location.href ="order_detail.html?=" + orderid;
}
});
});
wx.error(function(res){
document.location.href ="order_detail.html?=" + orderid;
});

總結(jié)

以上是生活随笔為你收集整理的微信支付调用API的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。