Пример #1
0
        public ActionResult SMSMessageApprove(PaymentResultModel inputModel)
        {
            int UserID = (int)MembershipHelper.GetCurrenUser().ProviderUserKey;
            PaymentResultModel resModel = new PaymentResultModel();
            resModel = inputModel;
            tPaymentMessage msg = _paymentMessageRepository.Find(inputModel.SMSUniqueID);
            if (msg == null) {
                resModel.PaymentStatus = false;
                resModel.StatusMessage += "SMS Code not found :" + msg.UniqueID;
                ModelState.AddModelError("SMSStatus", resModel.StatusMessage);
                return View("MakePayment", inputModel);
            }
            if (inputModel.PaymentCode != msg.SMSCode) {
                resModel.PaymentStatus = false;
                resModel.StatusMessage += "SMS Code is wrong :" + msg.UniqueID;
                ModelState.AddModelError("SMSStatus", resModel.StatusMessage);
                return View("MakePayment", inputModel);
            }

            tDeal currentDeal = _dealRepository.Find(inputModel.IDDeal);
            ValidateDeal(currentDeal);
            if (!ModelState.IsValid) {
                resModel.PaymentStatus = false;
                resModel.StatusMessage += "Deal Error";
                ModelState.AddModelError("SMSStatus", resModel.StatusMessage);
                return View("MakePayment", inputModel);
            }

            List<tCoupon> couponsForThisPartner = _couponRepository.GetListByIDPartnerNotUsedAndNotConsumed(currentDeal.IDPartner);
            if (couponsForThisPartner == null || couponsForThisPartner.Count == 0) {
                resModel.PaymentStatus = false;
                resModel.StatusMessage += "Coupon info could't be found, please contact web admin";
                ModelState.AddModelError("SMSStatus", resModel.StatusMessage);
                return View("MakePayment", inputModel);
            }
            tCoupon currCouponToUse = couponsForThisPartner[0];
            resModel.CouponCode = currCouponToUse.CustomCode;
            currCouponToUse.CouponStatus = (int)Enums.enmCouponStatus.Used;
            decimal AmountToBePaid = CalculateAmountToBePaid(currentDeal, inputModel.Quantity);
            if (AmountToBePaid <= 0) {
                resModel.PaymentStatus = false;
                resModel.StatusMessage += "Please verify amount to be paid for this deal!";
                ModelState.AddModelError("SMSStatus", resModel.StatusMessage);
                return View("MakePayment", inputModel);
            }

            resModel.StatusMessage = "Your Order has been approved succesfully!";
            resModel.PaymentStatus = true;
            _couponRepository.InsertOrUpdate(currCouponToUse);

            tOrder order = new tOrder();
            order.AmountPaid = AmountToBePaid;
            order.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes;
            order.IDCoupon = currCouponToUse.IDCoupon;
            order.IDDeal = currentDeal.IDDeal;

            order.IDUserBought = UserID;
            order.MobilePhoneNo = CommonUtils.Instance.ShoppingCart.MobilePhone;
            order.OrderNotes = CommonUtils.Instance.ShoppingCart.OrderNotes;
            order.OrderStatus = (int)Enums.enmOrderStatus.ToBePaid;
            order.PaymentType = (int)Enums.enmPaymentType.BeelineKG;
            order.Quantity = CommonUtils.Instance.ShoppingCart.Quantity;
            order.RefundStatus = (int)Enums.enmRefundStatus.OrderSuccessful;
            _orderRepository.InsertOrUpdate(order);

            if (resModel.PaymentStatus) {
                _orderRepository.Save();
                _couponRepository.Save();
            }

            return View(resModel);
        }
