public virtual IActionResult CancelRecurringPayment(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageRecurringPayments))
            {
                return(AccessDeniedView());
            }

            //try to get a recurring payment with the specified id
            var payment = _orderService.GetRecurringPaymentById(id);

            if (payment == null)
            {
                return(RedirectToAction("List"));
            }

            try
            {
                var errors = _orderProcessingService.CancelRecurringPayment(payment);
                if (errors.Any())
                {
                    foreach (var error in errors)
                    {
                        _notificationService.ErrorNotification(error);
                    }
                }
                else
                {
                    _notificationService.SuccessNotification(_localizationService.GetResource("Admin.RecurringPayments.Cancelled"));
                }

                //prepare model
                var model = _recurringPaymentModelFactory.PrepareRecurringPaymentModel(null, payment);

                //selected tab
                SaveSelectedTabName(persistForTheNextRequest: false);

                return(View(model));
            }
            catch (Exception exc)
            {
                _notificationService.ErrorNotification(exc);

                //prepare model
                var model = _recurringPaymentModelFactory.PrepareRecurringPaymentModel(null, payment);

                //selected tab
                SaveSelectedTabName(persistForTheNextRequest: false);

                return(View(model));
            }
        }
        public ActionResult CancelRecurringPayment(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageRecurringPayments))
            {
                return(AccessDeniedView());
            }

            var payment = _orderService.GetRecurringPaymentById(id);

            if (payment == null)
            {
                //No recurring payment found with the specified id
                return(RedirectToAction("List"));
            }

            try
            {
                var errors = _orderProcessingService.CancelRecurringPayment(payment);
                var model  = new RecurringPaymentModel();
                PrepareRecurringPaymentModel(model, payment);
                if (errors.Count > 0)
                {
                    foreach (var error in errors)
                    {
                        ErrorNotification(error, false);
                    }
                }
                else
                {
                    SuccessNotification(_localizationService.GetResource("Admin.RecurringPayments.Cancelled"), false);
                }

                //selected tab
                SaveSelectedTabIndex(persistForTheNextRequest: false);

                return(View(model));
            }
            catch (Exception exc)
            {
                //error
                var model = new RecurringPaymentModel();
                PrepareRecurringPaymentModel(model, payment);
                ErrorNotification(exc, false);

                //selected tab
                SaveSelectedTabIndex(persistForTheNextRequest: false);

                return(View(model));
            }
        }
Пример #3
0
        public async Task <IActionResult> CancelRecurringPayment(string id)
        {
            var payment = await _orderService.GetRecurringPaymentById(id);

            if (payment == null)
            {
                //No recurring payment found with the specified id
                return(RedirectToAction("List"));
            }

            try
            {
                var errors = await _orderProcessingService.CancelRecurringPayment(payment);

                var model = new RecurringPaymentModel();
                await PrepareRecurringPaymentModel(model, payment);

                if (errors.Count > 0)
                {
                    foreach (var error in errors)
                    {
                        ErrorNotification(error, false);
                    }
                }
                else
                {
                    SuccessNotification(_localizationService.GetResource("Admin.RecurringPayments.Cancelled"), false);
                }

                //selected tab
                SaveSelectedTabIndex(persistForTheNextRequest: false);

                return(View(model));
            }
            catch (Exception exc)
            {
                //error
                var model = new RecurringPaymentModel();
                await PrepareRecurringPaymentModel(model, payment);

                ErrorNotification(exc, false);

                //selected tab
                SaveSelectedTabIndex(persistForTheNextRequest: false);

                return(View(model));
            }
        }
