Completed
Push — master ( 341936...178071 )
by Florian
03:31
created

Calculation   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 32
c 0
b 0
f 0
wmc 1
lcom 1
cbo 3
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A sendRequest() 0 21 1
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 - 2017 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\Genericpayment;
28
29
use Payone\Core\Model\Methods\PayoneMethod;
30
use Magento\Quote\Model\Quote;
31
32
/**
33
 * Class for the PAYONE Server API request genericpayment - "calculation"
34
 */
35
class Calculation extends Base
36
{
37
    /**
38
     * Send request to PAYONE Server-API with request-type "genericpayment" and action "calculation"
39
     *
40
     * @param  PayoneMethod $oPayment payment object
41
     * @param  Quote        $oQuote   order object
42
     * @param  float        $dAmount  order sum amount
43
     * @return array
44
     */
45
    public function sendRequest(PayoneMethod $oPayment, Quote $oQuote, $dAmount)
46
    {
47
        $this->addParameter('request', 'genericpayment');
48
        $this->addParameter('add_paydata[action]', 'calculation');
49
50
        $this->addParameter('mode', $oPayment->getOperationMode());
51
        $this->addParameter('aid', $this->shopHelper->getConfigParam('aid')); // ID of PayOne Sub-Account
52
        $this->addParameter('api_version', '3.10');
53
54
        $this->addParameter('clearingtype', $oPayment->getClearingtype());
0 ignored issues
show
Bug introduced by
It seems like $oPayment->getClearingtype() targeting Payone\Core\Model\Method...thod::getClearingtype() can also be of type boolean; however, Payone\Core\Model\Api\Request\Base::addParameter() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
55
        $this->addParameter('financingtype', $oPayment->getSubType());
0 ignored issues
show
Bug introduced by
It seems like $oPayment->getSubType() targeting Payone\Core\Model\Method...oneMethod::getSubType() can also be of type boolean; however, Payone\Core\Model\Api\Request\Base::addParameter() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
56
57
        $this->addParameter('amount', number_format($dAmount, 2, '.', '') * 100);
58
        $this->addParameter('currency', $oQuote->getQuoteCurrencyCode());
59
60
        $oBilling = $oQuote->getBillingAddress();
61
        $this->addParameter('country', $oBilling->getCountryId());
62
        $this->addParameter('lastname', $oBilling->getLastname());
63
64
        return $this->send();
65
    }
66
}
67