3

我在使用 PayPal Adaptive Payments API 时遇到了一些非常烦人的问题。我正在尝试将付款嵌入到灯箱 iframe 中,我已经按照说明实施了所有操作。当我去付款时,点击按钮,灯箱 iframe 打开,我执行付款没有问题。但是,如果我取消付款或通过付款并调用 paymentSuccess,则结帐页面会加载到 iframe 中,而 iframe 不会关闭。paymentCanceled 根本没有被调用,因为应该提醒的pino没有显示出来。

我正在向您展示一些代码,但事实是它取自尚未工作的 Wordpress 插件,因此我无法向您展示页面的“工作版本”。无论如何,如果您需要更多详细信息,请询问,我会尽力提供。

贝宝 javascript

 <script type="text/javascript" charset="utf-8">
            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);
   </script>

谢谢你们!

4

1 回答 1

4

我的问题解决了。这是代码:

jQuery(document).ready(function($) {
   //Manage the closing of the iframe when payment is executed/canceled
   if (window != top) {
      top.location.replace(document.location);
   }
}

//Initialize PayPal embedded payment flow. Now loading it on document ready so that we only have it if user prepares payment, not just loads the page...
var dgFlow = new PAYPAL.apps.DGFlow({trigger: 'post_pay_counter_paypal_execute_payment'});
于 2012-09-29T09:47:58.230 回答