tomcat - 不允许使用 Squareup iFrame

标签 tomcat iframe square-connect

我是 Square 的新手,正在尝试让他们的简单 SqPaymentForm 在 Tomcat/Eclipse/Firefox 下工作。当表单出现时,我收到以下加载被拒绝的错误。 iFrame 似乎可以正常工作,因为我可以在其中输入数据并发布。但是,我收到 2 个错误。

每次加载表单时,我都会收到以下错误。我已经尝试在默认的 eclipse tomcat web.xml 和 Web 应用程序的 web.xml 中包含安全过滤器设置。我什至尝试过关闭反点击劫持,但这也没有用。

如有任何建议,我们将不胜感激...

X-Frame-Options 拒绝加载:https://connect.squareup.com/v2/logo.html?s=MY-ID不允许跨源框架。

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">

    <filter>
        <filter-name>httpHeaderSecurity</filter-name>
        <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
        <async-supported>true</async-supported>
        <init-param>
            <param-name>antiClickJackingEnabled</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>antiClickJackingOption</param-name>
            <param-value>SAMEORIGIN</param-value>
        </init-param>
        <init-param>
            <param-name>antiClickJackingUri</param-name>
            <param-value>https://connect.squareup.com</param-value>
        </init-param>
    </filter>

</web-app>

我得到的第二个错误是:

TypeError: event is undefined
   requestCardNonce()
   TestSquare1.jsp:142
   onclick()

这个错误是由支付表单“event.preventDefault()”产生的:

// This function is called when a buyer clicks the Submit button on the webpage to charge their card.
function requestCardNonce(event)
{
    // This prevents the Submit button from submitting its associated form.
    // Instead, clicking the Submit button should tell the SqPaymentForm to generate
    // a card nonce, which the next line does.
    event.preventDefault();

    paymentForm.requestCardNonce();
 }

最佳答案

首先回答你的第二个错误: 当您调用 requestCardNonce(event) 时,您的代码中可能有错误,当您提交表单时它只显示 requestCardNonce(),留下 event 变量在函数内部未定义。

您的第一个错误有点棘手。这听起来像 iframe 加载,但也有一个错误。如果您可以加载 iframe 并使其正常工作,那对我来说就是一个胜利。您能否分享更多具有 iframe 的代码?

关于tomcat - 不允许使用 Squareup iFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39596239/

相关文章:

jsp - 无法在tomcat中为JSP编译类

java - 外部化 spring boot 配置

javascript - onYouTubeIframeAPIReady 里面 jQuery(document).ready

javascript - SquareUp 支付 : Can we turn off SSL verification for development server?

rest - wso2 esb 捕获 http 请求

tomcat - Jenkins 将 war 文件部署到 Tomcat 8 - 网页显示错误

javascript - 从 iframe 底部隐藏特定区域

html - 我应该在同一域 iframe 中使用 head body 和 title 标签吗?

square-connect - Square Connect API - 如何获取location_id?

ios - 来自 SCCAPIResponse 的付款信息