I use the Paypal Adaptive API. So far I managed to display the paypal page using a lightbox. But I have a problem when trying to close the lightbox. I failed in Step 4
3. Include the PayPal JavaScript functions from dg.js.
</script>
4. Create an embedded flow object and associate it with your payment form or button.
<script>
var dgFlow = new PAYPAL.apps.DGFlow({ trigger: 'submitBtn' });
</script>
After Completing This Task:
On the pages you identify as the return and cancel URLs in the Pay API operation, you must
include the PayPal JavaScript functions from dg.js and close the PayPal window, as in the
following example:
dgFlow = top.dgFlow || top.opener.top.dgFlow;
dgFlow.closeFlow();
top.close();
What I did:
For step 4, I call the following JNSI method:
private native void paypalLight() /*-{
var dgFlow = new $wnd.PAYPAL.apps.DGFlow({
trigger : 'submitBtn'
});
}-*/;
public static native void paypalClose() /*-{
dgFlow = $wnd.top.dgFlow || $wnd.top.opener.top.dgFlow;
dgFlow.closeFlow();
$wnd.top.close();
}-*/;
When I cancel the transaction, the cancelUrl gets called, and the paypalClose method is called. I get the error: (TypeError): $wnd.top.opener is null.
Any ideas?
Thanks