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
|
|
|
public function getData() |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
$this->validate('merchantId', 'transactionId', 'sign', 'card'); |
53
|
|
|
|
54
|
|
|
$data = array( |
55
|
|
|
'amount' => $this->getAmountInteger(), |
56
|
|
|
'currency' => $this->getCurrency(), |
57
|
|
|
'aliasCC' => $this->getCard()->getNumber(), |
58
|
|
|
'expm' => $this->getCard()->getExpiryMonth(), |
59
|
|
|
'expy' => $this->getCard()->getExpiryDate('y'), |
60
|
|
|
'uppCustomerDetails' => [ |
61
|
|
|
'uppCustomerIpAddress' => $_SERVER['REMOTE_ADDR'] |
62
|
|
|
], |
63
|
|
|
'useAlias' => 'no' |
64
|
|
|
); |
65
|
|
|
|
66
|
|
View Code Duplication |
foreach ($this->optionalParameters as $param) { |
|
|
|
|
67
|
|
|
$value = $this->getParameter($param); |
68
|
|
|
|
69
|
|
|
if ($value) { |
70
|
|
|
$data[$param] = $value; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return $data; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param $data |
79
|
|
|
* @return XmlAuthorizationResponse |
80
|
|
|
*/ |
81
|
|
|
protected function createResponse($data) |
82
|
|
|
{ |
83
|
|
|
return $this->response = new XmlAuthorizationResponse($this, $data); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: