File: /var/www/admin.fixgini.com/app/Services/FlutterwaveService.php
<?php
namespace App\Services;
use Illuminate\Support\Facades\Http;
class FlutterwaveService
{
protected $baseUrl;
protected $secretKey;
public function __construct()
{
$this->baseUrl = "https://api.flutterwave.com/v3";
$this->secretKey = config('services.flutterwave.secret_key'); // load from config
}
public function transfer($accountBank, $accountNumber, $amount, $currency = 'NGN', $narration = 'Withdrawal Payout')
{
$response = Http::withToken($this->secretKey)
->post("{$this->baseUrl}/transfers", [
"account_bank" => $accountBank, // e.g., "044" for Access Bank
"account_number" => $accountNumber, // e.g., "0690000031"
"amount" => $amount,
"currency" => $currency,
"narration" => $narration,
"reference" => uniqid("wd_"), // unique reference
]);
return $response->json();
}
}