Skip to content

Commit

Permalink
#102 fix express checkout in paypal case
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Aug 20, 2016
1 parent e446496 commit f851638
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/java/alfio/controller/ReservationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public String showPaymentPage(@PathVariable("eventName") String eventName,
@RequestParam(value = "email", required = false) String email,
@RequestParam(value = "billingAddress", required = false) String billingAddress,
@RequestParam(value = "hmac", required = false) String hmac,
@RequestParam(value = "expressCheckoutRequested", required = false) Boolean expressCheckoutRequested,
Model model,
Locale locale) {

Expand All @@ -143,7 +144,8 @@ public String showPaymentPage(@PathVariable("eventName") String eventName,
.addAttribute("lastName", lastName)
.addAttribute("email", email)
.addAttribute("billingAddress", billingAddress)
.addAttribute("hmac", hmac);
.addAttribute("hmac", hmac)
.addAttribute("expressCheckoutRequested", expressCheckoutRequested == Boolean.TRUE);
} else {
model.addAttribute("paypalCheckoutConfirmation", false);
}
Expand Down Expand Up @@ -384,7 +386,7 @@ public String handleReservation(@PathVariable("eventName") String eventName,
if(paymentForm.getPaymentMethod() == PaymentProxy.PAYPAL && !paymentForm.hasPaypalTokens()) {
OrderSummary orderSummary = ticketReservationManager.orderSummaryForReservationId(reservationId, event, locale);
try {
String checkoutUrl = paypalManager.createCheckoutRequest(event, reservationId, orderSummary, customerName, paymentForm.getEmail(), paymentForm.getBillingAddress(), locale);
String checkoutUrl = paypalManager.createCheckoutRequest(event, reservationId, orderSummary, customerName, paymentForm.getEmail(), paymentForm.getBillingAddress(),paymentForm.getExpressCheckoutRequested(), locale);
return "redirect:" + checkoutUrl;
} catch (Exception e) {
bindingResult.reject(ErrorsCode.STEP_2_PAYMENT_REQUEST_CREATION);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/alfio/manager/PaypalManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static Item fromSummaryRow(SummaryRow summaryRow, Event event) {
return new Item(summaryRow.getName(), quantity, price, event.getCurrency());
}

public String createCheckoutRequest(Event event, String reservationId, OrderSummary orderSummary, CustomerName customerName, String email, String billingAddress, Locale locale) throws Exception {
public String createCheckoutRequest(Event event, String reservationId, OrderSummary orderSummary, CustomerName customerName, String email, String billingAddress, Boolean expressCheckoutRequested, Locale locale) throws Exception {

Optional<String> experienceProfileId = getOrCreateWebProfile(event, locale);

Expand All @@ -159,6 +159,7 @@ public String createCheckoutRequest(Event event, String reservationId, OrderSumm
.queryParam("lastName", customerName.getLastName())
.queryParam("email", email)
.queryParam("billingAddress", billingAddress)
.queryParam("expressCheckoutRequested", expressCheckoutRequested)
.queryParam("hmac", computeHMAC(customerName, email, billingAddress, event));
String finalUrl = bookUrlBuilder.toUriString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<input type="hidden" name="paymentMethod" value="PAYPAL">
<input type="hidden" name="paypalPaymentId" value="{{paypalPaymentId}}">
<input type="hidden" name="paypalPayerID" value="{{paypalPayerID}}">
<input type="hidden" name="expressCheckoutRequested" value="{{expressCheckoutRequested}}">
<input type="hidden" name="termAndConditionsAccepted" value="true">
{{#i18n}}reservation-page.paypal.confirm{{/i18n}}
{{/paypalCheckoutConfirmation}}
Expand Down

0 comments on commit f851638

Please sign in to comment.