-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathprocessPayment.php
More file actions
61 lines (50 loc) · 1.8 KB
/
processPayment.php
File metadata and controls
61 lines (50 loc) · 1.8 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?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;
use \Flutterwave\Config\ForkConfig;
// start a session.
session_start();
// Define custom config.
// $myConfig = ForkConfig::setUp(
// 'FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X', //Secret key
// 'FLWPUBK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X', // Public key
// 'FLWSECK_TESTXXXXXXXXXXX', //Encryption key
// 'staging' //Environment Variable
// );
// uncomment the block if you just want to pass the keys with a specific configuration.
// $_ENV['SECRET_KEY'] = "FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X";
// $_ENV['PUBLIC_KEY'] = "FLWPUBK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X";
// $_ENV['ENCRYPTION_KEY'] = "FLWSECK_TESTXXXXXXXXXXXX";
// $_ENV['ENV'] = "staging";
// controller default
$controller = null;
try {
Flutterwave::bootstrap(); // create a .env or Flutterwave::bootstrap($myConfig)
$customHandler = new PaymentHandler();
$client = new Flutterwave();
$modalType = Modal::STANDARD; // 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();