public TransactionHistoryModel GetTransactionHistoryByJobId(int jobid)
 {
     //unitOfWork.StartTransaction();
     TransactionHistoryRepository repo = new TransactionHistoryRepository(unitOfWork);
     TransactionHistoryModel transactionHistoryModel = new TransactionHistoryModel();
     //UserLocationModel userLocationModel = new UserLocationModel();
     TransactionHistory transactionHistory = new TransactionHistory();
     AutoMapper.Mapper.Map(transactionHistoryModel, transactionHistory);
     transactionHistory = repo.GetAll().Where(x => x.JobId == jobid && !string.IsNullOrEmpty(x.CustomerEmail)).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(transactionHistory, transactionHistoryModel);
     return transactionHistoryModel;
 }
 public TransactionHistoryModel GetTransactionHistoryByCartId(int id)
 {
     //unitOfWork.StartTransaction();
     TransactionHistoryRepository repo = new TransactionHistoryRepository(unitOfWork);
     TransactionHistoryModel transactionHistoryModel = new TransactionHistoryModel();
     //UserLocationModel userLocationModel = new UserLocationModel();
     TransactionHistory transactionHistory = new TransactionHistory();
     AutoMapper.Mapper.Map(transactionHistoryModel, transactionHistory);
     transactionHistory = repo.GetAll().Where(x => x.CartId == id).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(transactionHistory, transactionHistoryModel);
     return transactionHistoryModel;
 }
 public TransactionHistoryModel FindTransactionHistoryByMerchantRegrence(string merchantRegrence)
 {
     //unitOfWork.StartTransaction();
     TransactionHistoryRepository repo = new TransactionHistoryRepository(unitOfWork);
     TransactionHistoryModel transactionHistoryModel = new TransactionHistoryModel();
     //UserLocationModel userLocationModel = new UserLocationModel();
     TransactionHistory transactionHistory = new TransactionHistory();
      AutoMapper.Mapper.Map(transactionHistoryModel, transactionHistory);
     transactionHistory = repo.GetAll().Where(x => x.MerchantReference == merchantRegrence).SingleOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(transactionHistory, transactionHistoryModel);
     return transactionHistoryModel;
 }
