cancel
Showing results for 
Search instead for 
Did you mean: 

SIM Relay Response Redirect results in a 404 error

Hello,

I have integrated using SIM.

 

I have enabled Relay Response.

 

In my web architecture, I have two web applications.  My main business application, and a middle-ware web application to support the payment integration between the biz app and the gateway.

 

When I complete a payment on the hosted payment page, the Relay Response posts to the Relay Response URL on my web application just fine.

 

The final step on the Relay Response URL page is to redirect back to my biz app page.  For some reason this fails with a 404 error, and in the browser address field the Payment Gateway URL is displayed. https://test.authorize.net/gateway/transact.dll

 

The code is simply Response.Redirect(url here) in vb.net (asp.net).  The literal URL for the redirect works just fine if I paste it into my browser in the public internet, so it's not a URL issue.  I can't see a reason for the 404 unless the gateway is refusing to redirect to my page or can't for some reason.

 

Any ideas what could be causing this?

rvonschoech
Contributor
20 REPLIES 20

do a javascript redirect instead on a code behind Response.redirect.

The reason it relay response is like doing a webrequest on your page and using that info to display it on test.authorize.net website.

Are you using https? are you using the absolute path on the response.redirect?

And you have the EnableViewStateMac set to false?

RaynorC1emen7
Expert

Thank you for the assistance. 

 

Are you using https? are you using the absolute path on the response.redirect?

Yes to https, and yes the response.redirect was going to an absolute path beginning with https://www.. full URL to specific page.

 

Do a javascript redirect instead on a code behind Response.redirect.

 

I am still trying to figure out how to do this in my specific configuration.  Let me elaborate and then hopefully you can help me because at the moment I am stuck.

 

And you have the EnableViewStateMac set to false?

 

I have not modified this setting, so it's current state is probably true if that is the default setting

 

The reason it relay response is like doing a webrequest on your page and using that info to display it on test.authorize.net website.

 

So far I have done the following:

1) comment out the response.redirect.  After this, there is no longer a 404 error.

If I place a static URL a href =xxx on the aspx page, then it will display on the authorize.net server as you stated, no error.

 

My current problem is that I need to build the URL dynamically, and then display it for the user to click.  Ideally I would like to automatically redirect the user, but at this point I'll take what I can get because this is the last step in my implementation.

 

What I have tried so far is to create a variable in my code-behind that stores the full URL.

On the aspx page I tried to display at as follows: a href="<%= redirectURL %>">some text here<end a tag>

WHen I try to do the above, I get a timeout error on the page (as opposed to the 404).

 

Even if I do a javascript redirect, I would still like to append a dynamic query string to it ?key=val, before redirecting back to my biz app.

 

Just for full disclosure, on the Relay Response URL I do have business logic that interacts with the biz app server.  This all works great.  The final step is simply to bring the user back to the biz app web server via a redirect (or link if need be) with the dynamic URL I build on the code behind page.

 

I admit my asp is very rusty, so some of this is probably easy to someone who has been working with asp.net more frequently than me.  Thanks in advance for any assistance you can provide.

What I have tried so far is to create a variable in my code-behind that stores the full URL.

On the aspx page I tried to display at as follows: a href="<%= redirectURL %>">some text here<end a tag>

WHen I try to do the above, I get a timeout error on the page (as opposed to the 404).

Set the EnableViewStateMac to false, set in on the relay response url page, some said set it on the form that post to authorize.net too.

 

Then use ClientScript.RegisterStartupScript on the page_load,

