Alipay payment interface returned to the 3rd party site after the program on the cause of the failure to pay the treasure source analysis

Source: Internet
Author: User

Alipay interface payment after successful through synchronous or asynchronous jump back, the general need to make a check of the data source to judge whether the real Alipay submitted data.

However, some site checksums

Alipaynotify.verify (params)

Always return FALSE.


There are several reasons why the analysis returned to False

The content in Request.getparametermap () is not converted to normal encoding. If there are Chinese characters to be converted to utf-8 through encoding to normal content.
Slow network and other reasons, when the 3rd party Web gets the Alipay return parameter in the Notifyid parameter to pay the server verification delay is more than 1 minutes to complete. Will cause the Alipay side to fail validation. This generally does not appear. The 3rd reason is that the internal parameters of the system are attached to the synchronous and asynchronous callback methods in the Alipay interface. The following paction parameters are used internally by the 3rd party system. Need to filter out. The validation module can be invoked again to succeed. The following code is a red font. (Since the 2 URLs provided in the original demo are 2 JSP pages with no parameters)

The complete test source code snippet is as follows

Get paid treasure gets over feedback information map<string,string> params = new hashmap<string,string> ();
             Map requestparams = Request.getparametermap (); 
             for (Iterator iter = Requestparams.keyset (). iterator (); Iter.hasnext ();) {String name = (string) iter.next (); if (name.equals ("paction")) continue;//paction parameter is an internal system parameter to be removed. Cannot pass to params validation 
                String[] values = (string[]) requestparams.get (name);
                String valuestr = ""; for (int i = 0; i < values.length i++) {valuestr = (i = = values.length-1)? va
                Luestr + values[i]: Valuestr + values[i] + ","; //garbled solution, this code in the occurrence of garbled use.
                If MySign and sign are not equal, you can also use this code to convert VALUESTR = new String (valuestr.getbytes ("iso-8859-1"), "UTF-8");
            Params.put (name, VALUESTR); //Get Alipay notification return parameters, refer to Technical documentation page Jump sync notification parameter list (below for reference only)///Merchant order number String Out_trade_no = new St
            
            Ring (Request.getparameter ("Out_trade_no"). GetBytes ("Iso-8859-1"), "UTF-8");

            Alipay transaction Number String trade_no = new String (Request.getparameter ("Trade_no"). GetBytes ("Iso-8859-1"), "UTF-8"); Transaction status String trade_status = new String (Request.getparameter ("Trade_status"). GetBytes ("Iso-8859-1"), "U

           TF-8 "); Get the notification return parameters of Alipay, reference technical documents in the page Jump synchronization notification parameter list (above for reference only)//////Calculate the result of the notification validation Boolean verify_result = Alipaynotify. Verify (params);


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.