Reply
Member
Posts: 6
Registered: ‎05-16-2011

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?

 

 

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

Re: Redirecter not redirecting the client

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

Member
Posts: 6
Registered: ‎05-16-2011

Re: Redirecter not redirecting the client

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. 

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

Re: Redirecter not redirecting the client

Did you check both isValid and response.Approved variables?

Member
Posts: 6
Registered: ‎05-16-2011

Re: Redirecter not redirecting the client

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.

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

Re: Redirecter not redirecting the client

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?

 

Member
Posts: 6
Registered: ‎05-16-2011

Re: Redirecter not redirecting the client

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.

Member
Posts: 6
Registered: ‎05-16-2011

Re: Redirecter not redirecting the client

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

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

Re: Redirecter not redirecting the client

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

Member
Posts: 6
Registered: ‎05-16-2011

Re: Redirecter not redirecting the client

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?