ClientScript.RegisterStartupScript(this.GetType(), "scriptid", window.parent.location.href='xxxxxxx'", true);

I have set the EnableViewStateMac to false on both the posting page, and the response page.

 

I am just having no luck getting a redirect to work DYNAMICALLY. 

 

When I try to use the client script manager, I get an email saying the transaction times out and Authorize displays text indicating the payment was successful, but notify the merchant because an error occurred.

 

See below, all I'm trying to do with this is write out some javascript functions, just as a test.  The html on the aspx does not use these in any way.

 

If I comment out the registerstartup and registert client calls, my page displays without error on the authorize server after successful payment.

 

Dim CSM As ClientScriptManager = Page.ClientScript

Dim redirectJavascript As String = ""
Dim regBlockTest As String = ""

redirectJavascript = "function test1(){window.location='http://www.yahoo.com'}"

regBlockTest = "function test2(){window.location='http://www.yahoo.com'}"


CSM.RegisterStartupScript(Me.GetType(), "redirect1", redirectJavascript, True)

CSM.RegisterClientScriptBlock(Me.GetType(), "redirect2", regBlockTest, False)

 

If I update my html on the aspx page with the following, the redirect works like a charm, but I can only use a static url, I can't set it dynamically.

 

<body onload = "window.location= https://xxxx">

 

Has anyone successfully used the RegisterStartupScript with Relay Response?  Would it be possible for me to see a simple code sample of how it was accomplished?

CSM.RegisterClientScriptBlock(Me.GetType(), "redirect2", regBlockTest, False)


Should be True on the last param, cause your regBlockTest didn't have the <script /> tag.

 

Shouldn't need both, just keep the 

CSM.RegisterStartupScript(Me.GetType(), "redirect1", redirectJavascript, True)

 

Thanks.  In order to test this more cleanly, I have created a brand new Relay Response page.

 

In the @Page directive I have set enableviewstatemac = false.  My page is below.

<%@ EnableViewStateMac="False" Page Language="vb" AutoEventWireup="false" CodeBehind="PaymentResponse2.aspx.vb" Inherits="ACAPaymentAdapter.PaymentResponse2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>This is Payment Response 2 used for testing</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

Could the tag runat=server statements be a problem?  

(Edit: I removed the runat=server declarations and it didn't change anything).

 

 

Here is my code-behind:

Public Class PaymentResponse2
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Use for javascript redirect
        Dim CSM As ClientScriptManager = Page.ClientScript

        Dim redirectJavascript As String = ""
        redirectJavascript = "function test1(){window.location='http://www.yahoo.com'}"

        CSM.RegisterStartupScript(Me.GetType(), "redirect1", redirectJavascript, True)

    End Sub

End Class

 

My page does not display and I receive 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 has been approved.

It is advisable for you to contact the merchant to verify that you will receive the product or service.

 

In the merchant email, I receive the following:

Your script timed out while we were trying to post transaction results to it.

   Transaction ID: 2208265511

Transaction Result: This transaction has been approved.

 

 

I appreciate all your help.  At this point, should I try and call Authorize.NET for assistance?

Did it run if you put the relay response url in a browser?

 

And if you remove the code in Page_Load

the page show up fine in relay response?

 

Just try it with my test account C# code, forgot to set the enableviewstatemac the first time, but set it on the 2nd and it work fine.

protected void Page_Load(object sender, EventArgs e)
{
string redirectJavascript  =  "function test1(){window.location='http://www.yahoo.com'}";
Page.ClientScript.RegisterStartupScript(Page.GetType(), "redirect1", redirectJavascript, true);
}

Ok, I went to the page directly and found that I have an error because I messed up the @ page directive.  Page should be right after the @ below.  I can't test this again until Monday.

 

<%@ EnableViewStateMac="False" Page

Ok, was able to do the update.

 

And if you remove the code in Page_Load

the page show up fine in relay response?

 

It does now, yes.  This is what I get when I view source.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
	This is Payment Response 2 used for testing
</title></head>
<body>
    <form name="form1" method="post" action="PaymentResponse2.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGQ=" />
</div>

    <div>
    
    </div>
    

<script type="text/javascript">
//<![CDATA[
function test1(){window.location='http://www.yahoo.com'}//]]>
</script>
</form>
</body>
</html>

 

Just try it with my test account C# code, forgot to set the enableviewstatemac the first time, but set it on the 2nd and it work fine.

protected void Page_Load(object sender, EventArgs e) { string redirectJavascript  =  "function test1(){window.location='http://www.yahoo.com'}"; Page.ClientScript.RegisterStartupScript(Page.GetType(), "redirect1", redirectJavascript, true); }

 

Now I need to figure out why this script code is not writing out to my non-test page.