http://stephen830.iteye.com/blog/274072
★ ¡ï This article for the original, need to cite a friend reprint please specify: "http://stephen830.iteye.com/blog/274072", thank you for your support! ¡ï ★
I have previously written an article on "PayPal Online payment communication interface http://stephen830.iteye.com/blog/254565". A supplement to the previous article:
Since international PayPal has added the web version of traditional Chinese, many previous systems that integrate PayPal interface, when foreign customers through the system into the PayPal online payment interface, will often open the traditional Chinese page, rather than the previous English page, Cause foreign customers face is a bunch of garbled (foreign customers generally will not install traditional Chinese). Although the language can be switched manually on the PayPal page (UK english/Traditional Chinese).
All this more or less to the use of foreign customers brought inconvenience, for this need to improve the original PayPal interface to solve this small problem. Searching through the API interfaces provided by PayPal did not find the relevant language setting parameters. So after studying the HTML code of the PayPal website, adding a new parameter to the original interface solves the problem above.
HTML code
- <form name= "PayPal" action= "Https://www.paypal.com/cgi-bin/webscr?locale.x=zh_HK" method= "POST" >
- ...
- </form>
LOCALE.X=ZH_HK Traditional Chinese
LOCALE.X=EN_GB English (UK 中文版)
http://stephen830.iteye.com/blog/254565
This article will describe the communication interface issues with PayPal online payment:
Information about PayPal Online payment can be accessed directly from http://www.paypal.com. As a more commonly used tool for international online payments, PayPal has a lot to do with the current international e-commerce, with a detailed description of the PayPal payment interface that communicates with the enterprise's own online e-commerce system.
The general e-commerce system implementation process is as follows:
The customer submits the amount information of the order to the PayPal website, and PayPal pays the customer's payment completion information to the e-commerce system, and the system receives the PayPal information and determines that the customer's order has been paid, Gt Carry out follow-up processes such as shipping.
From this process, you can see that communication between the system and PayPal is particularly critical, enabling automatic payment confirmations for orders.
(1) How to invoke the PayPal interface? (Submit the Order amount information to the PayPal website)
HTML code
- <%@ page contenttype= "Text/html;charset=utf-8"%>
- <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
- "Http://www.w3.org/TR/html4/loose.dtd">
- <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
- <title>goto paypal</title>
- <body bgcolor= "#000000" leftmargin= "0" topmargin= "0" marginwidth= "0" marginheight= "0" >
- <form name= "PayPal" action= "HTTPS://WWW.PAYPAL.COM/CGI-BIN/WEBSCR" method= "POST" >
- <input type= "hidden" name= "cmd" value= "_xclick" >
- <input type= "hidden" name= "Business" value= "[email protected]" ><!--here to fill in your PayPal account email-->
- <input type= "hidden" name= "Item_name" value= "Order Information" ><!--here to fill in some information about the customer's order, Customers will see this information when they connect to the PayPal website-
- <input type= "hidden" name= "Amount" value= "220.00" ><!--Order Total Amount Information--
- <input type= "hidden" name= "Currency_code" value= "USD" ><!--the currency type of the total order amount, customers can pay in other currencies, for example, the order currency here is USD, Customers can pay in EUR EUR and automatically convert between currencies based on the current exchange rate.
- <input type= "hidden" name= "On0" value= "customerId" ><!--Custom Parameters 1--
- <input type= "hidden" name= "Os0" value= "Stephen" ><!--corresponds to the values above for the custom parameter 1-
- <input type= "hidden" name= "On1" value= "Address" ><!--custom Parameters 2--
- <input type= "hidden" name= "OS1" value= "Shanghai China" ><!--corresponds to the value of the custom parameter 2 above--
- <input type= "hidden" name= "Notify_url" value= "http://www.xxx.com/notifyurl.jsp?order_id=23876412" ><! --This tells PayPal the communication URL of the payment, that is, when the customer pays the call to the URL notification system--
- <input name= "paypal" type= "button" value= "Go to Paypal" onclick= "JavaScript:this.form.submit ();" ></td>
- </form>
- </body>
When generating the PayPal form above, [Cmd],[action],[business],[amount], [currency_code],[notify_url] parameter settings are absolutely not error, [CMD] and [action] Specify the Paypaly interface type, [business] error, you will not receive the customer's payment, [amount] and [Currency_code] relate to the amount of the order, [Notify_url] is the system with PayPal's payment notification interface URL.
When the customer orders to see the page above, they can connect to the PayPal.com website by setting the button [Go to Paypal] and then sign in and make payment.
(2) PayPay return payment information to the system
When the customer pays, PayPal will automatically invoke the [Notify_url] provided in the form above, and here is an example of [notifyurl.jsp]:
HTML code
- <%@ page contenttype= "text/html;charset=utf-8"%><%@ page import= "Com.soft4j.NotifyUrlMgr"%><%
- String ret = notifyurlmgr.insert (request);
- if (ret==null) {out.print ("OK");} Else{out.print ("fail");}
- %>
If you confirm receipt of customer payment information from PayPal, then return "OK" so that PayPal knows the system has received the information, otherwise return "fail", so PayPal will be sent again after a period of time. In fact, only when PayPal receives the "OK" return information will not stop sending payment information, otherwise it will automatically call the above every interval of time
[Notify_url] Communication interface.
(3) The system processes the payment information sent by PayPay
Java code
- /*
- * Created on 2005-6-12
- * Author Stephen
- * Email zhoujianqiang at gmail DOT com
- * CopyRight (C) 2005-2008, All rights reserved.
- */
- Package com.soft4j;
- Import java.sql.Connection;
- Import java.sql.SQLException;
- Import java.util.Enumeration;
- Import Java.util.Vector;
- Import Javax.servlet.http.HttpServletRequest;
- /**
- * PayPal payment notification interface.
- *
- * @author Stephen
- * @version 1.0.0
- */
- Public final class Notifyurlmgr {
- Public static String insert (HttpServletRequest httprequest) {
- //define variables and perform necessary initialization work
- Enumeration parameternames = null;
- String parametername = null;
- String parametervalue = null;
- int count = 0;
- vector[] params = null;
- Vector vparametername = new vector ();
- Vector vparametervalue = new vector ();
- //Determine if PayPal payment account is correct
- String business = Httprequest.getparameter ("Business");
- if (! " [Email protected] ". Equals (Business)) {
- System.out.println ("Gu:wrong receive PayPal Email:" +business);
- return null;
- }
- try {
- String orderId = Httprequest.getparameter ("order_id");//Order number
- if (orderid==null| | "". Equals (orderId)) orderid= "-1";
- Parameternames = Httprequest.getparameternames ();
- Boolean isprint = false;
- While (Parameternames.hasmoreelements ()) {//loops over all parameter information sent by PayPal
- ParameterName = (String) parameternames.nextelement ();
- ParameterValue = Httprequest.getparameter (parametername);
- if (parametervalue==null) parametervalue= "";
- Vparametername.add (parametername);
- Vparametervalue.add (ParameterValue);
- count++;
- }
- //Add the processing of the received information here: Generally, this information is stored in the database and then processed by the customer's order.
- return null;
- } catch (Exception e) {
- return e.tostring ();
- } finally {
- //
- }
- }
- }
In this way, the system can automatically track the payment of the customer's order and make the order processing quicker.
Appendix:
[1] paypay allowed currency
AUD Australian Dollar
CAD Canadian Dollar
CHF Swiss Franc
CZK Czech Koruna
DKK Danish Krone
EUR Euro
GBP Pound Sterling
HKD Hong Kong Dollar
HUF Hungarian forint
JPY Japanese Yen
NOK Norwegian Krone
NZD New Zealand Dollar
PLN Polish zloty
SEK Swedish Krona
SGD Singapore Dollar
USD U.S. Dollar
[2] The parameter meaning of PayPal payment information:
Https://www.paypal.com/IntegrationCenter/ic_ipn-pdt-variable-reference.html
[3] The PDF document of the development API provided by PayPal
PP_OrderManagement_IntegrationGuide.pdf.zip [can be downloaded in the attachment]
[4] The parameters and meanings (i.e. the parameters that you need to set in the form form that you submit to PayPal) are supported by PayPal's payment submission
Https://www.paypal.com/IntegrationCenter/ic_std-variable-reference.html
[5] PayPal Displays the language setting of the page (that is, the language that opens the PayPal website). It needs to be set with parameter locale.x, but this parameter is not in the parameter table provided by PayPal (see [4] above).
HTML code
- <form name= "PayPal" action= "Https://www.paypal.com/cgi-bin/webscr?locale.x=zh_HK" method= "POST" >
- ...
- </form>
LOCALE.X=ZH_HK Traditional Chinese
LOCALE.X=EN_GB English
If your e-commerce system is not a Java environment, you can also refer to the above content.
[Label] Reproduced [Web language settings for the Paypal]paypal online payment interface