How to display Authorize.net failure response on checkout_failure page
Hello,
The checkout wizard that generates all the checkout pages makes two final pages (along with all the others) checkout_success.php and checkout_failure.php.
Initially the checkout_failure page just says:
"Transaction Not Completed
We're sorry
Your transaction could not be completed. "
I want to add more detail and have it show the reason the card was declined, if possible.
By searching in the forms I found this thread: showthread.php?t=649&highlight=authorize.net+response
That gives me an idea but I still am not quite sure how to implement this...
In DreamWeaver I see that if I have the checkout_failure page up, there's not really anything in the Bindings panel that I can use, but if I open confirm.php, Bindings contains
something called "Local Checkout Response (Authorize.net)".
What I tried doing is posting all of those as hidden fields in the form, and then echoing the post on the checkout_failure page - but that's not working.
The form code on the confirm.php page looks like this:
<input name="rcode" type="hidden" id="rcode" value="<?php echo(AuthNet_Result("Response Code")) ?>" />
<input name="rsubcode" type="hidden" id="rsubcode" value="<?php echo(AuthNet_Result("Response Subcode")) ?>" />
<input name="rreasoncode" type="hidden" id="rreasoncode" value="<?php echo(AuthNet_Result("Response Reason Code")) ?>" />
<input name="rreasontext" type="hidden" id="rreasontext" value="<?php echo(AuthNet_Result("Response Reason Text")) ?>" />
(that's all just above the buttons for the checkout form)
and the post echo on the checkout_failure page looks like this:
<?php echo $_POST["rcode"]; ?> <?php echo $_POST["rsubcode"]; ?> <?php echo $_POST["rreasoncode"]; ?> <?php echo $_POST["rreasontext"]; ?>
Nothing is actually displayed, so either I'm not handling the echo right, or I'm it's not really getting into the hidden field (which seems more likely ... since the response data can't exist until after the form is posted ... but then how are you suppose to capture the data?).
(BTW ... we do NOT have the AVS service enabled at Authorize.net - but we should still be able to see and print out the reasons the card was declined, right? Or does the x_relay_response only work with AVS?)
I echoed all the session variables on the failure page and i see this (along with the rest):
["WAAuthNet"]=> string(455) "2::1::2::This transaction has been declined.::::U::3281283316::c984cdf88677653a2aea::
What is the proper way to do this? Should I forget the hidden fields and the _POST echo, and parse & echo out of the session variable array instead?
Also I don't quite understand: should x_test_request be set to TRUE or FALSE while I'm doing this - or does it not matter?
BTW I did change x_relay_response to "TRUE" in confirm.php.