Пример #4
0
        public virtual async Task <IActionResult> CancelRecurringPayment(IFormCollection form)
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(Challenge());
            }

            //get recurring payment identifier
            string recurringPaymentId = "";

            foreach (var formValue in form.Keys)
            {
                if (formValue.StartsWith("cancelRecurringPayment", StringComparison.OrdinalIgnoreCase))
                {
                    recurringPaymentId = formValue.Substring("cancelRecurringPayment".Length);
                }
            }

            var recurringPayment = await _orderService.GetRecurringPaymentById(recurringPaymentId);

            if (recurringPayment == null)
            {
                return(RedirectToRoute("CustomerOrders"));
            }

            if (await _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment))
            {
                var errors = await _orderProcessingService.CancelRecurringPayment(recurringPayment);

                var model = await _mediator.Send(new GetCustomerOrderList()
                {
                    Customer = _workContext.CurrentCustomer,
                    Language = _workContext.WorkingLanguage,
                    Store    = _storeContext.CurrentStore
                });

                model.CancelRecurringPaymentErrors = errors;

                return(View(model));
            }
            else
            {
                return(RedirectToRoute("CustomerOrders"));
            }
        }
        public ActionResult CancelRecurringPayment(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
            {
                return(AccessDeniedView());
            }

            var payment = _orderService.GetRecurringPaymentById(id);

            if (payment == null)
            {
                //No recurring payment found with the specified id
                return(RedirectToAction("List"));
            }

            ViewData["selectedTab"] = "history";

            try
            {
                var errors = _orderProcessingService.CancelRecurringPayment(payment);
                var model  = new RecurringPaymentModel();
                PrepareRecurringPaymentModel(model, payment, true);
                if (errors.Count > 0)
                {
                    foreach (var error in errors)
                    {
                        NotifyError(error, false);
                    }
                }
                else
                {
                    NotifySuccess(_localizationService.GetResource("Admin.RecurringPayments.Cancelled"), false);
                }
                return(View(model));
            }
            catch (Exception exc)
            {
                //error
                var model = new RecurringPaymentModel();
                PrepareRecurringPaymentModel(model, payment, true);
                NotifyError(exc, false);
                return(View(model));
            }
        }
Пример #6
0
        public ActionResult CancelRecurringPayment(FormCollection form)
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(new HttpUnauthorizedResult());
            }

            //get recurring payment identifier
            int recurringPaymentId = 0;

            foreach (var formValue in form.AllKeys)
            {
                if (formValue.StartsWith("cancelRecurringPayment", StringComparison.InvariantCultureIgnoreCase))
                {
                    recurringPaymentId = Convert.ToInt32(formValue.Substring("cancelRecurringPayment".Length));
                }
            }

            var recurringPayment = _orderService.GetRecurringPaymentById(recurringPaymentId);

            if (recurringPayment == null)
            {
                return(RedirectToRoute("CustomerOrders"));
            }

            if (_orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment))
            {
                var errors = _orderProcessingService.CancelRecurringPayment(recurringPayment);

                var model = PrepareCustomerOrderListModel();
                model.CancelRecurringPaymentErrors = errors;

                return(View(model));
            }
            else
            {
                return(RedirectToRoute("CustomerOrders"));
            }
        }
