Scan code payment is very popular in shopping malls. This article will share with you the problems encountered in the development of scan code payment and solutions-with the Ecshop payment plug-in, if you need it, you can refer to the recent relatively easy work to help a friend's ecshop-based mall to add the scan payment function, I thought it was a very simple thing-download the official sdk or development help documentation, and press the instructions in it to get it done. who knows it takes two or three days to get it done, I also found a lot of technical articles on the Internet with questions, but I found that they only roughly wrote how they developed and connected, and did not solve the problem I encountered ..., alas, sometimes you really feel that you can only rely on yourself '.
This article is intended to write out the problems and solutions you have encountered, so that developers can help you with this aspect!
Before development, check the official development document scan payment. scan payment is divided into the following two modes:
△ Mode 1:
Problem: The first scan of the QR code can still be normal scan, the next scan will prompt: OK or request the merchant information timeout HttpCode is not 200 -- this problem cannot be solved by any means. here, I hope some friends can answer it. 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 the QR code is generated again, the interface will prompt that the merchant's order number is repeated and cannot be regenerated.
How can I set the transaction order number to ensure that the corresponding order information in the merchant's platform can be queried or reconciliation can be realized through the interface later? The feasible method is: the unified order interface before scanning the code, out_trade_no should not be passed into the order number of the mall order system, but re-generate a new unique flow; add another table corresponding to the order number and the payment order number (out_trade_no), as shown below:
In the above table, there is a serial_is_paid field: used to mark whether the transaction has been completed, that is, in the callback processing of the successful payment notification, the payment status is updated based on the out_trade_no returned; as to how to query the order payment status, you should have known it too...
Well, if you haven't written a technical blog for a long time, you may not be able to find the feeling. you may write it roughly. if you have any questions, you can pay attention to and communicate with others!
Payment callback page for payment V3 is everywhere
According to the last time there was a lot of trouble to pay for V3, many garden friends finally jumped to the friendly payment interface after being abused for thousands of times, but they did not know how to deal with it after entering the password for payment, next, complete the payment process.
1. the html page jumps to the relevant page based on the feedback after the front-end payment.
If (res. err_msg = "get_brand_wcpay_request: OK") {// message: "Payment successful! ", Window. location. replace (" @ Url. Content ("~ /WxPay/Success? Ordercode = @ (Model. order_no) ");} else if (res. err_msg =" get_brand_wcpay_request: cancel ") {// message:" Payment canceled! "}
2. download the payment interface document and demo(public account No. ).zip in the payment Development Tutorial (Merchant Platform Edition ).
For the returned parameters, see section 4.2. common Notification interfaces in the interface documentation.
The notification URL is the parameter yy_url submitted in Section 4.1. after the payment is complete, the related and user information will be sent to the URL, and the merchant needs to receive the processing information.
// Payment callback page public ActionResult notice_url () {string resultFromWx = getPostStr (); // set the payment parameter RequestHandler paySignReqHandler = new RequestHandler (null ); writeLog ("micropayment 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") {// successful transaction 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 ("micro-payment transaction success =" + ordecode);} else {WriteLog ("micro-payment transaction failed =" + ordecode );}} catch (Exception ex) {WriteLog (ex, "micro-payment transaction Exception =" + ordecode) ;}} else {paySignReqHandler. setParameter ("return_code", "FAIL"); paySignReqHandler. setParameter ("return_msg", "transaction failed") ;}} else {paySignReqHandler. setParameter ("return_code", "FAIL"); paySignReqHandler. setParameter ("return_msg", "signature failed");} string data = paySignReqHandler. parseXML (); var result = tenpayv3.uniiedorder (data); WriteLog ("micropayment notice result =" + result); return View ();}
Note:
Therefore, after receiving a successful payment, you must return the red part of the code to remind the server that the payment has been processed. Otherwise, you will receive feedback from the server.
GetPostStr () method:
// Obtain The Post data 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 the front and back of the platform are connected. we need to debug it patiently and wish you good luck ~