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
@@ -20,6 +21,7 @@ public function getData()
20
21
$ this ->addSolutionId ($ data );
21
22
$ this ->addBillingData ($ data );
22
23
$ this ->addCustomerIP ($ data );
24
+ $ this ->addRetail ($ data );
23
25
$ this ->addTransactionSettings ($ data );
24
26
25
27
return $ data ;
@@ -54,4 +56,53 @@ protected function addCustomerIP(\SimpleXMLElement $data)
54
56
$ data ->transactionRequest ->customerIP = $ ip ;
55
57
}
56
58
}
59
+
60
+ protected function addRetail (\SimpleXMLElement $ data )
61
+ {
62
+ $ deviceType = $ this ->getDeviceType ();
63
+ $ marketType = $ this ->getMarketType ();
64
+
65
+ if (!isset ($ deviceType ) && !isset ($ marketType )) {
66
+ return ;
67
+ }
68
+
69
+ if (!isset ($ deviceType ) && isset ($ marketType )) {
70
+ throw new InvalidRequestException ("deviceType is required if marketType is set " );
71
+ }
72
+
73
+ if (isset ($ deviceType ) && !isset ($ marketType )) {
74
+ $ marketType = "2 " ;
75
+ }
76
+
77
+ if (!in_array ($ deviceType , [ "1 " , "2 " , "3 " , "4 " , "5 " , "6 " , "7 " , "8 " , "9 " , "10 " ])) {
78
+ throw new InvalidRequestException ("deviceType ` {$ deviceType }` is invalid " );
79
+ }
80
+
81
+ if (!in_array ($ marketType , [ "0 " , "1 " , "2 " ])) {
82
+ throw new InvalidRequestException ("marketType ` {$ marketType }` is invalid " );
83
+ }
84
+
85
+ $ data ->transactionRequest ->retail ->marketType = $ marketType ;
86
+ $ data ->transactionRequest ->retail ->deviceType = $ deviceType ;
87
+ }
88
+
89
+ public function getDeviceType ()
90
+ {
91
+ return $ this ->getParameter ('deviceType ' );
92
+ }
93
+
94
+ public function setDeviceType ($ value )
95
+ {
96
+ return $ this ->setParameter ('deviceType ' , $ value );
97
+ }
98
+
99
+ public function getMarketType ()
100
+ {
101
+ return $ this ->getParameter ('marketType ' );
102
+ }
103
+
104
+ public function setMarketType ($ value )
105
+ {
106
+ return $ this ->setParameter ('marketType ' , $ value );
107
+ }
57
108
}
0 commit comments