不允许使用 Squareup iFrame
Squareup iFrame not allowed
我是 Square 的新手,正在尝试让他们的简单 SqPaymentForm 在 Tomcat/Eclipse/Firefox 下工作。当表单出现时,我收到以下加载被拒绝的错误。 iFrame 似乎可以正常工作,因为我可以在其中输入数据并 post 它。但是,我收到 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 的代码?
我是 Square 的新手,正在尝试让他们的简单 SqPaymentForm 在 Tomcat/Eclipse/Firefox 下工作。当表单出现时,我收到以下加载被拒绝的错误。 iFrame 似乎可以正常工作,因为我可以在其中输入数据并 post 它。但是,我收到 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 的代码?