public virtual async Task SetDefaultPaymentMethod(CartContext cartContext) { var country = _countryService.Get(cartContext?.CountryCode); var paymentOption = _requestModelAccessor.RequestModel.ChannelModel?.Channel?.CountryLinks?.FirstOrDefault(x => x.CountrySystemId == country?.SystemId)?.PaymentOptions.FirstOrDefault(); if (paymentOption != null) { var paymentProvider = _paymentProviderService.Get(paymentOption.Id.ProviderId); var orderPaymentLink = _requestModelAccessor.RequestModel.Cart.Order.OrderPaymentLinks.FirstOrDefault(); if (orderPaymentLink != null) { var payment = _paymentService.Get(orderPaymentLink.PaymentSystemId); // Set default payment option if (payment != null && payment.PaymentOption.ProviderId != paymentProvider.Id && payment.PaymentOption.OptionId != paymentOption.Id.OptionId) { var selectPaymentArgs = new SelectPaymentOptionArgs { PaymentOptionId = paymentOption.Id }; await cartContext.SelectPaymentOptionAsync(selectPaymentArgs); } } } }