1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Generalization over Omnipay and Payum |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/php-merchant |
6
|
|
|
* @package php-merchant |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hiqdev\php\merchant\merchants; |
12
|
|
|
|
13
|
|
|
use hiqdev\php\merchant\credentials\CredentialsInterface; |
14
|
|
|
use hiqdev\php\merchant\factories\GatewayFactoryInterface; |
15
|
|
|
use Money\MoneyFormatter; |
16
|
|
|
use Money\MoneyParser; |
17
|
|
|
use Omnipay\Common\GatewayInterface; |
18
|
|
|
|
19
|
|
|
abstract class AbstractMerchant implements MerchantInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var GatewayInterface |
23
|
|
|
*/ |
24
|
|
|
protected $gateway; |
25
|
|
|
/** |
26
|
|
|
* @var CredentialsInterface |
27
|
|
|
*/ |
28
|
|
|
protected $credentials; |
29
|
|
|
/** |
30
|
|
|
* @var GatewayFactoryInterface |
31
|
|
|
*/ |
32
|
|
|
protected $gatewayFactory; |
33
|
|
|
/** |
34
|
|
|
* @var MoneyFormatter |
35
|
|
|
*/ |
36
|
|
|
protected $moneyFormatter; |
37
|
|
|
/** |
38
|
|
|
* @var MoneyParser |
39
|
|
|
*/ |
40
|
|
|
protected $moneyParser; |
41
|
|
|
|
42
|
30 |
|
public function __construct( |
43
|
|
|
CredentialsInterface $credentials, |
44
|
|
|
GatewayFactoryInterface $gatewayFactory, |
45
|
|
|
MoneyFormatter $moneyFormatter, |
46
|
|
|
MoneyParser $moneyParser |
47
|
|
|
) { |
48
|
30 |
|
$this->credentials = $credentials; |
49
|
30 |
|
$this->gatewayFactory = $gatewayFactory; |
50
|
30 |
|
$this->moneyFormatter = $moneyFormatter; |
51
|
30 |
|
$this->moneyParser = $moneyParser; |
52
|
30 |
|
$this->gateway = $this->createGateway(); |
53
|
30 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return CredentialsInterface |
57
|
|
|
*/ |
58
|
5 |
|
public function getCredentials(): CredentialsInterface |
59
|
|
|
{ |
60
|
5 |
|
return $this->credentials; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return GatewayInterface |
65
|
|
|
*/ |
66
|
|
|
abstract protected function createGateway(); |
67
|
|
|
} |
68
|
|
|
|