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
|
3 |
|
public function getData() |
52
|
|
|
{ |
53
|
3 |
|
$this->validate('merchantId', 'transactionId', 'sign', 'card'); |
54
|
|
|
|
55
|
|
|
$data = array( |
56
|
3 |
|
'amount' => $this->getAmountInteger(), |
57
|
3 |
|
'currency' => $this->getCurrency(), |
58
|
3 |
|
'aliasCC' => $this->getCard()->getNumber(), |
59
|
3 |
|
'expm' => $this->getCard()->getExpiryMonth(), |
60
|
3 |
|
'expy' => $this->getCard()->getExpiryDate('y'), |
61
|
|
|
'useAlias' => 'no' |
62
|
3 |
|
); |
63
|
|
|
|
64
|
3 |
View Code Duplication |
foreach ($this->optionalParameters as $param) { |
|
|
|
|
65
|
3 |
|
$value = $this->getParameter($param); |
66
|
|
|
|
67
|
3 |
|
if ($value) { |
68
|
1 |
|
$data[$param] = $value; |
69
|
1 |
|
} |
70
|
3 |
|
} |
71
|
|
|
|
72
|
3 |
|
return $data; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param $data |
77
|
|
|
* @return XmlAuthorizationResponse |
78
|
|
|
*/ |
79
|
3 |
|
protected function createResponse($data) |
80
|
|
|
{ |
81
|
3 |
|
return $this->response = new XmlAuthorizationResponse($this, $data); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param $value |
86
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
87
|
|
|
*/ |
88
|
1 |
|
public function setUseAlias($value) |
89
|
|
|
{ |
90
|
1 |
|
return $this->setParameter('useAlias', $value); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.