Skip to content

Commit

Permalink
remove redundant exception
Browse files Browse the repository at this point in the history
  • Loading branch information
cbellone committed Jan 27, 2020
1 parent 4623256 commit 1d14a6a
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/main/java/alfio/manager/payment/PayPalManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private String createCheckoutRequest(PaymentSpecification spec) throws Exception
if("APPROVED".equals(status)) {
saveToken(reservation.getId(), spec.getEvent(), new PayPalToken(order.payer().payerId(), order.id(), hmac));
}
throw new AlreadyApprovedException();
return "/event/"+spec.getEvent().getShortName()+"/reservation/"+spec.getReservationId();
} else if("CREATED".equals(status)) {
//add 15 minutes of validity in case the paypal flow is slow
ticketReservationRepository.updateValidity(spec.getReservationId(), DateUtils.addMinutes(reservation.getValidity(), 15));
Expand Down Expand Up @@ -329,8 +329,6 @@ public PaymentResult getToken(PaymentSpecification spec) {
return PaymentResult.initialized(gatewayToken.getToken());
}
return PaymentResult.redirect(createCheckoutRequest(spec));
} catch(AlreadyApprovedException ex) {
return PaymentResult.redirect("/event/"+spec.getEvent().getShortName()+"/reservation/"+spec.getReservationId());
} catch (Exception e) {
log.error(e);
return PaymentResult.failed( ErrorsCode.STEP_2_PAYMENT_REQUEST_CREATION );
Expand Down Expand Up @@ -403,10 +401,6 @@ private static class PayPalChargeDetails {
private final long payPalFee;
}

private static class AlreadyApprovedException extends RuntimeException {

}

private static boolean statusCodeIsSuccessful(HttpResponse<?> response) {
return requireNonNull(HttpStatus.resolve(response.statusCode())).is2xxSuccessful();
}
Expand Down

0 comments on commit 1d14a6a

Please sign in to comment.