-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathsetup.php
49 lines (40 loc) · 1.38 KB
/
setup.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
44
45
46
47
48
49
<?php
use Flutterwave\Helper;
use Dotenv\Dotenv;
$flutterwave_installation = 'composer';
if( !file_exists( '.env' )) {
$dotenv = Dotenv::createImmutable(__DIR__."/../../../"); # on the event that the package is install via composer.
} else {
$flutterwave_installation = "manual";
$dotenv = Dotenv::createImmutable(__DIR__); # on the event that the package is forked or donwload directly from Github.
}
$dotenv->safeLoad();
//check if the current version of php is compatible
if(!Helper\CheckCompatibility::isCompatible())
{
echo "Flutterwave: This SDK only support php version ". Helper\CheckCompatibility::MINIMUM_COMPATIBILITY. " or greater.";
exit;
}
// check for required key in ENV super global
$flutterwaveKeys = ["SECRET_KEY","PUBLIC_KEY","ENV", "ENCRYPTION_KEY"];
asort($flutterwaveKeys);
try{
foreach($flutterwaveKeys as $key)
{
if( empty( $_ENV[ $key ] ) )
{
throw new InvalidArgumentException("$key environment variable missing.");
}
}
}catch(\Exception $e)
{
echo "<code>Flutterwave sdk: " .$e->getMessage()."</code>";
echo "<br /> Kindly create a <code>.env </code> in the project root and add the required environment variables.";
exit;
}
$keys = [
'SECRET_KEY' => $_ENV['SECRET_KEY'],
'PUBLIC_KEY' => $_ENV['PUBLIC_KEY'],
'ENV' => $_ENV['ENV'],
'ENCRYPTION_KEY' => $_ENV['ENCRYPTION_KEY']
];