微信PC掃碼支付 二 發起支付

2021-09-10 09:31:16 字數 2142 閱讀 1707

統一下單:

public object pay(mapmap) throws payexception

if(stringutils.isblank(orderid))

if(stringutils.isblank(prices))

if(stringutils.isblank(amountpaid))

if(stringutils.isblank(outtradeno))

if (stringutils.isblank(ip))

//組裝引數

mappackageparams = new hashmap();

weixinconfig weixinconfig=new weixinconfig();

string mchid=weixinconfig.getmchid();

string notifyurl=weixinconfig.getnotifyurl();

int price=(int)(float.valueof(amountpaid)*100);//訂單總金額,單位為分

packageparams.put("mch_id", mchid);

packageparams.put("device_info", deviceinfo);

packageparams.put("nonce_str", noncestr);

packageparams.put("body", body);

packageparams.put("attach",orderid+";"+prices);

packageparams.put("out_trade_no",outtradeno);

packageparams.put("total_fee", integer.tostring(price));

packageparams.put("spbill_create_ip", ip);

packageparams.put("notify_url", notifyurl);

packageparams.put("trade_type", tradetype);

//簽名

string sign="";

mapresult=new hashmap<>();

try catch (exception e)

string returncode = result.get("return_code");

string returnmsg = result.get("return_msg");

//code 標記成功失敗,預設0:成功,1:失敗、用於alert,2:失敗、用於confirm

if (stringutils.isblank(returncode) || !"success".equals(returncode))

string resultcode = result.get("result_code");

if (stringutils.isblank(resultcode) || !"success".equals(resultcode))

// 以下欄位在return_code 和result_code都為success的時候有返回

string codeurl = result.get("code_url");

resultmap.put("returncode", "success");

resultmap.put("codeurl", codeurl);

return resultmap;

}

第二步:從呼叫返回的map中取出codeurl,發到客戶端(自己寫的頁面)

}訂單查詢:

$(function() else

repeat--;

}, 3000);//3秒執行一次 總共200次 10分鐘

});

微信支付之pc端掃碼支付

看文件是最簡單暴力的方式,千萬不要去看一些文章寫得真的是。好像我也是寫文章的 嗯 基本流程 首頁頁面引入 步驟1 var obj new wxlogin 然後就沒有然後了,就是這麼簡單。這裡的 引數 主要看一下文件非常詳細。有些同學可能就有些疑問了?文件上明明寫著 為什麼我沒有去去做呢?這個就要從安...

微信支付之掃碼支付

web一般選擇都是掃碼支付。類似於這個 下面鏈結可以幫助你去找到這個賬號 在公共號平台上找 下面鏈結可以幫助你去找到這個賬號 注意 第三步成功之後會收到乙個郵件,郵件中會有登入商戶平台的賬號和密碼 商戶id mch id 申請支付成功之後登入商戶平台就可以看到這個值了。api秘鑰 api key 呼...

微信掃碼支付 xml解析

解析xml,返回第一級元素鍵值對。如果第一級元素有子節點,則此節點的值是子節點的xml資料。param strxml return throws jdomexception throws ioexception public static map doxmlparse string strxml t...