I am having some problems using the verifyBuyer function to do SCA authentication. There are 3 issues that I am having.
I am in the sandbox. The first time I call the function, the SCA screen appears and prompts me for the code for my test card. I type in 123456 as per the instructions and the function returns the token which I then pass to the Square server and it lets me add the card just fine. This is all working ok.
However, the problems begin when a user either hits the Cancel button on the SCA screen, or if they type in an incorrect code and fail the authentication.
The main issue that I am experiencing is that after a failure (e.g. due to an incorrect code being entered), if the user then tries again for the second time, the verifyBuyer is called again but this time the SCA window never appears and the function never returns. It seems to be going into some kind of infinite loop or it is otherwise waiting for something to happen before it returns but it never happens and so it never returns, no matter how long I wait. From this point onwards, the entire payment system on my app is broken because any subsequent calls to verifyBuyer result in the error ‘An issue occurred while verifying the buyer. A verification request is already in progress’.
The second issue (which might not be an actual issue) is that if the user types in an incorrect code the verifyBuyer still returns a token as if everything was fine, but then when I try adding the card using the token it obviously fails. I can handle this error manually on my server and return an error message, but why is verifyBuyer generating a token when the code is wrong? Should it not be failing and returning an error instead?
The third issue is when the user clicks Cancel. An exception is throw when this happens, which I catch, but then the error message says ‘An issue occurred while verifying the buyer The verification was not successful: verf:CA4SELND5nqtcxHjsKfccwR9cmMgACgB’. This is then displayed to the user on the error box below the card details input. This error seems completely unsuitable though since all the person did was click on Cancel. There should never have been an attempt to verify the buyer when the cancel button was pressed, so why throw an error? Also, why make the error so confusing for the end user? Someone using the site is not going to understand what that error means and it will be confusing to them making them think that verification was attempted and failed even though they cancelled it.
Also, I have also witness the first issue happen (the lock up after subsequent calls to verifyBuyer) after the cancel button has been pressed, but this seems to happen intermittently where as after a failure it happens every single time.