模拟建行网上支付服务器通知
Code
String posID = request.getParameter("POSID"); //POSID 商户柜台代码 CHAR(9) 从商户传送的信息中获得
String branchID = request.getParameter("BRANCHID"); //BRANCHID 分行代码 CHAR(9) 从商户传送的信息中获得
String orderID = request.getParameter("ORDERID"); //ORDERID 定单号 CHAR(30) 从商户传送的信息中获得
String payment = request.getParameter("PAYMENT"); //PAYMENT 付款金额 NUMBER(16,2) 从商户传送的信息中获得
String curCode = request.getParameter("CURCODE"); //CURCODE 币种 CHAR(2) 从商户传送的信息中获得
String remark1 = new String(request.getParameter("REMARK1").getBytes(this.getServletContext().getInitParameter("URLEncoding")),this.getServletContext().getInitParameter("Encoding"));//REMARK1 备注1 CHAR(30) 网银不处理,直接传到城综网
String remark2 = new String(request.getParameter("REMARK2").getBytes(this.getServletContext().getInitParameter("URLEncoding")),this.getServletContext().getInitParameter("Encoding"));//REMARK2 备注2 CHAR(30) 网银不处理,直接传到城综网
String accType = request.getParameter("ACC_TYPE"); //ACC_TYPE 帐户类型 CHAR(2) 从银行信息中获得
String success = request.getParameter("SUCCESS"); //SUCCESS 成功标志 CHAR(1) 成功时返回Y N
String sign = request.getParameter("SIGN"); //SIGN 数字签名 CHAR(256)
StringBuffer src = new StringBuffer();
src.append("POSID=" + posID);
src.append("&BRANCHID=" + branchID);
src.append("&ORDERID=" + orderID);
src.append("&PAYMENT=" + payment);
src.append("&CURCODE=" + curCode);
src.append("&REMARK1=" + remark1);
src.append("&REMARK2=" + remark2);
src.append("&ACC_TYPE=" + accType);
src.append("&SUCCESS=" + success);
RSASig rsaSig = new RSASig();
rsaSig.setPrivateKey(this.getInitParameter("PrivateKey"));
sign = rsaSig.generateSigature(src.toString());
StringBuffer url = new StringBuffer();
url.append(this.getInitParameter("ServerNoticeUrl"));
url.append("?POSID=" + posID);
url.append("&BRANCHID=" + branchID);
url.append("&ORDERID=" + orderID);
url.append("&PAYMENT=" + payment);
url.append("&CURCODE=" + curCode);
url.append("&REMARK1=" + URLEncoder.encode(remark1,this.getServletContext().getInitParameter("Encoding")));
url.append("&REMARK2=" + URLEncoder.encode(remark2,this.getServletContext().getInitParameter("Encoding")));
url.append("&ACC_TYPE=" + accType);
url.append("&SUCCESS=" + success);
url.append("&SIGN=" + sign);
log.debug("src:" + src.toString());
log.debug("sign:" + sign);
log.debug("url:" + url.toString());
response.sendRedirect(url.toString());
String posID = request.getParameter("POSID"); //POSID 商户柜台代码 CHAR(9) 从商户传送的信息中获得
String branchID = request.getParameter("BRANCHID"); //BRANCHID 分行代码 CHAR(9) 从商户传送的信息中获得
String orderID = request.getParameter("ORDERID"); //ORDERID 定单号 CHAR(30) 从商户传送的信息中获得
String payment = request.getParameter("PAYMENT"); //PAYMENT 付款金额 NUMBER(16,2) 从商户传送的信息中获得
String curCode = request.getParameter("CURCODE"); //CURCODE 币种 CHAR(2) 从商户传送的信息中获得
String remark1 = new String(request.getParameter("REMARK1").getBytes(this.getServletContext().getInitParameter("URLEncoding")),this.getServletContext().getInitParameter("Encoding"));//REMARK1 备注1 CHAR(30) 网银不处理,直接传到城综网
String remark2 = new String(request.getParameter("REMARK2").getBytes(this.getServletContext().getInitParameter("URLEncoding")),this.getServletContext().getInitParameter("Encoding"));//REMARK2 备注2 CHAR(30) 网银不处理,直接传到城综网
String accType = request.getParameter("ACC_TYPE"); //ACC_TYPE 帐户类型 CHAR(2) 从银行信息中获得
String success = request.getParameter("SUCCESS"); //SUCCESS 成功标志 CHAR(1) 成功时返回Y N
String sign = request.getParameter("SIGN"); //SIGN 数字签名 CHAR(256)
StringBuffer src = new StringBuffer();
src.append("POSID=" + posID);
src.append("&BRANCHID=" + branchID);
src.append("&ORDERID=" + orderID);
src.append("&PAYMENT=" + payment);
src.append("&CURCODE=" + curCode);
src.append("&REMARK1=" + remark1);
src.append("&REMARK2=" + remark2);
src.append("&ACC_TYPE=" + accType);
src.append("&SUCCESS=" + success);
RSASig rsaSig = new RSASig();
rsaSig.setPrivateKey(this.getInitParameter("PrivateKey"));
sign = rsaSig.generateSigature(src.toString());
StringBuffer url = new StringBuffer();
url.append(this.getInitParameter("ServerNoticeUrl"));
url.append("?POSID=" + posID);
url.append("&BRANCHID=" + branchID);
url.append("&ORDERID=" + orderID);
url.append("&PAYMENT=" + payment);
url.append("&CURCODE=" + curCode);
url.append("&REMARK1=" + URLEncoder.encode(remark1,this.getServletContext().getInitParameter("Encoding")));
url.append("&REMARK2=" + URLEncoder.encode(remark2,this.getServletContext().getInitParameter("Encoding")));
url.append("&ACC_TYPE=" + accType);
url.append("&SUCCESS=" + success);
url.append("&SIGN=" + sign);
log.debug("src:" + src.toString());
log.debug("sign:" + sign);
log.debug("url:" + url.toString());
response.sendRedirect(url.toString());