3
3
namespace Omnipay \AuthorizeNet \Message ;
4
4
5
5
use Omnipay \Common \CreditCard ;
6
+ use Omnipay \Common \Exception \InvalidRequestException ;
6
7
7
8
/**
8
9
* Authorize.Net AIM Authorize Request
9
10
*/
10
11
class AIMAuthorizeRequest extends AIMAbstractRequest
11
12
{
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
+
12
28
protected $ action = 'authOnlyTransaction ' ;
13
29
14
30
public function getData ()
@@ -20,6 +36,7 @@ public function getData()
20
36
$ this ->addSolutionId ($ data );
21
37
$ this ->addBillingData ($ data );
22
38
$ this ->addCustomerIP ($ data );
39
+ $ this ->addRetail ($ data );
23
40
$ this ->addTransactionSettings ($ data );
24
41
25
42
return $ data ;
@@ -54,4 +71,68 @@ protected function addCustomerIP(\SimpleXMLElement $data)
54
71
$ data ->transactionRequest ->customerIP = $ ip ;
55
72
}
56
73
}
74
+
75
+ protected function addRetail (\SimpleXMLElement $ data )
76
+ {
77
+ $ deviceType = $ this ->getDeviceType ();
78
+ $ marketType = $ this ->getMarketType ();
79
+
80
+ if (!isset ($ deviceType ) && !isset ($ marketType )) {
81
+ return ;
82
+ }
83
+
84
+ if (!isset ($ deviceType ) && isset ($ marketType )) {
85
+ throw new InvalidRequestException ("deviceType is required if marketType is set " );
86
+ }
87
+
88
+ if (isset ($ deviceType ) && !isset ($ marketType )) {
89
+ $ marketType = static ::MARKET_TYPE_RETAIL ;
90
+ }
91
+
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
+ ])) {
104
+ throw new InvalidRequestException ("deviceType ` {$ deviceType }` is invalid " );
105
+ }
106
+
107
+ if (!in_array ($ marketType , [
108
+ static ::MARKET_TYPE_ECOMMERCE ,
109
+ static ::MARKET_TYPE_MOTO ,
110
+ static ::MARKET_TYPE_RETAIL ,
111
+ ])) {
112
+ throw new InvalidRequestException ("marketType ` {$ marketType }` is invalid " );
113
+ }
114
+
115
+ $ data ->transactionRequest ->retail ->marketType = $ marketType ;
116
+ $ data ->transactionRequest ->retail ->deviceType = $ deviceType ;
117
+ }
118
+
119
+ public function getDeviceType ()
120
+ {
121
+ return $ this ->getParameter ('deviceType ' );
122
+ }
123
+
124
+ public function setDeviceType ($ value )
125
+ {
126
+ return $ this ->setParameter ('deviceType ' , $ value );
127
+ }
128
+
129
+ public function getMarketType ()
130
+ {
131
+ return $ this ->getParameter ('marketType ' );
132
+ }
133
+
134
+ public function setMarketType ($ value )
135
+ {
136
+ return $ this ->setParameter ('marketType ' , $ value );
137
+ }
57
138
}
0 commit comments