I have a legacy script for a client that I'm trying to get their original authorize.net coding to work with the new acceptJS coding format.
The following code makes a call out to a credit card processing service (authorize.net). When it returns with validated info, it pops up a dialog box that the person then responds to in order to finalize the processing.
What I need to have this do is to postpone the processing of the popup dialog until I get a valid answer of either "Error" or "Ok" from authnet. Anything else should wait for that reply.
In the script below, the call to auth.net is made on line 23: var resp = sendPay2Auth(apiLoginID, clientID, extr);
On the next line it then looks for the value of resp.respcd. If it says, "Error" it returns false and thus the dialog box does not pop up.
If it returns "Ok" it pops up the dialog box for them to continue.
But the problem is if the call to authorize.net has sent back a response yet, it gives a value of "undefined" in which case it then just does nothing at this point. Which leaves the customer hanging.
So what I'm looking for is how to code this so that the script will just "wait" until it gets back either an "Ok" or and "Error" in the field designated as "resp.respcd" Any insight would be appreciated. Thanks.
I tried to implement what Leonidas D. shared but it didn't resolve the problem. But it then dawned on me like what stated that instead of a popup box, I need to redo the design to put in into the success handler. I will work on that tomorrow. If I can't get it working, I'll update here.
Thanks Julian for the insight.