So you see the failure message?
I'm sure you can get rid of:
$nextIndex = count($AuthNet_required);
$AuthNet_required[$nextIndex] = "x_type";
$AuthNet_required[$nextIndex] = "AUTH_CAPTURE";
But other than that it does look correct to me. Next I would check the session to see if you get an intelligent error message that might help you track down the problem. If you want to do a premier support ticket I could help you debug this.
before the echo to see what is in the response that might be helpful to track down what is wrong.