Completed
Pull Request — master (#5)
by
unknown
02:05
created

XmlAuthorizationRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 78.95%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 2
cbo 3
dl 0
loc 71
ccs 15
cts 19
cp 0.7895
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 23 3
A createResponse() 0 4 1
A setUseAlias() 0 4 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
        '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
     */
51 2
    public function getData()
52
    {
53 2
        $this->validate('merchantId', 'transactionId', 'sign', 'card');
54
55
        $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 2
            'expy'       => $this->getCard()->getExpiryDate('y'),
61
            'useAlias'   => 'no'
62 2
        );
63
64 2
        foreach ($this->optionalParameters as $param) {
65 2
            $value = $this->getParameter($param);
66
67 2
            if ($value) {
68
                $data[$param] = $value;
69
            }
70 2
        }
71
72 2
        return $data;
73
    }
74
75
    /**
76
     * @param $data
77
     * @return XmlAuthorizationResponse
78
     */
79 2
    protected function createResponse($data)
80
    {
81 2
        return $this->response = new XmlAuthorizationResponse($this, $data);
82
    }
83
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