-
Notifications
You must be signed in to change notification settings - Fork 5
/
OmniPayComponent.php
52 lines (43 loc) · 1.04 KB
/
OmniPayComponent.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
51
52
<?php
/**
* @author Bryan Tan <[email protected]>
*/
namespace bryglen\omnipay;
use Omnipay\Omnipay;
use yii\base\Component;
class OmniPayComponent extends Component
{
public $name;
public $testMode = null;
public $currency = null;
public $parameters = [];
private $_gateway;
public function init()
{
$this->prepareGateway();
}
public function prepareGateway()
{
$this->_gateway = Omnipay::create($this->name);
if ($this->testMode) {
$this->parameters['testMode'] = $this->testMode;
}
if ($this->currency) {
$this->parameters['currency'] = $this->currency;
}
$this->_gateway->initialize($this->parameters);
}
public function getGateway()
{
return $this->_gateway;
}
/**
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return call_user_func_array([$this->getGateway(), $method], $parameters);
}
}