Пример #2
0
        public ActionResult SMSMessageApprove(PaymentResultModel inputModel)
        {
            int UserID = (int)MembershipHelper.GetCurrenUser().ProviderUserKey;
            PaymentResultModel resModel = new PaymentResultModel();

            resModel = inputModel;
            tPaymentMessage msg = _paymentMessageRepository.Find(inputModel.SMSUniqueID);

            if (msg == null)
            {
                resModel.PaymentStatus  = false;
                resModel.StatusMessage += "SMS Code not found :" + msg.UniqueID;
                ModelState.AddModelError("SMSStatus", resModel.StatusMessage);
                return(View("MakePayment", inputModel));
            }
            if (inputModel.PaymentCode != msg.SMSCode)
            {
                resModel.PaymentStatus  = false;
                resModel.StatusMessage += "SMS Code is wrong :" + msg.UniqueID;
                ModelState.AddModelError("SMSStatus", resModel.StatusMessage);
                return(View("MakePayment", inputModel));
            }

            tDeal currentDeal = _dealRepository.Find(inputModel.IDDeal);

            ValidateDeal(currentDeal);
            if (!ModelState.IsValid)
            {
                resModel.PaymentStatus  = false;
                resModel.StatusMessage += "Deal Error";
                ModelState.AddModelError("SMSStatus", resModel.StatusMessage);
                return(View("MakePayment", inputModel));
            }

            List <tCoupon> couponsForThisPartner = _couponRepository.GetListByIDPartnerNotUsedAndNotConsumed(currentDeal.IDPartner);

            if (couponsForThisPartner == null || couponsForThisPartner.Count == 0)
            {
                resModel.PaymentStatus  = false;
                resModel.StatusMessage += "Coupon info could't be found, please contact web admin";
                ModelState.AddModelError("SMSStatus", resModel.StatusMessage);
                return(View("MakePayment", inputModel));
            }
            tCoupon currCouponToUse = couponsForThisPartner[0];

            resModel.CouponCode          = currCouponToUse.CustomCode;
            currCouponToUse.CouponStatus = (int)Enums.enmCouponStatus.Used;
            decimal AmountToBePaid = CalculateAmountToBePaid(currentDeal, inputModel.Quantity);

            if (AmountToBePaid <= 0)
            {
                resModel.PaymentStatus  = false;
                resModel.StatusMessage += "Please verify amount to be paid for this deal!";
                ModelState.AddModelError("SMSStatus", resModel.StatusMessage);
                return(View("MakePayment", inputModel));
            }

            resModel.StatusMessage = "Your Order has been approved succesfully!";
            resModel.PaymentStatus = true;
            _couponRepository.InsertOrUpdate(currCouponToUse);

            tOrder order = new tOrder();

            order.AmountPaid = AmountToBePaid;
            order.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes;
            order.IDCoupon   = currCouponToUse.IDCoupon;
            order.IDDeal     = currentDeal.IDDeal;

            order.IDUserBought  = UserID;
            order.MobilePhoneNo = CommonUtils.Instance.ShoppingCart.MobilePhone;
            order.OrderNotes    = CommonUtils.Instance.ShoppingCart.OrderNotes;
            order.OrderStatus   = (int)Enums.enmOrderStatus.ToBePaid;
            order.PaymentType   = (int)Enums.enmPaymentType.BeelineKG;
            order.Quantity      = CommonUtils.Instance.ShoppingCart.Quantity;
            order.RefundStatus  = (int)Enums.enmRefundStatus.OrderSuccessful;
            _orderRepository.InsertOrUpdate(order);

            if (resModel.PaymentStatus)
            {
                _orderRepository.Save();
                _couponRepository.Save();
            }


            return(View(resModel));
        }
