public virtual void RemovePaymentLog(PaymentLog paymentLog) { PaymentLogs.Remove(paymentLog); }
/// <summary> /// Extract check values /// </summary> /// <param name="check"></param> /// <param name="field"></param> /// <returns></returns> private static string ExtractCheckValue(PaymentLog paymentLog, string field) { var result = string.Empty; if (field == StaticValues.Report_Checks_Payee) { result = paymentLog.Name; } else if (field == StaticValues.Report_Checks_CheckNumber) { result = paymentLog.CheckNumber.ToString(); } else if(field == StaticValues.Report_Checks_Amount) { result = paymentLog.Amount.ToString("C"); } else if(field == StaticValues.Report_Checks_DateReceived) { result = paymentLog.DatePayment.ToString("d"); } else if (field == StaticValues.Report_Checks_Notes) { result = paymentLog.Notes; } else if (field == StaticValues.Report_Checks_TransactionId) { result = paymentLog.Transaction.TransactionNumber; } return result; }
public virtual void AddPaymentLog(PaymentLog paymentLog) { paymentLog.Transaction = this; PaymentLogs.Add(paymentLog); }
public ActionResult PaymentResult(PaymentResultParameters touchNetValues) { #region Actual Work // validate to make sure a transaction value was received if (!string.IsNullOrEmpty(touchNetValues.EXT_TRANS_ID)) { string parsedTransaction = touchNetValues.EXT_TRANS_ID.Substring(0, touchNetValues.EXT_TRANS_ID.LastIndexOf (" FID=")); var transaction = Repository.OfType<Transaction>() .Queryable.Where(a => a.TransactionGuid == new Guid(parsedTransaction)) .SingleOrDefault(); //var transaction = Repository.OfType<Transaction>().GetNullableById(touchNetValues.EXT_TRANS_ID.Value); if(transaction == null) { #region Email Error Results _notificationProvider.SendPaymentResultErrors(CloudConfigurationManager.GetSetting("EmailForErrors"), touchNetValues, Request.Params, null, PaymentResultType.TransactionNotFound); #endregion Email Error Results return View(); } // create a payment log var paymentLog = new PaymentLog(transaction.Total); paymentLog.Credit = true; // on success, save the valid information if (touchNetValues.PMT_STATUS.ToLower() == "success") { paymentLog.Name = touchNetValues.NAME_ON_ACCT; paymentLog.Amount = touchNetValues.PMT_AMT.Value; paymentLog.Accepted = true; paymentLog.GatewayTransactionId = touchNetValues.TPG_TRANS_ID; paymentLog.CardType = touchNetValues.CARD_TYPE; if (!transaction.IsActive) { //Possibly we could email someone here to say it has been re-activated transaction.IsActive = true; } } paymentLog.TnBillingAddress1 = touchNetValues.acct_addr; paymentLog.TnBillingAddress2 = touchNetValues.acct_addr2; paymentLog.TnBillingCity = touchNetValues.acct_city; paymentLog.TnBillingState = touchNetValues.acct_state; paymentLog.TnBillingZip = touchNetValues.acct_zip; paymentLog.TnCancelLink = touchNetValues.CANCEL_LINK; paymentLog.TnErrorLink = touchNetValues.ERROR_LINK; paymentLog.TnPaymentDate = touchNetValues.pmt_date; paymentLog.TnSubmit = touchNetValues.Submit; paymentLog.TnSuccessLink = touchNetValues.SUCCESS_LINK; paymentLog.TnSysTrackingId = touchNetValues.sys_tracking_id; paymentLog.TnUpaySiteId = touchNetValues.UPAY_SITE_ID; switch (touchNetValues.PMT_STATUS.ToLower()) { case "success": paymentLog.TnStatus = "S"; break; case "cancelled": case "canceled": paymentLog.TnStatus = "C"; break; default: paymentLog.TnStatus = "E"; break; } if(touchNetValues.posting_key != CloudConfigurationManager.GetSetting("TouchNetPostingKey")) { ModelState.AddModelError("PostingKey", "Posting Key Error"); paymentLog.Accepted = false; } if (touchNetValues.UPAY_SITE_ID != CloudConfigurationManager.GetSetting("TouchNetSiteId")) { ModelState.AddModelError("SiteId", "TouchNet Site Id Error"); paymentLog.Accepted = false; } if (touchNetValues.TPG_TRANS_ID == "DUMMY_TRANS_ID") { ModelState.AddModelError("TPG_TRANS_ID", "TouchNet TPG_TRANS_ID Error"); paymentLog.Accepted = false; } if (touchNetValues.PMT_AMT != transaction.Total) { paymentLog.Accepted = false; if (touchNetValues.PMT_AMT != 0 && paymentLog.TnStatus == "S") { ModelState.AddModelError("Amount", "TouchNet Amount does not match local amount"); } } transaction.AddPaymentLog(paymentLog); //paymentLog.Transaction = transaction; paymentLog.TransferValidationMessagesTo(ModelState); if (ModelState.IsValid) { Repository.OfType<Transaction>().EnsurePersistent(transaction); if (paymentLog.Accepted) { // attempt to get the contact information question set and retrieve email address var question = transaction.TransactionAnswers.Where( a => a.QuestionSet.Name == StaticValues.QuestionSet_ContactInformation && a.Question.Name == StaticValues.Question_Email).FirstOrDefault(); if (question != null) { // send an email to the user _notificationProvider.SendConfirmation(Repository, transaction, question.Answer); } if (transaction.TotalPaid > transaction.Total) { _notificationProvider.SendPaymentResultErrors( CloudConfigurationManager.GetSetting("EmailForErrors"), touchNetValues, Request.Params, null, PaymentResultType.OverPaid); } } } else { #region InValid PaymentLog -- Email Results var body = new StringBuilder(); try { body.Append("<br/><br/>Payment log values:<br/>"); body.Append("Name:" + paymentLog.Name + "<br/>"); body.Append("Amount:" + paymentLog.Amount + "<br/>"); body.Append("Accepted:" + paymentLog.Accepted + "<br/>"); body.Append("Gateway transaction id:" + paymentLog.GatewayTransactionId + "<br/>"); body.Append("Card Type: " + paymentLog.CardType + "<br/>"); body.Append("ModelState: " + ModelState.IsValid); body.Append("<br/><br/>===== modelstate errors text===<br/>"); foreach (var result in ModelState.Values) { foreach (var errs in result.Errors) { body.Append("Error:" + errs.ErrorMessage + "<br/>"); } } } catch (Exception ex) { body.Append(ex.Message); } _notificationProvider.SendPaymentResultErrors(CloudConfigurationManager.GetSetting("EmailForErrors"), touchNetValues, Request.Params, body.ToString(), PaymentResultType.InValidPaymentLog); #endregion InValid PaymentLog -- Email Results } } #endregion return View(); }