


Share the problems and solutions encountered in the development of WeChat scan code payment - Attached is the Ecshop WeChat payment plug-in, encounter problems ecshop_PHP tutorial
Share the problems and solutions encountered in the development of WeChat scan code payment - Attached is the Ecshop WeChat payment plug-in. When encountering problems with ecshop
It has been easier recently, and I helped a friend with his ecshop-based The developed mall added the WeChat scan payment function. I thought it would be a simple matter - download the official SDK or development help document and follow the instructions in it. Unexpectedly, it took two or three days to get it done. I also looked for a lot of technical articles on the Internet with questions, but found that they only wrote roughly how they developed the access, and did not solve the problems I encountered... Alas, sometimes I really feel that I just Can rely on oneself'.
The purpose of this article is to write down the problems and solutions I encountered, so that friends who develop in this area can be helpful!
Before development, please check the official [Scan QR code payment] development document. Scan QR code payment is divided into the following two modes:
△Mode 1:
Issues encountered: Scanning the QR code for the first time can still be scanned normally, but scanning again without payment will prompt: ok or the request for merchant information has timed out and the HttpCode is not 200 - this problem has been tried through various ways to find a solution, but to no avail As a result, I hope someone who knows can give me an answer, thank you!
△Mode 2:
Note: You cannot directly use the order number of the mall as the transaction order number (out_trade_no), otherwise when you generate the WeChat scan code payment QR code again, the interface will prompt: The merchant order number is duplicated and cannot be regenerated.
So here comes Jiang Zi’s question, how should I set the transaction order number and ensure that the corresponding order information in the WeChat merchant platform can be queried through the interface later or reconciliation can be achieved? The feasible method is: use the unified order interface before scanning the QR code. Instead of passing in the order number of the mall order system for out_trade_no, regenerate a new unique flow; add another order number corresponding to the WeChat payment transaction order number (out_trade_no). Table, as follows:
There is a serial_is_paid field in the above table: used to mark whether this transaction has been completed, that is: in the payment success notification callback processing, the payment status is updated based on the returned out_trade_no; as for how to query the order payment status, I believe you should also Got it...
Okay, I haven’t written a technical blog for a long time and I feel a bit confused. The writing may be rough. Friends who are not sure can pay attention and communicate!
WeChat Pay V3 is full of pitfalls - WeChat Pay callback page
According to WeChat Pay V3, which was full of pitfalls last time, many gardeners finally jumped to the friendly WeChat payment interface after being abused thousands of times. However, they did not know what to do after entering the password to pay. Next, make up for it. Post-payment processing procedures.
1. In the html, jump to the relevant page based on the success or failure of the feedback information after the payment at the front desk
if (res.err_msg == "get_brand_wcpay_request:ok") { // message: "微信支付成功!", window.location.replace("@Url.Content("~/WxPay/Success?ordercode=@(Model.order_no)")); }else if (res.err_msg == "get_brand_wcpay_request:cancel") { // message: "已取消微信支付!" }
2. Download the WeChat payment interface document and demo (public account) from the payment development tutorial (WeChat merchant platform version).zip
For the parameters returned, please refer to the section 4.2. General Notification Interface in the interface document.
The notification URL is the parameter notify_url submitted in Section 4.1. After the payment is completed, WeChat will send relevant and user information to this URL, and the merchant needs to receive the processing information.
//支付回调页面 public ActionResult notice_url() { string resultFromWx = getPostStr(); //设置支付参数 RequestHandler paySignReqHandler = new RequestHandler(null); WriteLog(" 微支付notice resultFromWx=" + resultFromWx); var res = XDocument.Parse(resultFromWx); //通信成功 if (res.Element("xml").Element("return_code").Value == "SUCCESS") { if (res.Element("xml").Element("result_code").Value == "SUCCESS") { //交易成功 paySignReqHandler.SetParameter("return_code", "SUCCESS"); paySignReqHandler.SetParameter("return_msg", "OK"); string ordecode = res.Element("xml").Element("out_trade_no").Value; BLL.orders Bll = new BLL.orders(); try { if (Bll.Update(ordecode )) { WriteLog(" 微支付交易成功=" + ordecode); } else { WriteLog(" 微支付交易失败=" + ordecode); } } catch (Exception ex) { WriteLog(ex," 微支付交易异常=" + ordecode); } } else { paySignReqHandler.SetParameter("return_code", "FAIL"); paySignReqHandler.SetParameter("return_msg", "交易失败"); } } else { paySignReqHandler.SetParameter("return_code", "FAIL"); paySignReqHandler.SetParameter("return_msg", "签名失败"); } string data = paySignReqHandler.ParseXML(); var result = TenPayV3.Unifiedorder(data); WriteLog(" 微支付notice result=" + result); return View(); }
Note:
Therefore, after receiving a successful payment, you need to return the red part of the code to remind the WeChat server that it has been processed, otherwise you will continue to receive feedback from the WeChat server.
getPostStr() method:
//获得Post过来的数据 public string getPostStr() { Int32 intLen = Convert.ToInt32(Request.InputStream.Length); byte[] b = new byte[intLen]; Request.InputStream.Read(b, 0, intLen); return System.Text.Encoding.UTF8.GetString(b); }
Now that the front and backend are connected, the main thing is to be patient in debugging. I wish you good luck~

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

In WeChat, users can enter their payment password to make purchases, but how do they retrieve their payment password if they forget it? Users need to go to My-Services-Wallet-Payment Settings-to recover their payment password if they forget it. This introduction to how to retrieve your payment password if you forget it will tell you the specific operation method. The following is a detailed introduction, so take a look! WeChat usage tutorial. How to find the WeChat payment password if you forget it? Answer: My-Service-Wallet-Payment Settings-Forgot payment password. Specific method: 1. First, click My. 2. Click on the service inside. 3. Click on the wallet inside. 4. Find the payment settings. 5. Click Forgot payment password. 6. Enter your own information for verification. 7. Then enter the new payment password to change it.

Solution for forgetting WeChat payment password: 1. Open WeChat APP, click "I" in the lower right corner to enter the personal center page; 2. In the personal center page, click "Pay" to enter the payment page; 3. On the payment page , click "..." in the upper right corner to enter the payment management page; 4. In the payment management page, find and click "Forgot payment password"; 5. Follow the page prompts and enter personal information for identity verification. After successful verification, you can Choose the method of "retrieve by swiping your face" or "retrieve by verifying bank card information" to retrieve your password, etc.

There are many food and snack shops provided in the Meituan takeout app, and all mobile phone users log in through their accounts. Add your personal delivery address and contact number to enjoy the most convenient takeout service. Open the homepage of the software, enter product keywords, and search online to find the corresponding product results. Just swipe up or down to purchase and place an order. The platform will also recommend dozens of nearby restaurants with high reviews based on the delivery address provided by the user. The store can also set up different payment methods. You can place an order with one click to complete the order. The rider can arrange the delivery immediately and the delivery speed is very fast. There are also takeout red envelopes of different amounts for use. Now the editor is online in detail for Meituan takeout users. We show you how to set up WeChat payment. 1. After selecting the product, submit the order and click Now

Steps to set the order of deductions for WeChat payment: 1. Open the WeChat APP, click on the "Me" interface, click on "Services", and then click on "Collect and Payment"; 2. Click on "Prioritize Use This Payment Method" under the payment code on the collection and payment interface; 3. Select the preferred payment method you need.

When everyone has nothing to do, they will choose to browse the Xianyu platform. Everyone can find that there are a large number of products on this platform, which can allow everyone to see various second-hand products. Although these products are second-hand products, there is absolutely no problem with the quality of these products, so everyone can buy them with confidence. The prices are very affordable, and they still allow everyone to face-to-face with these products. It is entirely possible for sellers to communicate and conduct some price bargaining operations. As long as everyone negotiates properly, then you can choose to conduct transactions, and when everyone pays here, they want to make WeChat payment, but it seems that the platform It's not allowed. Please follow the editor to find out what the specific situation is. Xianyu

WeChat payment cannot be canceled immediately after successful payment. Refunds usually need to meet the following conditions: 1. The merchant's refund policy. The merchant will formulate its own refund policy, including the refund time window, refund amount and refund method; 2. Payment time, refunds usually require Apply within a certain time frame, and refunds may not be possible beyond this time frame; 3. Goods or service status. If the user has received the goods or enjoyed the service, the merchant may require the user to return the goods or provide corresponding proof; 4. Refund process, etc.

Alibaba 1688 is a purchasing and wholesale website, and the items there are much cheaper than Taobao. So how does Alibaba use WeChat payment? The editor has compiled some relevant content to share with you. Friends in need can come and take a look. How does Alibaba use WeChat payment? Answer: WeChat payment cannot be used for the time being; 1. On the page where we purchase goods, we click [Change payment method] 2. Then in the pop-up page, we can only go to [Alipay, staged payment] , cashier] can be selected;

1. First, we need to open the WeChat APP on the mobile phone, and then click to log in to the WeChat account, so that we enter the WeChat homepage. 2. Click the [Me] button in the lower right corner of the WeChat homepage, then select the [Payment] option. We click to enter the payment page. 3. After entering the [Payment] page, click the [Wallet] option to enter, and click [Bill] in the upper right corner of the [Wallet] page.
