public virtual async Task <IActionResult> RePostPayment(string orderId) { var order = await _orderService.GetOrderById(orderId); if (!await order.Access(_workContext.CurrentCustomer, _groupService)) { return(Challenge()); } var paymentTransaction = await _paymentTransactionService.GetByOrdeGuid(order.OrderGuid); if (paymentTransaction == null || !await _paymentService.CanRePostRedirectPayment(paymentTransaction)) { return(RedirectToRoute("OrderDetails", new { orderId = orderId })); } await _paymentService.PostRedirectPayment(paymentTransaction); if (IsRequestBeingRedirected || IsPostBeingDone) { //redirection or POST has been done in PostProcessPayment return(Content("Redirected")); } //if no redirection has been done (to a third-party payment page) //theoretically it's not possible return(RedirectToRoute("OrderDetails", new { orderId = orderId })); }
public async Task <IActionResult> GoToOrderNumber(PaymentTransactionListModel model) { if (model.OrderNumber == null) { return(RedirectToAction("List", "PaymentTransaction")); } int.TryParse(model.OrderNumber, out var id); var order = await _orderService.GetOrderByNumber(id); if (order == null) { return(RedirectToAction("List", "PaymentTransaction")); } var paymentTransaction = await _paymentTransactionService.GetByOrdeGuid(order.OrderGuid); if (paymentTransaction == null) { //not found return(RedirectToAction("List", "PaymentTransaction")); } if (await _groupService.IsStaff(_workContext.CurrentCustomer) && paymentTransaction.StoreId != _workContext.CurrentCustomer.StaffStoreId) { return(RedirectToAction("List", "PaymentTransaction")); } return(RedirectToAction("Edit", "PaymentTransaction", new { id = paymentTransaction.Id })); }
private async Task PreparePaymentMethod(GetOrderDetails request, OrderDetailsModel model) { var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(request.Order.PaymentMethodSystemName); model.PaymentMethod = paymentMethod != null ? paymentMethod.FriendlyName : request.Order.PaymentMethodSystemName; model.PaymentMethodStatus = request.Order.PaymentStatusId.GetTranslationEnum(_translationService, request.Language.Id); var paymentTransaction = await _paymentTransactionService.GetByOrdeGuid(request.Order.OrderGuid); model.CanRePostProcessPayment = paymentTransaction != null ? await _paymentService.CanRePostRedirectPayment(paymentTransaction) : false; }
public async Task <bool> Handle(CancelOrderCommand request, CancellationToken cancellationToken) { if (request.Order == null) { throw new ArgumentNullException(nameof(request.Order)); } if (request.Order.OrderStatusId == (int)OrderStatusSystem.Cancelled) { throw new Exception("Cannot do cancel for order."); } var shipments = await _shipmentService.GetShipmentsByOrder(request.Order.Id); if (shipments.Any()) { throw new Exception("Cannot do cancel for order with shipments"); } //Cancel order await _mediator.Send(new SetOrderStatusCommand() { Order = request.Order, Os = OrderStatusSystem.Cancelled, NotifyCustomer = request.NotifyCustomer, NotifyStoreOwner = request.NotifyStoreOwner }); //add a note await _orderService.InsertOrderNote(new OrderNote { Note = "Order has been cancelled", DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow, OrderId = request.Order.Id, }); //return (add) back redeemded loyalty points await _mediator.Send(new ReturnBackRedeemedLoyaltyPointsCommand() { Order = request.Order }); //Adjust inventory foreach (var orderItem in request.Order.OrderItems) { var product = await _productService.GetProductById(orderItem.ProductId); await _inventoryManageService.AdjustReserved(product, orderItem.Quantity - orderItem.CancelQty, orderItem.Attributes, orderItem.WarehouseId); } //update open qty foreach (var orderItem in request.Order.OrderItems) { orderItem.OpenQty = 0; } await _orderService.UpdateOrder(request.Order); //cancel reservations await _productReservationService.CancelReservationsByOrderId(request.Order.Id); //cancel bid await _auctionService.CancelBidByOrder(request.Order.Id); //cancel discount await _discountService.CancelDiscount(request.Order.Id); //cancel payments var payment = await _paymentTransactionService.GetByOrdeGuid(request.Order.OrderGuid); if (payment != null) { await _paymentService.CancelPayment(payment); } //event notification await _mediator.Publish(new OrderCancelledEvent(request.Order)); return(true); }