title: PayPal embedded payment causes current page to be opened in iframe
body: <p>I am experiencing some really annoying issues with the PayPal Adaptive Payments API. I am trying to embed payments in a lightboxed iframe, I have implemented everything as instructions say. When I go to pay, and click on the button, the lightboxed iframe opens and I execute the payment without problems. However, if I cancel the payment or go through it and get the paymentSuccess called, the checkout page is loaded inside the iframe, which does not get closed. The paymentCanceled is not called at all, since the <em>pino</em> that should be alerted is not shown.</p>
  
  <p>I am showing some code to you, but the fact is that it is taken from a Wordpress plugin that is not yet working and I can not therefore show you a "working version" of the page. Anyway, if you needed some more details, just ask and I will try to make them available.</p>
  
  <p>The PayPal javascript</p>
  
  <pre><code> &lt;script type="text/javascript" charset="utf-8"&gt;
              var dgFlow = new PAYPAL.apps.DGFlow({trigger: 'post_pay_counter_paypal_execute_payment'});
  
              function MyEmbeddedFlow(embeddedFlow) {
                    this.embeddedPPObj = embeddedFlow;
                    this.paymentSuccess = function () {
                         this.embeddedPPObj.closeFlow();
                         // handle payment success here
                         top.close();
                    };
                    this.paymentCanceled = function () {
                         alert('pippo');
                         this.embeddedPPObj.closeFlow();
                         // handle payment cancellation here
                         top.close();
                    }
  
              }
              var myEmbeddedPaymentFlow = new MyEmbeddedFlow(dgFlow);
     &lt;/script&gt;
  </code></pre>
  
  <p>Thank you all!</p>