public RedirectToRouteResult Add_POST(OrderNote orderNote) { if (orderNote.Order != null) { orderNote.Order.OrderNotes.Add(orderNote); _orderNoteService.Save(orderNote); return(RedirectToAction("Edit", "Order", new { id = orderNote.Order.Id })); } else { return(RedirectToAction("Index", "Order")); } }
public void OrderNoteController_AddPOST_CallsIOrderNoteServiceAddWithPassedOrderNote() { var item = new OrderNote(); item.Order = new Order { Id = 1 }; var add = _orderNoteController.Add_POST(item); A.CallTo(() => _orderNoteService.Save(item)).MustHaveHappened(); }
public void HandleIPN(string ipnData) { Dictionary <string, string> values; if (VerifyIPN(ipnData, out values)) { #region values decimal total = decimal.Zero; try { total = decimal.Parse(values["mc_gross"], new CultureInfo("en-US")); } catch { } string payer_status = string.Empty; values.TryGetValue("payer_status", out payer_status); string payment_status = string.Empty; values.TryGetValue("payment_status", out payment_status); string pending_reason = string.Empty; values.TryGetValue("pending_reason", out pending_reason); string mc_currency = string.Empty; values.TryGetValue("mc_currency", out mc_currency); string txn_id = string.Empty; values.TryGetValue("txn_id", out txn_id); string txn_type = string.Empty; values.TryGetValue("txn_type", out txn_type); string rp_invoice_id = string.Empty; values.TryGetValue("rp_invoice_id", out rp_invoice_id); string payment_type = string.Empty; values.TryGetValue("payment_type", out payment_type); string payer_id = string.Empty; values.TryGetValue("payer_id", out payer_id); string receiver_id = string.Empty; values.TryGetValue("receiver_id", out receiver_id); string invoice = string.Empty; values.TryGetValue("invoice", out invoice); string payment_fee = string.Empty; values.TryGetValue("payment_fee", out payment_fee); #endregion var sb = new StringBuilder(); sb.AppendLine("Paypal IPN:"); foreach (KeyValuePair <string, string> kvp in values) { sb.AppendLine(kvp.Key + ": " + kvp.Value); } var newPaymentStatus = GetPaymentStatus(payment_status, pending_reason); sb.AppendLine("New payment status: " + newPaymentStatus); string orderNumber = string.Empty; values.TryGetValue("custom", out orderNumber); Guid orderNumberGuid = Guid.Empty; try { orderNumberGuid = new Guid(orderNumber); } catch { } var order = _orderService.GetByGuid(orderNumberGuid); if (order != null) { //order note _orderNoteService.Save(new OrderNote { Note = sb.ToString(), Order = order, ShowToClient = false }); _orderService.Save(order); switch (newPaymentStatus) { case PaymentStatus.Pending: break; case PaymentStatus.Paid: break; case PaymentStatus.Refunded: _orderRefundService.Add(new OrderRefund { Order = order, Amount = -total }); break; case PaymentStatus.Voided: break; default: break; } } else { CurrentRequestData.ErrorSignal.Raise(new Exception("PayPal IPN. Order is not found", new Exception(sb.ToString()))); } } else { CurrentRequestData.ErrorSignal.Raise(new Exception("PayPal IPN failed.", new Exception(ipnData))); } }