Issues (1092)

Helper/Request.php (4 issues)

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 - 2016 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 everything that has to do with request
33
 */
34
class Request extends \Payone\Core\Helper\Base
35
{
36
    /**
37
     * PAYONE environment helper
38
     *
39
     * @var \Payone\Core\Helper\Environment
40
     */
41
    protected $environmentHelper;
42
43
    /**
44
     * PAYONE shop helper
45
     *
46
     * @var \Payone\Core\Helper\Shop
47
     */
48
    protected $shopHelper;
49
50
    /**
51
     * PAYONE toolkit helper
52
     *
53
     * @var \Payone\Core\Helper\Toolkit
54
     */
55
    protected $toolkitHelper;
56
57
    /**
58
     * Constructor
59
     *
60
     * @param \Magento\Framework\App\Helper\Context      $context
61
     * @param \Magento\Store\Model\StoreManagerInterface $storeManager
62
     * @param \Payone\Core\Helper\Shop                   $shopHelper
63
     * @param \Payone\Core\Helper\Toolkit                $toolkitHelper
64
     * @param \Magento\Framework\App\State               $state
65
     * @param \Payone\Core\Helper\Environment            $environmentHelper
66
     */
67
    public function __construct(
68
        \Magento\Framework\App\Helper\Context $context,
0 ignored issues
show
The type Magento\Framework\App\Helper\Context was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
69
        \Magento\Store\Model\StoreManagerInterface $storeManager,
0 ignored issues
show
The type Magento\Store\Model\StoreManagerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
70
        \Payone\Core\Helper\Shop $shopHelper,
71
        \Payone\Core\Helper\Toolkit $toolkitHelper,
72
        \Magento\Framework\App\State $state,
0 ignored issues
show
The type Magento\Framework\App\State was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
73
        \Payone\Core\Helper\Environment $environmentHelper
74
    ) {
75
        parent::__construct($context, $storeManager, $shopHelper, $state);
76
        $this->environmentHelper = $environmentHelper;
77
        $this->shopHelper = $shopHelper;
78
        $this->toolkitHelper = $toolkitHelper;
79
    }
80
81
    /**
82
     * Get bankaccountcheck request for javascript in the checkout
83
     *
84
     * @return array
85
     */
86
    public function getBankaccountCheckRequest()
87
    {
88
        if ($this->getConfigParam('check_bankaccount', PayoneConfig::METHOD_DEBIT, 'payone_payment') == '1') {
89
            $aRequest = [
90
                'request' => 'bankaccountcheck',
91
                'responsetype' => 'JSON',
92
                'mode' => $this->getConfigParam('mode', PayoneConfig::METHOD_DEBIT, 'payone_payment'),
93
                'mid' => $this->getConfigParam('mid'), // your MID
94
                'aid' => $this->getConfigParam('aid'), // your AID
95
                'portalid' => $this->getConfigParam('portalid'), // your PortalId
96
                'encoding' => $this->environmentHelper->getEncoding(), // desired encoding
97
                'language' => $this->shopHelper->getLocale(),
98
                'checktype' => $this->getConfigParam('bankaccountcheck_type', PayoneConfig::METHOD_DEBIT, 'payone_payment'),
99
                'hash' => $this->getBankaccountCheckRequestHash(),
100
                'integrator_name' => 'Magento2',
101
                'integrator_version' => $this->shopHelper->getMagentoVersion(),
102
                'solution_name' => 'fatchip',
103
                'solution_version' => PayoneConfig::MODULE_VERSION,
104
            ];
105
            return $aRequest;
106
        }
107
        return '';
0 ignored issues
show
Bug Best Practice introduced by
The expression return '' returns the type string which is incompatible with the documented return type array.
Loading history...
108
    }
109
110
    /**
111
     * Get hosted iframe request hash
112
     *
113
     * @return string
114
     */
115
    public function getHostedIframeRequestCCHash()
116
    {
117
        $sStringToHash = $this->getConfigParam('aid').
118
            $this->environmentHelper->getEncoding().
119
            $this->getConfigParam('mid').
120
            $this->getConfigParam('mode', PayoneConfig::METHOD_CREDITCARD, 'payone_payment').
121
            $this->getConfigParam('portalid').
122
            'creditcardcheck'.
123
            'JSON'.
124
            'yes';
125
        return $this->toolkitHelper->hashString($sStringToHash, 'sha384', $this->getConfigParam('key'));
126
    }
127
128
    /**
129
     * Get bankaccount check request hash
130
     *
131
     * @return string
132
     */
133
    public function getBankaccountCheckRequestHash()
134
    {
135
        $sStringToHash = $this->getConfigParam('aid').
136
            $this->getConfigParam('bankaccountcheck_type', PayoneConfig::METHOD_DEBIT, 'payone_payment').
137
            $this->environmentHelper->getEncoding().
138
            $this->getConfigParam('mid').
139
            $this->getConfigParam('mode', PayoneConfig::METHOD_CREDITCARD, 'payone_payment').
140
            $this->getConfigParam('portalid').
141
            'bankaccountcheck'.
142
            'JSON';
143
        return $this->toolkitHelper->hashString($sStringToHash, 'sha384', $this->getConfigParam('key'));
144
    }
145
146
    /**
147
     * Get hosted iframe request for javascript in the checkout
148
     *
149
     * @return array
150
     */
151
    public function getHostedIframeRequest()
152
    {
153
        $aRequest = [
154
            'request' => 'creditcardcheck',
155
            'responsetype' => 'JSON', // fixed value
156
            'mode' => $this->getConfigParam('mode', PayoneConfig::METHOD_CREDITCARD, 'payone_payment'), // desired mode
157
            'mid' => $this->getConfigParam('mid'), // your MID
158
            'aid' => $this->getConfigParam('aid'), // your AID
159
            'portalid' => $this->getConfigParam('portalid'), // your PortalId
160
            'encoding' => $this->environmentHelper->getEncoding(), // desired encoding
161
            'storecarddata' => 'yes', // fixed value
162
            'hash' => $this->getHostedIframeRequestCCHash()
163
        ];
164
        return $aRequest;
165
    }
166
}
167