+ 做的 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參數
文章插图
第三步
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
- "剃发易服"后,为何瓜皮帽和马褂会成了中华服饰的代表
- # 汇编期末考试复习【选择易错题】
- 法国伟大国王路易十四的情妇有哪些人
- 个人汇率投资APP,海龟易购是一个投资app吗?
- 著名诗人白居易怒打行贿人是怎么回事呢
- 88vip网易云绑定还能换绑吗
- Excel 是您最容易被忽视的设计工具 设计师对世界排名第一的电子表格工具的看法
- 网易薄荷停服:他日山高水长,江湖再见
- 企业工商四要素核验 API:有效应对商业欺诈和恶意交易的利器
- 交易号是什么steam