예제 #1
0
        public ActionResult LoadBalanceIndex(LoadBalanceModel balance)
        {
            LoadBalanceCommon ld = new LoadBalanceCommon();

            balance.action_user    = Session["UserName"].ToString();
            balance.action_ip      = ApplicationUtilities.GetIP();
            balance.action_browser = HttpContext.Request.Browser.ToString();

            ld = balance.MapObject <LoadBalanceCommon>();

            string           redirectUrl = "";
            CommonDbResponse dbResponse  = _iLoad.LoadBalance(ld);

            if (dbResponse.Code == ResponseCode.Success)
            {
                var modeleResponse = MakeHttpRequest.InvokeGetProcessId("1", "anujApi", dbResponse.Extra1, balance.amount, "", "anujApi", "Anuj@123", "AnujSecert");
                if (modeleResponse.code == "0")
                {
                    ProcessResponse             midddlewareModel = ApplicationUtilities.MapObject <ProcessResponse>(modeleResponse.data);
                    Dictionary <String, string> formParams       = new Dictionary <string, string>();
                    formParams.Add("MerchantId", midddlewareModel.MerchantId);
                    formParams.Add("MerchantTxnId", midddlewareModel.MerchantTxnId);
                    formParams.Add("ProcessId", midddlewareModel.ProcessId);
                    formParams.Add("Amount", midddlewareModel.Amount.ToString());
                    formParams.Add("TransactionRemarks", balance.remarks);
                    formParams.Add("MerchantName", "anujApi");

                    var responseObj = ApplicationUtilities.FormBuilder("gateway", midddlewareModel.GatewayFormMethod, midddlewareModel.GatewayUrl, formParams);
                    Response.Write(responseObj);
                    Response.End();
                }
            }
            return(View(balance));
        }
        public ActionResult ReceivePaymentNotification(string MerchantTxnId, string GatewayTxnId)
        {
            //check MerchantTxnId in our db first
            var dbRes = _iLoad.CheckTrnasactionExistence(MerchantTxnId, GatewayTxnId);

            if (dbRes.Code == ResponseCode.Success)
            {
                string apiusername  = ApplicationUtilities.GetAppConfigValue("apiusername");
                string apipasssword = ApplicationUtilities.GetAppConfigValue("apipasssword");
                string apisecretkey = ApplicationUtilities.GetAppConfigValue("apisecretkey");
                string merchantname = ApplicationUtilities.GetAppConfigValue("merchantname");
                string merchantid   = ApplicationUtilities.GetAppConfigValue("merchantid");
                try
                {
                    MiddleServiceRequest serviceCall = new MiddleServiceRequest("cgpay", apiusername, apipasssword, apisecretkey);
                    var resp = serviceCall.GetTransactionDetail(merchantid, merchantname, MerchantTxnId);

                    if (resp.code == "0")
                    {
                        var transactionModel       = ApplicationUtilities.MapObject <CheckTransactionResponse>(resp.data);
                        LoadBalanceCommon lBalance = new LoadBalanceCommon()
                        {
                            pmt_gateway_id     = "",
                            pmt_gateway_txn_id = GatewayTxnId,
                            gateway_status     = transactionModel.Status,
                            gateway_process_id = "",
                            action_user        = "******",
                            action_ip          = ApplicationUtilities.GetIP(),
                            bank_name          = transactionModel.Institution,
                            payment_mode       = transactionModel.Instrument,
                            pmt_txn_id         = MerchantTxnId,
                            amount             = transactionModel.Amount,
                            service_charge     = transactionModel.ServiceCharge
                        };
                        _iLoad.UpdateTransaction(lBalance);
                    }
                }
                catch (Exception ex)
                {
                    string msg = ex.Message;
                    throw;
                }
            }
            Response.Write("Received");
            Response.End();
            return(View());



            // then check if transaction is already updated by merchanttxnid and gatewaytxnid



            //if transaction exists or already received or txn not found
            //return "Received";
            //
        }
예제 #3
0
 public ActionResult ReceivePaymentResponse(string MerchantTxnId, string GatewayTxnId)
 {
     ewallet.application.Models.OnePG.CommonResponse resp = MakeHttpRequest.InvokeCheckTransactionStatus("1", "anujApi", MerchantTxnId, "anujApi", "Anuj@123", "AnujSecert");
     if (resp.code == "0")
     {
         //check MerchantTxnId in our db,get detail  and print receipt
         var dbResponse = _iLoad.GetTransactionReposne(MerchantTxnId, GatewayTxnId);
         if (dbResponse.Code == 0)
         {
             var viewTransactionModel = ApplicationUtilities.MapObject <ViewTransactionReponseModel>(dbResponse.Data);
             return(View(viewTransactionModel));
         }
         else
         {
             return(RedirectToAction("Eror"));///remaining
         }
     }
     else
     {
         return(RedirectToAction("Eror"));///remaining
     }
 }
