diff --git a/src/main/java/alfio/controller/EventController.java b/src/main/java/alfio/controller/EventController.java index c02600c3ef..02882f3611 100644 --- a/src/main/java/alfio/controller/EventController.java +++ b/src/main/java/alfio/controller/EventController.java @@ -221,7 +221,7 @@ public String showEvent(@PathVariable("eventName") String eventName, List validCategories = ticketCategories.stream().filter(tc -> !tc.getExpired()).collect(Collectors.toList()); List additionalServices = additionalServiceRepository.loadAllForEvent(event.getId()).stream().map((as) -> getSaleableAdditionalService(event, locale, as, promoCodeDiscount.orElse(null))).collect(Collectors.toList()); Predicate waitingQueueTargetCategory = tc -> !tc.getExpired() && !tc.isBounded(); - boolean inValidOfflinePayment = event.getAllowedPaymentProxies().size() == 1 && event.getAllowedPaymentProxies().contains(PaymentProxy.OFFLINE) && !TicketReservationManager.hasValidOfflinePaymentWaitingPeriod(event, configurationManager); + boolean validPaymentConfigured = isEventHasValidPaymentConfigurations(event, configurationManager); model.addAttribute("event", eventDescriptor)// .addAttribute("organization", organizationRepository.getById(event.getOrganizationId())) .addAttribute("ticketCategories", validCategories)// @@ -242,9 +242,9 @@ public String showEvent(@PathVariable("eventName") String eventName, .addAttribute("showAdditionalServices", !additionalServices.isEmpty()) .addAttribute("enabledAdditionalServices", additionalServices.stream().filter(SaleableAdditionalService::isNotExpired).collect(Collectors.toList())) .addAttribute("disabledAdditionalServices", additionalServices.stream().filter(SaleableAdditionalService::isExpired).collect(Collectors.toList())) - .addAttribute("forwardButtonDisabled", (ticketCategories.stream().noneMatch(SaleableTicketCategory::getSaleable)) || inValidOfflinePayment) + .addAttribute("forwardButtonDisabled", (ticketCategories.stream().noneMatch(SaleableTicketCategory::getSaleable)) || !validPaymentConfigured) .addAttribute("useFirstAndLastName", event.mustUseFirstAndLastName()) - .addAttribute("validPaymentMethodAvailable", !inValidOfflinePayment); + .addAttribute("validPaymentMethodAvailable", validPaymentConfigured); model.asMap().putIfAbsent("hasErrors", false);// return "/event/show-event"; @@ -337,4 +337,15 @@ private static boolean shouldApplyDiscount(PromoCodeDiscount promoCodeDiscount, return promoCodeDiscount.getCategories().isEmpty() || promoCodeDiscount.getCategories().contains(ticketCategory.getId()); } + private boolean isEventHasValidPaymentConfigurations(Event event, ConfigurationManager configurationManager) { + if (event.isFreeOfCharge()) { + return true; + } else if (event.getAllowedPaymentProxies().size() == 0) { + return false; + } else { + //Check whether event already started and it has only PaymentProxy.OFFLINE as payment method + return !(event.getAllowedPaymentProxies().size() == 1 && event.getAllowedPaymentProxies().contains(PaymentProxy.OFFLINE) && !TicketReservationManager.hasValidOfflinePaymentWaitingPeriod(event, configurationManager)); + } + } + } diff --git a/src/main/java/alfio/controller/ReservationController.java b/src/main/java/alfio/controller/ReservationController.java index 53ee5aaa8d..d2858f0786 100644 --- a/src/main/java/alfio/controller/ReservationController.java +++ b/src/main/java/alfio/controller/ReservationController.java @@ -169,7 +169,7 @@ public String showPaymentPage(@PathVariable("eventName") String eventName, OrderSummary orderSummary = ticketReservationManager.orderSummaryForReservationId(reservationId, event, locale); List activePaymentMethods = paymentManager.getPaymentMethods(event.getOrganizationId()) .stream() - .filter(p -> p.isActive() && event.getAllowedPaymentProxies().contains(p.getPaymentProxy()) && !p.getPaymentProxy().equals(PaymentProxy.OFFLINE) || (p.getPaymentProxy().equals(PaymentProxy.OFFLINE) && p.isActive() && event.getAllowedPaymentProxies().contains(p.getPaymentProxy()) && TicketReservationManager.hasValidOfflinePaymentWaitingPeriod(event, configurationManager))) + .filter(p -> TicketReservationManager.isValidPaymentMethod(p, event, configurationManager)) .map(PaymentManager.PaymentMethod::getPaymentProxy) .collect(toList()); model.addAttribute("multiplePaymentMethods" , activePaymentMethods.size() > 1 ); diff --git a/src/main/java/alfio/manager/TicketReservationManager.java b/src/main/java/alfio/manager/TicketReservationManager.java index afaca9db4f..212cc39cab 100644 --- a/src/main/java/alfio/manager/TicketReservationManager.java +++ b/src/main/java/alfio/manager/TicketReservationManager.java @@ -501,6 +501,19 @@ public static boolean hasValidOfflinePaymentWaitingPeriod(Event event, Configura } } + + /** + * ValidPaymentMethod should be configured in organisation and event. And if even already started then event should not have PaymentProxy.OFFLINE as only payment method + * + * @param paymentMethod + * @param event + * @param configurationManager + * @return + */ + public static boolean isValidPaymentMethod(PaymentManager.PaymentMethod paymentMethod, Event event, ConfigurationManager configurationManager) { + return paymentMethod.isActive() && event.getAllowedPaymentProxies().contains(paymentMethod.getPaymentProxy()) && (!paymentMethod.getPaymentProxy().equals(PaymentProxy.OFFLINE) || hasValidOfflinePaymentWaitingPeriod(event, configurationManager)); + } + private void reTransitionToPending(String reservationId) { int updatedReservation = ticketReservationRepository.updateTicketStatus(reservationId, TicketReservationStatus.PENDING.toString()); Validate.isTrue(updatedReservation == 1, "expected exactly one updated reservation, got "+updatedReservation); diff --git a/src/main/resources/alfio/i18n/public.properties b/src/main/resources/alfio/i18n/public.properties index 9cca41cbaa..d53485270a 100644 --- a/src/main/resources/alfio/i18n/public.properties +++ b/src/main/resources/alfio/i18n/public.properties @@ -307,7 +307,7 @@ show-event.sold-out.message=Subscribe to the waiting queue and we''ll inform you show-event.sold-out.subscribe=subscribe show-event.sold-out.subscription-complete=Thank you for joining the waiting queue. We''ll keep you posted! show-event.sold-out.subscription-error=Something went wrong, please retry in few minutes. Thank you! -show-event.offline-payment-not-available=We''re sorry, Cannot confirm an offline reservation after event start. +show-event.offline-payment-not-available=Due to a wrong configuration, it''s not possible to sell tickets right now. Please contact the organizers. email-waiting-queue.subscribed.subject=You joined the waiting queue for {0} email-waiting-queue.subscribed.text=As requested, you joined the waiting queue for the event {0}. We''ll keep you posted if something comes up\! diff --git a/src/main/resources/alfio/i18n/public_de.properties b/src/main/resources/alfio/i18n/public_de.properties index 123b005d59..2e4a412b72 100644 --- a/src/main/resources/alfio/i18n/public_de.properties +++ b/src/main/resources/alfio/i18n/public_de.properties @@ -271,6 +271,7 @@ show-event.sold-out.message=Registrieren dich auf der Warteliste, sobald ein Pla show-event.sold-out.subscribe=abonnieren show-event.sold-out.subscription-complete=Vielen Dank f\u00FCr die Teilnahme an unserer Warteliste. Wir halten dich auf dem Laufenden! show-event.sold-out.subscription-error=Etwas ist schief gelaufen, bitte versuche es in einigen Minuten erneut. Vielen Dank! +show-event.offline-payment-not-available=DE-Due to a wrong configuration, it''s not possible to sell tickets right now. Please contact the organizers. email-waiting-queue.subscribed.subject=Du bist der Warteliste beigetreten {0} email-waiting-queue.subscribed.text=Wie gew\u00FCnscht, haben wir dich der Warteliste f\u00FCr die Veranstaltung {0} hinzugef\u00FCgt. \u00DCber Neuigkeiten halten wir dich auf dem Laufenden! diff --git a/src/main/resources/alfio/i18n/public_it.properties b/src/main/resources/alfio/i18n/public_it.properties index 617ec21876..19da14e9c5 100644 --- a/src/main/resources/alfio/i18n/public_it.properties +++ b/src/main/resources/alfio/i18n/public_it.properties @@ -261,6 +261,8 @@ show-event.sold-out.message=Iscriviti alla lista d''attesa e verrai avvisato non show-event.sold-out.subscribe=iscriviti show-event.sold-out.subscription-complete=Grazie per esserti iscritto alla lista d''attesa. Ti terremo informato\! show-event.sold-out.subscription-error=Iscrizione non riuscita. Per favore riprova tra qualche minuto, grazie\! +show-event.offline-payment-not-available=IT-Due to a wrong configuration, it''s not possible to sell tickets right now. Please contact the organizers. + email-waiting-queue.subscribed.subject=Conferma iscrizione alla lista d''attesa per {0} email-waiting-queue.subscribed.admin.text=Qualcuno si \u00E8 aggiunto alla lista d''attesa ({0}) per {1}. Maggiori informazioni nell''admin area email-waiting-queue.subscribed.text=Come richiesto, abbiamo aggiunto il tuo nome alla lista d''attesa per {0}. Ti faremo sapere non appena ci saranno novit\u00E0\! diff --git a/src/main/resources/alfio/i18n/public_nl.properties b/src/main/resources/alfio/i18n/public_nl.properties index f0cc33279d..320a02640c 100644 --- a/src/main/resources/alfio/i18n/public_nl.properties +++ b/src/main/resources/alfio/i18n/public_nl.properties @@ -275,6 +275,7 @@ show-event.sold-out.message=Abonneer op de wachtrij en wij zullen u een bericht show-event.sold-out.subscribe=Abonneer show-event.sold-out.subscription-complete=Dankuwel voor het abonneren op de wachtrij. We houden contact\! show-event.sold-out.subscription-error=Er ging iets fout, probeer het opnieuw in een paar minuten. +show-event.offline-payment-not-available=NL-Due to a wrong configuration, it''s not possible to sell tickets right now. Please contact the organizers. email-waiting-queue.subscribed.subject=U heeft zich geabonneerd op de wachtrij voor {0} email-waiting-queue.subscribed.text=U heeft zich geabonneerd op de wachtrij voor {0}. We houden u op de hoogte\!