private CommonDbResponse NeaValidation(NeaBillPaymentCommon PC) { CommonDbResponse response = new CommonDbResponse(); if (Convert.ToDouble(PC.PayableAmount) < Convert.ToDouble(PC.MinAmount) || Convert.ToDouble(PC.PayableAmount) > Convert.ToDouble(PC.MaxAmount)) { response.Code = ResponseCode.Failed; response.Message = "Invalid Amount"; return(response); } if (!Regex.IsMatch(PC.ScNo, @"^[0 - 9][0 - 9.] *[A - za - z0-9] *$")) { response.Code = ResponseCode.Failed; response.Message = "Please input valid SC.No"; return(response); } if (!Regex.IsMatch(PC.ConsumerId, @"^\d+$")) { response.Code = ResponseCode.Failed; response.Message = "Please input valid Consumer Number"; return(response); } else if (!Regex.IsMatch(PC.OfficeCode, @"^\d+$")) { response.Code = ResponseCode.Failed; response.Message = "Please Select valid Branch"; return(response); } else { response.Code = ResponseCode.Success; return(response); } }
public CommonDbResponse payment(NeaBillPaymentCommon BP) { CommonDbResponse response = new CommonDbResponse(); var checkvalidation = NeaValidation(BP); if (checkvalidation.Code != ResponseCode.Success) { response.Code = ResponseCode.Failed; response.Message = checkvalidation.Message; return(response); } //var ServiceName = "NEA"; //var ServiceCode = "1"; Dictionary <string, string> Dict = new Dictionary <string, string>(); Dict.Add("OfficeCode", BP.OfficeCode); Dict.Add("ConsumerId", BP.ConsumerId); Dict.Add("SCharge", BP.Charges); GatewaySwitchAbstractService factory = GatewaySwitchAbstractFactory.Create("cgpay"); factory.TransactionId = BP.TransactionId; var payment = factory.ProcessTransactions(Dict); if (payment.GatewayName.ToUpper() == "PRABHUPAY") { if (payment.Code == "000") { response.Code = ResponseCode.Success; response.Data = payment.Data; } else if (payment.Code == "777") { response.Code = ResponseCode.Exception; response.Data = payment.Data; } else { response.Code = ResponseCode.Failed; } } //response.Id = payment.TransactionId; //response.Data = payment; return(response); }
public ActionResult NeaBillPayment(NeaBillPaymentModel NBP, string ActionType) { if (ActionType != "submitaction") { return(RedirectToAction("NeaBillInquiry")); } if (NBP.EncryptedContent.DecryptParameter() != NBP.ScNo + NBP.ConsumerId + NBP.BillAmount) { return(RedirectToAction("NeaBillInquiry")); } var jstring = Newtonsoft.Json.JsonConvert.SerializeObject(NBP); MobileTopUpPaymentRequest mtpr = new MobileTopUpPaymentRequest() { action_user = Session["UserName"].ToString(), product_id = NBP.ProductId, amount = NBP.TotalPayingAmount, subscriber_no = NBP.ScNo, quantity = "", additonal_data = jstring }; var response = _mtp.MobileTopUpPaymentRequest(mtpr); if (response.Code == 0) { NBP.TransactionId = response.Extra1; NeaBillPaymentCommon NPC = NBP.MapObject <NeaBillPaymentCommon>(); var amt = NBP.PayableAmount.Contains(".") ? NBP.PayableAmount.Split('.')[0].ToString() : NBP.PayableAmount; NPC.PayableAmount = amt; var payment = _nea.payment(NPC); bool failed = true; if (payment.GatewayName == "PRABHUPAY") { if (payment.Code == shared.Models.ResponseCode.Success) { var ppresponse = (prabhupay.service.data.ReturnTransaction)payment.Data; var data = new MobileTopUpPaymentUpdateRequest(); data.action_user = Session["username"].ToString(); data.transaction_id = response.Extra1; data.additonal_data = Newtonsoft.Json.JsonConvert.SerializeObject(ppresponse); data.amount = NPC.PayableAmount; data.refstan = ppresponse.TransactionId; data.status_code = ppresponse.Code; data.remarks = ppresponse.Message; data.ip_address = ApplicationUtilities.GetIP(); data.product_id = NPC.ProductId; data.partner_txn_id = ppresponse.TransactionId; response = _mtp.MobileTopUpPaymentResponse(data); failed = false; return(RedirectToAction("ResultPage", "NeaBillPayment", new { payment = ppresponse })); } else if (payment.Code == shared.Models.ResponseCode.Exception) { var ppresponse = (prabhupay.service.data.ReturnTransaction)payment.Data; var data = new MobileTopUpPaymentUpdateRequest(); data.action_user = Session["username"].ToString(); data.transaction_id = response.Extra1; data.additonal_data = Newtonsoft.Json.JsonConvert.SerializeObject(ppresponse); data.amount = NPC.PayableAmount; data.refstan = ppresponse.TransactionId; data.status_code = ppresponse.Code; data.remarks = ppresponse.Message; data.ip_address = ApplicationUtilities.GetIP(); data.product_id = NPC.ProductId; data.partner_txn_id = ppresponse.TransactionId; response = _mtp.MobileTopUpPaymentResponse(data); failed = false; return(RedirectToAction("ResultPage", "NeaBillPayment", new { payment = ppresponse })); } else { var ppresponse = (prabhupay.service.data.ReturnTransaction)payment.Data; var data = new MobileTopUpPaymentUpdateRequest(); data.action_user = Session["UserName"].ToString(); data.transaction_id = response.Extra1; data.additonal_data = Newtonsoft.Json.JsonConvert.SerializeObject(ppresponse); data.amount = NPC.PayableAmount; data.status_code = ((int)payment.Code).ToString(); data.remarks = payment.Message; data.ip_address = ApplicationUtilities.GetIP(); data.product_id = NPC.ProductId; response = _mtp.MobileTopUpPaymentResponse(data); } } response.SetMessageInTempData(this, "NEAPayment"); if (failed) { NeaBillInquiryModel query = new NeaBillInquiryModel() { ConsumerId = NBP.ConsumerId, OfficeCode = NBP.OfficeCode, ScNo = NBP.ScNo }; return(RedirectToAction("NeaBillInquiry", new { INQ = query })); } } response.SetMessageInTempData(this, "NEAPayment"); NeaBillInquiryModel que = new NeaBillInquiryModel() { ConsumerId = NBP.ConsumerId, OfficeCode = NBP.OfficeCode, ScNo = NBP.ScNo }; return(RedirectToAction("NeaBillInquiry", new { INQ = que })); }
public CommonDbResponse payment(NeaBillPaymentCommon BP) { return(repo.payment(BP)); }