I have had a problem with impatient users pressing the submit button to create a payment – pressing multiple times while waiting for a ‘success’ message, and thereby creating multiple payments.
I have been adding code to prevent this by disabling the button until the process succeeds or fails
I have been testing and retesting and at the moment I am continually getting INVALID REQUest ERROR messages.
I show a cURL result below,
I have tried using all of the 4 cards I own, all are good, all have been used successfully, some as recently as this morning.
I have found out on my own that sometimes the payment SDK creates the same nonce for a card, and this might be the problem?? reusing a nonce?
Or so many failures as I test outcome success vs outcome failed (by intentionally modifying expdate or CVV?
Any help would be welcome!
Array
(
[errors] => Array
(
[0] => Array
(
[category] => INVALID_REQUEST_ERROR
[code] => INVALID_CARD_DATA
[detail] => Invalid card data.
[field] => source_id
)
)
)
Array
(
[0] => Array
(
[errors] => Array
(
[0] => Array
(
[category] => INVALID_REQUEST_ERROR
[code] => INVALID_CARD_DATA
[detail] => Invalid card data.
[field] => source_id
)
)
)
)
Array
(
[0] => FINAL RESULT card
[1] =>
)
INSERT INTO carderrorlog SET
reservation='39',
person='56',
squareid='YKWN3RNCYRHZ2X5Y9NQ14VKBPW',
cardid='',
nonce='cnon:CA4SECYpdG3csHMBfAcf0nKdhHIYASgB',
result='CARD ERROR NEW person=56, nonce=cnon:CA4SECYpdG3csHMBfAcf0nKdhHIYASgB,
Array
(
[errors] => Array
(
[0] => Array
(
[category] => INVALID_REQUEST_ERROR
[code] => INVALID_CARD_DATA
[detail] => Invalid card data.
[field] => source_id
)
)
)
'
=>
Sorry, we could not confirm your card. Please check your entries.
I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:
Additional Documentation
Troubleshoot In-App Payments SDK Problems
Create a Card on File from a Payment ID
Cards API
If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.
Is the source_id targeting the right environment and was it created with the same app that your trying to charge it? 
I don’t understand the question?
Yes.
FYI, this whole app works just fine sometime with no change in code. In fact too well (multiple unintended duplicate payments)
Also FYI, this from the ‘create card’ cURL - I’m saving ccof responses in ‘user’ database records.
So it seems to be something where nonces are being reused and rejected, or square is sick of me trying and failing to make $1 charges so often.
If Square is closing the card requests down based on some sort of ‘this shouldn’t be happening’ logic, I’d like know.
Also the response snippet in my original post shows the data that was sent that created a failure the cnon nonce and Square ID down near the bottom - INSERT INTO 1carderrorlog`` values
Thanks for your Help.
What’s the application ID your using that is returning this error? 
App ID: sq0idp-afFlPIgpSo21oKNxmDemAA
I’ve been looking into the situation and discovered that I had made a bug that would submit the same request multiple times. The cURL for creating a card would capture the card and place the info in the customer record. If the cURL code didn’t incldue a nonce, it checked if the user had saved a cardid. The cardid got saved when theing worke, and so the payment cURL would file.
What this means is that I have unintentionally created duplicate payment cURLs multiple times. Mostly for $1, but in some cases, much more.
If I were square I’d be shutting this app down.
If that a shut down is what has happened, FYI I have worked all day to discover and fix the problem. I won’t know that is fixed until I can do the process.
Tomorrow I’tl try to use the Sandbox to prove I have fixed the problem. I thought I was smart enough to use production instance. I wasn’t.
Glad to hear you found what you think is the issue. Hopefully the fix goes well. 
I think I wrote a confusing reply.
Just made changes to test this, and my code works ok in SANDBOX mode →get squareid, get card from nonce, make payment using the new card.
But I still can’t process production payments without an INVALID error.
So I think that I may have triggered some internal Square corporate error because of the problems created →Square may be rejecting production cURL activity?
I need to find out if that’s the case, and get help addressing it.
Are you making a lot of requests to CreateCard in a row? 
Probably 200+ requests in the course of debugging and tasting over the during 12 February, many intentionally designed to fail (using a bad CVV). Finally figured out what was causing intended duplicate requests, also figured out to prevent multiple clicks of the ‘Submit’ button,