Reply
Contributor
Posts: 13
Registered: ‎10-21-2013

Re: Unable to read Relay Response POST Data in ASP.NET

Hi,

 

In the following URL  https://www.whatever.com/Thanks.aspx?OrderId=9  '9' May not be static always.

 

In the merchant account relay URL can i give it as  https://www.whatever.com/Thanks.aspx?OrderId={0}

 

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Unable to read Relay Response POST Data in ASP.NET

[ Edited ]

In the merchant account relay URL can i give it as  https://www.whatever.com/Thanks.aspx?OrderId={0}

no

 

Then either you could remove all valid relay url from the account and try it again.

 

or

you can send it as a merchant defined fields

The thing to be careful is make sure it bigger then 4 digit, I think authorize.net will masked it if it think it is a CCV code.

Contributor
Posts: 13
Registered: ‎10-21-2013

Re: Unable to read Relay Response POST Data in ASP.NET

can you please share the sample code to send and receive mercahnt fields.

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Unable to read Relay Response POST Data in ASP.NET

Any fields that are not authorize.net defined(e.g. x_relay_url) is merchant defined fields. And you read it the same way you are reading any of the x_??? response fields on your relay response page.

Highlighted
Member
Posts: 4
Registered: ‎04-30-2014

Re: Unable to read Relay Response POST Data in ASP.NET

[ Edited ]

This is a code sample using ASP.NET Web Forms that I got working using .NET 4.5:

 

<%@ page language="C#" autoeventwireup="true" codebehind="RelayResponse.aspx.cs" inherits="SIM_Example.RelayResponse" EnableViewStateMac="false"  %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Transaction Receipt Page</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body bgcolor="#FFFFFF">
    <form id="form1" runat="server">
        <%
              //Test to see if this is a test transaction.
            if (TransID == "0" && ResponseCode == "1")
            {

                Response.Write("<table align='center'>");
                Response.Write("<tr>");
                Response.Write("<th><font size='5' color='red' face='arial'>TEST MODE</font></th>");
                Response.Write("<tr>");
                Response.Write("<th valign='top'><font size='1' color='black' face='arial'>This transaction will <u>NOT</u> be processed because your account is in Test Mode.</font></th>");
                Response.Write("</tr>");
                Response.Write("</table>");
            }//if
            Response.Write("<br>");
            Response.Write("<br>");
            //Test to see if the transaction resulted in Approval, Decline or Error
            switch (ResponseCode)
            {
                case "1":
                    Response.Write("<table align='center'>");
                    Response.Write("<tr>");
                    Response.Write("<th><font size='3' color='#000000' face='Verdana, Arial, Helvetica, sans-serif'>This transaction has been approved.</font></th>");
                    Response.Write("</tr>");
                    Response.Write("</table>");
                    break;
                case "2":
                    Response.Write("<table align='center'>");
                    Response.Write("<tr>");
                    Response.Write("<th width='312'><font size='3' color='#000000' face='Verdana, Arial, Helvetica, sans-serif'>This transaction has been declined.</font></th>");
                    Response.Write("</tr>");
                    Response.Write("</table>");
                    break;
                default:

                    Response.Write("<table align='center'>");
                    Response.Write("<tr>");
                    Response.Write("<th colspan='2'><font size='3' color='Red' face='Verdana, Arial, Helvetica, sans-serif'>There was an error processing this transaction.</font></th>");
                    Response.Write("</tr>");
                    Response.Write("</table>");
                    break;
            }//switch 

            Response.Write("<br>");
            Response.Write("<br>");

            Response.Write("<table align='center' width='60%'>");
            Response.Write("<tr>");
            Response.Write("<td align='right' width='175' valign='top'>");
            Response.Write("<font size='2' color='black' face='arial'>");
            Response.Write("<b>");
            Response.Write("Amount:" + "</b>");
            Response.Write("</font>");
            Response.Write("</td>");
            Response.Write("<td align='left'>");
            Response.Write("<font size='2' color='black' face='arial'>");

            Response.Write("$" + Amount);
            Response.Write("</td>");
            Response.Write("</tr>");

            Response.Write("<tr>");
            Response.Write("<td align='right' width='175' valign='top'>");
            Response.Write("<font size='2' color='black' face='arial'>");
            Response.Write("<b>");
            Response.Write("Transaction ID:" + "</b>");
            Response.Write("</font>");
            Response.Write("</td>");
            Response.Write("<td align='left'>");
            Response.Write("<font size='2' color='black' face='arial'>");
            switch (TransID)
            {
                case "0":
                    Response.Write("Not Applicable.");
                    break;

                default:
                    Response.Write(TransID);
                    break;
            }//switch 
            Response.Write("</td>");
            Response.Write("</tr>");

            Response.Write("<tr>");
            Response.Write("<td align='right' width='175' valign='top'>");
            Response.Write("<font size='2' color='black' face='arial'>");
            Response.Write("<b>");
            Response.Write("Authorization Code:" + "</b>");
            Response.Write("</font>");
            Response.Write("</td>");
            Response.Write("<td align='left'>");
            Response.Write("<font size='2' color='black' face='arial'>");
            switch (AuthCode)
            {
                case "000000":
                    Response.Write("Not Applicable.");
                    break;
                default:
                    Response.Write(AuthCode);
                    break;
            }//switch 
            Response.Write("</td>");
            Response.Write("</tr>");
            Response.Write("<tr>");
            Response.Write("<td align='right' width='175' valign='top'>");
            Response.Write("<font size='2' color='black' face='arial'>");
            Response.Write("<b>");
            Response.Write("Response Reason:" + "</b>");
            Response.Write("</font>"); Response.Write("</td>");
            Response.Write("<td align='left'>");
            Response.Write("<font size='2' color='black' face='arial'>");
            Response.Write("(" + ResponseReasonCode + ")");
            Response.Write("&nbsp");
            Response.Write(ResponseReasonText);
            Response.Write("</font>");
            Response.Write("<font size='1' color='black' face='arial'>");
            Response.Write("</td>");
            Response.Write("</tr>");
            Response.Write("<tr>");

            Response.Write("<td align='right' width='175' valign='top'>");
            Response.Write("<font size='2' color='black' face='arial'>");
            Response.Write("<b>");
            Response.Write("Address Verification:" + "</b>");
            Response.Write("</font>");
            Response.Write("</td>");
            Response.Write("<td align='left'>");
            Response.Write("<font size='2' color='black' face='arial'>");

            //Turn the AVS code into the corresponding text string.
            switch (AVS)
            {
                case "A":
                    Response.Write("Address (Street) matches, ZIP does not.");
                    break;
                case "B":
                    Response.Write("Address Information Not Provided for AVS Check.");
                    break;
                case "C":
                    Response.Write("Street address and Postal Code not verified for international transaction due to incompatible formats. (Acquirer sent both street address and Postal Code.");
                    break;
                case "D":
                    Response.Write("International Transaction:  Street address and Postal Code match.");
                    break;
                case "E":
                    Response.Write("AVS Error.");
                    break;
                case "G":
                    Response.Write("Non U.S. Card Issuing Bank.");
                    break;
                case "N":
                    Response.Write("No Match on Address (Street) or ZIP.");
                    break;
                case "P":
                    Response.Write("AVS not applicable for this transaction.");
                    break;
                case "R":
                    Response.Write("Retry. System unavailable or timed out.");
                    break;
                case "S":
                    Response.Write("Service not supported by issuer.");
                    break;
                case "U":
                    Response.Write("Address information is unavailable.");
                    break;
                case "W":
                    Response.Write("9 digit ZIP matches, Address (Street) does not.");
                    break;
                case "X":
                    Response.Write("Address (Street) and 9 digit ZIP match.");
                    break;
                case "Y":
                    Response.Write("Address (Street) and 5 digit ZIP match.");
                    break;
                case "Z":
                    Response.Write("5 digit ZIP matches, Address (Street) does not.");
                    break;
                default:
                    Response.Write("The address verification system returned an unknown value.");
                    break;
            }//switch 
            Response.Write("</td>");
            Response.Write("</tr>");
            Response.Write("</table>");
        %>
    </form>
