1. 程式人生 > >匯付天下聚合支付APP+網銀支付介面程式碼

匯付天下聚合支付APP+網銀支付介面程式碼

上篇文章我寫了匯付天下聚合支付APP+快捷支付的介面程式碼,今天,我就在上篇的基礎上寫一下APP+網銀支付的介面程式碼。 下面是網銀支付介面程式碼:

JAVA程式碼示例: 首先將需要收集的引數都寫成json格式的字串。 String valueObj = “{ “version”: “10”, “cmd_id”: “123”, //網銀支付的交易指令ID具體可以參見對方的介面文件 “mer_cust_id”: “123123123123”,//入駐商戶id “user_cust_id”: “321321321321321”,//入駐商戶下級商戶ID “order_id”: “1234567”,//訂單編號 “order_date”: “20170830”, “gate_id”: “09”, “trans_amt”: “21.03”, “ret_url”: “”, “bg_ret_url”: “

http://192.168.0.74:8001/npayCallBack/asyncHandle.json”, “mer_priv”: “et”, “extension”: “…n”, “div_detail”: “[{‘divCustId’:‘123123123123’,‘divAcctId’:‘45841’,‘divAmt’:‘6.92’,‘divFreezeFg’:‘01’},{‘divCustId’:‘321321321321’,‘divAcctId’:‘12345’,‘divAmt’:‘0.03’,‘divFreezeFg’:‘00’}]”,//分賬串資訊 }”;

String testUrl = “http://192.168.3.170:8083/npay/merchantRequest

”; //地址可以詢問對方運營 String checkValue = sign(valueObj); String cmdId = “204”; String merCustId = “123123123123”;//入駐商戶id String version = “10”; httpServletResponse.setContentType(“application/x-www-form-urlencoded; charset=UTF-8”); PrintWriter out = httpServletResponse.getWriter(); out.println(); out.println(""); out.println(""); out.println("

sender"); out.println(" <BODY style=“display: none”>"); out.println("<form name=“submitForm” action="" + url + “” method=“post”>"); out.println("<input type=“hidden” name=“cmd_id” value="" + cmd_id + “”/>"); out.println("<input type=“hidden” name=“version” value="" + version + “”/>"); out.println("<input type=“hidden” name=“mer_cust_id” value="" + merCustId + “”/>"); out.println("<input type=“hidden” name=“check_value” value="" + checkValue + “”/>"); out.println(""); out.println(“”); out.println(" “); out.println(”"); out.flush(); out.close();

成功響應: { “cmd_id”: “123”, “resp_code”: “123000”, “resp_desc”: “交易成功”, “mer_cust_id” : “123123123123”, “order_date”: “20180327”, “order_id”: “10000000001”, … }

失敗響應: { “cmd_id”: “123”, “resp_code”: “123003”, “resp_desc”: “交易失敗”, “mer_cust_id” : “123123123123”, “order_date”: “20180327”, “order_id”: “10000000001”, … } 加簽方法: private static String sign(String valueObj) { // 加簽用pfx檔案 String pfxFileName = “888888-匯付測試商戶.pfx”; // 加簽用密碼 String pfxFilePwd = “888888”; // 進行base64轉換 String base64RequestParams = Base64.encodeBase64String(valueObj.getBytes(Charset.forName(“utf-8”))); // 加簽 SignResult signResult = CFCASignature.signature("/app/etc/product/" + pfxFileName, pfxFilePwd,base64RequestParams, “utf-8”); if (“000”.equals(signResult.getCode())) { return signResult.getSign(); } else { return “加簽失敗”; } }

好了,今天就記錄到這裡,相關的報錯資訊在介面文件中也有,根據提示除錯吧。 有興趣的童鞋,也可以直接去他們官微看看。

在這裡插入圖片描述