Пример #3
0
        public ActionResult MakePayment(tDealBuyModel currentCheckoutData)
        {
            currentCheckoutData.Quantity = CommonUtils.Instance.ShoppingCart.Quantity;
            currentCheckoutData.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes;
            currentCheckoutData.MobilePhone = CommonUtils.Instance.ShoppingCart.MobilePhone;

            PaymentResultModel resModel = new PaymentResultModel();
            resModel.IDDeal = currentCheckoutData.IDDeal;
            int UserID = (int)MembershipHelper.GetCurrenUser().ProviderUserKey;
            tOrder ordData = _orderRepository.GetOrderByIDDealIDUser(currentCheckoutData.IDDeal, UserID);
            tDeal currentDeal = _dealRepository.Find(currentCheckoutData.IDDeal);
            tDealBuyModel buyModel = GetBuyModel(currentDeal);
            if (ordData != null && ordData.tCoupon.ConsumeStatus == (int)Enums.enmCouponConsumeStatus.NotConsumed) {
                resModel.PaymentStatus = false;
                resModel.StatusMessage += "You have already bought this deal, please use it's coupon and try again";
                ModelState.AddModelError("Error", resModel.StatusMessage);

                return View("Checkout", buyModel);
            }

            ValidateDeal(currentDeal);
            if (!ModelState.IsValid) {
                resModel.PaymentStatus = false;
                resModel.StatusMessage += "Deal Error";
                ModelState.AddModelError("Error", resModel.StatusMessage);

                return View("Checkout", buyModel);
            }
            if (currentCheckoutData.Quantity < currentDeal.QuantityMinimum) {
                resModel.PaymentStatus = false;
                resModel.StatusMessage += "Minimum Quantity allowed :" + currentDeal.QuantityMinimum;
                ModelState.AddModelError("Error", resModel.StatusMessage);
                return View("Checkout", buyModel);
            }

            List<tCoupon> couponsForThisPartner = _couponRepository.GetListByIDPartnerNotUsedAndNotConsumed(currentDeal.IDPartner);
            if (couponsForThisPartner == null || couponsForThisPartner.Count == 0) {
                resModel.PaymentStatus = false;
                resModel.StatusMessage += "Coupon info could't be found, please contact web admin";
                currentCheckoutData.currentDeal = currentDeal;
                ModelState.AddModelError("Error", resModel.StatusMessage);
                return View("Checkout", buyModel);
            }
            tCoupon currCouponToUse = couponsForThisPartner[0];
            resModel.CouponCode = currCouponToUse.CustomCode;
            currCouponToUse.CouponStatus = (int)Enums.enmCouponStatus.Used;
            IPayment paymentAgent = new PaymentAgentBeelineKg();
            decimal AmountToBePaid = CalculateAmountToBePaid(currentDeal, currentCheckoutData.Quantity);
            if (AmountToBePaid <= 0) {
                resModel.PaymentStatus = false;
                resModel.StatusMessage += "Please verify amount to be paid for this deal!";
                ModelState.AddModelError("Error", resModel.StatusMessage);
                return View("Checkout", buyModel);
            }
            PaymentBLL pBLL = new PaymentBLL();
            bool paymentResult = pBLL.MakePayment(AmountToBePaid, paymentAgent);
            resModel.StatusMessage = pBLL.StatusMessage;
            resModel.PaymentStatus = paymentResult;
            resModel.CouponCode = currCouponToUse.CustomCode;

            if (paymentAgent.GetType() == typeof(PaymentAgentBeelineKg)) {
                System.Guid uniqueID = Guid.NewGuid();
                tPaymentMessage msg = new tPaymentMessage();
                msg.UniqueID = uniqueID.ToString();
                msg.IDDeal = currentCheckoutData.IDDeal;
                msg.IDUsed = UserID;
                msg.SMSCode = pBLL.PaymentCode;
                msg.DateAdded = DateTime.Now;
                msg.Approved = false;
                _paymentMessageRepository.InsertOrUpdate(msg);
                resModel.PaymentType = (int)Enums.enmPaymentType.BeelineKG;
                resModel.SMSUniqueID = uniqueID.ToString();
            } else {
                //Burdan aşağısı sadece kredikartı için çalışır
                _couponRepository.InsertOrUpdate(currCouponToUse);

                tOrder order = new tOrder();
                order.AmountPaid = AmountToBePaid;
                order.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes;
                order.IDCoupon = currCouponToUse.IDCoupon;
                order.IDDeal = currentDeal.IDDeal;

                order.IDUserBought = UserID;
                order.MobilePhoneNo = CommonUtils.Instance.ShoppingCart.MobilePhone;
                order.OrderNotes = currentCheckoutData.OrderNotes;
                CommonUtils.Instance.ShoppingCart.OrderNotes = currentCheckoutData.OrderNotes;
                order.OrderStatus = (int)Enums.enmOrderStatus.ToBePaid;
                order.PaymentType = (int)Enums.enmPaymentType.BeelineKG;
                order.Quantity = currentCheckoutData.Quantity;
                order.RefundStatus = (int)Enums.enmRefundStatus.OrderSuccessful;
                _orderRepository.InsertOrUpdate(order);

                if (paymentResult) {
                    _orderRepository.Save();
                    _couponRepository.Save();
                }
            }
            return View(resModel);
        }
