public long AddFee(FeeObject fee) { try { if (fee == null) { return(-2); } var feeEntity = ModelMapper.Map <FeeObject, Fee>(fee); if (feeEntity == null || feeEntity.FeeTypeId < 1) { return(-2); } using (var db = new ImportPermitEntities()) { var returnStatus = db.Fees.Add(feeEntity); db.SaveChanges(); return(returnStatus.FeeId); } } catch (DbEntityValidationException e) { var str = ""; foreach (var eve in e.EntityValidationErrors) { str += string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State) + "\n"; str = eve.ValidationErrors.Aggregate(str, (current, ve) => current + (string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage) + " \n")); } ErrorLogger.LoggError(e.StackTrace, e.Source, str); return(0); } }
public ActionResult EditFee(FeeObject fee) { var gVal = new GenericValidator(); try { var stat = ValidateFee(fee); if (stat.Code < 1) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_fee"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldfee = Session["_fee"] as FeeObject; if (oldfee == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldfee.ImportStageId = fee.ImportStageId; oldfee.FeeTypeId = fee.FeeTypeId; oldfee.Amount = fee.Amount; oldfee.Name = fee.Name; oldfee.PrincipalSplit = fee.PrincipalSplit; oldfee.VendorSplit = fee.VendorSplit; oldfee.PaymentGatewaySplit = fee.PaymentGatewaySplit; oldfee.BillableToPrincipal = fee.BillableToPrincipal; oldfee.CurrencyCode = fee.CurrencyCode; var docStatus = new FeeServices().UpdateFee(oldfee); if (docStatus < 1) { gVal.Code = -1; gVal.Error = docStatus == -3 ? "Fee already exists." : "Fee information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldfee.FeeId; gVal.Error = "Fee information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "Fee information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public long UpdateFee(FeeObject fee) { try { return(_feeManager.UpdateFee(fee)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public Lineitem[] ComputeExpenditionaryPaymentSplit(FeeObject expenditionaryfee) { try { if (expenditionaryfee == null) { return(new Lineitem[] { }); } var list = new List <Lineitem>(); var principalExpSplit = 0.0; var vendorExpSplit = 0.0; if (expenditionaryfee.VendorSplit > 0) { vendorExpSplit = expenditionaryfee.VendorSplit; } principalExpSplit = expenditionaryfee.PrincipalSplit; if (expenditionaryfee.PaymentGatewaySplit > 0) { principalExpSplit = principalExpSplit + expenditionaryfee.PaymentGatewaySplit; } var principalSplit = principalExpSplit; if (principalSplit < 1) { return(new Lineitem[] { }); } var principalDetails = GetDprDetails(principalSplit.ToString(CultureInfo.InvariantCulture)); list.Add(principalDetails); var vendorSplit = vendorExpSplit; if (vendorSplit > 0) { var vendoDetails = GetMaxfrontDetails(vendorSplit.ToString(CultureInfo.InvariantCulture)); list.Add(vendoDetails); } return(list.ToArray()); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(new Lineitem[] { }); } }
public ActionResult AddFee(FeeObject fee) { var gVal = new GenericValidator(); try { var importerInfo = GetLoggedOnUserInfo(); if (importerInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateFee(fee); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var appStatus = new FeeServices().AddFee(fee); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "Fee could not be added. Please try again." : "The Fee Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "Fee was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "Fee processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
private GenericValidator ValidateFee(FeeObject fee) { var gVal = new GenericValidator(); try { if (fee.FeeTypeId < 1) { gVal.Code = -1; gVal.Error = "Please select Fee."; return(gVal); } if (fee.ImportStageId < 1) { gVal.Code = -1; gVal.Error = "Please select Document Type."; return(gVal); } if (fee.Amount < 1) { gVal.Code = -1; gVal.Error = "Please fee Amount."; return(gVal); } gVal.Code = 5; return(gVal); } catch (Exception) { gVal.Code = -1; gVal.Error = "Fee Validation failed. Please provide all required fields and try again."; return(gVal); } }
public GenericValidator PostSplitPaymentForExpenditionaryFee(double amount, string orderId, string payerName, string payerEmail, string payerPhone, string returnUrl, FeeObject expenditionaryFee) { var helper = new SplitPaymentHelper(); var mecharntId = ((long)RemitaServiceType.MecharntId).ToString(); var serviceTypeId = ((long)RemitaServiceType.Expenditionary).ToString(); var apiKey = ((long)RemitaServiceType.ApiKey).ToString(); const string url = "https://login.remita.net/remita/ecomm/split/init.reg"; //const string mecharntId = "2547916"; //const string serviceTypeId = "4430731"; //const string apiKey = "1946"; //const string url = "http://www.remitademo.net/remita/ecomm/v2/init.reg"; var hashValue = mecharntId + serviceTypeId + orderId + amount + returnUrl + apiKey; var hash = helper.GetHash(hashValue); var items = helper.ComputeExpenditionaryPaymentSplit(expenditionaryFee); var gVal = new GenericValidator(); try { var splitPay = new SplitPayment { MerchantId = mecharntId, ServiceTypeId = serviceTypeId, TotalAmount = amount.ToString(CultureInfo.InvariantCulture), Hash = hash, OrderId = orderId, Responseurl = returnUrl, PayerName = payerName, PayerEmail = payerEmail, PayerPhone = payerPhone, LineItems = items, }; var json = JsonConvert.SerializeObject(splitPay); using (var client = new WebClient()) { try { client.Headers[HttpRequestHeader.Accept] = "application/json"; client.Headers[HttpRequestHeader.ContentType] = "application/json"; var result = client.UploadString(url, "POST", json); result = result.Replace("jsonp", ""); result = result.Replace("(", ""); result = result.Replace(")", ""); var res = JsonConvert.DeserializeObject <ResponseObject>(result); if (string.IsNullOrEmpty(res.RRR)) { gVal.Code = -1; gVal.Error = "Payment Reference could not be generated. Please try again later."; return(gVal); } gVal.Code = 5; gVal.Error = res.RRR; gVal.Hash = hash; var list = new List <PaymentDistributionSummaryObject>(); items.ToList().ForEach(m => { double bAmount; var d = double.TryParse(m.BeneficiaryAmount, out bAmount); if (!d || bAmount < 1) { return; } list.Add(new PaymentDistributionSummaryObject { ServiceId = (int)ServiceDescriptionEnum.Import_Permit_Application_Fee, Beneficiary = m.BeneficiaryName, Amount = bAmount, PaymentReference = res.RRR, PaymentDate = DateTime.Now, Status = false }); }); var logStatus = new FeeServices().LogPaymentDetails(list); if (logStatus < 1) { gVal.Code = -1; gVal.Error = "An unknown error was encountered. Request could not be completed."; return(gVal); } return(gVal); } catch (Exception e) { gVal.Code = -1; gVal.Error = e.Message; return(gVal); } } } catch (Exception e) { gVal.Code = -1; gVal.Error = e.Message; return(gVal); } }