Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Domain.Payments;
using Grand.Web.Features.Models.Checkout;
using Grand.Mediator;
namespace Grand.Web.Features.Handlers.Checkout;
public class GetIsPaymentWorkflowRequiredHandler : IRequestHandler<GetIsPaymentWorkflowRequired, bool>
{
private readonly IOrderCalculationService _orderTotalCalculationService;
private readonly PaymentSettings _paymentSettings;
public GetIsPaymentWorkflowRequiredHandler(IOrderCalculationService orderTotalCalculationService,
PaymentSettings paymentSettings)
{
_orderTotalCalculationService = orderTotalCalculationService;
_paymentSettings = paymentSettings;
}
public async Task<bool> Handle(GetIsPaymentWorkflowRequired request, CancellationToken cancellationToken)
{
var result = true;
//check whether order total equals zero
var shoppingCartTotalBase =
(await _orderTotalCalculationService.GetShoppingCartTotal(request.Cart, request.UseLoyaltyPoints))
.shoppingCartTotal;
if (shoppingCartTotalBase is 0 && !_paymentSettings.ShowPaymentIfCartIsZero)
result = false;
return result;
}
}