Skip to content

Commit 202c660

Browse files
committed
Move some mystery numbers to constants.
These are parameters (market place and device type) that come up time and time again across gateways, but have different values for each gateway, e.g. 0, 1, 2 vs E, M, R. A mapping should be standardised.
1 parent 5276ada commit 202c660

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

src/Message/AIMAuthorizeRequest.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@
1010
*/
1111
class AIMAuthorizeRequest extends AIMAbstractRequest
1212
{
13+
const MARKET_TYPE_ECOMMERCE = '0';
14+
const MARKET_TYPE_MOTO = '1';
15+
const MARKET_TYPE_RETAIL = '2';
16+
17+
const DEVICE_TYPE_UNKNOWN = '1';
18+
const DEVICE_TYPE_UNATTENDED_TERMINAL = '2';
19+
const DEVICE_TYPE_SELF_SERVICE_TERMINAL = '3';
20+
const DEVICE_TYPE_ELECTRONIC_CASH_REGISTER = '4';
21+
const DEVICE_TYPE_PC_BASED_TERMINAL = '5';
22+
const DEVICE_TYPE_AIRPAY = '6';
23+
const DEVICE_TYPE_WIRELESS_POS = '7';
24+
const DEVICE_TYPE_WEBSITE = '8';
25+
const DEVICE_TYPE_DIAL_TERMINAL = '9';
26+
const DEVICE_TYPE_VIRTUAL_TERMINAL = '10';
27+
1328
protected $action = 'authOnlyTransaction';
1429

1530
public function getData()
@@ -71,14 +86,29 @@ protected function addRetail(\SimpleXMLElement $data)
7186
}
7287

7388
if (isset($deviceType) && !isset($marketType)) {
74-
$marketType = "2";
89+
$marketType = static::MARKET_TYPE_RETAIL;
7590
}
7691

77-
if (!in_array($deviceType, [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ])) {
92+
if (!in_array($deviceType, [
93+
static::DEVICE_TYPE_UNKNOWN,
94+
static::DEVICE_TYPE_UNATTENDED_TERMINAL,
95+
static::DEVICE_TYPE_SELF_SERVICE_TERMINAL,
96+
static::DEVICE_TYPE_ELECTRONIC_CASH_REGISTER,
97+
static::DEVICE_TYPE_PC_BASED_TERMINAL,
98+
static::DEVICE_TYPE_AIRPAY,
99+
static::DEVICE_TYPE_WIRELESS_POS,
100+
static::DEVICE_TYPE_WEBSITE,
101+
static::DEVICE_TYPE_DIAL_TERMINAL,
102+
static::DEVICE_TYPE_VIRTUAL_TERMINAL,
103+
])) {
78104
throw new InvalidRequestException("deviceType `{$deviceType}` is invalid");
79105
}
80106

81-
if (!in_array($marketType, [ "0", "1", "2" ])) {
107+
if (!in_array($marketType, [
108+
static::MARKET_TYPE_ECOMMERCE,
109+
static::MARKET_TYPE_MOTO,
110+
static::MARKET_TYPE_RETAIL,
111+
])) {
82112
throw new InvalidRequestException("marketType `{$marketType}` is invalid");
83113
}
84114

0 commit comments

Comments
 (0)