/** * 1, Alipay recharge, or task payment * @author Yangxujia * @throws unsupportedencodingexception * @date October 28, 2015 morning 11:44:0 7 */@RequestMapping ("/receivefromalipay.do") @ResponseBody public String Receivefromalipay (HttpServletRequest re Quest) throws unsupportedencodingexception{//Get Alipay post over feedback map<string,string> params = new Hashmap<strin
G,string> ();
Map requestparams = Request.getparametermap ();
Log.info ("Requestparams:" +requestparams.tostring ());
Log.info ("params:" +params.tostring ()); for (Iterator iter = Requestparams.keyset (). iterator (); Iter.hasnext ();)
{String name = (string) iter.next ();
String[] values = (string[]) requestparams.get (name);
String valuestr = ""; for (int i = 0; i < values.length i++) {valuestr = (i = = values.length-1)? Valuestr + values[i]: Valu
Estr + 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"), "GBK");
Params.put (name, VALUESTR); //Get Alipay's notification return parameter, refer to technical documentation page Jump sync notification parameter list (below for reference only)//merchant order number String Out_trade_no = new String (Request.getparameter ("O
Ut_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");
if (Request.getparameter ("Trade_status") ==null) {Log.info ("fail");
return "fail";
//Transaction status String trade_status = new String (Request.getparameter ("Trade_status"). GetBytes ("Iso-8859-1"), "UTF-8"); Params.put ("Trade_status", trade_status);//add by Yangxj mondb.insertalipayparms (params)//add by YANGXJ//Get Alipay Notice Return parameters, refer to the page Jump synchronization notification parameter list in technical documentation (above for reference only)/if (alipaynotify.verify (params)) {//Verify success/////////////////////////////////////
Please add the merchant's business Logic program code//--please write the program according to your business logic (the following code is for reference only)-- if (Trade_status.equals ("trade_finished")) {//Determine if the order has been processed on the merchant website//If no processing has been done, according to the order number (Out_TRADE_NO) in the Merchant website's order system to find the details of the order, and execute Merchant's business procedure//If have done processing, do not carry out merchant's business procedure//NOTE:///Refund date over refundable refund period (such as three month refund), Alipay system send This transaction status notification//Please be sure to determine when the request is Total_fee, seller_id and notifications obtained at Total_fee, seller_id as a consistent} else if (Trade_status.equals ("trade_succes S ")" {//determine if the order has been processed on the merchant website///If no processing has been done, according to order number (OUT_TRADE_NO) in the Merchant website Order system to find out the details of the order, and the implementation of business procedures//If there has been done, do not carry out business
The user's business procedure//YXJ//judge whether it belongs to the recharge or the guarantee Integer Rtncode = Userservice.rechargefromalipay (params);
Log.info ("Recharge result from AliPay:" +rtncode.tostring ());
Save transaction Journalaccount Journalaccount = Userservice.savetransaction (params);
Log.info ("Journalaccount from AliPay:" +journalaccount);
YXJ//Note: When payment is completed, the Alipay system sends the transaction status notice//Please make sure to judge the Total_fee, seller_id and the Total_fee, seller_id to be consistent at the time of the request.
--Please write the program according to your business logic (the above code is for reference only)--return "success"; OUT.PRINTLN ("Success"); Please do not modify or delete////////////////////////////////////////////////////////////////////////////////////}else{//validation Failure return "fail";//Out.println ("fail"); }
}