Square payment form cannot execute requestCardNonc

2019-09-05 15:58发布

I've also submitted a request to Square support and hope to hear back soon.

Steps to reproduce

Expectation

  • All fields should be highlighted in red to indicate they are required.

Observation

  • Firefox cannot fire the event requestCardNonce() because it is not defined. Error message in Firefox console:

    ReferenceError: event is not defined
    requestCardNonce()    payment:121
    onclick()    payment:1
    
  • Form is submitted to the server with nonce = "" (empty string or NULL).

1条回答
贪生不怕死
2楼-- · 2019-09-05 16:34

Unfortunately, we've published a bug in the documentation We're working on it. Firefox requires an event to be passed as an argument to the function, whereas chrome and safari don't. If you edit the definition of requestCardNonce that you copied from the example to instead be the following, it should work for you:

function requestCardNonce(event) {
  event.preventDefault();
  paymentForm.requestCardNonce();
}

Notice the event argument. That's the part you have to add. Sorry for the confusion. We'll fix the docs.

edited to include a current screenshot as of 2016-08-31 17:04:43. This is the location in the script where you need to add an event argument to the function definition, and then where you need to provide the event argument to the function call on the submit button.

function definition needs event argument function invocation needs event argument

Having added event in both places, using firefox, I've gotten the following with your test form:

enter image description here

查看更多
登录 后发表回答