2016-10-08 3 views
2

웹 사이트에서 새로운 지불 옵션을 만들고 있습니다. 저는 사각형 공간을 성공적으로 구현했습니다. 그러나 어떤 사람이 장바구니에서 물건을 지울 때 문제가됩니다.ajax로 결제 게이트웨이 양식 정사각형

ajax가 호출되면 전체 내용을 다시로드합니다. 하지만, 형태는로드 내가 게이트웨이 문서에서 제공하는 기본 코드를 사용하고 console error undefined object SqPaymentForm.

var sqPaymentForm = new SqPaymentForm({ 

    // Replace this value with your application's ID (available from the merchant dashboard). 
    // If you're just testing things out, replace this with your _Sandbox_ application ID, 
    // which is also available there. 
    applicationId: '***********', 
    inputClass: 'sq-input', 
    cardNumber: { 
    elementId: 'sq-card-number', 
    placeholder: "0000 0000 0000 0000" 
    }, 
    cvv: { 
    elementId: 'sq-cvv', 
    placeholder: 'CVV' 
    }, 
    expirationDate: { 
    elementId: 'sq-expiration-date', 
    placeholder: 'MM/YY' 
    }, 
    postalCode: { 
    elementId: 'sq-postal-code', 
    placeholder: 'Postal Code' 
    }, 
    inputStyles: [ 

    // Because this object provides no value for mediaMaxWidth or mediaMinWidth, 
    // these styles apply for screens of all sizes, unless overridden by another 
    // input style below. 
    { 
     fontSize: '14px', 
     padding: '3px' 
    }, 

    // These styles are applied to inputs ONLY when the screen width is 400px 
    // or smaller. Note that because it doesn't specify a value for padding, 
    // the padding value in the previous object is preserved. 
    { 
     mediaMaxWidth: '400px', 
     fontSize: '18px', 
    } 
    ], 
    callbacks: { 
    cardNonceResponseReceived: function(errors, nonce, cardData) { 
     if (errors) { 
     var errorDiv = document.getElementById('errors'); 
     errorDiv.innerHTML = ""; 
     errors.forEach(function(error) { 
      var p = document.createElement('p'); 
      p.innerHTML = error.message; 
      errorDiv.appendChild(p); 
     }); 
     } else { 
     // This alert is for debugging purposes only. 
     alert('Nonce received! ' + nonce + ' ' + JSON.stringify(cardData)); 

     // Assign the value of the nonce to a hidden form element 
     var nonceField = document.getElementById('card-nonce'); 
     nonceField.value = nonce; 

     // Submit the form 
     document.getElementById('form').submit(); 
     } 
    }, 
    unsupportedBrowserDetected: function() { 
     // Alert the buyer that their browser is not supported 
    } 
    } 
}); 

표시하지 않습니다. 지불 옵션은 이벤트 매니저 프로의 애드온입니다. 당신이

<script type="text/javascript" src="https://js.squareup.com/v2/paymentform"></script>

은 또한 광장과 Squarespace는 매우 다른 회사 참고이 라인을 포함하도록 잊어 버린 것처럼

답변

0

는 것 같습니다.

+0

답변 해 주셔서 감사합니다. 나는 이것을 포함하고있다. 내가 아약스와 함께로드하려고하면 작동하지만 아약스로로드되지 않습니다. 아약스로 양식에 전화를하십시오. 죄송합니다 광장과 광장 공간에 대한 내 실수입니다. –

+0

아약스로 외부 라이브러리를로드하는 경우 라이브러리가로드 될 때까지 'var sqPaymentForm = new SqPaymentForm ({...') 코드 실행을 지연해야합니다. 외부 스크립트가 지연되었지만 의존하는 일부 코드로 실행이 계속됩니다. – tristansokol

+0

지연을 시도하지만 콘솔의 메시지가 표시되지만 폼이로드되지 않습니다. 또한 eval도 시도하지만 그 또한 그렇지 않습니다. 마지막으로 그것을 확인하고 ajax로 그 작업이 더 나은 방법인지 제안 할 수 있습니까? –

관련 문제