Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Kikismedia's avatar

fluutterwave acoount number verification

i have been trying to verify user account name using flutterwave api but i kept getting error

Verification Result:
status: error
message: invalid account
data

code

$banks = Flutterwave::banks()->nigeria();

// Find the bank code based on the provided bank name
$selectedBankName = $this->bank_name;
$selectedBankCode = null;

foreach ($banks['data'] as $bank) {
    if ($bank['name'] === $selectedBankName) {
        $selectedBankCode = $bank['code'];
        break;
    }
}

//dd($selectedBankCode);

// Check if the bank code was found
if ($selectedBankCode) {
    $secretKey = getenv('FLW_SECRET_KEY');

    $response = Http::withHeaders([
        'Authorization' => 'Bearer ' . $secretKey,
    ])->post('https://api.flutterwave.com/v3/accounts/resolve', [
        'account_number' => $this->account_number,
        'account_bank' => $selectedBankCode, // Use the bank code
    ]);
    //dd($selectedBankCode);
    if ($response->successful()) {
        $this->accountName = $response->json()['account_name'];
    } else {
        $this->accountName = $response->json();
    }
} else {
    // Handle the case where the bank name doesn't match any bank code
    $this->accountName = 'Invalid bank name';
}

the curl

curl --request POST 'https://api.flutterwave.com/v3/accounts/resolve' \
  --header 'Authorization: Bearer YOUR_SECRET_KEY'\
  --header 'Content-Type: application/json'\
  --data-raw '{
    "account_number": "0690000032",
    "account_bank": "044"
}'

link to documentation https://developer.flutterwave.com/docs/verifications/bank-account

0 likes
3 replies
Snapey's avatar
Snapey
Best Answer
Level 122

for starters DON'T use env values directly.

In a config file, eg services.php, add a key like;

'flutterwave' => [
        'key' => env('FLW_SECRET_KEY'),
        'url' => 'https://api.flutterwave.com/v3/accounts/resolve',
],

and then use it in your code like

    $secretKey = config('services.flutterwave.key');

and

    ->post(config('services.flutterwave.url'), [

You can also dd() the http request to make sure your request has all the required elements

Snapey's avatar

Sometimes when working with an API and getting a result like you have, I would deliberately introduce a change to the secret key and check the response. If you get a different result (eg an authorisation error), then you know that when you use the correct code, the authorisation was successful.

1 like

Please or to participate in this conversation.