cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to read Relay Response POST Data in ASP.NET

I am using SIM, trying to get relay_response to work on a test account with an ASP.NET 2.0 application.  It is displaying the response URL page fine, but there is no data displayed... it's as if there was no form data posted to it at all, the same as if you just typed in the URL.

 

However, when I use https://developer.authorize.net/tools/paramdump/ as the response url I can see the posted data, so I know the problem is probably not with Authorize.net.  However, when I post to my response page from a test page, it does recognize and display the posted data, so I know the page is handling the posted data correctly.  

This is the test page that DOES work... the response page does display the posted data:

 

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
<form id="form1" runat="server"  method='post' action="http://localhost/www.faea.org/FAEAWeb/TransSuccess.aspx">
<input type='hidden' runat="server" name='x_response_code' id='x_response_code' value="1" />
<input type='hidden' runat="server" name='x_response_reason_text' id='x_response_reason_text' value='Test response reason text' />
<input type='hidden' runat="server" name='x_description' id='x_description' value="Test Description" />
<input type='submit' runat="server" id='buttonLabel' />
</div>
</form>
</body>
</html>

 

But for some reason, whenever Authorize.net posts to my response page after a transaction, the page comes up but with none of the POST data.  

 

I have disabled viewStateMAC in the Page directive.  I'm not behind a firewall other than the Windows 7 firewall.  I'm running IIS 7 and the application is using ASP.NET 2.0.   I'm not getting any error messages anywhere, it's just displaying my response page with all the data fields empty. 

 

Here is my ASP.Net script that is handling the relay response page:

 

 

 

  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Response.Expires = 0  '--I've tried with and without the Response.Expires

            Dim s_x_response_code As String = ""
            If Not String.IsNullOrEmpty(Request.Form("x_response_code")) Then
                s_x_response_code = Request.Form("x_response_code")
            End If

            Dim n_x_response_reason_code As Integer = 0
            If Not String.IsNullOrEmpty(Request.Form("x_response_reason_code")) Then
                n_x_response_reason_code = CInt(Request.Form("x_response_reason_code"))
            End If

            Dim s_x_response_reason_text As String = ""
            If Not String.IsNullOrEmpty(Request.Form("x_response_reason_text")) Then
                s_x_response_reason_text = Request.Form("x_response_reason_text")
            End If

            Dim s_x_auth_code As String = ""
            If Not String.IsNullOrEmpty(Request.Form("x_auth_code")) Then
                s_x_auth_code = Request.Form("x_auth_code")
            End If

            Dim s_x_invoice_num As String = ""
            If Not String.IsNullOrEmpty(Request.Form("x_invoice_num")) Then
                s_x_invoice_num = Request.Form("x_invoice_num")
            End If

            Dim s_x_description As String = ""
            If Not String.IsNullOrEmpty(Request.Form("x_description")) Then
                s_x_description = Request.Form("x_description")
            End If

            Dim s_x_amount As String = ""
            If Not String.IsNullOrEmpty(Request.Form("x_amount")) Then
                s_x_amount = Request.Form("x_amount")
            End If

            If s_x_response_code = "1" Then
                UpdateTransaction(s_x_invoice_num)
                lblDescription.Text = "TRANSACTION APPROVED!! <BR /> A receipt has been sent to the e-mail address you provided on the previous screen.<br /><br />" & _
                    s_x_description & "<br />Total Amount: " & s_x_amount & "<br />Approval Code: " & s_x_auth_code
            Else
                lblDescription.Text = "YOUR CARD HAS BEEN DECLINED!!!!<BR />" & s_x_response_code & "<br />" & s_x_response_reason_text & "<br /><br />"
               
            End If
        End Sub

 

 

In searching these forums, I found that someone was told by Authorize.net support that you can't use ASP.NET with Relay Response, you have to use classic ASP (which I really don't want to do), but others have gotten it to work using EnableViewStateMAC="false" so I do have hope that this is possible and there is just something else that I haven't thought about yet.

 

Any help would be greatly appreciated!!!!

 

 

joshbula99
Contributor
46 REPLIES 46

Hi,

I have tried the following solution as specified in forum,Still am not able to redirect to my website pageusing relay url.I have set the enableviewstateMAC=false in all pages.here is my code.Please let me know where am doing the mistake.

 

my code behind

btnSubmit.PostBackUrl = "https://test.authorize.net/gateway/transact.dll";

