Skip to content

Commit

Permalink
Merge pull request #9 from 7u7u/master
Browse files Browse the repository at this point in the history
Add more encryption algorithms
  • Loading branch information
gonimar authored Dec 5, 2017
2 parents cea1c73 + 3dcf908 commit 8785073
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Merchant.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Merchant extends Object
public $isTest = false;

public $baseUrl = 'https://auth.robokassa.ru/Merchant/Index.aspx';

public $hashAlgo = 'md5';

public function payment($nOutSum, $nInvId, $sInvDesc = null, $sIncCurrLabel=null, $sEmail = null, $sCulture = null, $shp = [], $returnLink = false)
{
Expand All @@ -24,7 +26,7 @@ public function payment($nOutSum, $nInvId, $sInvDesc = null, $sIncCurrLabel=null
if (!empty($shp)) {
$signature .= ':' . $this->implodeShp($shp);
}
$sSignatureValue = md5($signature);
$sSignatureValue = $this->encryptSignature($signature);

$url .= '?' . http_build_query([
'MrchLogin' => $this->sMerchantLogin,
Expand Down Expand Up @@ -66,7 +68,12 @@ public function checkSignature($sSignatureValue, $nOutSum, $nInvId, $sMerchantP
if (!empty($shp)) {
$signature .= ':' . $this->implodeShp($shp);
}
return strtolower(md5($signature)) === strtolower($sSignatureValue);
return strtolower($this->encryptSignature($signature)) === strtolower($sSignatureValue);

}

private function encryptSignature($signature)
{
return hash($this->hashAlgo, $signature);
}
}

0 comments on commit 8785073

Please sign in to comment.