</body>
</html>

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SIM_Example
{
    public partial class RelayResponse : System.Web.UI.Page
    {
        public string ResponseCode, ResponseReasonText, ResponseReasonCode, ResponseSubcode, AVS, ReceiptLink, TransID;
        public string Amount, AuthCode;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Form.Count > 0)
            {
                //Retrieving and defining Form Data from Post command body from Authorize.Net
                ResponseCode = Request.Form["x_response_code"].Trim();
                ResponseReasonText = Request.Form["x_response_reason_text"].Trim();
                ResponseReasonCode = Request.Form["x_response_reason_code"].Trim();
                AVS = Request.Form["x_avs_code"].Trim();
                TransID = Request.Form["x_Trans_ID"].Trim();
                AuthCode = Request.Form["x_Auth_Code"].Trim();
                Amount = Request.Form["x_Amount"].Trim();
                ReceiptLink = "http://www.authorizenet.com";
            }//if

            
        }//event: Page_Load
    }
}

 

It is worthwhile to note that I needed to configure my x_relay_url field BOTH in my SIM Form AS WELL AS in the Authorize.Net Response/Receipt URL settings.

If I did not have them configured in BOTH places, the Relay Response WOULD NOT WORK!!

Member
Posts: 1
Registered: ‎11-21-2014

Re: Unable to read Relay Response POST Data in ASP.NET

Thanks Buddy it saved my lot of time .

Member
Posts: 1
Registered: ‎09-17-2015

Re: Unable to read Relay Response POST Data in ASP.NET