Пример #4
0
        public ActionResult MakePayment(tDealBuyModel currentCheckoutData)
        {
            currentCheckoutData.Quantity    = CommonUtils.Instance.ShoppingCart.Quantity;
            currentCheckoutData.BuyerNotes  = CommonUtils.Instance.ShoppingCart.BuyerNotes;
            currentCheckoutData.MobilePhone = CommonUtils.Instance.ShoppingCart.MobilePhone;

            PaymentResultModel resModel = new PaymentResultModel();

            resModel.IDDeal = currentCheckoutData.IDDeal;
            int           UserID      = (int)MembershipHelper.GetCurrenUser().ProviderUserKey;
            tOrder        ordData     = _orderRepository.GetOrderByIDDealIDUser(currentCheckoutData.IDDeal, UserID);
            tDeal         currentDeal = _dealRepository.Find(currentCheckoutData.IDDeal);
            tDealBuyModel buyModel    = GetBuyModel(currentDeal);

            if (ordData != null && ordData.tCoupon.ConsumeStatus == (int)Enums.enmCouponConsumeStatus.NotConsumed)
            {
                resModel.PaymentStatus  = false;
                resModel.StatusMessage += "You have already bought this deal, please use it's coupon and try again";
                ModelState.AddModelError("Error", resModel.StatusMessage);

                return(View("Checkout", buyModel));
            }


            ValidateDeal(currentDeal);
            if (!ModelState.IsValid)
            {
                resModel.PaymentStatus  = false;
                resModel.StatusMessage += "Deal Error";
                ModelState.AddModelError("Error", resModel.StatusMessage);

                return(View("Checkout", buyModel));
            }
            if (currentCheckoutData.Quantity < currentDeal.QuantityMinimum)
            {
                resModel.PaymentStatus  = false;
                resModel.StatusMessage += "Minimum Quantity allowed :" + currentDeal.QuantityMinimum;
                ModelState.AddModelError("Error", resModel.StatusMessage);
                return(View("Checkout", buyModel));
            }

            List <tCoupon> couponsForThisPartner = _couponRepository.GetListByIDPartnerNotUsedAndNotConsumed(currentDeal.IDPartner);

            if (couponsForThisPartner == null || couponsForThisPartner.Count == 0)
            {
                resModel.PaymentStatus          = false;
                resModel.StatusMessage         += "Coupon info could't be found, please contact web admin";
                currentCheckoutData.currentDeal = currentDeal;
                ModelState.AddModelError("Error", resModel.StatusMessage);
                return(View("Checkout", buyModel));
            }
            tCoupon currCouponToUse = couponsForThisPartner[0];

            resModel.CouponCode          = currCouponToUse.CustomCode;
            currCouponToUse.CouponStatus = (int)Enums.enmCouponStatus.Used;
            IPayment paymentAgent   = new PaymentAgentBeelineKg();
            decimal  AmountToBePaid = CalculateAmountToBePaid(currentDeal, currentCheckoutData.Quantity);

            if (AmountToBePaid <= 0)
            {
                resModel.PaymentStatus  = false;
                resModel.StatusMessage += "Please verify amount to be paid for this deal!";
                ModelState.AddModelError("Error", resModel.StatusMessage);
                return(View("Checkout", buyModel));
            }
            PaymentBLL pBLL          = new PaymentBLL();
            bool       paymentResult = pBLL.MakePayment(AmountToBePaid, paymentAgent);

            resModel.StatusMessage = pBLL.StatusMessage;
            resModel.PaymentStatus = paymentResult;
            resModel.CouponCode    = currCouponToUse.CustomCode;

            if (paymentAgent.GetType() == typeof(PaymentAgentBeelineKg))
            {
                System.Guid     uniqueID = Guid.NewGuid();
                tPaymentMessage msg      = new tPaymentMessage();
                msg.UniqueID  = uniqueID.ToString();
                msg.IDDeal    = currentCheckoutData.IDDeal;
                msg.IDUsed    = UserID;
                msg.SMSCode   = pBLL.PaymentCode;
                msg.DateAdded = DateTime.Now;
                msg.Approved  = false;
                _paymentMessageRepository.InsertOrUpdate(msg);
                resModel.PaymentType = (int)Enums.enmPaymentType.BeelineKG;
                resModel.SMSUniqueID = uniqueID.ToString();
            }
            else
            {
                //Burdan aşağısı sadece kredikartı için çalışır
                _couponRepository.InsertOrUpdate(currCouponToUse);

                tOrder order = new tOrder();
                order.AmountPaid = AmountToBePaid;
                order.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes;
                order.IDCoupon   = currCouponToUse.IDCoupon;
                order.IDDeal     = currentDeal.IDDeal;

                order.IDUserBought  = UserID;
                order.MobilePhoneNo = CommonUtils.Instance.ShoppingCart.MobilePhone;
                order.OrderNotes    = currentCheckoutData.OrderNotes;
                CommonUtils.Instance.ShoppingCart.OrderNotes = currentCheckoutData.OrderNotes;
                order.OrderStatus  = (int)Enums.enmOrderStatus.ToBePaid;
                order.PaymentType  = (int)Enums.enmPaymentType.BeelineKG;
                order.Quantity     = currentCheckoutData.Quantity;
                order.RefundStatus = (int)Enums.enmRefundStatus.OrderSuccessful;
                _orderRepository.InsertOrUpdate(order);

                if (paymentResult)
                {
                    _orderRepository.Save();
                    _couponRepository.Save();
                }
            }
            return(View(resModel));
        }