close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to display Authorize.net failure response on checkout_failure page

Thread began 11/09/2010 5:40 pm by SaladoGuy | Last modified 11/11/2010 4:48 pm by Dave Buchholz | 2756 views | 14 replies |

SaladoGuyBeta Tester

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"]; ?>&nbsp;<?php echo $_POST["rsubcode"]; ?>&nbsp;<?php echo $_POST["rreasoncode"]; ?>&nbsp;<?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.

Sign in to reply to this post

Dave BuchholzBeta Tester

This is how I do it on the Cotswold Site

We're sorry, your transaction could not be completed for the following reason:<br /> <span><?php echo(AuthNet_Result("Response Reason Text")) ?>
Sign in to reply to this post

SaladoGuyBeta Tester

Originally Said By: Dave Buchholz
  This is how I do it on the Cotswold Site

We're sorry, your transaction could not be completed for the following reason:<br /> <span><?php echo(AuthNet_Result("Response Reason Text")) ?>
  



Hi Dave,

I tried that code in checkout_failure.php and it still didn't work ... I must be missing something. Is there an include I need to put at the top of the checkout_failure page in order for it to access this information?

In other words how do I make sure php has access to the AuthNet_Result function and how do I make sure that it's initialized properly (in the sense of getting the authnet response assigned to the variables).

I'm brand new to all of this so please assume that I don't know anything :-)

I have x_test_request set to FALSE and x_relay_response set to TRUE in confirm.php. Is there anything else I need to set? Is there anything I need to configure in my authorize.net account settings?

I'm using the test card number 4222222222222 to make it fail.

Thanks

Sign in to reply to this post

Dave BuchholzBeta Tester

have you got this include on your page ?

php:
<?php

require_once("WA_eCart/Adv_CO_Scripts/AuthNet_PHP.php");
?>
Sign in to reply to this post

tom92909Beta Tester

The following defines Authorize.net FULL TEXT responses...

Primer: The first digit: "**1**":1:1:This transaction has been approved

1 = approved
2 = declined
3 = error
4 = under review

Those are the only possible response codes that you will receive from Authorize.net

Sign in to reply to this post

SaladoGuyBeta Tester

Originally Said By: tom92909
  The following defines Authorize.net FULL TEXT responses...

Primer: The first digit: "**1**":1:1:This transaction has been approved

1 = approved
2 = declined
3 = error
4 = under review

Those are the only possible response codes that you will receive from Authorize.net  



OK Tom, I appreciate that. Still, my problem is I don't know how to "get" those values so that I can do something with them. Am I supposed to extract them out of the session variable WAAuthNet ?

Sign in to reply to this post

tom92909Beta Tester

In your confirm page, you'll want to store these to responses from Authorize.net...

"".(AuthNet_Result("Response Reason Text")) .""
"".(AuthNet_Result("Full Response")) .""

It's been awhile since I did this, but I want to say that the "".(AuthNet_Result("Full Response")) ."" will general a number and the FIRST digit will provide you with what you're looking for...

1 = approved
2 = declined
3 = error
4 = under review

Sign in to reply to this post

tom92909Beta Tester

I just checked two of my client sites... I found (6) different results.

"".(AuthNet_Result("Response Reason Text")) ."" will provide the following possible outputs.

This transaction has been approved.
The transaction resulted in an AVS mismatch. The address provided does not
A valid amount is required.
Credit card number is required.
The card code is invalid.
This transaction has been declined.

Sign in to reply to this post

SaladoGuyBeta Tester

Originally Said By: tom92909
  In your confirm page, you'll want to store these to responses from Authorize.net...

"".(AuthNet_Result("Response Reason Text")) .""
"".(AuthNet_Result("Full Response")) .""  



I'm sorry but I'm such a newbie that I don't know what exactly "store these to responses " means in precise technical terms.

Are you saying that I should post these as the value of a hidden field to the next page?

Something like this?:

<input name="fullresponse" type="hidden" id="fullresponse" value="<?php echo(AuthNet_Result("Full Response")) ?>" />

This is similar to what I had before: in confirm.php I put a bunch of these things in hidden fields:
<input name="rcode" type="hidden" id="rcode" value="<?php echo(AuthNet_Result("Response Code")) ?>" />

And then on the checkout_failed page I tried to echo the $_POST but it did not work.

I'm probably misunderstanding something or missing a simple step ... can you enlighten me?

Thanks for all the help.

Sign in to reply to this post

tom92909Beta Tester

In addition to eCart, I also developed an Administrative backend using DataAssist to store all of the sales history into a MySQL table.

I have (2) tables that I write to (storing the data) when a transaction occurs...

php:
$WA_table = "orders";
  $WA_redirectURL = "";
  $WA_indexField = "OrderID";
  $WA_fieldNamesStr = "OrderReferenceID|OrderUserID|OrderShipping|OrderTotal|OrderDate|OrderStatus|ppTransID";

  $WA_table = "orderdetails";
  $WA_redirectURL = "";
  $WA_indexField = "DetailOrderID";
  $WA_fieldNamesStr = "DetailOrderID|DetailProductID|DetailProductName|DetailProductDesc|DetailQuantity|DetailPrice|DetailOption1";



Having said that, this development took me probably 3 months to finish the 1st time I implemented an eCart web application. I too was really new to all of this and many of the concepts were initially hard for me to grasp.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...