-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathprocessPayment.php
43 lines (35 loc) · 1.06 KB
/
processPayment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
# if vendor file is not present, notify developer to run composer install.
require __DIR__.'/vendor/autoload.php';
use Flutterwave\Controller\PaymentController;
use Flutterwave\EventHandlers\ModalEventHandler as PaymentHandler;
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();