<?php

namespace App\Libraries\PaymentGateways;

/**
 * No automated charge/webhook exists for bank transfer — the agency
 * uploads a payment slip and a Support-staff member manually marks the
 * payment as verified via the admin panel (Phase 6). charge() here simply
 * creates a 'pending' payment record; verifyWebhook() is a no-op since
 * bank transfers never call back automatically.
 */
class BankTransferGateway implements PaymentGatewayInterface
{
    public function charge(float $amount, string $currency, array $metadata = []): array
    {
        $reference = 'BT' . date('YmdHis') . bin2hex(random_bytes(3));

        return [
            'status'            => 'pending',
            'redirect_url'      => null,
            'client_secret'     => null,
            'gateway_reference' => $reference,
            'instructions'      => 'Transfer the amount to the account details on your invoice and upload the payment slip for verification.',
        ];
    }

    public function verifyWebhook(string $rawPayload, array $headers): array
    {
        return ['verified' => false, 'gateway_transaction_id' => null, 'status' => null, 'raw' => []];
    }

    public function refund(string $gatewayTransactionId, float $amount): array
    {
        return ['status' => 'manual_processing_required', 'raw' => []];
    }

    public function getStatus(string $gatewayTransactionId): array
    {
        return ['status' => 'awaiting_manual_verification', 'raw' => []];
    }
}
