MVC architectural question - Where should payment processing go?

Posted by Keltex on Stack Overflow See other posts from Stack Overflow or by Keltex
Published on 2010-03-23T14:52:24Z Indexed on 2010/03/23 15:03 UTC
Read the original article Hit count: 379

This question is related to my ASP.NET MVC 2 development, but it could apply to any MVC environment and a question of where the logic should go.

So let's say I have a controller that takes an online payment such as a shopping cart application. And I have the method that accepts the customers' credit card information:

public class CartController : Controller
    CartRepository cartRepository = new CartRepository()

    [HttpPost]
    public ActionResult Payment(PaymentViewModel rec)
    {
        if(!ModelState.IsValid)
        {
            return View(rec);
        }

        // process payment here

        return RedirectToAction("Receipt");
    }

At the comment process payment here should the payment processing be handled:

  1. In the controller?
  2. By the repository?
  3. Someplace else?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about mvc