Sharing the problems and solutions of the development of micro-credit-sweep-code payment--a case study of Ecshop micro-credit Payment plugin _php

Source: Internet
Author: User

Recently compared to work more easily, to help a friend based on the Ecshop development of the Mall to join the micro-letter scanning payment function, this thought is very simple thing--Download the official SDK or development help documents, press the inside to do OK, who had to toss the time of two or three days to settle, In the middle also with doubt on the Internet to find a lot of technical articles, but found that they are only a relatively rough write how they developed access, and did not solve the problems I encountered ..., alas, sometimes the feeling of sincerity ' can only rely on their own '.

This article is to put their own problems and solutions to write out, so that the development of the friends to help!

Before development, check the official "Sweep code Payment" Development document, sweep code payment is divided into the following two modes:

  Mode one:

Problems encountered: The first scan two-dimensional code can also be normal scan, unpaid again scan will be prompted: OK or request the Merchant information Timeout Httpcode 200--This problem to try to find solutions through various means are fruitless, here hope to have know friends can give and answer, thank you!

  Mode two:

Note: You can not directly use the mall's order number as a transaction order number (OUT_TRADE_NO), or again generated micro-letter sweep code to pay the two-dimensional code, the interface will prompt: Merchant order number Repeat, can not be rebuilt.

So purple problem, how should set up the trading order number, but also to ensure that the back through the interface to the micro-letter merchant platform of the corresponding order information or to achieve reconciliation? Feasible way is: Sweep code before the unified single interface, out_trade_no do not pass into the mall order system order number, but to regenerate a new only water; Add an order number and a micro-letter 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, namely: in the payment success notification callback processing, according to the return of the Out_trade_no update payment status; As to how to inquire about the order payment status, presumably you should also know ...

Well, long time no write technology blog some can not find the feeling, write may be more rough, there are not clear friends to pay attention to & communication!

It's all over the pit. Micro-letter Payment V3 Payment Callback page

According to the last time everywhere is a pit of micro-letter pay V3 after a lot of friends after being abused times finally jump to the kind of micro-letter payment interface, but the input password paid but do not know how to deal with, and then pay the processing process after payment.

1. HTML in accordance with the foreground payment after the feedback information success to jump to the relevant page

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

2. Payment development tutorial (micro letter Merchant platform version) download the micro-letter payment Interface Document and demo (public account). zip

Returns a section of the parameter reference interface document in the 4.2 Common notification interface.

The notification URL is a notify_url of the parameters submitted in section 4.1, and when the payment is completed, the micro-letter sends the relevant and user information to the URL, and the merchant needs to receive processing information.

Payment callback page Public ActionResult Notice_url () {String resultfromwx = Getpoststr ();
      Set up payment parameters RequestHandler Paysignreqhandler = new RequestHandler (null);
      Writelog ("micro-payment Notice resultfromwx=" + resultfromwx);
      var res = xdocument.parse (RESULTFROMWX); Communication Success if (res. Element ("xml"). Element ("Return_code"). Value = = "SUCCESS") {if (res). Element ("xml"). Element ("Result_code").
          Value = = "SUCCESS") {//Transaction 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 succeeded =" + 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 your code to remind the micro-server that it has been processed, or you will receive feedback from the micro-server continuously.

Getpoststr () Method:

Gets the data public
    string Getpoststr ()
    {
      Int32 Intlen = Convert.ToInt32 (Request.InputStream.Length)
      that came post. 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 have been opened, the main or patience to debug, I wish you good luck ~

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.