PHP code example of abraham-flutterwave / laravel-payment
1. Go to this page and download the library: Download abraham-flutterwave/laravel-payment library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
abraham-flutterwave / laravel-payment example snippets
use Flutterwave\Payments\Data\Stablecoin;
// Check the fee first. For stablecoin-to-stablecoin sends it is deducted from the amount.
Flutterwave::stablecoins()->fee(50, Stablecoin::USDT);
// Pay from your USDC balance
Flutterwave::stablecoins()->send(Stablecoin::POLYGON, '0xd0c7...', 50, Stablecoin::USDC);
// Or convert from NGN and pay in one step (the fee is charged to your NGN balance)
Flutterwave::stablecoins()->send(Stablecoin::SOLANA, '7EcDh...', 50, Stablecoin::USDT, 'NGN');
// Top up your USDC wallet from NGN, USD, GBP, EUR or GHS (needs FLW_MERCHANT_ID)
Flutterwave::stablecoins()->fund(100, Stablecoin::USDC, 'USD');
Flutterwave::stablecoins()->balances(); // ['USDC' => [...], 'USDT' => [...]]
Flutterwave::stablecoins()->find($transferId);
$plan = Flutterwave::plans()->create('Pro', 5000, 'monthly');
// Subscribe a customer by checking out against the plan
return Flutterwave::redirect([
'amount' => 5000,
'email' => $user->email,
'payment_plan' => $plan['data']['id'],
]);
Flutterwave::subscriptions()->all(['email' => $user->email]);
Flutterwave::subscriptions()->cancel($subscriptionId);
use Flutterwave\Payments\Billable;
class User extends Authenticatable
{
use Billable;
}
$hold = $user->preauthorizeSavedCard(20000);
$ref = $hold['data']['flw_ref'];
Flutterwave::preauth()->capture($ref, 15000); // charge part or all of it, once or several times
Flutterwave::preauth()->void($ref); // or release the hold
Flutterwave::preauth()->refund($ref, 5000); // give back money you captured
$account = Flutterwave::virtualAccounts()->create([
'email' => $user->email,
'is_permanent' => true,
'bvn' => '12345678901',
'narration' => $user->name,
]);
$account['data']['account_number']; // your customer pays into this account
$wallet = Flutterwave::payoutSubaccounts()->create('Jane Doe', '[email protected]', 'NG', '08100000000');
$reference = $wallet['data']['account_reference']; // store this on the customer
$wallet['data']['nuban']; // the account number to fund it
Flutterwave::payoutSubaccounts()->balance($reference);
Flutterwave::payoutSubaccounts()->transactions($reference, '2026-10-01', '2026-10-31');
$open = Flutterwave::chargebacks()->all(['status' => 'initiated']);
Flutterwave::chargebacks()->find($flwRef); // one chargeback with its history
// The customer didn't get what they paid for: refund them
Flutterwave::chargebacks()->accept($chargebackId, 'Order was never shipped.');
// You have evidence they did: upload it and dispute
Flutterwave::chargebacks()->declineWithProof($chargebackId, 'Delivered on 3 October and signed for.', $request->file('proof'));
$quote = Flutterwave::fx()->quote('NGN', 'USD', 2_000_000, 'FX-ORDER-7'); // spend NGN 2,000,000 on dollars
// When the quote is ready (usually seconds later), check the rate and trade it
$ready = Flutterwave::fx()->findQuote($quote['data']['id'])['data'];
// $ready['status'] === 'READY'; $ready['quote']['best_available_rate'], ['approved_quantity'], ['total_value']
$trade = Flutterwave::fx()->tradeIfReady($ready['id'], 'Supplier payment');
Flutterwave::fx()->findTrade($trade['data']['id']); // NEW, PENDING, then SETTLED or FAILED
Flutterwave::bills()->categories(); // AIRTIME, MOBILEDATA, CABLEBILLS, UTILITYBILLS...
Flutterwave::bills()->billers('CABLEBILLS'); // DSTV is BIL119
Flutterwave::bills()->items('BIL119'); // DSTV Premium is CB140, with its price and fee
$consent = Flutterwave::bvn()->requestConsent($bvn, $firstName, $lastName, route('kyc.done'));
// Store $consent['data']['reference'], then send the customer to $consent['data']['url'] to consent.
// When they come back:
Flutterwave::bvn()->matches($reference, $firstName, $lastName); // true once consented and the names match
Flutterwave::transactions()->all(['status' => 'successful', 'from' => '2026-10-01']); // last 30 days when no dates are given
Flutterwave::transactions()->timeline($transactionId); // every step the customer took
Flutterwave::transactions()->fee(10000, 'NGN', 'card'); // what Flutterwave charges on a payment
Flutterwave::transactions()->resendFailedHooks($transactionId);
Flutterwave::refund($transactionId); // full refund
Flutterwave::refund($transactionId, 1000, ['comments' => 'Damaged']); // partial, with a reason
Flutterwave::refunds()->all(['status' => 'completed']);
Flutterwave::refunds()->find($refundId);
Flutterwave::settlements()->all(['from' => '2026-10-01']);
Flutterwave::settlements()->find($settlementId); //
use Flutterwave\Payments\Exception\FlutterwaveException;
try {
Flutterwave::transfers()->create($payload);
} catch (FlutterwaveException $e) {
$e->getMessage(); // "Insufficient wallet balance"
$e->getStatusCode(); // 400
$e->getResponse(); // full Flutterwave response body
}
use Flutterwave\Payments\Facades\Flutterwave;
it('starts a checkout for the order total', function () {
$flutterwave = Flutterwave::fake();
$this->post('/orders/42/pay')->assertRedirect();
$flutterwave->assertCheckoutCreated(fn (array $payment) => $payment['amount'] === 5000);
});