@@ -75,7 +75,6 @@ public function getHash($transaction_reference, $amount, $httpRequest)
75
75
} else {
76
76
return $ this ->getMd5Hash ($ transaction_reference , $ amount );
77
77
}
78
-
79
78
}
80
79
81
80
/**
@@ -100,14 +99,16 @@ public function getMd5Hash($transaction_reference, $amount)
100
99
/**
101
100
* Generate sha512 hash.
102
101
* Required fields are provided in Table 18 in https://www.authorize.net/content/dam/authorize/documents/SIM_guide.pdf#page=73
103
- *
104
102
* @param $httpRequest
105
103
* @return string|null
106
104
*/
107
105
public function getSha512Hash ($ httpRequest )
108
106
{
109
107
$ signatureKey = $ this ->getSignatureKey ();
110
- if (empty ($ signatureKey ) || empty ($ httpRequest )) return null ;
108
+ if (empty ($ signatureKey ) || empty ($ httpRequest )) {
109
+ return null ;
110
+ }
111
+
111
112
$ hashData = implode ('^ ' , [
112
113
$ httpRequest ->request ->get ('x_trans_id ' ),
113
114
$ httpRequest ->request ->get ('x_test_request ' ),
@@ -140,7 +141,7 @@ public function getSha512Hash($httpRequest)
140
141
$ httpRequest ->request ->get ('x_ship_to_country ' ),
141
142
$ httpRequest ->request ->get ('x_invoice_num ' ),
142
143
]);
143
- $ hash = hash_hmac ('sha512 ' , '^ ' . $ hashData. '^ ' , hex2bin ($ signatureKey ));
144
+ $ hash = hash_hmac ('sha512 ' , '^ ' . $ hashData . '^ ' , hex2bin ($ signatureKey ));
144
145
$ hash = strtoupper ($ hash );
145
146
146
147
return $ hash ;
@@ -154,11 +155,14 @@ public function getSha512Hash($httpRequest)
154
155
*/
155
156
public function getPostedHash ($ httpRequest )
156
157
{
157
- if (empty ($ httpRequest )) return null ;
158
+ if (empty ($ httpRequest )){
159
+ return null ;
160
+ }
158
161
159
- if ($ signatureKey = $ this ->getSignatureKey ()){
162
+ if ($ signatureKey = $ this ->getSignatureKey ()) {
160
163
return strtoupper ($ httpRequest ->request ->get ('x_SHA2_Hash ' ));
161
164
}
165
+
162
166
return strtolower ($ httpRequest ->request ->get ('x_MD5_Hash ' ));
163
167
}
164
168
0 commit comments