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);