|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Omnipay\Emp\Message; |
|
4
|
|
|
|
|
5
|
|
|
use Omnipay\Emp\Threatmetrix; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @author Ivan Kerin <[email protected]> |
|
9
|
|
|
* @copyright 2014, Clippings Ltd. |
|
10
|
|
|
* @license http://spdx.org/licenses/BSD-3-Clause |
|
11
|
|
|
*/ |
|
12
|
|
|
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @return string |
|
16
|
|
|
*/ |
|
17
|
|
|
abstract function getEndpoint(); |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @return string |
|
21
|
|
|
*/ |
|
22
|
3 |
|
public function getClientId() |
|
23
|
|
|
{ |
|
24
|
3 |
|
return $this->getParameter('clientId'); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param string $value |
|
29
|
|
|
*/ |
|
30
|
5 |
|
public function setClientId($value) |
|
31
|
|
|
{ |
|
32
|
5 |
|
return $this->setParameter('clientId', $value); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @return string |
|
37
|
|
|
*/ |
|
38
|
3 |
|
public function getApiKey() |
|
39
|
|
|
{ |
|
40
|
3 |
|
return $this->getParameter('apiKey'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param string $value |
|
45
|
|
|
*/ |
|
46
|
5 |
|
public function setApiKey($value) |
|
47
|
|
|
{ |
|
48
|
5 |
|
return $this->setParameter('apiKey', $value); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return string |
|
53
|
|
|
*/ |
|
54
|
1 |
|
public function getProxy() |
|
55
|
|
|
{ |
|
56
|
1 |
|
return $this->getParameter('proxy'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param string $value |
|
61
|
|
|
*/ |
|
62
|
5 |
|
public function setProxy($value) |
|
63
|
|
|
{ |
|
64
|
5 |
|
return $this->setParameter('proxy', $value); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return Threatmetrix |
|
69
|
|
|
*/ |
|
70
|
1 |
|
public function getThreatmetrix() |
|
71
|
|
|
{ |
|
72
|
1 |
|
return $this->getParameter('threatmetrix'); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param Threatmetrix $value |
|
77
|
|
|
*/ |
|
78
|
1 |
|
public function setThreatmetrix(Threatmetrix $value) |
|
79
|
|
|
{ |
|
80
|
1 |
|
return $this->setParameter('threatmetrix', $value); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Base "getData" should be extended by other requests |
|
85
|
|
|
* |
|
86
|
|
|
* @return array |
|
87
|
|
|
*/ |
|
88
|
2 |
|
public function getData() |
|
89
|
|
|
{ |
|
90
|
2 |
|
$data = array(); |
|
91
|
|
|
|
|
92
|
2 |
|
if ($this->getTestMode()) { |
|
93
|
1 |
|
$data['test_transaction'] = '1'; |
|
94
|
1 |
|
} |
|
95
|
|
|
|
|
96
|
2 |
|
if ($this->getThreatmetrix()) { |
|
97
|
1 |
|
$data['thm_session_id'] = $this->getThreatmetrix()->getSessionId(); |
|
98
|
1 |
|
} |
|
99
|
|
|
|
|
100
|
2 |
|
$data['client_id'] = $this->getClientId(); |
|
101
|
2 |
|
$data['api_key'] = $this->getApiKey(); |
|
102
|
|
|
|
|
103
|
2 |
|
return $data; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @param mixed $data |
|
108
|
|
|
* @return array |
|
109
|
|
|
*/ |
|
110
|
1 |
|
public function sendData($data) |
|
111
|
|
|
{ |
|
112
|
1 |
|
$httpRequest = $this->httpClient->post( |
|
113
|
1 |
|
$this->getEndpoint(), |
|
114
|
1 |
|
null, |
|
115
|
1 |
|
$data, |
|
116
|
1 |
|
$this->getProxy() ? array('proxy' => $this->getProxy()) : array() |
|
117
|
1 |
|
); |
|
118
|
|
|
|
|
119
|
1 |
|
$httpResponse = $httpRequest->send(); |
|
120
|
|
|
|
|
121
|
1 |
|
return json_decode(json_encode($httpResponse->xml()), true); |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.