public HttpResponseMessage PostPayPalNotification(WebPayPalIPN notification) { if (!ModelState.IsValid || notification == null) { return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, ModelState)); } try { repo.addNotification(notification); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest, e)); } }
public void addNotification(WebPayPalIPN notification) { PayPalNotification n = new PayPalNotification(); n.dateReceived = DateTime.UtcNow; n.transactionId = notification.txn_id; n.payerId = notification.payer_id; n.paymentGross = notification.payment_gross; n.paymentFee = notification.payment_fee; n.mcCurrency = notification.mc_currency; n.mcGross = notification.mc_gross; n.reasonCode = notification.reason_code; n.paymentDate = notification.payment_date; n.paymentStatus = notification.payment_status; n.custom = notification.custom; db.PayPalNotifications.Add(n); db.SaveChanges(); updateRegistrationPayment(n); }