Question

My app is built with Rails and I'm using the PayPal Adaptive Payments gem but this question is not specific to Rails so please don't run away, you might be able to answer it.

Users of my app can transfer money from their PayPal account to their UserWallet on my site.

To get to the page where I let them do this they must click on two AJAX links.

Because I'm using the embedded payments flow, the PayPal stuff happens in a nice modal window, but PayPal docs seem to want me to provide a returnURL so that they can perform a GET request on it when the flow completes.

I definitely don't want to redirect the browser window after the Payment has gone through.

Do I have to send a returnURL? I've got an instant payment notifications controller to handle the PayPal response and I can use js.erb to update the page on my site myself meaning that the user won't lose the AJAX state that the calling page is in.

Was it helpful?

Solution

Do I understand you correctly that you're working with Embedded Payments (within a lightbox window) and you simply want to close it rather than redirect anywhere?

If so, all you need to do is prepare a return.rb (or whatever the extension is) with nothing but the PayPal javascript included and the following snippet.

dgFlow = top.dgFlow || top.opener.top.dgFlow;
dgFlow.closeFlow();
top.close();

It will actually redirect to that script, which will immediately close the window leaving the user right back where they were before they started the payment process.

More details are available about your flow options here: https://developer.paypal.com/docs/classic/adaptive-payments/integration-guide/APIntro/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top