-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfpiapi.php
52 lines (36 loc) · 978 Bytes
/
fpiapi.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
50
<?php
/**
*
* FpiAPI main factory class
*
* TODO: Ability to give default settings to the gateways via factory methods
*
*/
require_once "exception.php";
require_once "transaction.php";
class FpiapiFactory {
private static $included = array(); // booleans for file inclusions
/**
* getGateway
* Get geteway object by name
* @param string $gatewayName
* @throws Exception
*/
static public function getGateway($gatewayName) {
if (!isset(self::$included['gateway'])) {
require "gateways/gateway.php";
self::$included['gateway'] = true;
}
$dir = dirname(__FILE__)."/gateways/";
$file = $dir . $gatewayName . ".php";
$className = "FpiapiGateway" . ucwords($gatewayName);
if (!isset(self::$included[$gatewayName])) {
if (file_exists($file)) {
require($file);
} else {
throw new Exception("No such gateway as " . $gatewayName);
}
}
return new $className();
}
}