<?php

namespace App\Core\Traits;

use Illuminate\Support\Str;

trait GeneratesReference
{
    public static function generateReference(string $prefix = 'TXN'): string
    {
        return $prefix . '-' . strtoupper(Str::random(4)) . '-' . now()->format('YmdHis');
    }

    public static function generateVTPassRequestId(): string
    {
        $datePart = now('Africa/Lagos')->format('YmdHi');
        $suffix = strtoupper(bin2hex(random_bytes(4)));

        return $datePart . $suffix;
    }

    public static function generateIdempotencyKey(): string
    {
        return (string) Str::uuid();
    }
}
