Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use java to realize WeChat Pay's official account payment

Shulou Source: shulou.com Published: 2022-06-03 09:46:03 10月03日 Update

< 32 ; i ++ ){ sb.append(str.charAt(rd.nextInt(str.length()))); } return sb.toString(); } /** * 插入XML标签 * @param sb * @param Key * @param value * @return */ public static StringBuilder setXmlKV(StringBuilder sb,String Key,String value){ sb.append(""); sb.append(value); sb.append(""); return sb; } /** * 解析XML 获得名称为para的参数值 * @param xml * @param para * @return */ public static String getXmlPara(String xml,String para){ int start = xml.indexOf(""); int end = xml.indexOf(""); if(start < 0 && end < 0){ return null; } return xml.substring(start + ("").length(),end).replace("",""); } /** * 获取ip地址 * @param request * @return */ public static String getIpAddr(HttpServletRequest request) { InetAddress addr = null; try { addr = InetAddress.getLocalHost(); } catch (UnknownHostException e) { return request.getRemoteAddr(); } byte[] ipAddr = addr.getAddress(); String ipAddrStr = ""; for (int i = 0; i < ipAddr.length; i++) { if (i >

0) {ipAddrStr + = ".";} ipAddrStr + = ipAddr [I] & 0xFF;} return ipAddrStr;}}

② constant class (set according to merchant information):

Public class WxPayConstants {/ / third-party user unique ID public static String APPID = ""; / / third-party user unique credential password public static String APP_SECRET = ""; / / Merchant ID public static String MCH_ID = ""; / / Wechat Merchant platform-account Settings-Security Settings-api Security, configure 32-bit key public static String KEY = ""; / / transaction type public static String TRADE_TYPE_JS = "JSAPI" / / WeChat Pay callback url public static String NOTIFY_URL = "";}

After reading this article, I believe you have a certain understanding of "how to use java to achieve WeChat Pay's official account payment". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Tags: Payments users public parameters unification merchants success results pages information goods platforms orders development configuration security addresses passwords interfaces documents Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Linux MariaDB macOS Redmi