I'm trying to implement adaptive payments as embedded payment with lightbox.
It works fine until a user makes a payment, but after user completes the payment
page specified by return url
gets loaded within the iframe.
I'm expecting it to be loaded in the window NOT in the iframe.
Following is the code that I have. Am I missing something?
Environment
Java(play framework)
PayPal_Platform_Java_SDK_N
Expected Page Transfer Scenario
PageA - ("pay with paypal" button click)
→ paypal dialog - ("close" button click)
→ PageB
PageA.html
<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame">
<dl>
<dt></dt>
<dd>
<input id="type" type="hidden" name="expType" value="light">
<input id="paykey" type="hidden" name="paykey" value="AP-KEY">
<input type="submit" id="paypalSubmitBtn" value="Pay with paypal" />
</dd>
</dl>
</form>
<script type="text/javascript">
var dgFlow;
$(function(){
dgFlow = new PAYPAL.apps.DGFlow({ trigger: 'paypalSubmitBtn' });
});
</script>
PageB.html
<p>Thank you for your payment!</p>
<script type="text/javascript">
function handleEmbeddedFlow() {
if (top && top.opener && top.opener.top) {
top.opener.top.dgFlow.closeFlow();
}
else{
top.dgFlow.closeFlow();
}
top.close();
}
jQuery.event.add(window, "load", function(){
alert("window.load");
handleEmbeddedFlow();
});
</script>
I also noticed that dgFlow
can not be resolved in else case's top.dgFlow.closeFlow();
in PageB.html.
You can try to detect if the page is running in an iframe, and if so redirect to the page directly.
How to detect: How to identify if a webpage is being loaded inside an iframe or directly into the browser window?
How to redirect: Redirect the parent page from IFrame
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With