Completed
Pull Request — master (#5)
by
unknown
03:33
created

XmlAuthorizationRequest::setUseAlias()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
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
        'useAlias'
31
    );
32
33
    /**
34
     * @var string
35
     */
36
    protected $apiEndpoint = 'XML_authorize.jsp';
37
38
    /**
39
     * @var string
40
     */
41
    protected $serviceName = 'authorizationService';
42
43
    /**
44
     * @var int
45
     */
46
    protected $serviceVersion = 3;
47
48
    /**
49
     * @return array
50 2
     */
51
    public function getData()
52 2
    {
53
        $this->validate('merchantId', 'transactionId', 'sign', 'card');
54
55 2
        $data = array(
56 2
            'amount'     => $this->getAmountInteger(),
57 2
            'currency'   => $this->getCurrency(),
58 2
            'aliasCC'    => $this->getCard()->getNumber(),
59 2
            'expm'       => $this->getCard()->getExpiryMonth(),
60
            'expy'       => $this->getCard()->getExpiryDate('y'),
61 2
            'useAlias'   => 'no'
62
        );
63 2
64 2
        foreach ($this->optionalParameters as $param) {
65
            $value = $this->getParameter($param);
66 2
67
            if ($value) {
68
                $data[$param] = $value;
69 2
            }
70
        }
71 2
72
        return $data;
73
    }
74
75
    /**
76
     * @param $data
77
     * @return XmlAuthorizationResponse
78 2
     */
79
    protected function createResponse($data)
80 2
    {
81
        return $this->response = new XmlAuthorizationResponse($this, $data);
82
    }
83 1
84
    /**
85
     * @param $value
86
     * @return \Omnipay\Common\Message\AbstractRequest
87
     */
88
    public function setUseAlias($value)
89
    {
90
        return $this->setParameter('useAlias', $value);
91
    }
92
}
93