diff --git a/src/main/java/alfio/controller/ReservationController.java b/src/main/java/alfio/controller/ReservationController.java index e1f1ef0467..016c024d20 100644 --- a/src/main/java/alfio/controller/ReservationController.java +++ b/src/main/java/alfio/controller/ReservationController.java @@ -94,20 +94,6 @@ public class ReservationController { @RequestMapping(value = "/event/{eventName}/reservation/{reservationId}/book", method = RequestMethod.GET) public String showBookingPage(@PathVariable("eventName") String eventName, @PathVariable("reservationId") String reservationId, - //paypal related parameters - @RequestParam(value = "paymentId", required = false) String paypalPaymentId, - @RequestParam(value = "PayerID", required = false) String paypalPayerID, - @RequestParam(value = "paypal-success", required = false) Boolean isPaypalSuccess, - @RequestParam(value = "paypal-error", required = false) Boolean isPaypalError, - @RequestParam(value = "fullName", required = false) String fullName, - @RequestParam(value = "firstName", required = false) String firstName, - @RequestParam(value = "lastName", required = false) String lastName, - @RequestParam(value = "email", required = false) String email, - @RequestParam(value = "billingAddress", required = false) String billingAddress, - @RequestParam(value = "customerReference", required = false) String customerReference, - @RequestParam(value = "hmac", required = false) String hmac, - @RequestParam(value = "postponeAssignment", required = false) Boolean postponeAssignment, - @RequestParam(value = "invoiceRequested", required = false) Boolean invoiceRequested, Model model, Locale locale) { @@ -119,31 +105,21 @@ public String showBookingPage(@PathVariable("eventName") String eventName, return redirectReservation(Optional.of(reservation), eventName, reservationId); } + TicketReservationAdditionalInfo additionalInfo = ticketReservationRepository.getAdditionalInfo(reservationId); + if (additionalInfo.hasBeenValidated()) { + return "redirect:/event/" + eventName + "/reservation/" + reservationId + "/overview"; + } + Function partialConfig = Configuration.from(event.getOrganizationId(), event.getId()); Configuration.ConfigurationPathKey forceAssignmentKey = partialConfig.apply(FORCE_TICKET_OWNER_ASSIGNMENT_AT_RESERVATION); boolean forceAssignment = configurationManager.getBooleanConfigValue(forceAssignmentKey, false); List ticketsInReservation = ticketReservationManager.findTicketsInReservation(reservationId); - if (Boolean.TRUE.equals(isPaypalSuccess) && paypalPayerID != null && paypalPaymentId != null) { - model.addAttribute("paypalPaymentId", paypalPaymentId) - .addAttribute("paypalPayerID", paypalPayerID) - .addAttribute("paypalCheckoutConfirmation", true) - .addAttribute("fullName", fullName) - .addAttribute("firstName", firstName) - .addAttribute("lastName", lastName) - .addAttribute("email", email) - .addAttribute("billingAddress", billingAddress) - .addAttribute("hmac", hmac) - .addAttribute("postponeAssignment", Boolean.TRUE.equals(postponeAssignment)) - .addAttribute("invoiceRequested", Boolean.TRUE.equals(invoiceRequested)) - .addAttribute("customerReference", customerReference) - .addAttribute("showPostpone", !forceAssignment && Boolean.TRUE.equals(postponeAssignment)); - } else { - model.addAttribute("paypalCheckoutConfirmation", false) - .addAttribute("postponeAssignment", false) - .addAttribute("showPostpone", !forceAssignment && ticketsInReservation.size() > 1); - } + + model.addAttribute("postponeAssignment", false) + .addAttribute("showPostpone", !forceAssignment && ticketsInReservation.size() > 1); + try { model.addAttribute("delayForOfflinePayment", Math.max(1, TicketReservationManager.getOfflinePaymentWaitingPeriod(event, configurationManager))); @@ -330,7 +306,14 @@ public String validateToOverview(@PathVariable("eventName") String eventName, @P } @RequestMapping(value = "/event/{eventName}/reservation/{reservationId}/overview", method = RequestMethod.GET) - public String showOverview(@PathVariable("eventName") String eventName, @PathVariable("reservationId") String reservationId, Locale locale, Model model) { + public String showOverview(@PathVariable("eventName") String eventName, @PathVariable("reservationId") String reservationId, + //paypal + @RequestParam(value = "paymentId", required = false) String paypalPaymentId, + @RequestParam(value = "PayerID", required = false) String paypalPayerID, + @RequestParam(value = "paypal-success", required = false) Boolean isPaypalSuccess, + @RequestParam(value = "paypal-error", required = false) Boolean isPaypalError, + // + Locale locale, Model model) { return eventRepository.findOptionalByShortName(eventName) .map(event -> ticketReservationManager.findById(reservationId) .map(reservation -> { @@ -342,6 +325,14 @@ public String showOverview(@PathVariable("eventName") String eventName, @PathVar return "redirect:/event/" + eventName + "/reservation/" + reservationId + "/book"; } + if (Boolean.TRUE.equals(isPaypalSuccess) && paypalPayerID != null && paypalPaymentId != null) { + model.addAttribute("paypalPaymentId", paypalPaymentId) + .addAttribute("paypalPayerID", paypalPayerID) + .addAttribute("paypalCheckoutConfirmation", true); + } else { + model.addAttribute("paypalCheckoutConfirmation", false); + } + OrderSummary orderSummary = ticketReservationManager.orderSummaryForReservationId(reservationId, event, locale); @@ -493,7 +484,8 @@ private String redirectReservation(Optional ticketReservation switch(reservation.getStatus()) { case PENDING: - return baseUrl + "/book"; + TicketReservationAdditionalInfo additionalInfo = ticketReservationRepository.getAdditionalInfo(reservationId); + return additionalInfo.hasBeenValidated() ? baseUrl + "/overview" : baseUrl + "/book"; case COMPLETE: return baseUrl + "/success"; case OFFLINE_PAYMENT: @@ -720,7 +712,7 @@ private Optional checkReservation(boolean backFromOverview, boolean canc } if (cancelReservation) { - ticketReservationManager.cancelPendingReservation(reservationId, false); //FIXME + ticketReservationManager.cancelPendingReservation(reservationId, false); //FIXME SessionUtil.removeSpecialPriceData(request); return Optional.of("redirect:/event/" + eventName + "/"); } diff --git a/src/main/java/alfio/manager/PaypalManager.java b/src/main/java/alfio/manager/PaypalManager.java index a66913324d..3e3da2d4b9 100644 --- a/src/main/java/alfio/manager/PaypalManager.java +++ b/src/main/java/alfio/manager/PaypalManager.java @@ -148,17 +148,9 @@ public String createCheckoutRequest(Event event, String reservationId, OrderSumm RedirectUrls redirectUrls = new RedirectUrls(); String baseUrl = StringUtils.removeEnd(configurationManager.getRequiredValue(Configuration.from(event.getOrganizationId(), event.getId(), ConfigurationKeys.BASE_URL)), "/"); - String bookUrl = baseUrl+"/event/" + eventName + "/reservation/" + reservationId + "/book"; + String bookUrl = baseUrl+"/event/" + eventName + "/reservation/" + reservationId + "/overview"; UriComponentsBuilder bookUrlBuilder = UriComponentsBuilder.fromUriString(bookUrl) - .queryParam("fullName", customerName.getFullName()) - .queryParam("firstName", customerName.getFirstName()) - .queryParam("lastName", customerName.getLastName()) - .queryParam("email", email) - .queryParam("billingAddress", billingAddress) - .queryParam("customerReference", customerReference) - .queryParam("postponeAssignment", postponeAssignment) - .queryParam("invoiceRequested", invoiceRequested) .queryParam("hmac", computeHMAC(customerName, email, billingAddress, event)); String finalUrl = bookUrlBuilder.toUriString(); diff --git a/src/main/webapp/WEB-INF/templates/event/overview.ms b/src/main/webapp/WEB-INF/templates/event/overview.ms index 709406d17b..3f083de712 100644 --- a/src/main/webapp/WEB-INF/templates/event/overview.ms +++ b/src/main/webapp/WEB-INF/templates/event/overview.ms @@ -104,6 +104,16 @@
+ {{#paypalCheckoutConfirmation}} + + + + +
+

{{#i18n}}reservation-page.paypal.confirm{{/i18n}}

+
+ {{/paypalCheckoutConfirmation}} + {{^paypalCheckoutConfirmation}} {{^orderSummary.free}} @@ -149,6 +159,8 @@ {{/orderSummary.free}} + + {{#event.privacyPolicyLinkOrNull}}
{{/event.privacyPolicyLinkOrNull}} + {{/paypalCheckoutConfirmation}} +
- {{#orderSummary.free}} -
-
-
-
- {{/orderSummary.free}} - {{^orderSummary.free}} -
-
- -
-
-
- {{/orderSummary.free}} +
+
+
+
+