微信JSAPI支付 跟 所遇到的那些坑

2021-09-08 19:48:18 字數 2043 閱讀 5410

weixin.senparc sdk 官網:

public actionresult jsapi(string code, string

state)

if (!state.contains("|"

))

try viewdata[

"product

"] =product;}}

//通過,用code換取access_token

if (openidresult.errcode !=returncode.請求成功)

string sp_billno = request["

order_no"];

if (string

.isnullorempty(sp_billno))

", tenpayv3info.mchid, datetime.now.tostring("

yyyymmdd"),

tenpayv3util.buildrandomstr(

10));

}else

var timestamp =tenpayv3util.gettimestamp();

var noncestr =tenpayv3util.getnoncestr();

var body = product == null ? "

test

": product.name;

var price = product == null ? 100 : product.price * 100

;

var xmldatainfo = new

var result = tenpayv3.unifiedorder(xmldatainfo);//

呼叫統一訂單介面

//var package = string.format("

prepay_id=

", result.prepay_id);

viewdata[

" viewdata[

"timestamp

"] =timestamp;

viewdata[

"noncestr

"] =noncestr;

viewdata[

"package

"] =package;

viewdata[

"paysign

return

view();

}catch

(exception ex)

return

content(msg);

}}

先說說在統一下單這裡遇到的坑。

1.在統一下單的時候解析返回結果,一直出現以下問題:您沒有jsapi支付許可權

2)檢查你的授權目錄是否正確,格式要這樣,後面記得別漏了乙個/   例如:

這裡詳細說一下對應的引數:

3.在統一下單,解析返回來的結果出現 cdata[openid is invalid],openid無效

原因是,傳過去不是有效的opendid。不小心看錯了,把使用者id 當做openid傳過去了。

當統一下單成功,會返回以下格式的引數

解析獲得預支付單號:

string prepayid = res.element("xml").element("prepay_id").value; //獲取預支付訂單號

給頁面對應地引數

viewdata["

viewdata[

"timestamp

"] =timestamp;

viewdata[

"noncestr

"] =noncestr;

viewdata[

"package

"] =package;

viewdata[

"paysign

靜態頁面js呼叫:

wx.choosewxpay( else

});

微信支付 微信JSAPI支付

pay.php baby extend wx pay.php namespace wx class pay 通過redirecturi獲取授權資訊 return mixed public function getauthinfo 通過code換取網頁授權資訊 res this curlgetreq ...

微信支付JSAPI支付

這裡是報錯 下面是前端拿到資料後的一些操作 var jsapi ajax success function str function jsapicall function callpay else if document.attachevent else 把乙個官方sdk整合到thinkphp框架中...

微信支付JSAPI支付

1.介紹 2.商戶號配置 開發jsapi支付時,在統一下單介面中要求必傳使用者openid,而獲取openid則需要您在公眾平台設定獲取openid的網域名稱 只有被設定過的網域名稱才是乙個有效的獲取openid的網域名稱,否則將獲取失敗。由於我們公司只需要獲取code調取後台介面換取openid,...