Share WeChat Scan code payment development encountered problems and solutions-with ecshop WeChat payment plugin, encounter problems ecshop_php tutorial

Source: Internet
Author: User

Share Scan code payment development encountered problems and solutions-with ecshop payment plugin, encountered problems ecshop


Relatively easy to compare work recently, to help a friend based on the Ecshop development of the mall to join the scanning payment function, this thought is very simple thing-download the official SDK or development help documents, according to the inside of the do OK, behold the two or three days of the time to calculate the fix, In the middle also with questions on the internet to find a lot of technical articles, but found that they are only relatively rough write how they are developing access, and did not solve the problems I encountered ..., alas, sometimes the real feeling ' only on their own '.

This article is to want to put their own problems and solutions to write, so that the development of this area of the friend has helped!

Before development, review the official "Scan code Payment" Development document, scan code payment is divided into the following two modes:

  Mode one:

Problems encountered: The first scan of the QR code can also be normal scan, unpaid re-scan will prompt: OK or request merchant Information Timeout Httpcode non-200--This problem try to find a solution through a variety of ways have no effect, here want to know friends can give and answer, thank you!

  Mode two:

Note: You can not directly use the mall's order number as the trade order number (OUT_TRADE_NO), or else to generate a scan code to pay the QR code, the interface will prompt: Merchant order number is duplicated, cannot be regenerated.

So Jiangzi question, how to set the trade order number, but also to ensure that the subsequent interface to query the merchant platform for the corresponding order information or to achieve reconciliation? The feasible way is: before sweeping the unified next single interface, out_trade_no do not pass the order number of the mall order system, but regenerate a new unique water, and then add an order number and payment transaction order number (OUT_TRADE_NO) corresponding table, as follows:

There is a Serial_is_paid field in the table above: used to mark whether this transaction has been completed, that is: in the payment success notification callback processing, according to the return of the Out_trade_no update payment status, as to how to check the status of the order payment, presumably you should also know ...

Well, a long time did not write technical blog some can not find the feeling, writing may be relatively sketchy, have not clear friends to pay attention to & exchange!

It's all over the pit. Payment V3 of Payment callback page

According to the last place is the pit of the payment V3 after a lot of friends after being abused times finally jumped to the kind of payment interface, but the input password after payment but do not know how to deal with, then make up the processing flow after payment.

1. The HTML in accordance with the reception after payment feedback information success or not to jump to the relevant page

if (res.err_msg = = "Get_brand_wcpay_request:ok") {   //message: "Payment succeeded!",   window.location.replace ("@ Url.content ("~/wxpay/success?ordercode=@ (Model.order_no)"));} else if (res.err_msg = = "Get_brand_wcpay_request:cancel") {   //message: ' Canceled payment! '}

2. Payment development Tutorial (Merchant Platform Edition) to download the payment interface Documentation and demo (public account). zip

The parameters returned in the reference interface document in the 4.2. Generic Notification Interface section.

The notification URL is the parameter Notify_url submitted in section 4.1, after payment is completed, the relevant and user information is sent to the URL and the merchant needs to receive processing information.

Payment callback page Public ActionResult Notice_url () {String resultfromwx = Getpoststr ();      Set Payment parameters RequestHandler Paysignreqhandler = new RequestHandler (null);      Writelog ("micro-payment Notice resultfromwx=" + resultfromwx);      var res = xdocument.parse (RESULTFROMWX); Communication succeeds if (res. Element ("xml"). Element ("Return_code"). Value = = "SUCCESS") {if (res. Element ("xml"). Element ("Result_code").          Value = = "SUCCESS") {//Trading 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 ("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 failure");        }} else {paysignreqhandler.setparameter ("Return_code", "FAIL");      Paysignreqhandler.setparameter ("Return_msg", "Signature failed");      } String data = Paysignreqhandler.parsexml ();      var result = Tenpayv3.unifiedorder (data);      Writelog ("micro-payment Notice result=" + result);    return View (); }

Attention:

Therefore, after receiving a successful payment, you need to return the red part of the code to remind the server that it has been processed, or you will receive feedback from the server continuously.

Getpoststr () Method:

Get 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 rear stations are open, the main is to be patient debugging, wish June Good Luck ~

http://www.bkjia.com/PHPjc/1049133.html www.bkjia.com true http://www.bkjia.com/PHPjc/1049133.html techarticle Share Scan Code payment development encountered problems and solutions-with ecshop payment plug-in, encountered problems Ecshop recently compared to work relatively easy to help a friend based on the Ecshop development of the business ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.