Completed
Push — master ( 8b82fe...3184ae )
by Dominik
07:19 queued 02:41
created

XmlAuthorizationRequest::getData()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4.125

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
ccs 8
cts 16
cp 0.5
rs 9.0856
cc 3
eloc 14
nc 3
nop 0
crap 4.125
1
<?php
2
/**
3
 * w-vision
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the GNU General Public License version 3 (GPLv3)
8
 * For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
9
 * files that are distributed with this source code.
10
 *
11
 * @copyright  Copyright (c) 2016 Woche-Pass AG (http://www.w-vision.ch)
12
 * @license    GNU General Public License version 3 (GPLv3)
13
 */
14
15
namespace Omnipay\Datatrans\Message;
16
17
/**
18
 * Class XmlSettlementRequest
19
 *
20
 * @package Omnipay\Datatrans\Message
21
 */
22
class XmlAuthorizationRequest extends XmlRequest
23
{
24
    /**
25
     * @var array
26
     */
27
    protected $optionalParameters = [
28
        'reqtype',
29
        'uppCustomerIpAddress'
30
    ];
31
32
    /**
33
     * @var string
34
     */
35
    protected $apiEndpoint = 'XML_authorize.jsp';
36
37
    /**
38
     * @var string
39
     */
40
    protected $serviceName = 'authorizationService';
41
42
    /**
43
     * @var int
44
     */
45
    protected $serviceVersion = 3;
46
47
    /**
48
     * @return array
49
     */
50 2
    public function getData()
51
    {
52 2
        $this->validate('merchantId', 'transactionId', 'sign', 'card');
53
54
        $data = array(
55 2
            'amount'     => $this->getAmountInteger(),
56 2
            'currency'   => $this->getCurrency(),
57 2
            'aliasCC'    => $this->getCard()->getNumber(),
58 2
            'expm'       => $this->getCard()->getExpiryMonth(),
59 2
            'expy'       => $this->getCard()->getExpiryDate('y'),
60
            'useAlias' => 'no'
61 2
        );
62
63
        foreach ($this->optionalParameters as $param) {
64
            $value = $this->getParameter($param);
65
66
            if ($value) {
67
                $data[$param] = $value;
68
            }
69
        }
70
71
        return $data;
72
    }
73
74
    /**
75
     * @param $data
76
     * @return XmlAuthorizationResponse
77
     */
78
    protected function createResponse($data)
79
    {
80
        return $this->response = new XmlAuthorizationResponse($this, $data);
81
    }
82
}
83