public virtual async Task <IActionResult> RequestBulkControlNumbers([FromBody] RequestBulkControlNumbersModel model) { if (!ModelState.IsValid) { var error = ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage; if (model != null) { return(BadRequest(new ErrorResponseV2() { error_occured = true, error_message = error })); } else { return(BadRequest(new ErrorResponseV2() { error_occured = true, error_message = "10-Uknown type of payment" })); } } // var officer = _payment.GetOfficerInfo(model.OfficerId); var result = await _payment.RequestBulkControlNumbers(model); return(Ok(result)); }
public override async Task <string> RequestBulkControlNumbers(RequestBulkControlNumbersModel model) { var gepg = new GepgUtility(_hostingEnvironment, Configuration, _loggerFactory); var bills = await gepg.CreateBulkBills(Configuration, model); var signature = gepg.GenerateSignature(bills); var signedMesg = gepg.FinaliseSignedMsg(signature); string accountCode = gepg.GetAccountCodeByProductCode(model.ProductCode); var billAck = await gepg.SendHttpRequest("/api/bill/sigqrequest", signedMesg, accountCode, "default.sp.in"); string sentbill = JsonConvert.SerializeObject(bills); _gepgFileLogger.Log("Bulk_CN_Request", sentbill + "********************" + billAck); // if the response is not 7101(SUCCESS) then delete all the entries from DB if (!billAck.Contains("7101")) { _ = DeleteFailedControlNumberRequests(bills); } return(billAck); }
public virtual async Task <string> RequestBulkControlNumbers(RequestBulkControlNumbersModel model) { return(await Task.FromResult("")); }
public async Task <string> RequestBulkControlNumbers(RequestBulkControlNumbersModel model) { var imisPayment = new ImisPayment(_configuration, _hostingEnvironment, _loggerFactory); return(await imisPayment.RequestBulkControlNumbers(model)); }
public async Task <string> CreateBulkBills(IConfiguration configuration, RequestBulkControlNumbersModel model) { var billTrxRefs = new List <BillTrxInf>(); var rand = new Random(); var sSQL = "uspPrepareBulkControlNumberRequests"; SqlParameter[] parameters = { new SqlParameter("@Count", model.ControlNumberCount), new SqlParameter("@ProductCode", model.ProductCode), new SqlParameter("@ErrorCode", SqlDbType.Int) { Direction = ParameterDirection.Output } }; var dh = new DataHelper(configuration); DataTable dt = dh.GetDataTable(sSQL, parameters, CommandType.StoredProcedure); foreach (DataRow dr in dt.Rows) { var billItems = new List <BillItem>(); BillItem item = new BillItem() { BillItemRef = model.ProductCode, BillItemAmt = Convert.ToDouble(dr["Amount"]), BillItemEqvAmt = Convert.ToDouble(dr["Amount"]), BillItemMiscAmt = 0, UseItemRefOnPay = "N", GfsCode = configuration["PaymentGateWay:GePG:GfsCode:0"] }; billItems.Add(item); BillTrxInf billTrxInf = new BillTrxInf() { BillId = (int)dr["BillId"], SubSpCode = Convert.ToInt32(configuration["PaymentGateWay:GePG:SubSpCode"]), SpSysId = configuration["PaymentGateWay:GePG:SystemId"], Ccy = "TZS", BillPayOpt = 3, BillGenDt = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"), BillEqvAmt = Convert.ToDecimal(dr["Amount"]), RemFlag = true, BillExprDt = DateTime.Now.AddYears(3).ToString("yyyy-MM-ddTHH:mm:ss"), BillAmt = Convert.ToDecimal(dr["Amount"]), MiscAmt = 0, BillItems = billItems, BillDesc = "Bill", BillApprBy = "Imis", BillGenBy = "Imis" }; billTrxInf.PyrId = dr["BillId"].ToString(); billTrxInf.PyrName = "CHF IMIS"; billTrxInf.PyrEmail = "*****@*****.**"; billTrxInf.PyrCellNum = ""; billTrxRefs.Add(billTrxInf); } string accountCode = GetAccountCodeByProductCode(model.ProductCode); newBill = new gepgBillSubReq(); newBill.BillHdr = new BillHdr() { SpCode = accountCode, RtrRespFlg = true }; newBill.BillTrxInf = billTrxRefs; var xs = new XmlSerializer(typeof(gepgBillSubReq)); var ns = new XmlSerializerNamespaces(); ns.Add("", ""); var settings = new XmlWriterSettings() { OmitXmlDeclaration = true }; var sb = new StringBuilder(); using (var xw = XmlWriter.Create(sb, settings)) { try { xs.Serialize(xw, newBill, ns); xw.Flush(); } catch (Exception ex) { _logger.LogError(ex, "Exception during XML serialization"); } return(sb.ToString()); } }