diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index 715e1bc..8d213b5 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -47,9 +47,9 @@ protected function guardParameters() ); } - protected function createSignatureFromString($fullStringToHash) + protected function createSignatureFromString($fullStringToHash, $merchantKey) { - return hash('sha256', $fullStringToHash); + return hash_hmac('sha512', $fullStringToHash, $merchantKey); } // private function hex2bin($hexSource) diff --git a/src/Message/CompletePurchaseRequest.php b/src/Message/CompletePurchaseRequest.php index 5808109..30e12d6 100644 --- a/src/Message/CompletePurchaseRequest.php +++ b/src/Message/CompletePurchaseRequest.php @@ -45,6 +45,6 @@ protected function signature($merchantKey, $merchantCode, $paymentId, $refNo, $a $paramsInArray = [$merchantKey, $merchantCode, $paymentId, $refNo, $amount, $currency, $status]; - return $this->createSignatureFromString(implode('', $paramsInArray)); + return $this->createSignatureFromString(implode('', $paramsInArray), $merchantKey); } } diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 5c9f869..d99fdfd 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -20,7 +20,7 @@ public function getData() 'UserContact' => $this->getCard()->getNumber(), 'Remark' => '', 'Lang' => '', - 'SignatureType' => 'SHA256', + 'SignatureType' => 'HMAC-SHA512', 'Signature' => $this->signature( $this->getMerchantKey(), $this->getMerchantCode(), @@ -44,7 +44,6 @@ private function signature($merchantKey, $merchantCode, $refNo, $amount, $curren $paramsInArray = [$merchantKey, $merchantCode, $refNo, $amount, $currency]; - return $this->createSignatureFromString(implode('', $paramsInArray)); + return $this->createSignatureFromString(implode('', $paramsInArray), $merchantKey); } - }