|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
|
5
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
|
6
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
7
|
|
|
* (at your option) any later version. |
|
8
|
|
|
* |
|
9
|
|
|
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
|
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12
|
|
|
* GNU Lesser General Public License for more details. |
|
13
|
|
|
* |
|
14
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
15
|
|
|
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
|
16
|
|
|
* |
|
17
|
|
|
* PHP version 5 |
|
18
|
|
|
* |
|
19
|
|
|
* @category Payone |
|
20
|
|
|
* @package Payone_Magento2_Plugin |
|
21
|
|
|
* @author FATCHIP GmbH <[email protected]> |
|
22
|
|
|
* @copyright 2003 - 2021 Payone GmbH |
|
23
|
|
|
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
|
24
|
|
|
* @link http://www.payone.de |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace Payone\Core\Helper; |
|
28
|
|
|
|
|
29
|
|
|
use Payone\Core\Model\PayoneConfig; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Helper class for sending emails |
|
33
|
|
|
*/ |
|
34
|
|
|
class ApplePay extends \Payone\Core\Helper\Base |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* Returns ApplePay file upload path |
|
38
|
|
|
* |
|
39
|
|
|
* @return string |
|
40
|
|
|
*/ |
|
41
|
|
|
public function getApplePayUploadPath() |
|
42
|
|
|
{ |
|
43
|
|
|
return __DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."ApplePay".DIRECTORY_SEPARATOR; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Checks if all needed configuration fields are correctly configured |
|
48
|
|
|
* |
|
49
|
|
|
* @return bool |
|
50
|
|
|
*/ |
|
51
|
|
|
public function isConfigurationComplete() |
|
52
|
|
|
{ |
|
53
|
|
|
if ($this->hasMerchantId() && $this->hasCertificateFile() && $this->hasPrivateKeyFile()) { |
|
54
|
|
|
return true; |
|
55
|
|
|
} |
|
56
|
|
|
return false; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Check if merchant id configured |
|
61
|
|
|
* |
|
62
|
|
|
* @return bool |
|
63
|
|
|
*/ |
|
64
|
|
|
public function hasMerchantId() |
|
65
|
|
|
{ |
|
66
|
|
|
if (!empty($this->getConfigParam("merchant_id", PayoneConfig::METHOD_APPLEPAY, "payment"))) { |
|
67
|
|
|
return true; |
|
68
|
|
|
} |
|
69
|
|
|
return false; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Check if file exists in ApplePay upload directory |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $sFile |
|
76
|
|
|
* @return bool |
|
77
|
|
|
*/ |
|
78
|
|
|
protected function isFileExisting($sFile) |
|
79
|
|
|
{ |
|
80
|
|
|
if (empty($sFile)) { |
|
81
|
|
|
return false; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
if (file_exists($this->getApplePayUploadPath().$sFile)) { |
|
85
|
|
|
return true; |
|
86
|
|
|
} |
|
87
|
|
|
return false; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Check if certificate file is configured and exists |
|
92
|
|
|
* |
|
93
|
|
|
* @return bool |
|
94
|
|
|
*/ |
|
95
|
|
|
public function hasCertificateFile() |
|
96
|
|
|
{ |
|
97
|
|
|
$sCertificateFile = $this->getConfigParam("certificate_file", PayoneConfig::METHOD_APPLEPAY, "payment"); |
|
98
|
|
|
if ($this->isFileExisting($sCertificateFile) === true) { |
|
99
|
|
|
return true; |
|
100
|
|
|
} |
|
101
|
|
|
return false; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Check if private key file is configured and exists |
|
106
|
|
|
* |
|
107
|
|
|
* @return bool |
|
108
|
|
|
*/ |
|
109
|
|
|
public function hasPrivateKeyFile() |
|
110
|
|
|
{ |
|
111
|
|
|
$sPrivateKeyFile = $this->getConfigParam("private_key_file", PayoneConfig::METHOD_APPLEPAY, "payment"); |
|
112
|
|
|
if ($this->isFileExisting($sPrivateKeyFile) === true) { |
|
113
|
|
|
return true; |
|
114
|
|
|
} |
|
115
|
|
|
return false; |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|