传款易paydollar VISA 支付

+ 做的 VISA 支付 做个笔记 。
在开发中一直想行项目中抽离出来
以下是 大概的流程图
第一步先确定数据的发送
源码是这样的
package com.vb.controller;import java.util.Map;import java.util.concurrent.ConcurrentHashMap;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.servlet.ModelAndView;import com.asiapay.secure.PaydollarSecureUtil;/*** 此類將用於數據封裝提交到VISA* @author **/@Controllerpublic class OnliePay {/*** The merchant ID we provide to you百度翻譯 ----我们提供给你的商人身份证* * 意思就是我們跟銀行申請支付功能 , 銀行反饋給我們這邊的id , 來標識身份*/private static final String merchantId = "88061970";/*** The currency of the payment i.e.* 貨幣的類型* “344” – HKD港幣“840” – USD 美元“702” – SGD“156” – CNY (RMB)毛爺爺“392” – JPY 日元“901” – TWD “036” – AUD“978” – EUR“826” – GBP“124” – CAD */private static final String currCode = "344" ;@RequestMapping("/VISARequest")public ModelAndView virtualRequest(HttpServletRequest request,HttpServletResponse reponse) throws Exception{Map map = new ConcurrentHashMap();String bankId = "258465466";//插入數據庫生成的流水帳號id  , 有助於客戶付款成功後返回給我們的唯一標識String amount = "100";//支付銀行100塊錢String payType = "N";//正常付款/*** 必須获取加密的字符 , 作用餘銀行收錢成功後返回數據時 , 做校驗 , 以防安全隱患里面源码访问secureHashSecret.config文件里面的字符 去生成*/StringsecureHash = PaydollarSecureUtil.generatePaymentSecureHash(merchantId, bankId, currCode, amount, payType);map.put("amount", amount);map.put("merchantId", merchantId);map.put("secureHash", secureHash);map.put("orderRef", bankId);map.put("remark", "備註隨意");//不超過Text (200)字符return new ModelAndView("vbank/submitfFormBank","map",map);}}
接下来就是跳到页面代码
VISA支付demo參數















传款易paydollar  VISA 支付

文章插图

第三步
package com.vb.controller;import java.io.PrintWriter;import java.util.ArrayList;import java.util.Enumeration;import java.util.List;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import com.asiapay.secure.PaydollarSecureUtil;@Controllerpublic class DataBack {@RequestMapping("/VISAdataback")public void databack(HttpServletRequest request,HttpServletResponse reponse) throws Exception{System.out.println(request.getParameterMap()+"--------"+ request.getParameterNames()+"Ord="+request.getParameter("Ord")+"holder="+request.getParameter("Holder")+"Ref="+request.getParameter("Ref")+"successcode="+request.getParameter("successcode")+"remark="+request.getParameter("remark")+"PayRef="+request.getParameter("PayRef")+"Amt="+request.getParameter("Amt")+"src="http://www.kingceram.com/post/+request.getParameter("src")+"prc="+request.getParameter("prc")+"Cur="+request.getParameter("Cur")+"payerAuth="+request.getParameter("payerAuth")+"secureHash="+request.getParameter("secureHash"));//打印Enumeration paramNames = request.getParameterNames();while (paramNames.hasMoreElements()) {String name =(String) paramNames.nextElement();String value = http://www.kingceram.com/post/request.getParameter(name);System.out.println(name+"="+value);}String reqsuccesscode = request.getParameter("successcode") == null ? "": request.getParameter("successcode");String reqremark = request.getParameter("remark") == null ? "": request.getParameter("remark");//付款成功標識if ("0".equals(reqsuccesscode)) {String src = http://www.kingceram.com/post/request.getParameter("src");String prc = request.getParameter("prc");String successcode = request.getParameter("successcode"); //0- succeeded, 1- failure, Others - errorString ref = request.getParameter("Ref");//银行的交易编号String payRef = request.getParameter("PayRef"); //paydollar支付编号 //PayDollar Payment Reference NumberString amt = request.getParameter("Amt"); //交易金额//Transaction AmountString cur = request.getParameter("Cur"); //交易货币种类 344 - HKD ; 156 – CNY (RMB)//Transaction CurrencyString payerAuth = request.getParameter("payerAuth"); String[] secureHash = request.getParameterValues("secureHash");//解密過程 start List tempList = new ArrayList();if (secureHash != null) {for (int k = 0; k