Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (!(authentication instanceof AnonymousAuthenticationToken)) {
String currentCustomerName = authentication.getName();
if(StringUtils.isNotEmpty(currentCustomerName)){
Customer customer = customerService.getCustomerByLoginOrEmail(currentCustomerName);
MarketArea marketArea = marketService.getMarketAreaByCode(checkoutProcessPojoRequest.getMarketAreaCode());
if(checkoutProcessPojoRequest.getPaymentPojo().isWantSavedPaymentInformations()){
// Save payment information
final CustomerPaymentInformation customerPaymentInformation = new CustomerPaymentInformation();
customerPaymentInformation.setPaymentType(checkoutProcessPojoRequest.getPaymentPojo().getPaymentType());
customerPaymentInformation.setCardHolderName(checkoutProcessPojoRequest.getPaymentPojo().getCardHolderName());
customerPaymentInformation.setCardNumber(checkoutProcessPojoRequest.getPaymentPojo().getCardNumber());
customerPaymentInformation.setCardExpMonth(checkoutProcessPojoRequest.getPaymentPojo().getCardExpMonth());
customerPaymentInformation.setCardExpYear(checkoutProcessPojoRequest.getPaymentPojo().getCardExpYear());
customerPaymentInformation.setCardCVV(checkoutProcessPojoRequest.getPaymentPojo().getCardCVV());
customerPaymentInformation.setCustomerMarketAreaId(marketArea.getId());
customerService.savePaymentInformation(customer, customerPaymentInformation);
}
Cart cart = cartService.getCartByMarketAreaIdAndCustomerId(marketArea.getId(), customer.getId());
// Create and Save a new order
checkoutService.checkout(customer, cart);
// WebManagementService.buildAndSaveNewOrderConfirmationMail