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?
05-16-2011 08:24 PM
Are you getting any error on the screen? Also is webHelper.webHome return something like "http://www.yousite.com/"
05-17-2011 05:02 AM
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.
05-17-2011 06:42 AM
Did you check both isValid and response.Approved variables?
05-17-2011 07:25 AM
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.
05-17-2011 10:16 AM
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?
05-17-2011 01:13 PM
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.
05-17-2011 03:46 PM
...and no, I didn't check the client's browser to see if the script is written. I'll try that...
05-17-2011 03:48 PM
Also, try adding Response.End(); and/or Response.Flush(); after the Response.Write();
05-17-2011 04:49 PM
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?
05-17-2011 07:19 PM