【问题标题】:Redirect Parent Page after PayPal Express CheckoutPayPal Express Checkout 后重定向父页面
【发布时间】:2013-03-21 12:22:48
【问题描述】:

我有一个父页面,上面有PayPal 按钮。按下按钮将触发一个迷你浏览器,用户可以在其中登录并付款。

以下代码在用户支付成功后关闭 PayPal mini 浏览器。

// Add javascript to close Digital Goods frame. You may want to
                // add more javascript code to
                // display some info message indicating status of purchase in
                // the parent window
                response.setContentType("text/html");
                response.getWriter()
                        .println(
                                "<script>\n alert(\"Payment Successful\");\n// add relevant message above or remove the line if not required \n window.onload = function(){\nif(window.opener){\nwindow.close();\n}\nelse{\nif(top.dg.isOpen() == true){\ntop.dg.closeFlow();\nreturn true;\n}\n}\n};\n</script>");

迷你浏览器已成功关闭,但我的应用程序上的父页面保持不变。如何使用付款状态更新父页面?

【问题讨论】:

    标签: javascript servlets spring-mvc paypal


    【解决方案1】:

    我通过在window.close(); 之前添加以下JS 代码来访问父页面上的表单来解决这个问题。获得表单后,我可以提交页面或显示有关状态的对话框通知。

        window.onload = function() {
        if (window.opener) {
            window.opener.document.forms[0].submit(); // submit form
            window.close();
        } else {
            if (top.dg.isOpen() == true) {
                top.document.forms[0].submit(); // submit form
                top.dg.closeFlow();
                return true;
            }
        }
    };
    

    【讨论】:

      猜你喜欢
      • 2015-03-05
      • 2020-05-20
      • 1970-01-01
      • 2017-04-13
      • 2021-02-25
      • 2016-01-02
      • 1970-01-01
      • 2018-02-09
      • 2011-08-24
      相关资源
      最近更新 更多