Skip to content

Commit

Permalink
Merge pull request #19 from yii-cms/fix
Browse files Browse the repository at this point in the history
fix user params
  • Loading branch information
gonimar authored Jul 2, 2019
2 parents 6fb7deb + e99126a commit b7f02c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Merchant.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function payment($nOutSum, $nInvId, $sInvDesc = null, $sIncCurrLabel = nu
{
$url = $this->baseUrl;

$sSignatureValue = $this->generateSignature($nOutSum, $nInvId);
$sSignatureValue = $this->generateSignature($nOutSum, $nInvId, $shp);

$url .= '?' . http_build_query([
'MrchLogin' => $this->sMerchantLogin,
Expand Down Expand Up @@ -80,7 +80,7 @@ private function implodeShp($shp)
return implode(':', $shp);
}

private function generateSignature($nOutSum, $nInvId)
private function generateSignature($nOutSum, $nInvId, $shp = [])
{
if ($nInvId === null) {
// MerchantLogin:OutSum:Пароль#1
Expand All @@ -90,6 +90,10 @@ private function generateSignature($nOutSum, $nInvId)
$signature = "{$this->sMerchantLogin}:{$nOutSum}:{$nInvId}:{$this->sMerchantPass1}";
}

if (!empty($shp)) {
$signature .= ':' . $this->implodeShp($shp);
}

return strtolower($this->encryptSignature($signature));
}

Expand Down
4 changes: 3 additions & 1 deletion tests/unit/MerchantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ public function testRedirectUrlUserParams()
'shp_login' => 'user1',
];

$signatureHash = md5('demo:100:1:password_1:shp_id=1:shp_login=user1');

$returnUrl = $merchant->payment(100, 1, 'Description', null, null, 'en', $userParams, true);

$this->assertEquals("https://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin=demo&OutSum=100&InvId=1&Desc=Description&SignatureValue=8a50b8d86ed28921edfc371cff6e156f&Culture=en&IsTest=1&shp_id=1&shp_login=user1", $returnUrl);
$this->assertEquals("https://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin=demo&OutSum=100&InvId=1&Desc=Description&SignatureValue={$signatureHash}&Culture=en&IsTest=1&shp_id=1&shp_login=user1", $returnUrl);
}

public function testResponseRedirect()
Expand Down

0 comments on commit b7f02c5

Please sign in to comment.