Paypal integration in java

I’ve generated some expresscheckout and paypalfunctions classes via wizard, tried to integrate it to my spring mvc app and make it to communicate with sandbox account. I get a success respond and then the generated function wants to redirect to paypal with this piece of code in expresscheckout class:

  //' Redirect to paypal.com            
response.sendRedirect(response.encodeRedirectURL(nvp.get("TOKEN").toString()));

Neveretheless it redirects to something like http://localhost:8080/EC-48480369JN366854F

I’m confused if this is really how it should work or do I have to adjust the code? Is there any decent tutorial, how to integrate it to java projects? All what I’ve found was out of date or for PHP only.

Answer

You probably need to be doing this instead:

//' Redirect to paypal.com
response.sendRedirect(response.encodeRedirectURL("https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + nvp.get("TOKEN").toString()));

(Change www.paypal.com to www.sandbox.paypal.com if you’re testing on the Sandbox.)

Leave a Reply

Your email address will not be published. Required fields are marked *