<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\PaymentTransaction;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/** @extends Factory<PaymentTransaction> */
class PaymentTransactionFactory extends Factory
{
    protected $model = PaymentTransaction::class;

    /** @return array<string, mixed> */
    public function definition(): array
    {
        return [
            'user_id' => User::factory(),
            'gateway' => fake()->randomElement(['stripe', 'paypal']),
            'gateway_transaction_id' => 'txn_'.fake()->unique()->bothify('############'),
            'amount' => fake()->randomFloat(2, 5, 500),
            'currency' => 'USD',
            'status' => 'completed',
            'payment_method' => 'card',
            'description' => fake()->sentence(),
        ];
    }

    public function pending(): static
    {
        return $this->state(fn (): array => ['status' => 'pending']);
    }

    public function completed(): static
    {
        return $this->state(fn (): array => ['status' => 'completed']);
    }

    public function failed(): static
    {
        return $this->state(fn (): array => ['status' => 'failed']);
    }
}
