From 047352838439f0385991bbdea6c1c19d1c8fba22 Mon Sep 17 00:00:00 2001 From: Shane Brown Date: Sun, 5 Jan 2025 12:12:52 -0500 Subject: [PATCH] CustomOfflinePaymentManager: Add missing LICENSE header --- .../payment/CustomOfflinePaymentManager.java | 77 +++++++++++-------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/src/main/java/alfio/manager/payment/CustomOfflinePaymentManager.java b/src/main/java/alfio/manager/payment/CustomOfflinePaymentManager.java index 7b16ecc61..61189deb9 100644 --- a/src/main/java/alfio/manager/payment/CustomOfflinePaymentManager.java +++ b/src/main/java/alfio/manager/payment/CustomOfflinePaymentManager.java @@ -1,3 +1,19 @@ +/** + * This file is part of alf.io. + * + * alf.io is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * alf.io is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with alf.io. If not, see . + */ package alfio.manager.payment; import java.time.ZonedDateTime; @@ -35,11 +51,10 @@ public class CustomOfflinePaymentManager implements PaymentProvider { private static final Logger log = LoggerFactory.getLogger(CustomOfflinePaymentManager.class); public CustomOfflinePaymentManager( - ClockProvider clockProvider, - ConfigurationRepository configurationRepository, - TicketReservationRepository ticketReservationRepository, - TransactionRepository transactionRepository - ) { + ClockProvider clockProvider, + ConfigurationRepository configurationRepository, + TicketReservationRepository ticketReservationRepository, + TransactionRepository transactionRepository) { this.clockProvider = clockProvider; this.configurationRepository = configurationRepository; this.ticketReservationRepository = ticketReservationRepository; @@ -51,7 +66,7 @@ public Set getSupportedPaymentMethods(PaymentContext paymentConte TransactionRequest transactionRequest) { OptionalInt orgId = paymentContext.getConfigurationLevel().getOrganizationId(); - if(orgId.isPresent()) { + if (orgId.isPresent()) { configurationRepository.findByKeyAtOrganizationLevel(orgId.getAsInt(), "CUSTOM_OFFLINE_PAYMENTS"); } @@ -66,14 +81,14 @@ public PaymentProxy getPaymentProxy() { @Override public boolean accept(PaymentMethod paymentMethod, PaymentContext context, TransactionRequest transactionRequest) { // TODO Auto-generated method stub - //throw new UnsupportedOperationException("Unimplemented method 'accept'"); + // throw new UnsupportedOperationException("Unimplemented method 'accept'"); return true; } @Override public boolean accept(Transaction transaction) { // TODO Auto-generated method stub - //throw new UnsupportedOperationException("Unimplemented method 'accept'"); + // throw new UnsupportedOperationException("Unimplemented method 'accept'"); return true; } @@ -85,7 +100,7 @@ public PaymentMethod getPaymentMethodForTransaction(Transaction transaction) { @Override public boolean isActive(PaymentContext paymentContext) { - //throw new UnsupportedOperationException("Unimplemented method 'isActive'"); + // throw new UnsupportedOperationException("Unimplemented method 'isActive'"); return true; } @@ -98,34 +113,32 @@ public PaymentResult doPayment(PaymentSpecification spec) { // POST PONE int updatedReservation = ticketReservationRepository.postponePayment( - spec.getReservationId(), - CUSTOM_OFFLINE_PAYMENT, - Date.from(deadline.toInstant()), - spec.getEmail(), - spec.getCustomerName().getFullName(), - spec.getCustomerName().getFirstName(), - spec.getCustomerName().getLastName(), - spec.getBillingAddress(), - spec.getCustomerReference() - ); + spec.getReservationId(), + CUSTOM_OFFLINE_PAYMENT, + Date.from(deadline.toInstant()), + spec.getEmail(), + spec.getCustomerName().getFullName(), + spec.getCustomerName().getFirstName(), + spec.getCustomerName().getLastName(), + spec.getBillingAddress(), + spec.getCustomerReference()); Validate.isTrue(updatedReservation == 1, "expected exactly one updated reservation, got " + updatedReservation); // OVERRIDE EXISTING TRANSACTION PaymentManagerUtils.invalidateExistingTransactions(spec.getReservationId(), transactionRepository); transactionRepository.insert( - UUID.randomUUID().toString(), - null, - spec.getReservationId(), - ZonedDateTime.now(clockProvider.getClock()), - spec.getPriceWithVAT(), - spec.getCurrencyCode(), - "", - PaymentProxy.OFFLINE.name(), - 0L, - 0L, - Transaction.Status.PENDING, - Map.of() - ); + UUID.randomUUID().toString(), + null, + spec.getReservationId(), + ZonedDateTime.now(clockProvider.getClock()), + spec.getPriceWithVAT(), + spec.getCurrencyCode(), + "", + PaymentProxy.OFFLINE.name(), + 0L, + 0L, + Transaction.Status.PENDING, + Map.of()); // RETURN RESULT return PaymentResult.successful(NOT_YET_PAID_TRANSACTION_ID);