A member of the development team nicknamed Zeo, living in south California sent me an email asking help to solve an issue. In his spare time he was migrating a web store application in Java/Spring 3.1 to the Google App Engine. One of the requirements was to integrate Express Checkout API to streamline the checkout process for buyers of digital goods. PayPal X delivers an open source java toolkit for Google App Engine available on Google Code named paypalx-gae-toolkit, which provides support for the Adaptive Payments APIs. Unfortunatly using the Adaptive Payments API, PayPal redirect page is not designed for mobile, so it creates a bad user experience. Googling the internet Zeo found an entry in the x.commerce forum which talk about this issue.
Currently PayPal don't have a mobile version of Adaptive Checkout, we only provide a full web flow or the embedded checkout flow (lightbox). At the moment the only mobile web solution PayPal offers is Mobile Express Checkout. One alternative is to have the customers sign up to a preApproval, once they set that up you can charge their PayPal account without the need for a redirect to PayPal for each payment. The main issue again with this is that there is no mobile friendly PreApproval flow.
In addition, after reviewing the source code developed by Zeo I realized that most of the application use the Paypal NVP HTTP API to interface the Express Checkout and to adopt the Paypalx GAE toolkit would require major changes to the application and would provide limited support for mobile devices.
The first issue Zeo faced, was an exception raised during the application start up.The problem was related to the xerces.jar included with the Paypal SDK. A solution was to remove the dependency changing the original code :
APICallerBase.java
- protected static void setupHandler(final String message, DefaultHandler handler)
- throws SAXException, IOException {
- ClassLoader cl = APICallerBase.class.getClassLoader();
- URL url = cl.getResource(message);
- SAXParserFactory factory = SAXParserFactory.newInstance();
- try {
- SAXParser saxParser = factory.newSAXParser();
- XMLReader xr = saxParser.getXMLReader();
- xr.setContentHandler(handler);
- xr.parse(new InputSource(url.openStream()));
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- }
- }
EndpointsReader.java
- public void startElement(String uri, String xname, String name, Attributes atts) {
- /* Do not change the original code */
- }
- public void endElement(String uri, String xname, String name) {
- /* Do not change the original code */
- }
Basically it replaces the xerces parser with the SAX Parser included with the Java SDK, which removes the dependency from the library delivered with the Paypal SDK. One less library that needs to be included in the application WEB-INF/lib.
The second issue related to the Google app engine “Black List” , in other words, Java APIs that did not work on GAE. In this case the issue was related to the Apache Http Client dependency, because of the NVPClientSocket class. .
Also in this case, a solution was to remove the dependency from the Apache Http Library (what a shame) and use the Google App Engine's URL fetch service.
Below is the code:
NVPAPICaller.java- public final String call(String payload) throws PayPalException {
- String nvpResponse = "";
- URLFetchService fetcher = URLFetchServiceFactory.getURLFetchService();
- try {
- HTTPRequest request = new HTTPRequest(url, HTTPMethod.POST);
- StringBuffer payloadData = new StringBuffer(payload).append("&").append(header);
- request.setPayload( payloadData.toString().getBytes() );
- HTTPResponse response = fetcher.fetch(request);
- byte[] content = response.getContent();
- // 200, 404, 500, etc
- int responseCode = response.getResponseCode();
- if ( responseCode == HttpURLConnection.HTTP_OK) {
- nvpResponse = new String(content);
- } else {
- throw new FatalException("HTTP Error code " + responseCode + " received, transaction not submitted");
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return nvpResponse;
- }
Another change, was to remove the NVPSSLSocketFactory.java and all the references to the org.apache.commons.httpclient.* in the code.
I packed the changes in a new paypal-base-gae.jar and sent to Zeo to test on the web store: it worked. I explained to Zeo this solution is a workaround, and does not pretend to be "the solution" to run the Paypal API on GAE. He promised me next time I will be in South California we will grab a burger at one of my favorite places Hodads.
Cheers !
I packed the changes in a new paypal-base-gae.jar and sent to Zeo to test on the web store: it worked. I explained to Zeo this solution is a workaround, and does not pretend to be "the solution" to run the Paypal API on GAE. He promised me next time I will be in South California we will grab a burger at one of my favorite places Hodads.
Cheers !
I find this a good read as I have never imagined that migrating Paypal API to the GCE was even possible. Since I am using a PHP epos system for my site, such a move I cannot accommodate due to natural restrictions.
ReplyDeleteAs you find your professional mover, get moving boxes and the necessary paperwork ready, know some moving apps you can find in your app store and the android market to help you move.Moving Checklist app
ReplyDeleteUsing this programming language, software builders can create powerful and efficient software for a number of devices like set-top boxes, printers, peripheral devices for computers, video games, medical equipment, and so much more.forum for software engineers
ReplyDeleteYou created some decent points there. I looked on the web for the issue and discovered most people goes coupled with with all your web site. get paypal money
ReplyDeleteOutbound Jogja
ReplyDeleteOutbound Jogja
Outbound Jogja
Outbound Jogja
Outbound Jogja
Rafting Magelang
Baby Spa Jakarta
ReplyDeleteArung Jeram Magelang
Pijat Bayi Jogja
ReplyDeletePijat Bayi Jogja
Pijat Bayi Jogja
Pijat Bayi Jogja
Outbound Jogja
ReplyDeleteBaby Spa Jogja
Outbound Jogja
Outbound Kopeng
Rafting Jogja
Paintball Jogja
Outbound Bandungan
ReplyDeletePaket Outbound Bandungan
Outbound Jogja
ReplyDeletePaket Outbound Jogja
1 Baby
ReplyDeleteBaby
Outbound
Outbound
Outbound
Baby
Baby
Outbound
2 Baby
ReplyDeleteOutbound
Baby
Outbound
Outbound
Outbound
3 Outbound
ReplyDeleteOutbound
Outbound
Outbound
Outbound
Outbound
Outbound
Outbound
4 Outbound
ReplyDeleteOutbound
Outbound
Outbound
Outbound
Outbound
Baby
Baby
1 Pijat Bayi Jakarta
ReplyDeleteBaby Spa Jakarta
Baby Care Jakarta
Cukur Rambut Bayi Jakarta
Spa Hamil Jakarta
Pijat Melahirkan Jakarta
Pijat Laktasi Jakarta
2 Pregnancy Spa Jakarta
ReplyDeletePijat Bayi Tangerang
Baby Spa Tangerang
Cukur Rambut Bayi Tangerang
Pijat Bayi Depok
Baby Spa Depok
Cukur Bayi Depok
3 Pijat Bayi Bogor
ReplyDeleteBaby Spa Bogor
Cukur Rambut Bayi Bogor
Pijat Bayi Bekasi
Baby Spa Bekasi
Cukur Rambut Bayi Bekasi
Tindik Bayi Jakarta
4 Baby Spa Jakarta Barat
ReplyDeletePijat Bayi Jakarta Barat
Baby Spa Jakarta Selatan
Pijat Bayi Jakarta Selatan
Baby Spa Jakarta Utara
Baby Spa Jakarta Timur
Baby Spa Jakarta Pusat
Pijat
ReplyDeleteBayi Solo
Potong Rambut Bayi Solo
Memandikan Bayi Solo
Pijat Hamil Solo
Pijat Laktasi Solo
Spa
Bayi Solo
Pijat
Nifas Solo
Pijat
Anak Solo
Pijat
Prenatal Solo