// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
//     private final PaymentId paymentId;
//     private final CustomerId customerId;
//     private final PaymentMethod paymentMethod;
//     private final Transaction transaction;
//     private final LocalDateTime timestamp = LocalDateTime.now();
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
// @Component
// public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
// 
//     @Override
//     public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
//         return Either.right(command);
//     }
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
//     CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentAuthorized.java
// @Value(staticConstructor = "eventOf")
// public class PaymentAuthorized implements PaymentEvent {
//     private final PaymentEventId eventId = new PaymentEventId();
//     private final PaymentId paymentId;
//     private final CustomerId customerId;
//     private final PaymentMethod paymentMethod;
//     private final Transaction transaction;
//     private final LocalDateTime timestamp;
// 
//     @Override
//     public PaymentEventType getEventType() {
//         return PaymentEventType.PAYMENT_AUTHORIZED;
//     }
// 
//     @Override
//     public LocalDateTime getTimestamp() {
//         return timestamp;
//     }
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
//     public final Set<I18nCode> codes;
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
//     CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
// 
//     @Override
//     protected String getPrefix() {
//         return "PEV-%s";
//     }
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
// 
//     public PaymentId() {
//         super();
//     }
// 
//     public PaymentId(String id) {
//         super(id);
//     }
// 
//     @Override
//     protected String getPrefix() {
//         return "PAY-%s";
//     }
// }


import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.command.validation.AuthorizePaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentAuthorized;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;



@Component
public class AuthorizePaymentHandler implements CommandHandler<AuthorizePayment, PaymentAuthorized, PaymentId> {

// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
//     private final PaymentId paymentId;
//     private final CustomerId customerId;
//     private final PaymentMethod paymentMethod;
//     private final Transaction transaction;
//     private final LocalDateTime timestamp = LocalDateTime.now();
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
// @Component
// public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
// 
//     @Override
//     public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
//         return Either.right(command);
//     }
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
//     CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentAuthorized.java
// @Value(staticConstructor = "eventOf")
// public class PaymentAuthorized implements PaymentEvent {
//     private final PaymentEventId eventId = new PaymentEventId();
//     private final PaymentId paymentId;
//     private final CustomerId customerId;
//     private final PaymentMethod paymentMethod;
//     private final Transaction transaction;
//     private final LocalDateTime timestamp;
// 
//     @Override
//     public PaymentEventType getEventType() {
//         return PaymentEventType.PAYMENT_AUTHORIZED;
//     }
// 
//     @Override
//     public LocalDateTime getTimestamp() {
//         return timestamp;
//     }
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
//     public final Set<I18nCode> codes;
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
//     CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
// 
//     @Override
//     protected String getPrefix() {
//         return "PEV-%s";
//     }
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
// 
//     public PaymentId() {
//         super();
//     }
// 
//     public PaymentId(String id) {
//         super(id);
//     }
// 
//     @Override
//     protected String getPrefix() {
//         return "PAY-%s";
//     }
// }


// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/AuthorizePaymentHandler.java
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.command.validation.AuthorizePaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentAuthorized;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

package com.github.sandokandias.payments.domain.command.handler;



@Component
public class AuthorizePaymentHandler implements CommandHandler<AuthorizePayment, PaymentAuthorized, PaymentId> {

    private static final Logger LOG = LoggerFactory.getLogger(AuthorizePaymentHandler.class);