Short Version: You’re trying to send the request before you get the authKey back. You need to move $REQUEST.doPayment into the callback function of the ajax request.
So let’s say we do this:
This is where the issue comes in, which is something like this:
I hope this helps clarify things. Please let us know if you need any additional information or assistance. You are welcome to post here in the forums or to contact us directly at [email protected].