Пример #1
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
     }
 }
        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));
            }
        }