using Baya.Application.Models.Common;
using Baya.Application.Models.Payments;
using Mediator;

namespace Baya.Application.Features.Payments.Commands.InitiatePayment;

/// <summary>
/// Starts a card payment for an <c>accepted_awaiting_payment</c> booking request owned by the caller: selects
/// the active <c>standard</c> gateway, asks the PSP to open an IPG session, and persists a <c>pending</c>
/// <c>payment_transactions</c> row (with the gateway reference, honouring its filtered unique). The charged
/// amount is the request's frozen gross (variant price × session count) — never client-supplied. A repeat for
/// a request already captured is a <c>409</c>: the filtered <c>UNIQUE(booking_id) WHERE status='succeeded'</c>
/// is the structural backstop.
/// </summary>
/// <param name="BookingRequestId">The accepted request to pay for (a b9 <c>bookings</c> row exists only on capture).</param>
/// <param name="IdempotencyKey">The client's idempotency key, so a retried initiate reuses the same reference.</param>
public record InitiatePaymentCommand(long BookingRequestId, string? IdempotencyKey)
    : IRequest<OperationResult<InitiatePaymentResult>>;
