Skip to content

Commit de5eb0c

Browse files
issue-123: fix SIMCompleteAuthorizeRequest
1 parent 519011b commit de5eb0c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Message/SIMCompleteAuthorizeRequest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public function getHash($transaction_reference, $amount, $httpRequest)
7575
} else {
7676
return $this->getMd5Hash($transaction_reference, $amount);
7777
}
78-
7978
}
8079

8180
/**
@@ -100,14 +99,16 @@ public function getMd5Hash($transaction_reference, $amount)
10099
/**
101100
* Generate sha512 hash.
102101
* Required fields are provided in Table 18 in https://www.authorize.net/content/dam/authorize/documents/SIM_guide.pdf#page=73
103-
*
104102
* @param $httpRequest
105103
* @return string|null
106104
*/
107105
public function getSha512Hash($httpRequest)
108106
{
109107
$signatureKey = $this->getSignatureKey();
110-
if(empty($signatureKey) || empty($httpRequest)) return null;
108+
if (empty($signatureKey) || empty($httpRequest)) {
109+
return null;
110+
}
111+
111112
$hashData = implode('^', [
112113
$httpRequest->request->get('x_trans_id'),
113114
$httpRequest->request->get('x_test_request'),
@@ -140,7 +141,7 @@ public function getSha512Hash($httpRequest)
140141
$httpRequest->request->get('x_ship_to_country'),
141142
$httpRequest->request->get('x_invoice_num'),
142143
]);
143-
$hash = hash_hmac('sha512', '^'.$hashData.'^', hex2bin($signatureKey));
144+
$hash = hash_hmac('sha512', '^' . $hashData . '^', hex2bin($signatureKey));
144145
$hash = strtoupper($hash);
145146

146147
return $hash;
@@ -154,11 +155,14 @@ public function getSha512Hash($httpRequest)
154155
*/
155156
public function getPostedHash($httpRequest)
156157
{
157-
if (empty($httpRequest)) return null;
158+
if (empty($httpRequest)){
159+
return null;
160+
}
158161

159-
if($signatureKey = $this->getSignatureKey()){
162+
if ($signatureKey = $this->getSignatureKey()) {
160163
return strtoupper($httpRequest->request->get('x_SHA2_Hash'));
161164
}
165+
162166
return strtolower($httpRequest->request->get('x_MD5_Hash'));
163167
}
164168

0 commit comments

Comments
 (0)