2016-09-20 75 views
0

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

回答

1

第一回答你的第二個錯誤:從繳款書 「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