Пример #7
0
        public virtual IActionResult CancelRecurringPayment(IFormCollection form)
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(Challenge());
            }

            //get recurring payment identifier
            string recurringPaymentId = "";

            foreach (var formValue in form.Keys)
            {
                if (formValue.StartsWith("cancelRecurringPayment", StringComparison.OrdinalIgnoreCase))
                {
                    recurringPaymentId = formValue.Substring("cancelRecurringPayment".Length);
                }
            }

            var recurringPayment = _orderService.GetRecurringPaymentById(recurringPaymentId);

            if (recurringPayment == null)
            {
                return(RedirectToRoute("CustomerOrders"));
            }

            if (_orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment))
            {
                var errors = _orderProcessingService.CancelRecurringPayment(recurringPayment);

                var model = _orderWebService.PrepareCustomerOrderList();
                model.CancelRecurringPaymentErrors = errors;

                return(View(model));
            }
            else
            {
                return(RedirectToRoute("CustomerOrders"));
            }
        }
        public ActionResult CancelRecurringPayment(int id)
        {
            var payment = _orderService.GetRecurringPaymentById(id);

            if (payment == null)
            {
                return(RedirectToAction("List"));
            }

            try
            {
                var errors = _orderProcessingService.CancelRecurringPayment(payment);
                var model  = new RecurringPaymentModel();

                PrepareRecurringPaymentModel(model, payment, true);

                if (errors.Count > 0)
                {
                    foreach (var error in errors)
                    {
                        NotifyError(error, false);
                    }
                }
                else
                {
                    NotifySuccess(T("Admin.RecurringPayments.Cancelled"), false);
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                var model = new RecurringPaymentModel();
                PrepareRecurringPaymentModel(model, payment, true);
                NotifyError(ex, false);
                return(View(model));
            }
        }
        public virtual IActionResult CancelRecurringPayment(IFormCollection form)
        {
            if (!_customerService.IsRegistered(_workContext.CurrentCustomer))
            {
                return(Challenge());
            }

            //get recurring payment identifier
            var recurringPaymentId = 0;

            foreach (var formValue in form.Keys)
            {
                if (formValue.StartsWith("cancelRecurringPayment", StringComparison.InvariantCultureIgnoreCase))
                {
                    recurringPaymentId = Convert.ToInt32(formValue.Substring("cancelRecurringPayment".Length));
                }
            }

            var recurringPayment = _orderService.GetRecurringPaymentById(recurringPaymentId);

            if (recurringPayment == null)
            {
                return(RedirectToRoute("CustomerOrders"));
            }

            if (_orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment))
            {
                var errors = _orderProcessingService.CancelRecurringPayment(recurringPayment);

                var model = _orderModelFactory.PrepareCustomerOrderListModel();
                model.RecurringPaymentErrors = errors;

                return(View(model));
            }

            return(RedirectToRoute("CustomerOrders"));
        }
Пример #10
0
 /// <summary>
 /// Cancels a recurring payment
 /// </summary>
 /// <param name="recurringPayment">Recurring payment</param>
 public IList <string> CancelRecurringPayment(RecurringPayment recurringPayment)
 {
     return(_orderProcessingService.CancelRecurringPayment(recurringPayment));
 }
Пример #11
0
        public ActionResult Rebilling(FormCollection parameters)
        {
            var storeScope             = GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var bluePayPaymentSettings = _settingService.LoadSetting <BluePayPaymentSettings>(storeScope);
            var bpManager = new BluePayManager
            {
                AccountId = bluePayPaymentSettings.AccountId,
                UserId    = bluePayPaymentSettings.UserId,
                SecretKey = bluePayPaymentSettings.SecretKey
            };

            if (!bpManager.CheckRebillStamp(parameters))
            {
                _logger.Error("BluePay recurring error: the response has been tampered with");
                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }

            var authId = bpManager.GetAuthorizationIdByRebillId(parameters["rebill_id"]);

            if (string.IsNullOrEmpty(authId))
            {
                _logger.Error(string.Format("BluePay recurring error: the initial transaction for rebill {0} was not found",
                                            parameters["rebill_id"]));
                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }

            var initialOrder = _orderService.GetOrderByAuthorizationTransactionIdAndPaymentMethod(authId, "Payments.BluePay");

            if (initialOrder == null)
            {
                _logger.Error(string.Format("BluePay recurring error: the initial order with the AuthorizationTransactionId {0} was not found",
                                            parameters["rebill_id"]));
                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }

            var recurringPayment = _orderService.SearchRecurringPayments(initialOrderId: initialOrder.Id).FirstOrDefault();

            if (recurringPayment != null)
            {
                switch (parameters["status"])
                {
                case "expired":
                case "active":
                    var processPaymentResult = new ProcessPaymentResult
                    {
                        NewPaymentStatus = PaymentStatus.Paid,
                    };
                    _orderProcessingService.ProcessNextRecurringPayment(recurringPayment, processPaymentResult);
                    break;

                case "failed":
                case "error":
                    _logger.Error(string.Format("BluePay recurring order {0} {1}", initialOrder.Id, parameters["status"]));
                    break;

                case "deleted":
                case "stopped":
                    _orderProcessingService.CancelRecurringPayment(recurringPayment);
                    _logger.Information(string.Format("BluePay recurring order {0} was {1}", initialOrder.Id, parameters["status"]));
                    break;
                }
            }

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }