Squareup iFrame不允许

问题描述:

我是Square新手,试图让他们的简单SqPaymentForm在Tomcat/Eclipse/Firefox下工作。当表单出现时,我得到下面的负载被拒绝的错误。 iFrames似乎能够工作,因为我可以在其中输入数据并发布。但是,我收到2个错误。Squareup iFrame不允许

每次载入表单时,都会收到以下错误消息。我已经尝试在默认的eclipse tomcat web.xml中以及在web应用程序的web.xml中包含安全过滤器设置。我甚至尝试关闭反点顶起,但这也不起作用。

任何建议,将不胜感激......

负载由X框选项否认: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> 

第二届的错误,我得到的是:

// 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(); 
} 

第一回答你的第二个错误:从缴款书 “event.preventDefault()” 产生

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

此错误: 当您拨打requestCardNonce(event)时,您可能在代码中存在错误,因此当您提交表单时,它只会显示requestCardNonce(),而将event变量在函数内部未定义。

你的第一个错误是有点棘手。这听起来像iframe加载,但也有一个错误。如果你可以加载iframe并让它起作用,那听起来像是一场胜利。你可以分享一些有iframe的代码吗?

+0

当然,我可以共享代码,但我不知道如何在这里上传文件。我有一个简单的HTML网页。与此同时,我直接从Square的开发人员网站获取代码。事件参数在默认情况下存在。这里的链接: https://docs.connect.squareup.com/articles/adding-payment-form/?q=embed%20payment%20form – zappullae

+0

是的,看起来像有该文件的错误。但是,您不应该有任何问题处理付款。 – tristansokol

+0

感谢您的帮助。事件是错误吗?我不能把事务放在没有现成的情况下,而且必须来自SqPaymentForm,由于X-Frame的原因,我无法工作。即使我评论出requestCardNonce(事件) – zappullae