So, I actually do have a valid relay url set up. It's an absolute URL that points back to my website, and I know my site is picking up on it because it's performing the Error Trapping I have set up. What I'm trying to figure out is why my transactions aren't coming back approved even though I'm giving it a good, real credit card, and why it's giving me a Code 3 (Payment Declined), but an error message that cites the relay URL.
The message I posted above is what the site gives me when it hits the Response.Write() line below. It posts the details in the page for a second until the method hits a redirect I have set up in my SimReponse method. So, the Relay URL (as far as I can tell) is doing its job, but the gateway is still sending back an error. I can't figure out why... and, I can't really make much sense of the code in order to figure out what's wrong. This is what my accept method is doing:
[HttpPost]
public ActionResult SimResponse(FormCollection post)
{
var response = new AuthorizeNet.SIMResponse(post);
Response.Write(response.ToString());
Thread.Sleep(10000);
//first order of business - validate that it was Auth.net that posted this using the
//MD5 Hash passed to use from Auth.net
var isValid = response.Validate(ConfigHelper.MerchantHash,
ConfigHelper.AuthNetApiLogin);
//if it's not valid - just send them to the home page. Don't throw - that's how
//hackers figure out what's wrong :)
//if(!isValid)
// return Redirect("/");
//pull the order ID from the order
var orderId = Request.Form["order_id"];
recordError(1, "orders", "orderid", orderId.ToString(), "", "", 1);
//pull the order
/*var order = MvcApplication.FindOrder(orderId);*/
//the URL to redirect to
var redirectAction = Url.Action("recentpurchases", "report" /*, new { id = orderId.ToString() }*/);
var returnUrl = Url.SiteRoot() + redirectAction;
var order = new Order();
if (response.Approved)
{
order.AuthCode = response.ToString();
order.TransactionId = response.TransactionID;
//order.OrderMessage = string.Format("Thank you! Order approved: {0}", response.AuthorizationCode);
}
else
{
//pin the message to the order so we can show it to the user
//order.OrderMessage = response.Message;
redirectAction = Url.Action("error", "search");
returnUrl = Url.SiteRoot() + redirectAction;
}
//save the order somewhere
//MvcApplication.SaveOrder(order);
//Direct Post method
return Content(CheckoutFormBuilders.Redirecter(returnUrl));
//or just return the page back to the AuthNet server if you don't want to bounce the return
//MAKE SURE it has absolute URLs
//return Redirect(redirectAction);
}