WeChat scan code payment (Mode 1)
Problems encountered by WeChat scan code payment
Native payment URL parameter error
CallbackInterfaceThe URL has a callback, but the parameters cannot be received
Merchant backend The returned data field structure is illegal
Timed out to obtain merchant order information or the httpcode returned by the merchant was not 200
Solution to the problem
Native payment URL parameter error
This error generally occurs when the QR code is generated and scanned on WeChat after obtaining the QR code URL. If you encounter this type of problem, please check
1. Whether there are errors in the parameters in the parameter list required to generate the QR code (case sensitive)
2. Sign in the parameters Correct signature algorithm at the time Signature verification tool
The following is the code to generate the QR code URL
/** * * @author Javen * 2016年5月14日 * 扫码支付获取二维码URL(模式一) */ public String getCodeUrl(){ String url="weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXX&time_stamp=XXXXX&nonce_str=XXXXX"; String product_id="001"; String timeStamp=Long.toString(System.currentTimeMillis() / 1000); String nonceStr=Long.toString(System.currentTimeMillis()); Map<string> packageParams = new HashMap<string>(); packageParams.put("appid", appid); packageParams.put("mch_id", partner); packageParams.put("product_id",product_id); packageParams.put("time_stamp", timeStamp); packageParams.put("nonce_str", nonceStr); String packageSign = PaymentKit.createSign(packageParams, paternerKey); return StringUtils.replace(url, "XXXXX", packageSign,appid,partner,product_id,timeStamp,nonceStr); }</string></string>
-
The callback interface URL has a callback , but the parameters cannot be received
Enumeration
en=getParaNames(); while (en.hasMoreElements()) { Object o= en.nextElement(); System.out.println(o.toString()+"="+getPara(o.toString())); }
The parameters output in the above code are all NULL
Since the official document description is not very clear, everyone thinks that the callback request will take the productid and user's openid and other parameters as ordinary parameters. In fact, the parameter returned by this callback is an XMLInput stream
HttpServletRequest request = getRequest(); /** * 获取用户扫描二维码后,微信返回的信息 */ InputStream inStream = request.getInputStream(); ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = inStream.read(buffer)) != -1) { outSteam.write(buffer, 0, len); } outSteam.close(); inStream.close(); String result = new String(outSteam.toByteArray(),"utf-8");
resultThe result is
Public void wxpay () { The above is the detailed content of WeChat scan code payment mode. For more information, please follow other related articles on the PHP Chinese website!
< ;return_msg>
Try {
httpservletRequest Request = getRequest () /** ## r 代

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)
