I am creating a shopping cart application and using paypal as payment gateway integration.
The usual way to checkout is put all the paypal variables in the form as hidden variables and post it to payapl.
For safety reasons, i was trying to post the checkout process to a servlet, intercepted by a filter where i create a custom request object inserting all the paypal values and pass the new request object to the servlet.
Now the servlet has the request object which contains all required paypal parameters.
Is there any way to forward the request to paypal from servlet or a filter.
SCJP 1.5, SCWCD 1.4.
Hanging between Web Services and EJB
If you are thinking about a forward like we do using request dispatcher, then that's not possible. You'll have to connect to Paypal using HttpsURLConnection or a API like Apache HttpClient to make a request to paypal...
Yes it is possible. I have just implemented a code my application where my customer leaves my application site and goes to paypal page. Customer logs in and clicks "I agree" and gets back to my application/site.
I am using Spring framework. The first call that I mentioned above is where Paypal send me a token which I can use to actually charge the customer account. When customers reviews the final order on my site and decides to submit, I use this token and give a call to Paypal to charge the account.
How I am doing this:
Customer chooses option: I want to pay via Paypal. The call comes to my servlet.
Step 1. Get the paypal token. You will need to call the PayPal Api to get the token. Check Paypal developer guide.
Step 2. "Forward" customer to Paypal site by appending the token(REMEBER NEVER SEND PAYMENT INFORMATION IN THE URL.)
Step3: After customer clicks agree on Paypal URL. Paypal automatically redirects the customer to my site. How is that possible. When you requested token number in step one, you pass information such as CancelUrl, SuccessUrl. Paypal uses this url to forward customer back to your site.
So now in my forward URL I have provided logic that if everything was fine then take the customer to the next page.
Step 4. Customer reviews the order and asks to charge the Paypal account. Use the same token number and send a another request to Paypal API to charge the account.
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad: