|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © 2016 Magento. All rights reserved. |
|
4
|
|
|
* See COPYING.txt for license details. |
|
5
|
|
|
*/ |
|
6
|
|
|
namespace Getloy\GetloyMagentoGateway\Gateway\Config; |
|
7
|
|
|
|
|
8
|
|
|
use Magento\Payment\Gateway\Config\Config as BaseConfig; |
|
9
|
|
|
|
|
10
|
|
|
// use Magento\Store\Model\StoreManagerInterface; |
|
11
|
|
|
// use Magento\Framework\App\Config\ScopeConfigInterface; |
|
12
|
|
|
// use Getloy\GetloyMagentoGateway\Model\Ui\ConfigProvider; |
|
13
|
|
|
// use Magento\Store\Model\ScopeInterface; |
|
14
|
|
|
|
|
15
|
|
|
class Config extends BaseConfig |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
const KEY_ACTIVE = 'active'; |
|
19
|
|
|
const KEY_SANDBOX = 'sandbox'; |
|
20
|
|
|
const KEY_GETLOY_MERCHANT_KEY = 'getloy_merchant_key'; |
|
21
|
|
|
const KEY_PAYWAY_TITLE = 'payway_title'; |
|
22
|
|
|
const KEY_PAYWAY_MERCHANT_ID = 'payway_merchant_id'; |
|
23
|
|
|
const KEY_PAYWAY_API_KEY_TEST = 'payway_api_key_test'; |
|
24
|
|
|
const KEY_PAYWAY_API_KEY_PROD = 'payway_api_key_prod'; |
|
25
|
|
|
const KEY_ACCEPTED_CURRENCIES = 'accepted_currencies'; |
|
26
|
|
|
|
|
27
|
|
|
const PAYMENT_METHOD_PAYWAY_KH = 'payway_kh'; |
|
28
|
|
|
const PAYMENT_METHOD_VARIANT_DEFAULT = 'default'; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Determines if the environment is set as live (production) mode. |
|
32
|
|
|
* |
|
33
|
|
|
* @return bool |
|
34
|
|
|
*/ |
|
35
|
|
|
public function isLive() |
|
36
|
|
|
{ |
|
37
|
|
|
return !$this->isSandbox(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Determines if the environment is set as sandbox (test) mode. |
|
42
|
|
|
* |
|
43
|
|
|
* @return bool |
|
44
|
|
|
*/ |
|
45
|
|
|
public function isSandbox() |
|
46
|
|
|
{ |
|
47
|
|
|
return (bool) $this->getValue(self::KEY_SANDBOX); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Returns the currencies allowed for payment. |
|
52
|
|
|
* |
|
53
|
|
|
* @return array |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getAcceptedCurrencies() |
|
56
|
|
|
{ |
|
57
|
|
|
return [ 'USD' ]; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Determines if the gateway is active. |
|
62
|
|
|
* |
|
63
|
|
|
* @return bool |
|
64
|
|
|
*/ |
|
65
|
|
|
public function isActive() |
|
66
|
|
|
{ |
|
67
|
|
|
return (bool) $this->getValue(self::KEY_ACTIVE); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Returns the payment method titles |
|
72
|
|
|
* |
|
73
|
|
|
* @return array |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getMethodTitles() |
|
76
|
|
|
{ |
|
77
|
|
|
return [ |
|
78
|
|
|
self::PAYMENT_METHOD_PAYWAY_KH => [ |
|
79
|
|
|
self::PAYMENT_METHOD_VARIANT_DEFAULT => (string) $this->getValue(self::KEY_PAYWAY_TITLE), |
|
80
|
|
|
] |
|
81
|
|
|
]; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Returns the GetLoy merchant key |
|
86
|
|
|
* |
|
87
|
|
|
* @return string |
|
88
|
|
|
*/ |
|
89
|
|
|
public function getGetloyMerchantKey() |
|
90
|
|
|
{ |
|
91
|
|
|
return (string) $this->getValue(self::KEY_GETLOY_MERCHANT_KEY); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Returns the PayWay merchant ID |
|
96
|
|
|
* |
|
97
|
|
|
* @return string |
|
98
|
|
|
*/ |
|
99
|
|
|
public function getPaywayMerchantId() |
|
100
|
|
|
{ |
|
101
|
|
|
return (string) $this->getValue(self::KEY_PAYWAY_MERCHANT_ID); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Returns the PayWay API key (sandbox) |
|
106
|
|
|
* |
|
107
|
|
|
* @return string |
|
108
|
|
|
*/ |
|
109
|
|
|
public function getPaywayApiKeySandbox() |
|
110
|
|
|
{ |
|
111
|
|
|
return (string) $this->getValue(self::KEY_PAYWAY_API_KEY_TEST); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Returns the PayWay API key (live) |
|
116
|
|
|
* |
|
117
|
|
|
* @return string |
|
118
|
|
|
*/ |
|
119
|
|
|
public function getPaywayApiKeyLive() |
|
120
|
|
|
{ |
|
121
|
|
|
return (string) $this->getValue(self::KEY_PAYWAY_API_KEY_PROD); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Returns the PayWay API key for the the currently active mode (live or sandbox) |
|
126
|
|
|
* |
|
127
|
|
|
* @return string |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getPaywayApiKey() |
|
130
|
|
|
{ |
|
131
|
|
|
if ($this->isSandbox()) { |
|
132
|
|
|
return $this->getPaywayApiKeySandbox(); |
|
133
|
|
|
} |
|
134
|
|
|
return $this->getPaywayApiKeyLive(); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|