PHP code example of flutterwavedev / flutterwave-v3
1. Go to this page and download the library: Download flutterwavedev/flutterwave-v3 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/ */
flutterwavedev / flutterwave-v3 example snippets
declare(strict_types=1);
# if vendor file is not present, notify developer to run composer install.
ndler;
use Flutterwave\Flutterwave;
use Flutterwave\Library\Modal;
# start a session.
session_start();
try {
Flutterwave::bootstrap();
$customHandler = new PaymentHandler();
$client = new Flutterwave();
$modalType = Modal::POPUP; // Modal::POPUP or Modal::STANDARD
$controller = new PaymentController( $client, $customHandler, $modalType );
} catch(\Exception $e ) {
echo $e->getMessage();
}
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$request = $_REQUEST;
$request['redirect_url'] = $_SERVER['HTTP_ORIGIN'] . $_SERVER['REQUEST_URI'];
try {
$controller->process( $request );
} catch(\Exception $e) {
echo $e->getMessage();
}
}
$request = $_GET;
# Confirming Payment.
if(isset($request['tx_ref'])) {
$controller->callback( $request );
} else {
}
exit();
use \Flutterwave\Flutterwave;
# normal configuration
Flutterwave::bootstrap(); # this will use the default configuration set in .env