Package com.test.util.alipay;
Import java.util.ArrayList;
Import Java.util.HashMap;
Import java.util.List;
Import Java.util.Map; public class Alipayservice {/** * feature: Structuring form submission HTML * @param partner Partner ID * @param seller_email sign up for Alipay account or seller Alipay accounts * @pa Ram Return_url After paying the paragraph to jump to the page to the HTTP opening format of the full path, not allowed to add? id=123 such custom parameters * @param notify_url The full path of the server notification in the course of the transaction to HTTP open format, not allowed to add? ID =123 This kind of custom parameter * @param show_url website product display address, not allowed to add? id=123 such custom parameters * @param out_trade_no please match the unique order number in your site order system * @param subject Order
The name, shown in the Alipay cashier's "Commodity name", is displayed in the "Commodity name" list of Alipay's transaction management. * @param the body Order description, Order details, order notes, shown in the Alipay cashier's "description of goods" * @param total_fee Order Total amount, shown in the Alipay Cashier's "Total payable" * @param paymethod Default payment method, four Value Optional: Bankpay (net silver); Cartoon (Cartoon); DirectPay (balance); CASH (dot payment) * @param defaultbank Default network Silver code, code list see club.alipay.com/read.php?tid=8681379 * @param encrypt_key Fishing time stamp * @param e XTER_INVOKE_IP Buyer Local Computer IP address * @param extra_common_param custom parameters, can be stored in any content (except for special characters), will not appear on the page * @param buyer_email default Buyer pay Treasure Account * @param royalty_type Commission type, which is a fixed value: 10, no need to modify
* @param royalty_parameters Commission information set, and the need to combine the situation of the merchant site itself dynamically obtain each transaction splitting collection account number, splitting amount, each splitting description. Up to 10 * @param input_charset character encoding format currently supports GBK or Utf-8 * @param key Security Check code * @param sign_type Signature without modification * @param key
Secure Checksum code * @return Form Submit HTML text/public static string Buildform (string partner, String seller_email, String Return_url, String Notify_url, String Show_url, String out_trade_no, string subject, String body, String Total_fee, String Paym Ethod, String Defaultbank, String Anti_phishing_key, String exter_invoke_ip, String Extra_common_param, String buyer_ Email, string royalty_type, String royalty_parameters, String input_charset, String key, String Sign_type, string it
_b_pay) {Map Spara = new HashMap ();
Spara.put ("service", "Create_direct_pay_by_user");
Spara.put ("Payment_type", "1");
Spara.put ("partner", partner);
Spara.put ("Seller_email", Seller_email);
Spara.put ("Return_url", Return_url);
Spara.put ("Notify_url", Notify_url); Spara.put ("_input_charset", Input_charset);
Spara.put ("Show_url", Show_url);
Spara.put ("Out_trade_no", out_trade_no);
Spara.put ("Subject", subject);
Spara.put ("Body", the body);
Spara.put ("Total_fee", Total_fee);
Spara.put ("Paymethod", Paymethod);
Spara.put ("Defaultbank", Defaultbank);
Spara.put ("Anti_phishing_key", Anti_phishing_key);
Spara.put ("Exter_invoke_ip", exter_invoke_ip);
Spara.put ("Extra_common_param", Extra_common_param);
Spara.put ("Buyer_email", Buyer_email);
Spara.put ("Royalty_type", Royalty_type);
Spara.put ("Royalty_parameters", royalty_parameters);
Spara.put ("It_b_pay", It_b_pay); Map sparanew = Alipayfunction.parafilter (Spara); Drop null values and signature parameters in arrays String mysign = alipayfunction.buildmysign (sparanew, key);//Generate signature result StringBuffer sbhtml = new Stringbuffe
R ();
List keys = new ArrayList (Sparanew.keyset ());
String gateway = "https://www.alipay.com/cooperate/gateway.do?"; Get Way Passes//sbhtml.append ("<form id=\" alipaysubmit\ "name=\" alipaysubmit\ "action=\" "+ Gateway +" _input_charset= " + Input_charset + "" \ "method=\" Get\ ">"); Post mode pass (GET and post two must be selected) Sbhtml.append ("<form id=\" alipaysubmit\ "name=\" alipaysubmit\ "action=\" "+ Gateway +" _
Input_charset= "+ input_charset +" \ "method=\" post\ ">");
for (int i = 0; i < keys.size (); i++) {String name = (string) keys.get (i);
String value = (string) sparanew.get (name);
Sbhtml.append ("<input type=\" hidden\ "name=\" "+ name +" \ "value=\" "+ Value +" \ "/>");
} sbhtml.append ("<input type=\" hidden\ "name=\" sign\ "value=\" "+ mysign +" \ "/>");
Sbhtml.append ("<input type=\" hidden\ "name=\" sign_type\ "value=\" "+ Sign_type +" \ "/>");
Submit Button control Please do not include the Name property Sbhtml.append ("<input type=\" submit\ "value=\" Alipay confirm payment \ "></form>");
Sbhtml.append ("<script>document.forms[' Alipaysubmit '].submit ();</script>");
return sbhtml.tostring (); }
}