5

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.

Josh
  • 8,082
  • 5
  • 43
  • 41
TAT
  • 113
  • 1
  • 6
  • I'm just interested if other developers who try the same thing have succeeded this.... – TAT Feb 20 '12 at 15:42
  • 1
    okay, got the lightbox working, but as mentioned the mini browser will most likely display for 90% of users because who actually remains logged into PayPal? I am getting the same result as you, the returnUrl and cancelUrls appear in the IFrame. Very annoying. Did you find a fix for this? Is it possible to get the url of the IFrame before closing it? – Jordan May 23 '12 at 17:42

1 Answers1

2

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

Community
  • 1
  • 1
Sire
  • 4,086
  • 4
  • 39
  • 74