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

namespace Baya.Application.Features.Bnpl.Commands.InitiateBnplOrder;

/// <summary>
/// Starts a BNPL order for an <c>accepted_awaiting_payment</c> booking request owned by the caller: ensures the
/// 1:1 <c>bnpl_transactions</c> row (under the <c>UNIQUE(payment_transaction_id)</c> guard), normalizes the
/// order amount to IRR at the provider boundary, asks the provider for a payment token, transitions
/// <c>eligible → token_issued</c>, and returns the token + redirect. Runs under <c>lock(booking:{id}:payment)</c>
/// and carries an idempotency key so a retried start reuses the same token.
/// </summary>
public record InitiateBnplOrderCommand(long BookingRequestId, string ProviderCode, string? IdempotencyKey)
    : IRequest<OperationResult<InitiateBnplResult>>;
