Jarek
Jarek

Reputation: 7729

Spring MVC - Post redirect (PayPal related)

I need to solve a problem with POST redirect in Spring MVC application.

PayPal lets you to place a simple html form that can redirect to PayPal pages with post. But I need to perform some actions in application after user clicks the PayPal button, but before actual action is taken.

So i was thinking about doing it like this: place PayPal button on webpage, pointing to local controller. There i would need to make some actions like checking whether user is logged to application and if yes then put his email as custom field for PayPal request parameters. If not then log user in and do the previous. After all the information is gathered I need to make post. I know how I could make such a Post, but I need user's web browse to be redirected there. Is there any way to do this?

Upvotes: 1

Views: 923

Answers (1)

Peter Szanto
Peter Szanto

Reputation: 7722

You canno't instruct the user's browser to do redirection and a post, but you can do that with javascript. The flow would be something like this :

  1. User clicks the paypal button
  2. The paypal button sends data to your controller using ajax
  3. your controller returns a success message and any additional information needed
  4. Java script on your page receives the message and redirects to paypal

Upvotes: 1

Related Questions