I won’t say much nonsense, I will just post java code to you.
The specific code is as follows:
/*Payment Process*//****Controller.java The code is as follows: */@RequestMapping(value = "/paySubmit.htm", method = RequestMethod.POST)public ModelAndView paySubmit(HttpServletRequest request,HttpServletResponse response, @RequestParam Map<String, Object> maps){ModelAndView model = new ModelAndView("***/submit");/*** Code block*/return model;}/*submit.jsp The code is as follows: */<%@ page contentType="text/html;charset=UTF-8" language="java" trimDirectiveWhitespaces="true" %><%@ page import="com.***.util.PayUtil" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Pay</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"></head><body><%request.setCharacterEncoding("UTF-8");String type = (String) request.getAttribute("type");String sHtmlText = "";if ("1".equals(type)){sHtmlText = PayUtil.buildForm((String) request.getAttribute("orderNo"),(String) request.getAttribute("amt"),type);}else{sHtmlText = PayUtil.allInPaybuildForm((String) request.getAttribute("orderNo"),(String) request.getAttribute("amt"),type,request);}out.println(sHtmlText);%></body></html>/* The PayUtil.java code is as follows: *//*** Generate page data* @param url The URL for third-party payment* @param sPara* @param strMethod* @return*/public static String buildRequest(String url, Map<String, String> sPara, String strMethod) {ArrayList keys = new ArrayList(sPara.keySet());StringBuffer sbHtml = new StringBuffer();sbHtml.append("<form id=/"paySubForm/" name=/"paySubForm/" action=/" + url + "/" method=/"" + strMethod + "/">");for(int i = 0; i < keys.size(); ++i) {String name = (String)keys.get(i);String value = (String)sPara.get(name);sbHtml.append("<input type=/"hidden/" name=/"" + name + "/" value=/" + value + "/"/>");}sbHtml.append("<input type=/"submit/" name=/"b1/" value=/"confirm/" style=/"display:none;/"></form>");sbHtml.append("<script>document.forms[/'paySubForm/'].submit();</script>");return sbHtml.toString();}/*** Take people's livelihood payment as an example* @param orderNo* @param amt* @param type* @return*/public static String buildForm(String orderNo, String amt,String type) {//Merchant number String merchantid = PropertiesRead.use_classLoador().getProperty("CMBC.pay.id");//Order number Merchant's transaction order number is generated by the merchant website, with a maximum length of 30String merchant = orderNo;//Amount String amountsum = amt;//Product type String subject = PropertiesRead.use_classLoador().getProperty("CMBC.pay.type");//"empty";//Currency 01 is cnyString currencytype = "01";//Automatic transfer of pickup page 0→No jump; 1→Jump String autojump = "1";//Jump waiting time String waittime = "0";//Merry pickup URL String merurl = PropertiesRead.use_classLoador().getProperty("CMBC.pay.return.page.url"); //Whether to notify merchants: 0→Not notify; 1→Not notify String informmer = "1";//Merchant Notification URLString informurl = PropertiesRead.use_classLoador().getProperty("CMBC.pay.return.notify.url");/*** Merchant return confirmation: 0→No return; 1→Return*/String confirm = "1";//Pay bank String merbank = "empty";//Pay type 0→Instant arrival; 1→Secure transaction String tradetype = "0";//Whether to select a bank on the merchant side: 0→Other; 1→Select a bank on the merchant side String bankInput = "0";//Interface version String strInterface = "5.00";//Remarks (optional) Payment remark information, maximum length 50String remark = "Recharge";//Pay bank card type 00→Debit and loan mix; 01→Pure debit String bankcardtype = "00";//Product description String pdtdnm = "Virtual product";//Product description address String pdtdetailurl = PropertiesRead.use_classLoador().getProperty("CMBC.pay.return.detail.url");//Payment key (required): It needs to be set on the payment platform, you can log in to the merchant management system for maintenance, and use it to send merchant payments up and upload payment results to encrypt String MD5key = PropertiesRead.use_classLoador().getProperty("CMBC.pay.pwd");//Split encrypted source string String mac_src="merchantid="+merchantid+"&merorderid="+merorderid+"&amountsum="+amountsum+"&subject="+subject+"¤cytype="+currencytype+"&autojump="+autojump+"&waittime=" + waittime +"&merurl="+merurl+ "&informer=" + informmer +"&informurl=" + informurl+ "&confirm=" + confirm + "&merbank=" + merbank+ "&tradetype=" + tradetype + "&bankInput=" + bankInput+ "&interface=" + strInterface + "&bankcardtype=" + bankcardtype+ "&pdtdetailurl=" + pdtdetailurl + "&merkey="+MD5key;String mac = Crypto.GetMessageDigest(mac_src);// Pack the request parameters into mapMap<String, String> sParaTemp = new HashMap<String,String>();sParaTemp.put("merchantid", merchantid);sParaTemp.put("merorderid", merchantid);sParaTemp.put("amountsum", amountsum);sParaTemp.put("subject", subject);sParaTemp.put("currencytype", currencytype);sParaTemp.put("autojump", autojump);sParaTemp.put("waittime", waittime);sParaTemp.put("merurl", merurl);sParaTemp.put("informer", informer);sParaTemp.put("informurl", informer);sParaTemp.put("confirm", confirm);sParaTemp.put("merbank", merbank);sParaTemp.put("tradetype", tradetype);sParaTemp.put("bankInput", bankInput);sParaTemp.put("interface", strInterface);sParaTemp.put("remark", remark);sParaTemp.put("bankcardtype", bankcardtype);sParaTemp.put("pdtdnm", pdtdnm);sParaTemp.put("pdtdetailurl", pdtdetailurl);sParaTemp.put("mac", mac);//Create request String sHtmlText = buildRequest(PropertiesRead.use_classLoador().getProperty("CMBC.pay.url"), sParaTemp, "post");logger.info("McPay request: {}", sHtmlText);return sHtmlText;}/" Crypto.java code is as follows"/import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;/*** <p>Title: MD5 encryption algorithm</p>* <p>Description: Merchant does not need to modify</p>* <p>********* Technology Development Company 2009. All rights reserved.</p>*/public class Crypto {/*** Function: MD5 encryption* @param strSrc Encrypted source string* @return Encrypted string length 32 bits*/public static String GetMessageDigest(String strSrc) {MessageDigest md = null;String strDes = null;final String ALGO_MD5 = "MD5";byte[] bt = strSrc.getBytes();try {md = MessageDigest.getInstance(ALGO_MD5);md.update(bt);strDes = bytes2Hex(md.digest());} catch (NoSuchAlgorithmException e) {throw new IllegalStateException("The MD5 algorithm is not supported by the system! ");}return strDes;}/*** Convert the byte array to HEX string (hex string)* @param bts byte array to convert* @return The converted HEX string bytes2Hex(byte[] bts) {String des = "";String tmp = null;for (int i = 0; i < bts.length; i++) {tmp = (Integer.toHexString(bts[i] & 0xFF));if (tmp.length() == 1) {des += "0";}des += tmp;}return des;}}/*** Pay return call url (return to page)* @param session* @param request* @return*/@RequestMapping(value = "/allPayReturn.htm", method = RequestMethod.POST)public ModelAndView allInPayReturnCall(HttpServletRequest request,HttpServletResponse response, @RequestParam Map<String, Object> maps){ModelAndView model = new ModelAndView("***/payReturn");/*** Code block*/return model;}The above is the relevant knowledge of the general process of implementing payment and recharge based on Java code introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!