strAuthorizeNet_x_amount = row["Amount"].ToString();
strAuthorizeNet_x_login = "************";
strAuthorizeNet_x_first_name = userRow["FirstName"].ToString();
strAuthorizeNet_x_last_name = userRow["LastName"].ToString();
strAuthorizeNet_x_address = userRow["Address1"].ToString();
strAuthorizeNet_x_city = userRow["City"].ToString();
strAuthorizeNet_x_state = userRow["State"].ToString();
strAuthorizeNet_x_zip = userRow["PostalCode"].ToString();
strAuthorizeNet_x_relay_url = "http://localhost:54269/WebForm2.aspx";
Random random = new Random();
strAuthorizeNet_x_fp_timestamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();
strAuthorizeNet_x_fp_sequence = (random.Next(0, 1000)).ToString();
strAuthorizeNet_x_relay_response = "TRUE";
strAuthorizeNet_x_test_request = "TRUE";
strAuthorizeNet_x_fp_hash = HMAC_MD5("***************", strAuthorizeNet_x_login + "^" + strAuthorizeNet_x_fp_sequence + "^" + strAuthorizeNet_x_fp_timestamp + "^" + decimal.Parse(strAuthorizeNet_x_amount) + "^");

 

 

Whenever i submit the form with the post data am getting the following error

 

An error occurred while trying to report this transaction to the merchant. An e-mail has been sent to the merchant informing them of the error. The following is the result of the attempt to charge your credit card.

      This transaction cannot be accepted. 

Please help me out to solve this issue.

Problem is your relay response URL

From

http://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/Relay-Response-Basics-a...

If the merchant’s Web server is not available on the public Internet, has authentication enabled, or if the Relay URL uses a non-standard port for HTTP or HTTPS traffic, Relay Response timeouts will occur. Authorize.Net will not have any means to connect to your server or authenticate itself on your server, and can only use ports 80 and 443 for all Web traffic

Hi,

 

As suggested we have hosted the project in webserver and we are able to redirect the page as configured in relay response url.Please help me out how to receive the relay response for the request in C#.Based on the response we need to redirect to the URL.

Hi ,
My requirement is once the payment is done the site should be redirected to update the transaction in databased based on the response , If this can be achieved by relay url, plz provide the sample.If not plz provide the sample to receive the response of the payment , based on the response updation has to be triggered in the database

btnSubmit.PostBackUrl = "https://test.authorize.net/gateway/transact.dll";
strAuthorizeNet_x_amount = row["Amount"].ToString();
strAuthorizeNet_x_login = "************";
strAuthorizeNet_x_first_name = userRow["FirstName"].ToString();
strAuthorizeNet_x_last_name = userRow["LastName"].ToString();
strAuthorizeNet_x_address = userRow["Address1"].ToString();
strAuthorizeNet_x_city = userRow["City"].ToString();
strAuthorizeNet_x_state = userRow["State"].ToString();
strAuthorizeNet_x_zip = userRow["PostalCode"].ToString();
strAuthorizeNet_x_relay_url = "http://localhost:54269/WebForm2.aspx";
Random random = new Random();
strAuthorizeNet_x_fp_timestamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();
strAuthorizeNet_x_fp_sequence = (random.Next(0, 1000)).ToString();
strAuthorizeNet_x_relay_response = "TRUE";
strAuthorizeNet_x_test_request = "TRUE";
strAuthorizeNet_x_fp_hash = HMAC_MD5("***************", strAuthorizeNet_x_login + "^" + strAuthorizeNet_x_fp_sequence + "^" + strAuthorizeNet_x_fp_timestamp + "^" + decimal.Parse(strAuthorizeNet_x_amount) + "^");


Am not sure whether am following the correct mechanism.Please help me out to solve this issue.

Yes, you can use relay response url page to first update the database that do a javascript redirect.

authorize.net didn't have any sample code but you modify the example post here

http://community.developer.authorize.net/t5/Integration-and-Testing/Unable-to-read-Relay-Response-PO...

Hi ,

 

I have integrated the payment response codein my application and configured the receipt /Relay URL in my settings test mode.But am getting the error as 

"Response Code 3 TEST MODE The referrer relay response or receipt link URL is invalid authorize net".

 

My URL Is:http://www...............com/testpayment/thanks.aspx

 

Please let me know  where am i doing wrong.

 

You need to set the relay response URL in the merchant account. Login to the account and it under settings.

I configured the same under settings but still I am facing the error.

http://developer.authorize.net/tools/responsereasoncode/

put in 14

 

you must be sending something different. are you hardcode the url or a variable? do you only have 1 account or multiple?