예제 #4
0
        public ActionResult ReceivePaymentNotification(string MerchantTxnId, string GatewayTxnId)
        {
            //check MerchantTxnId in our db first
            var dbRes = _iLoad.CheckTrnasactionExistence(MerchantTxnId, GatewayTxnId);

            if (dbRes.Code == 0)
            {
                ewallet.application.Models.OnePG.CommonResponse resp = MakeHttpRequest.InvokeCheckTransactionStatus("1", "anujApi", MerchantTxnId, "anujApi", "Anuj@123", "AnujSecert");
                if (resp.code == "0")
                {
                    var transactionModel       = ApplicationUtilities.MapObject <CheckTransactionResponse>(resp.data);
                    LoadBalanceCommon lBalance = new LoadBalanceCommon()
                    {
                        pmt_gateway_id     = "",
                        pmt_gateway_txn_id = GatewayTxnId,
                        gateway_status     = transactionModel.Status,
                        gateway_process_id = "",
                        action_user        = "******",
                        action_ip          = ApplicationUtilities.GetIP(),
                        bank_name          = transactionModel.Institution,
                        payment_mode       = transactionModel.Instrument,
                        pmt_txn_id         = MerchantTxnId
                    };
                    _iLoad.UpdateTransaction(lBalance);
                }
            }

            // then check if transaction is already updated by merchanttxnid and gatewaytxnid

            //if transaction exists or already received or txn not found
            //return "Received";


            //
            Response.Write("Received");
            Response.End();
            return(View());
        }
        public ActionResult ReceivePaymentResponse(string MerchantTxnId, string GatewayTxnId)
        {
            if (string.IsNullOrEmpty(MerchantTxnId) && string.IsNullOrEmpty(GatewayTxnId))
            {
                CommonDbResponse            dbRes     = new CommonDbResponse();
                ViewTransactionReponseModel viewModel = new ViewTransactionReponseModel();


                viewModel.code           = 1;
                viewModel.Message        = "Tranasaction Failed";
                viewModel.gateway_status = "Failed";
                //dbRes.SetMessageInTempData(this);
                return(View(viewModel));
            }
            string                      apiusername  = ApplicationUtilities.GetAppConfigValue("apiusername");
            string                      apipasssword = ApplicationUtilities.GetAppConfigValue("apipasssword");
            string                      apisecretkey = ApplicationUtilities.GetAppConfigValue("apisecretkey");
            string                      merchantname = ApplicationUtilities.GetAppConfigValue("merchantname");
            string                      merchantid   = ApplicationUtilities.GetAppConfigValue("merchantid");
            CommonDbResponse            dbResponse   = new CommonDbResponse();
            ViewTransactionReponseModel model        = new ViewTransactionReponseModel();

            try
            {
                MiddleServiceRequest serviceCall = new MiddleServiceRequest("cgpay", apiusername, apipasssword, apisecretkey, Session["UserName"].ToString());
                var resp = serviceCall.GetTransactionDetail(merchantid, merchantname, MerchantTxnId);

                //if (resp != null && resp.code == "0" && resp.data.Status.ToLower() == "success" )
                //{
                //    dbResponse = _iLoad.GetTransactionReposne(MerchantTxnId, GatewayTxnId);
                //    if (dbResponse.Code == ResponseCode.Success)
                //    {
                //        model = ApplicationUtilities.MapObject<ViewTransactionReponseModel>(dbResponse.Data);
                //        model.code = int.Parse(resp.code);
                //        return View(model);
                //    }
                //    else
                //    {
                //        //dbResponse.SetMessageInTempData(this);
                //        model.code = 1;
                //        return View(model);
                //    }
                //}
                //else if (resp != null && resp.code == "0" && resp.data.Status.ToLower() == "fail")
                //{

                //    model.code = 1;
                //    model.Message = "Tranasaction Failed";
                //    //dbResponse.SetMessageInTempData(this);
                //    return View(model);
                //}
                //else if (resp != null && resp.code == "1")
                //{
                //    dbResponse.Code = ResponseCode.Failed;
                //    dbResponse.Message = resp.message;
                //    dbResponse.SetMessageInTempData(this);
                //    model.code = int.Parse(resp.code);
                //    return View(model);
                //}
                //else
                //{
                //    dbResponse.Code = ResponseCode.Failed;
                //    dbResponse.Message = "Service Call Failed";
                //    dbResponse.SetMessageInTempData(this);
                //    model.code = 1;
                //    return View(model);
                //}
                if (resp != null && resp.code == "0")
                {
                    dbResponse = _iLoad.GetTransactionReposne(MerchantTxnId, GatewayTxnId);
                    if (dbResponse.Code == ResponseCode.Success)
                    {
                        model      = ApplicationUtilities.MapObject <ViewTransactionReponseModel>(dbResponse.Data);
                        model.code = int.Parse(resp.code);
                        return(View(model));
                    }
                    else
                    {
                        model.code           = 1;
                        model.Message        = "Transaction status failed.";
                        model.gateway_status = "Failed";
                        return(View(model));
                    }
                }
                else if (resp != null && resp.code == "1")
                {
                    //dbResponse.Code = ResponseCode.Failed;
                    model.Message        = "Transaction status failed.";
                    model.gateway_status = "Failed";
                    model.code           = 1;
                    return(View(model));
                }
                else
                {
                    //dbResponse.Code = ResponseCode.Failed;
                    model.Message        = "Transaction status failed.";
                    model.gateway_status = "Failed";
                    model.code           = 1;
                    return(View(model));
                }
            }
            catch (Exception)
            {
                //dbResponse.Code = ResponseCode.Failed;
                model.Message        = "Transaction status failed.";
                model.gateway_status = "Failed";
                //dbResponse.SetMessageInTempData(this);
                model.code = 1;
                return(View(model));
            }
        }
        public ActionResult LoadBalanceIndex(LoadBalanceModel balance)
        {
            CommonDbResponse dbResponse = new CommonDbResponse();
            var dbLimits = _iLoad.GetTransactionLimit(Session["AgentId"].ToString());
            var limits   = dbLimits.Data.MapObject <LoadBalanceModel>();

            if (Convert.ToInt32(balance.amount) < 10 || Convert.ToInt32(balance.amount) > 100000)
            {
                return(View(limits));
            }

            //if (
            //    int.Parse(balance.amount) > limits.transactiondailylimitmax
            //    || int.Parse(balance.amount) > limits.transactionmonthlylimitmax
            //    )
            //{
            //    dbResponse.Code = ResponseCode.Failed;
            //    dbResponse.Message = "Amount Exceeded Transaction Limit";
            //    dbResponse.SetMessageInTempData(this);
            //    return View(limits);
            //}
            if (int.Parse(balance.amount) > limits.transactiondailylimitmax && int.Parse(balance.amount) <= limits.transactionmonthlylimitmax)
            {
                dbResponse.Code    = ResponseCode.Failed;
                dbResponse.Message = "Amount Exceeded Daily Transaction Limit";
                dbResponse.SetMessageInTempData(this);
                return(View(limits));
            }
            if (int.Parse(balance.amount) > limits.transactionmonthlylimitmax)
            {
                dbResponse.Code    = ResponseCode.Failed;
                dbResponse.Message = "Amount Exceeded Monthly Transaction Limit";
                dbResponse.SetMessageInTempData(this);
                return(View(limits));
            }


            LoadBalanceCommon ld = new LoadBalanceCommon();

            if (ModelState.IsValid)
            {
                balance.action_user    = Session["UserName"].ToString();
                balance.action_ip      = ApplicationUtilities.GetIP();
                balance.action_browser = HttpContext.Request.Browser.ToString();



                ld         = balance.MapObject <LoadBalanceCommon>();
                dbResponse = _iLoad.LoadBalance(ld);
                if (dbResponse.Code == ResponseCode.Success)
                {
                    string apiusername  = ApplicationUtilities.GetAppConfigValue("apiusername");
                    string apipasssword = ApplicationUtilities.GetAppConfigValue("apipasssword");
                    string apisecretkey = ApplicationUtilities.GetAppConfigValue("apisecretkey");
                    string merchantname = ApplicationUtilities.GetAppConfigValue("merchantname");
                    string merchantid   = ApplicationUtilities.GetAppConfigValue("merchantid");

                    try
                    {
                        MiddleServiceRequest middlewareCall = new MiddleServiceRequest("cgpay", apiusername, apipasssword, apisecretkey, Session["UserName"].ToString());
                        var response = middlewareCall.GetFormObject(merchantid, merchantname, dbResponse.Extra1, balance.amount, dbResponse.Extra2, balance.instrument_code);
                        if (response != null && response.code == "0")
                        {
                            var formString = ApplicationUtilities.MapObject <MiddlewareResponse.FormDataObject>(response.data);
                            Response.Write(formString.FormData);
                            Response.End();
                        }
                        else if (response != null && response.code == "1")
                        {
                            dbResponse.Code    = ResponseCode.Failed;
                            dbResponse.Message = response.message;
                            // dbResponse.SetMessageInTempData(this);
                            return(View(limits));
                        }
                        else
                        {
                            dbResponse.Code    = ResponseCode.Failed;
                            dbResponse.Message = "Service Call Failed";
                            //dbResponse.SetMessageInTempData(this);
                            return(View(limits));
                        }
                    }
                    catch (Exception)
                    {
                        dbResponse.Code    = ResponseCode.Failed;
                        dbResponse.Message = "Service Call Failed";
                        // dbResponse.SetMessageInTempData(this);
                        return(View(limits));
                    }
                }
                //dbResponse.SetMessageInTempData(this);
                return(View(limits));
            }

            return(View(limits));
        }