cancel
Showing results for 
Search instead for 
Did you mean: 

Redirecter not redirecting the client

I'm using a bastardized version of DPM found here because my site was completely built without MVC before looking into Authorize.Net.

 

I've got the entire thing working, except for the client redirect at the end of the transaction.  After peeling through some

of the source code and reviewing the documentation, I've put this together:

 

public void Page_Load(object sender, EventArgs e)
    {


         AuthorizeNet.SIMResponse response = new AuthorizeNet.SIMResponse(Request.Form);
         bool isValid = response.Validate("hashinfo", "xxxxxxxxx");

         if (!isValid)
         {
              //put inValid response here
         }
         else
         {
           
             if (response.Approved)
             {
                 try
                 {
                     //the transaction went through--this is what my site does upon order completion
                     responseString = webHelper.completeTransaction(response.InvoiceNumber, this);


//This generates the JavaScript that is supposed to redirect the client
  string returnUrl = AuthorizeNet.Helpers.CheckoutFormBuilders.Redirecter(webHelper.webHome + "orderComplete.aspx"); //From what I understand, this should use the javascript generated above to redirect the client, but it doesn't work
Response.Write(returnUrl); } catch (Exception exp) { int afsd = 0; }
}

Any ideas?

 

 

julio9
Member
10 REPLIES 10

Are you getting any error on the screen? Also is webHelper.webHome return something like "http://www.yousite.com/"

RaynorC1emen7
Expert

I get nothing.  No errors.  Nada.

 

And yes, the redirect string points to my site.  webHelper.webHome simply points to the root of my site.  Then I add the actual page. 

Did you check both isValid and response.Approved variables?

Yes.  As posted above,

 

 if (!isValid)
         {
              //put inValid response here
         }
         else
         {
           
             if (response.Approved)
             {

...etc

 

I can step through the code, and it all works.  The only thing that doesn't work is the redirect.  The string is properly generated as well.  Everything just stops there.

After the page finish loading. Did you check to page source(from the browser) to see if the script get written?

Let backup a little. It there a reason not to use Response.Redirect() from asp.net?

 

The documentation mentions that Authorize.Net is expecting a reply to the POST sent by their server.  This reply is in the form of a URL that Authorize.Net will pass on to the client's browser to redirect them to the desired location using Javascript.

 

Also, I did try the Response.Redirect, but it also ended with failure.

...and no, I didn't check the client's browser to see if the script is written.  I'll try that...

Also, try adding Response.End(); and/or Response.Flush(); after the Response.Write();

No dice.  This is driving me nuts.  I also checked the client browser, and tested throwing in a javascript alert to see if the information was being pushed to client at all.

 

Nothing.

 

The POST comes across from Authorize.NET, and I can check it's validity and complete the transaction.  The final redirect is simply not working. 

 

Is there another way to do this?