在PayPal Express Checkout之后重定向父页面

abi*_*eez 3 javascript servlets paypal spring-mvc

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

用户成功付款后,以下代码关闭PayPal迷你浏览器.

// 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>");
Run Code Online (Sandbox Code Playgroud)

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

abi*_*eez 5

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

    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;
        }
    }
};
Run Code Online (Sandbox Code Playgroud)