Completed
Push — master ( e6924a...b3599f )
by Dominik
02:35
created

XmlAuthorizationRequest::createResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * w-vision
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the MIT License
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that are distributed with this source code.
10
 *
11
 * @copyright  Copyright (c) 2016 Woche-Pass AG (http://www.w-vision.ch)
12
 * @license    MIT License
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 = array(
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 2
        foreach ($this->optionalParameters as $param) {
64 2
            $value = $this->getParameter($param);
65
66 2
            if ($value) {
67
                $data[$param] = $value;
68
            }
69 2
        }
70
71 2
        return $data;
72
    }
73
74
    /**
75
     * @param $data
76
     * @return XmlAuthorizationResponse
77
     */
78 2
    protected function createResponse($data)
79
    {
80 2
        return $this->response = new XmlAuthorizationResponse($this, $data);
81
    }
82
}
83