<?php

declare(strict_types=1);

namespace apexl\Io\modules\payment\Dto;

/**
 * Outcome of {@see \apexl\Io\modules\payment\Contract\RefundableGatewayInterface::refund()}.
 *
 * Most gateways return immediately with status `succeeded`; some (notably
 * GoCardless + ACH-based providers) return `pending` while the refund
 * settles. Consumers should listen for the corresponding `payment.refunded`
 * webhook before treating the refund as final.
 */
final readonly class RefundResult
{
    public function __construct(
        public string $gatewayRefundRef,
        public string $gatewayPaymentRef,
        public int    $amountRefundedCents,
        public string $currency,
        public string $status,
        public ?string $failureReason = null,
        public ?int    $createdAt = null,
    ) {}

    public const string STATUS_SUCCEEDED = 'succeeded';
    public const string STATUS_PENDING   = 'pending';
    public const string STATUS_FAILED    = 'failed';
}
