Need to get CardNonce and CANNOT get Callback?

2019-09-12 07:37发布

问题:

I'm trying to follow this example to submit credit card information and get back a CardNonce.

https://docs.connect.squareup.com/articles/adding-payment-form/

The form works. I can enter in all the information. I press the button and the function requestCardNonce() IS getting called because I inserted a debug statement to bring up a message box window.alert("IN requestCardNonce"); and it shows up after I click the button.

HOWEVER, I cannot seem to get cardNonceResponseReceived to work after I click the button. I put in windows.alert message boxes in that function and it never fires. The browser processes like it's connecting to the server and the text boxes reset but I can't seem to get the cardNonceResponseReceived() callback to fire.

What might I be missing? I copied the example almost verbatim with the exception of message box alerts. I inserted my applicationId from Square, and even if I didn't, I would still expect the callback to fire but populate errors.

回答1:

Looks like the problem was I was putting the following code usually generated form ASP.NET around my page elements and that was causing the issue.

<form id="form1" runat="server">
</form>

After I removed that, it started working.