title: Embedded Payment return url shown in iframe
body: <p>I'm trying to implement adaptive payments as embedded payment with lightbox.</p>
  
  <p>It works fine until a user makes a payment, but after user completes the payment 
  page specified by <code>return url</code> 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?</p>
  
  <p><strong>Environment</strong><br>
  Java(play framework)<br>
  PayPal_Platform_Java_SDK_N</p>
  
  <p><strong>Expected Page Transfer Scenario</strong><br>
  PageA - ("pay with paypal" button click)<br>
      &rarr; paypal dialog - ("close" button click)<br>
      &rarr; PageB</p>
  
  <p><strong>PageA.html</strong></p>
  
  <pre><code>&lt;form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame"&gt;
    &lt;dl&gt;
      &lt;dt&gt;&lt;/dt&gt;
      &lt;dd&gt;
        &lt;input id="type" type="hidden" name="expType" value="light"&gt;
        &lt;input id="paykey" type="hidden" name="paykey" value="AP-KEY"&gt;
        &lt;input type="submit" id="paypalSubmitBtn" value="Pay with paypal" /&gt;
      &lt;/dd&gt;
    &lt;/dl&gt;
  &lt;/form&gt;
  &lt;script type="text/javascript"&gt; 
    var dgFlow;
    $(function(){
      dgFlow = new PAYPAL.apps.DGFlow({ trigger: 'paypalSubmitBtn' });
    }); 
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>PageB.html</strong></p>
  
  <pre><code>&lt;p&gt;Thank you for your payment!&lt;/p&gt;
  
  &lt;script type="text/javascript"&gt;
    function handleEmbeddedFlow() {
      if (top &amp;&amp; top.opener &amp;&amp; top.opener.top) {
        top.opener.top.dgFlow.closeFlow();
      }
      else{
        top.dgFlow.closeFlow();
      }
      top.close();
    }
  
    jQuery.event.add(window, "load", function(){
      alert("window.load");
      handleEmbeddedFlow();
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>I also noticed that <code>dgFlow</code> can not be resolved in else case's <code>top.dgFlow.closeFlow();</code>  in PageB.html.</p>