Issues (1092)

Model/Api/Request/Managemandate.php (2 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\Model\Api\Request;
28
29
use Payone\Core\Model\Methods\PayoneMethod;
30
use Magento\Quote\Model\Quote;
0 ignored issues
show
The type Magento\Quote\Model\Quote 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...
31
32
/**
33
 * Class for the PAYONE Server API request "managemandate"
34
 */
35
class Managemandate extends AddressRequest
36
{
37
    /**
38
     * PAYONE database helper
39
     *
40
     * @var \Payone\Core\Helper\Database
41
     */
42
    protected $databaseHelper;
43
44
    /**
45
     * Constructor
46
     *
47
     * @param \Payone\Core\Helper\Shop                $shopHelper
48
     * @param \Payone\Core\Helper\Environment         $environmentHelper
49
     * @param \Payone\Core\Helper\Api                 $apiHelper
50
     * @param \Payone\Core\Helper\Toolkit             $toolkitHelper
51
     * @param \Payone\Core\Model\ResourceModel\ApiLog $apiLog
52
     * @param \Payone\Core\Helper\Customer            $customerHelper
53
     * @param \Payone\Core\Helper\Database            $databaseHelper
54
     */
55
    public function __construct(
56
        \Payone\Core\Helper\Shop $shopHelper,
57
        \Payone\Core\Helper\Environment $environmentHelper,
58
        \Payone\Core\Helper\Api $apiHelper,
59
        \Payone\Core\Helper\Toolkit $toolkitHelper,
60
        \Payone\Core\Model\ResourceModel\ApiLog $apiLog,
61
        \Payone\Core\Helper\Customer $customerHelper,
62
        \Payone\Core\Helper\Database $databaseHelper
63
    ) {
64
        parent::__construct($shopHelper, $environmentHelper, $apiHelper, $toolkitHelper, $apiLog, $customerHelper);
65
        $this->databaseHelper = $databaseHelper;
66
    }
67
68
    /**
69
     * Send request "managemandate" to PAYONE server API
70
     *
71
     * @param  PayoneMethod $oPayment
72
     * @param  Quote        $oQuote
73
     * @return array
74
     */
75
    public function sendRequest(PayoneMethod $oPayment, Quote $oQuote)
76
    {
77
        $oCustomer = $oQuote->getCustomer();
78
79
        $this->addParameter('request', 'managemandate'); // Request method
80
        $this->addParameter('mode', $oPayment->getOperationMode()); // PayOne Portal Operation Mode (live or test)
81
        $this->addParameter('aid', $this->shopHelper->getConfigParam('aid')); // ID of PayOne Sub-Account
82
        $this->addParameter('clearingtype', 'elv');
83
84
        if ($this->shopHelper->getConfigParam('transmit_customerid') == '1') {
85
            $this->addParameter('customerid', $oCustomer->getId());
86
        }
87
        $sPayOneUserId = $this->databaseHelper->getPayoneUserIdByCustNr($oCustomer->getId());
88
        if ($sPayOneUserId) {
89
            $this->addParameter('userid', $sPayOneUserId);
90
        }
91
92
        $oBilling = $oQuote->getBillingAddress();
93
        $this->addUserDataParameters(
94
            $oBilling,
95
            $oPayment,
96
            $oCustomer->getGender(),
97
            $oCustomer->getEmail(),
98
            $oCustomer->getDob()
99
        );
100
101
        $this->addParameter('language', $this->shopHelper->getLocale());
102
103
        $oInfoInstance = $oPayment->getInfoInstance();
104
        $this->addParameter('bankcountry', $oInfoInstance->getAdditionalInformation('bank_country'));
105
        $this->addParameter('iban', $oInfoInstance->getAdditionalInformation('iban'));
106
        if ($oInfoInstance->getAdditionalInformation('bic')) {
107
            $this->addParameter('bic', $oInfoInstance->getAdditionalInformation('bic'));
108
        }
109
        $this->addParameter('currency', $this->apiHelper->getCurrencyFromQuote($oQuote));
110
111
        $aResponse = $this->send($oPayment);
112
        if (is_array($aResponse)) {
0 ignored issues
show
The condition is_array($aResponse) is always true.
Loading history...
113
            $aResponse['mode'] = $oPayment->getOperationMode();
114
        }
115
116
        return $aResponse;
117
    }
118
}
119