Skip to content

Commit b7c2d1a

Browse files
committed
fix
1 parent f2eb8bc commit b7c2d1a

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

src/Message/CompletePurchaseRequest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Omnipay\MyCash\Message;
44

5+
use Omnipay\Common\Exception\InvalidRequestException;
56
use Omnipay\Common\Exception\InvalidResponseException;
67
use Omnipay\Common\Message\AbstractRequest;
78
use Omnipay\MyCash\Traits\HasMyCash;
@@ -13,15 +14,13 @@ class CompletePurchaseRequest extends AbstractRequest
1314
/**
1415
* @return array
1516
*
16-
* @throws InvalidResponseException
17+
* @throws InvalidRequestException
1718
*/
1819
public function getData()
1920
{
2021
$data = $this->httpRequest->request->all();
21-
$validate = $data['Validate'];
22-
23-
if ($this->makeHash($data) !== $validate) {
24-
throw new InvalidResponseException('Incorrect hash');
22+
if (! hash_equals($this->makeHash($data), $data['Validate'])) {
23+
throw new InvalidRequestException('Incorrect hash');
2524
}
2625

2726
return $data;

src/Message/GetPaymentInfoRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Omnipay\MyCash\Message;
44

5+
use Omnipay\Common\Exception\InvalidRequestException;
56
use Omnipay\Common\Exception\InvalidResponseException;
67
use Omnipay\Common\Message\AbstractRequest;
78
use Omnipay\MyCash\Traits\HasMyCash;
@@ -13,14 +14,13 @@ class GetPaymentInfoRequest extends AbstractRequest
1314
/**
1415
* @return array
1516
*
16-
* @throws InvalidResponseException
17+
* @throws InvalidRequestException
1718
*/
1819
public function getData()
1920
{
2021
$data = $this->httpRequest->request->all();
21-
22-
if (! hash_equals($this->httpRequest->request->get('Validate'), $this->makeHash($data))) {
23-
throw new InvalidResponseException('Incorrect hash');
22+
if (! hash_equals($this->makeHash($data), $this->httpRequest->request->get('Validate'))) {
23+
throw new InvalidRequestException('Incorrect hash');
2424
}
2525

2626
return $data;

tests/Message/AcceptNotificationRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Omnipay\MyCash\Tests\Message;
44

5-
use Omnipay\Common\Exception\InvalidResponseException;
5+
use Omnipay\Common\Exception\InvalidRequestException;
66
use Omnipay\Common\Message\NotificationInterface;
77
use Omnipay\MyCash\Message\AcceptNotificationRequest;
88
use Omnipay\MyCash\Message\CompletePurchaseRequest;
@@ -18,7 +18,7 @@ class AcceptNotificationRequestTest extends TestCase
1818

1919
public function testValidateFails(): void
2020
{
21-
$this->expectException(InvalidResponseException::class);
21+
$this->expectException(InvalidRequestException::class);
2222

2323
$options = [
2424
'RtnCode' => '1',

tests/Message/CompletePurchaseRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Omnipay\MyCash\Tests\Message;
44

5-
use Omnipay\Common\Exception\InvalidResponseException;
5+
use Omnipay\Common\Exception\InvalidRequestException;
66
use Omnipay\MyCash\Message\CompletePurchaseRequest;
77
use Omnipay\Tests\TestCase;
88

@@ -16,7 +16,7 @@ class CompletePurchaseRequestTest extends TestCase
1616

1717
public function testValidateFails(): void
1818
{
19-
$this->expectException(InvalidResponseException::class);
19+
$this->expectException(InvalidRequestException::class);
2020
$this->expectExceptionMessage('Incorrect hash');
2121

2222
$options = [

0 commit comments

Comments
 (0)