Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Foundation/Features/Checkout/Services/CheckoutService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ public virtual IPurchaseOrder PlaceOrder(ICart cart, ModelStateDictionary modelS
{
modelState.AddModelError("", _localizationService.GetString("/Checkout/Payment/Errors/ProcessingPaymentFailure") + ex.Message);
}
catch (Exception ex)
{
modelState.AddModelError("", ex.Message);
}

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
using Foundation.Commerce.Customer.Services;
using Foundation.Commerce.Extensions;
using Foundation.Features.CatalogContent.Services;
using Foundation.Features.Checkout.Payments;
using Foundation.Features.Checkout.Services;
using Foundation.Features.Checkout.ViewModels;
using Foundation.Features.Header;
using Foundation.Features.MyAccount.OrderConfirmation;
using Foundation.Features.Settings;
using Foundation.Infrastructure;
using Foundation.Personalization;
using Mediachase.Commerce;
using Mediachase.Commerce.Catalog;
using Mediachase.Commerce.Orders;
using Mediachase.Commerce.Security;
Expand Down Expand Up @@ -56,6 +58,8 @@ public class DefaultCartController : PageController<CartPage>
private readonly IProductService _productService;
private readonly LanguageResolver _languageResolver;
private readonly ISettingsService _settingsService;
private readonly IPaymentService _paymentService;
private readonly ICurrentMarket _currentMarket;

private const string b2cMinicart = "~/Features/Shared/Foundation/Header/_HeaderCart.cshtml";

Expand All @@ -75,7 +79,9 @@ public DefaultCartController(
CartItemViewModelFactory cartItemViewModelFactory,
IProductService productService,
LanguageResolver languageResolver,
ISettingsService settingsService)
ISettingsService settingsService,
IPaymentService paymentService,
ICurrentMarket currentMarket)

{
_cartService = cartService;
Expand All @@ -94,6 +100,8 @@ public DefaultCartController(
_productService = productService;
_languageResolver = languageResolver;
_settingsService = settingsService;
_paymentService = paymentService;
_currentMarket = currentMarket;
}

private CartWithValidationIssues CartWithValidationIssues => _cart ?? (_cart = _cartService.LoadCart(_cartService.DefaultCartName, true));
Expand Down Expand Up @@ -373,12 +381,13 @@ public async Task<ActionResult> BuyNow(RequestParamsToCart param)
}

var totals = _orderGroupCalculator.GetOrderGroupTotals(CartWithValidationIssues.Cart);

var creditCardPayment = _paymentService.GetPaymentMethodsByMarketIdAndLanguageCode(CartWithValidationIssues.Cart.MarketId.Value, _currentMarket.GetCurrentMarket().DefaultLanguage.Name).FirstOrDefault(x => x.SystemKeyword == "GenericCreditCard");
var payment = CartWithValidationIssues.Cart.CreateCardPayment();

payment.BillingAddress = paymentAddress;
payment.CardType = "Credit card";
payment.PaymentMethodId = new Guid("B1DA37A6-CF19-40D5-915B-B863D74D8799");
payment.PaymentMethodName = "GenericCreditCard";
payment.PaymentMethodId = creditCardPayment.PaymentMethodId;
payment.PaymentMethodName = creditCardPayment.SystemKeyword;
payment.Amount = CartWithValidationIssues.Cart.GetTotal().Amount;
payment.CreditCardNumber = creditCard.CreditCardNumber;
payment.CreditCardSecurityCode = creditCard.SecurityCode;
Expand All @@ -401,7 +410,7 @@ public async Task<ActionResult> BuyNow(RequestParamsToCart param)
await _recommendationService.TrackOrder(HttpContext, order);

var referencePages = _settingsService.GetSiteSettings<ReferencePageSettings>();
if (referencePages?.OrderConfirmationPage.IsNullOrEmpty() ?? false)
if (!(referencePages?.OrderConfirmationPage.IsNullOrEmpty() ?? true))
{
var orderConfirmationPage = _contentLoader.Get<OrderConfirmationPage>(referencePages.OrderConfirmationPage);
var queryCollection = new NameValueCollection
Expand Down