I am using the Square api in a node.js backend (square - npm) to create credit card payments using the paymentsApi.createPayment()
method as a promise and using a .then()
block to handle success and a .catch()
block to handle failure.
Infrequently this call will take longer than 3000ms, which is the timeout I passed in when creating the Client. When that happens, an error is thrown and caught by my .catch()
block and the user trying to process a card is told something went wrong and to try again.
The problem, though, is that in those cases the card actually does eventually run, but we don’t process the success. So, our software doesn’t record that a successful transaction occurred, and the user doesn’t realize they were successful so they try again. We figure it out because, of course, we have duplicate card transactions from the user running the card repeatedly.
Obviously, I can increase the timeout length to have fewer of these happen, but that is messy. Is there a way to cancel the api call if it times out? This seems like a huge hole in the node.js SDK that it will throw a timeout error while simultaneously actually successfully running the card.