Issues (547)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

Helper/Payment.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
use Magento\Framework\Phrase;
31
use Payone\Core\Model\Source\CreditcardTypes;
32
33
/**
34
 * Helper class for everything that has to do with payment
35
 */
36
class Payment extends \Payone\Core\Helper\Base
37
{
38
    /**
39
     * List of all currently available PAYONE payment types
40
     *
41
     * @var array
42
     */
43
    protected $aAvailablePayments = [
44
        PayoneConfig::METHOD_CREDITCARD,
45
        PayoneConfig::METHOD_DEBIT,
46
        PayoneConfig::METHOD_PAYPAL,
47
        PayoneConfig::METHOD_CASH_ON_DELIVERY,
48
        PayoneConfig::METHOD_ADVANCE_PAYMENT,
49
        PayoneConfig::METHOD_INVOICE,
50
        PayoneConfig::METHOD_OBT_SOFORTUEBERWEISUNG,
51
        PayoneConfig::METHOD_OBT_GIROPAY,
52
        PayoneConfig::METHOD_OBT_EPS,
53
        PayoneConfig::METHOD_OBT_POSTFINANCE_EFINANCE,
54
        PayoneConfig::METHOD_OBT_POSTFINANCE_CARD,
55
        PayoneConfig::METHOD_OBT_IDEAL,
56
        PayoneConfig::METHOD_OBT_PRZELEWY,
57
        PayoneConfig::METHOD_BARZAHLEN,
58
        PayoneConfig::METHOD_PAYDIREKT,
59
        PayoneConfig::METHOD_SAFE_INVOICE,
60
        PayoneConfig::METHOD_PAYOLUTION_INVOICE,
61
        PayoneConfig::METHOD_PAYOLUTION_DEBIT,
62
        PayoneConfig::METHOD_PAYOLUTION_INSTALLMENT,
63
    ];
64
65
    /**
66
     * Mapping of payment method code to payment abbreviation
67
     *
68
     * @var array
69
     */
70
    protected $aPaymentAbbreviation = [
71
        PayoneConfig::METHOD_CREDITCARD => 'cc',
72
        PayoneConfig::METHOD_CASH_ON_DELIVERY => 'cod',
73
        PayoneConfig::METHOD_DEBIT => 'elv',
74
        PayoneConfig::METHOD_ADVANCE_PAYMENT => 'vor',
75
        PayoneConfig::METHOD_INVOICE => 'rec',
76
        PayoneConfig::METHOD_OBT_SOFORTUEBERWEISUNG => 'sb',
77
        PayoneConfig::METHOD_OBT_GIROPAY => 'sb',
78
        PayoneConfig::METHOD_OBT_EPS => 'sb',
79
        PayoneConfig::METHOD_OBT_POSTFINANCE_EFINANCE => 'sb',
80
        PayoneConfig::METHOD_OBT_POSTFINANCE_CARD => 'sb',
81
        PayoneConfig::METHOD_OBT_IDEAL => 'sb',
82
        PayoneConfig::METHOD_OBT_PRZELEWY => 'sb',
83
        PayoneConfig::METHOD_PAYPAL => 'wlt',
84
        PayoneConfig::METHOD_PAYDIREKT => 'wlt',
85
        PayoneConfig::METHOD_BILLSAFE => 'fnc',
86
        PayoneConfig::METHOD_KLARNA => 'fnc',
87
        PayoneConfig::METHOD_BARZAHLEN => 'csh',
88
        PayoneConfig::METHOD_SAFE_INVOICE => 'rec',
89
        PayoneConfig::METHOD_PAYOLUTION_INVOICE => 'fnc',
90
        PayoneConfig::METHOD_PAYOLUTION_DEBIT => 'fnc',
91
        PayoneConfig::METHOD_PAYOLUTION_INSTALLMENT => 'fnc',
92
    ];
93
94
    /**
95
     * Return available payment types
96
     *
97
     * @return array
98
     */
99
    public function getAvailablePaymentTypes()
100
    {
101
        return $this->aAvailablePayments;
102
    }
103
104
    /**
105
     * Get all activated creditcard types
106
     *
107
     * @return array
108
     */
109 View Code Duplication
    public function getAvailableCreditcardTypes()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
110
    {
111
        $aReturn = [];
112
113
        $sCreditcardTypes = $this->getConfigParam('types', PayoneConfig::METHOD_CREDITCARD, 'payone_payment');
114
        if ($sCreditcardTypes) {
115
            $aAllTypes = CreditcardTypes::getCreditcardTypes();
116
117
            $aCreditcardTypes = explode(',', $sCreditcardTypes);
118
            foreach ($aCreditcardTypes as $sType) {
119
                $aReturn[] = [
120
                    'id' => $sType,
121
                    'title' => $aAllTypes[$sType],
122
                ];
123
            }
124
        }
125
        return $aReturn;
126
    }
127
128
    /**
129
     * Return if cvc has to be checked
130
     *
131
     * @return bool
132
     */
133
    public function isCheckCvcActive()
134
    {
135
        return (bool)$this->getConfigParam('check_cvc', PayoneConfig::METHOD_CREDITCARD, 'payone_payment');
136
    }
137
138
    /**
139
     * Return if mandate management is activated
140
     *
141
     * @return bool
142
     */
143
    public function isMandateManagementActive()
144
    {
145
        return (bool)$this->getConfigParam('sepa_mandate_enabled', PayoneConfig::METHOD_DEBIT, 'payone_payment');
146
    }
147
148
    /**
149
     * Return if mandate download is activated
150
     *
151
     * @return bool
152
     */
153
    public function isMandateManagementDownloadActive()
154
    {
155
        return (bool)$this->getConfigParam('sepa_mandate_download_enabled', PayoneConfig::METHOD_DEBIT, 'payone_payment');
156
    }
157
158
    /**
159
     * Get status mapping configuration for given payment type
160
     *
161
     * @param  string $sPaymentCode
162
     * @return array
163
     */
164
    public function getStatusMappingByCode($sPaymentCode)
165
    {
166
        $sStatusMapping = $this->getConfigParam($sPaymentCode, 'statusmapping');
167
        $aStatusMapping = $this->unserialize($sStatusMapping);
168
        $aCleanMapping = [];
169
        if ($aStatusMapping) {
170
            foreach ($aStatusMapping as $aMap) {
171
                if (isset($aMap['txaction']) && isset($aMap['state_status'])) {
172
                    $aCleanMapping[$aMap['txaction']] = $aMap['state_status'];
173
                }
174
            }
175
        }
176
        return $aCleanMapping;
177
    }
178
179
    /**
180
     * Return display-message for the case that the bankaccount check
181
     * returned, that the given bankaccount was blocked
182
     *
183
     * @return Phrase
184
     */
185
    public function getBankaccountCheckBlockedMessage()
186
    {
187
        $sMessage = $this->getConfigParam('message_response_blocked', PayoneConfig::METHOD_DEBIT, 'payone_payment');
188
        if (empty($sMessage)) {
189
            $sMessage = 'Bankdata invalid.';
190
        }
191
        return __($sMessage);
192
    }
193
194
    /**
195
     * Return is PayPal Express is activated in the configuration
196
     *
197
     * @return bool
198
     */
199
    public function isPayPalExpressActive()
200
    {
201
        return (bool)$this->getConfigParam('express_active', PayoneConfig::METHOD_PAYPAL, 'payone_payment');
202
    }
203
204
    /**
205
     * Get abbreviation for the given payment type
206
     *
207
     * @param  string $sPaymentCode
208
     * @return string
209
     */
210
    public function getPaymentAbbreviation($sPaymentCode)
211
    {
212
        if (isset($this->aPaymentAbbreviation[$sPaymentCode])) {
213
            return $this->aPaymentAbbreviation[$sPaymentCode];
214
        }
215
        return 'unknown';
216
    }
217
}
218