GOOD SHELL MAS BOY
Server: Apache/2.4.52 (Ubuntu)
System: Linux vmi1836763.contaboserver.net 5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:53 UTC 2024 x86_64
User: www-data (33)
PHP: 8.4.10
Disabled: NONE
Upload Files
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();
    }
}