Esempio n. 4
0
        public IHttpActionResult ReturnSucceesCallback(TransactionHistoryModel model)
        {
            try
            {
                //string headers = string.Empty;
                //foreach (var head in Request.Content.Headers)
                //{
                //    headers += "Key : " + head.Key + " , Value : " + head.Value;
                //}

                //string parameters = string.Empty;

                //foreach (var param in HttpContext.Current.Request.Params)
                //{
                var merchantRefrence = model.MerchantReference;
                TransactionHistoryModel historyModel = new TransactionHistoryModel();
                historyModel = transactionHistoryService.FindTransactionHistoryByMerchantRegrence(merchantRefrence);
                historyModel.Status = model.Status;
                historyModel.ResponseMessage = model.ResponseMessage;
                historyModel.Eci = model.Eci;
                historyModel.CardNumber = model.CardNumber;
                historyModel.FortId = model.FortId;
                historyModel.ResponseCode = model.ResponseCode;
                historyModel.CustomerEmail = model.CustomerEmail;
                historyModel.CustomerIp = model.CustomerIp;
                //historyModel.Amount = model.Amount;
                historyModel.Command = model.Command;
                historyModel.PaymentOption = model.PaymentOption;
                historyModel.ExpiryDate = model.ExpiryDate;
                historyModel.Signature = model.Signature;
                if (historyModel.URFXPaymentType == URFXPaymentType.PlanPayment)
                {

                    if (historyModel.Status == Utility.Constants.SUCCESS_STATUS)
                    {

                        var startDate = DateTime.Now;
                        UserPlanModel userPlanModel = new UserPlanModel();
                        userPlanModel.PlanId = historyModel.PlanId;
                        userPlanModel.UserId = historyModel.UserId;
                        userPlanModel.NumberOfTeams = historyModel.NumberOfTeams;
                        userPlanModel.CreatedDate = startDate;
                        userPlanModel.ExpiredDate = startDate.AddDays(30);
                        bool planExist = userPlanService.CheckExistanceOfUserPlan(userPlanModel.UserId);
                        if (!planExist)
                        {
                            userPlanModel = userPlanService.InsertUserPlan(userPlanModel);

                        }
                        transactionHistoryService.UpdateTransactionHistory(historyModel);
                        //parameters += "Key : " + param + " , value:" + HttpContext.Current.Request.Params[param.ToString()];
                    }
                    else
                    {
                        transactionHistoryService.UpdateTransactionHistory(historyModel);
                    }
                }
                else if(historyModel.URFXPaymentType == URFXPaymentType.JobPayment)
                {
                    ApplicationUser user = UserManager.FindById(historyModel.UserId);
                    transactionHistoryService.UpdateTransactionHistory(historyModel);
                    JobModel jobModel = new JobModel();
                    if (historyModel.Status == Utility.Constants.SUCCESS_STATUS)
                    {

                        jobModel = jobService.GetJobById(historyModel.JobId);
                        jobModel.IsPaid = true;
                        jobModel.CreatedDate = DateTime.UtcNow;
                        jobService.UpadteJob(jobModel);
                    }

                    if (user.DeviceType == Utility.Constants.DEVICE_TYPE_ANDROID)
                    {
                        string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.userId=" + historyModel.UserId + "&data.jobId=" + historyModel.JobId + "&data.type=" + Utility.Constants.JOB_CREATED_TYPE + "&data.message=" + Utility.Constants.MESSAGE_FOR_JOB_CREATED + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + user.DeviceToken + "";
                        var response = sendNotificationService.SendNotificationForAndroid(postData);
                    }
                    else if (user.DeviceType == Utility.Constants.DEVICE_TYPE_IOS)
                    {
                        string payload = "{\"aps\":{\"alert\":\"" + "Hi, " + Utility.Constants.MESSAGE_FOR_JOB_CREATED + "" + "\",\"badge\":1,\"sound\":\"default\"},\"JobId\":" + historyModel.JobId + ",\"userId\":\"" + historyModel.UserId + "\",\"type\":\"" + Utility.Constants.JOB_CREATED_TYPE + "\"}";
                        sendNotificationService.SendNotificationForIOS(user.DeviceToken, payload);
                    }
                }
                else
                {
                    ApplicationUser user = UserManager.FindById(historyModel.UserId);
                    transactionHistoryService.UpdateTransactionHistory(historyModel);
                    if (user.DeviceType == Utility.Constants.DEVICE_TYPE_ANDROID)
                    {
                        string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.userId=" + historyModel.UserId + "&data.jobId=" + historyModel.JobId + "&data.type=" + Utility.Constants.ADD_ADDITIONAL_TYPE + "&data.message=" + Utility.Constants.MESSAGE_FOR_ADD_ADDITIONAL + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + user.DeviceToken + "";
                        var response = sendNotificationService.SendNotificationForAndroid(postData);
                    }
                    else if (user.DeviceType == Utility.Constants.DEVICE_TYPE_IOS)
                    {
                        string payload = "{\"aps\":{\"alert\":\"" + "Hi, " + Utility.Constants.MESSAGE_FOR_ADD_ADDITIONAL + "" + "\",\"badge\":1,\"sound\":\"default\"},\"JobId\":" + historyModel.JobId + ",\"userId\":\"" + historyModel.UserId + "\",\"type\":\"" + Utility.Constants.ADD_ADDITIONAL_TYPE + "\"}";
                        sendNotificationService.SendNotificationForIOS(user.DeviceToken, payload);
                    }
                }
                // parameters += "Key : " + param + " , value:" + HttpContext.Current.Request.Params[param.ToString()];
                // }

                // System.IO.File.WriteAllText(HttpContext.Current.Server.MapPath("~/ExceptionFile.txt"), headers + parameters);

                return Ok(historyModel);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                System.IO.File.WriteAllText(HttpContext.Current.Server.MapPath("~/ExceptionFile.txt"), ex.Message);
                return Ok();
            }
        }
Esempio n. 5
0
        public IHttpActionResult PayNow(UserPlanBindingModel plan)
        {
            try
            {
                plan.UserId = User.Identity.GetUserId();
                plan.Email = User.Identity.GetUserName();
                plan.MerchantIdentifier = Utility.Constants.MERCHANT_IDENTIFIER;
                plan.AccessCode = Utility.Constants.ACCESS_CODE;
                plan.Command = Utility.Constants.COMMAND;
                //Guid id = Guid.NewGuid();
                Random r = new Random();
                int randNum = r.Next(1000000);
                string sixDigitNumber = randNum.ToString("D20");
                plan.Amount = plan.TotalValue;
                plan.MerchantReference = sixDigitNumber;
                plan.URFXPaymentType = Data.Enums.URFXPaymentType.PlanPayment;
                TransactionHistoryModel historyModel = new TransactionHistoryModel();
                AutoMapper.Mapper.Map(plan, historyModel);
                historyModel.CreatedDate = DateTime.UtcNow;
                historyModel = transactionHistoryService.InsertTransactionHistory(historyModel);
                AutoMapper.Mapper.Map(historyModel, plan);
                plan.TotalValue = plan.TotalValue * 100;
                byte[] secretkey = new Byte[64];
                SHA256Managed mysha256 = new SHA256Managed();

                byte[] bytedText = System.Text.UTF8Encoding.UTF8.GetBytes("" + Utility.Constants.PHRASE + "access_code=" + plan.AccessCode + "amount=" + plan.TotalValue + "command=" + plan.Command + "currency=" + plan.Currency + "customer_email=" + plan.Email + "language=" + plan.Language + "merchant_identifier=" + plan.MerchantIdentifier + "merchant_reference=" + plan.MerchantReference + Utility.Constants.PHRASE);
                byte[] hashValue = mysha256.ComputeHash(bytedText);
                byte[] hash = HashHMAC(bytedText);
                plan.SecretKey = HashEncode(hash);

                return Ok(plan);
            }
            catch (Exception ex)
            {
                return BadRequest(ex.Message);
            }
        }
