Posts

Showing posts from April, 2015

Creating a PayPal IPN Web API Endpoint

Image
PayPal's IPN service allows you to perform server side business logic once you are sure that payment has been received. This is extremely useful if you want to hold off on shipping order until payment has arrived. However, as convenient as it is, it is equally under-documented, and there are little resources for a .NET developer. Here is one way of setting up a PayPal IPN endpoint using Web API. [RoutePrefix("paypal")] public class PayPalController : ApiController { private PayPalValidator _validator; public PayPalController() { this._validator = new PayPalValidator(); } [HttpPost] [Route("ipn")] public void ReceiveIPN(IPNBindingModel model) { if (!_validator.ValidateIPN(model.RawRequest)) throw new Exception("Error validating payment"); switch (model.PaymentStatus) { case "Compl