05-09-2013 11:41 PM
I have a problem with interacting with a child window.
I developed an app with phonegap (2.7.0) and I'm trying to realise a paypal payment within my app.
This require to open a child window to display the Paypal login and after verification paypal redirect me to whatever I want.
My problem is that I have no ways to know when the transaction is complete and when to close the window.
Ideally, I would like to read the url inside the childwindow to act accordingly but once I've opened my window, i can't do anything in it.
Here is my call:
childwindow = window.open('https://www.sandbox.paypal.com/webscr?cmd=_express
My childwindow object contains handlers for loadstart, loadstop and exit.
I'm suspecting that the inAppBrowser from phonegap is just useless and prevent me from using the proper webworks childbrowser.
Has anyone had this problem before ?
Solved! Go to Solution.
05-10-2013 04:15 PM
Check out this sample here:
PayPal will likely have a URL that it redirects to / some token that gets appended to that URL. You can monitor via setInterval to see what the URL of the childWindow currently is and, once it matches what you're waiting for (i.e. the success page), you can close the childWindow programmatically.
05-11-2013 04:10 AM
Hi Erik, Thanks for your answer.
I finally solved my problem: the new phonegap feature inAppBrowser.
Since cordova 2.3.0, they introduced a childBrowser based on one of the previous plugins. Problem is, if it work pretty well on Android and iOS, they didn't spent any time at all on Blackberry I'd say. Their instance override the webworks one, but on this one, you can't execute any code in the child window, therefore no way to know the currently location.
I stripped down that inAppBrowser in the cordova code to fallback on the webworks one on blackberry and everything's fine now: finally access to the location.href and use a setInterval to close the window after redirection as suggested by Erik.
Hope this will help people with that issue too.