Esempio n. 6
0
        public IHttpActionResult ClientPayment(UserPlanBindingModel plan)
        {
            try
            {
                ApplicationUser user = UserManager.FindById(plan.UserId);
                if (user != null)
                {
                    plan.Email = user.Email;// User.Identity.GetUserName();
                    plan.MerchantIdentifier = Utility.Constants.MERCHANT_IDENTIFIER;
                    plan.AccessCode = Utility.Constants.ACCESS_CODE;
                    plan.Command = Utility.Constants.COMMAND;//"AUTHORIZATION"; //
                                                             //Guid id = Guid.NewGuid();
                    Random r = new Random();
                    int randNum = r.Next(1000000);
                    string sixDigitNumber = randNum.ToString("D20");
                    plan.Amount = plan.TotalValue;
                    plan.MerchantReference = sixDigitNumber;
                    if(plan.PaymentType == URFXPaymentType.JobPayment.ToString())
                    {
                        plan.URFXPaymentType = Data.Enums.URFXPaymentType.JobPayment;
                    }
                    else
                    {
                        plan.URFXPaymentType = Data.Enums.URFXPaymentType.JobAdditionalPayment;
                    }
                    TransactionHistoryModel historyModel = new TransactionHistoryModel();
                    AutoMapper.Mapper.Map(plan, historyModel);
                    historyModel.CreatedDate = DateTime.UtcNow;
                    historyModel = transactionHistoryService.InsertTransactionHistory(historyModel);
                    AutoMapper.Mapper.Map(historyModel, plan);
                    plan.TotalValue = plan.TotalValue * 100;
                    byte[] secretkey = new Byte[64];
                    SHA256Managed mysha256 = new SHA256Managed();

                    byte[] bytedText = System.Text.UTF8Encoding.UTF8.GetBytes("" + Utility.Constants.PHRASE + "access_code=" + plan.AccessCode + "amount=" + plan.TotalValue + "command=" + plan.Command + "currency=" + plan.Currency + "customer_email=" + plan.Email + "language=" + plan.Language + "merchant_identifier=" + plan.MerchantIdentifier + "merchant_reference=" + plan.MerchantReference + Utility.Constants.PHRASE);
                    byte[] hashValue = mysha256.ComputeHash(bytedText);
                    byte[] hash = HashHMAC(bytedText);
                    plan.SecretKey = HashEncode(hash);
                    plan.Url = Utility.Constants.PAYMENT_URL;
                    return Json(plan);
                }
                else
                {
                    return BadRequest("User not found");
                }

            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
        }
        public TransactionHistoryModel UpdateTransactionHistory(TransactionHistoryModel transactionHistoryModel)
        {
            //unitOfWork.StartTransaction();
            TransactionHistoryRepository repo = new TransactionHistoryRepository(unitOfWork);
            //UserLocationModel userLocationModel = new UserLocationModel();
            TransactionHistory transactionHistory = new TransactionHistory();

            transactionHistory = repo.GetAll().Where(x => x.CartId == transactionHistoryModel.CartId).SingleOrDefault();

            transactionHistoryModel.CartId = transactionHistory.CartId;
            AutoMapper.Mapper.Map(transactionHistoryModel, transactionHistory);
            repo.Update(transactionHistory);
            //unitOfWork.Commit();
            AutoMapper.Mapper.Map(transactionHistory, transactionHistoryModel);
            return transactionHistoryModel;
        }
 public TransactionHistoryModel InsertTransactionHistory(TransactionHistoryModel transactionHistoryModel)
 {
     //unitOfWork.StartTransaction();
     TransactionHistoryRepository repo = new TransactionHistoryRepository(unitOfWork);
     //UserLocationModel userLocationModel = new UserLocationModel();
     TransactionHistory transactionHistory = new TransactionHistory();
     AutoMapper.Mapper.Map(transactionHistoryModel, transactionHistory);
     transactionHistory = repo.Insert(transactionHistory);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(transactionHistory, transactionHistoryModel);
     return transactionHistoryModel;
 }
Esempio n. 9
0
 public IHttpActionResult GetReceipt(int jobId)
 {
     TransactionHistoryBindingModel transactionHistoryBindingModel = new TransactionHistoryBindingModel();
     TransactionHistoryModel transactionHistoryModel = new TransactionHistoryModel();
     transactionHistoryModel = transactionHistoryService.GetTransactionHistoryByJobId(jobId);
     AutoMapper.Mapper.Map(transactionHistoryModel, transactionHistoryBindingModel);
     return Ok(transactionHistoryBindingModel);
 }