<?php

declare(strict_types=1);

namespace App\Services\Payment\Providers;

use App\Models\Payment;

class StripeProvider extends AbstractProvider
{
    public function provider(): string
    {
        return 'stripe';
    }

    public function authorize(Payment $payment, array $context = []): array
    {
        return $this->mockResponse(Payment::STATUS_AUTHORIZED, $payment);
    }

    public function capture(Payment $payment, ?int $amount = null): array
    {
        return $this->mockResponse(Payment::STATUS_CAPTURED, $payment);
    }

    public function refund(Payment $payment, int $amount, ?string $reason = null): array
    {
        return $this->mockResponse(Payment::STATUS_REFUNDED, $payment, ['refund_amount' => $amount]);
    }

    public function getStatus(Payment $payment): array
    {
        return [
            'status' => $payment->status,
            'pg_tid' => $payment->pg_tid,
            'raw' => ['provider' => $this->provider()],
        ];
    }
}
