Skip to content

Commit c5a92ca

Browse files
committed
fix
1 parent f2eb8bc commit c5a92ca

File tree

6 files changed

+14
-18
lines changed

6 files changed

+14
-18
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: true
1111
matrix:
12-
php: [ '7.1','7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
12+
php: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
1313

1414
name: PHP ${{ matrix.php }}
1515

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"omnipay/common": "^3.0"
1919
},
2020
"require-dev": {
21-
"roave/security-advisories": "dev-latest",
2221
"omnipay/tests": "^3.0|^4.0",
2322
"squizlabs/php_codesniffer": "^3"
2423
},

src/Message/CompletePurchaseRequest.php

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

33
namespace Omnipay\MyCash\Message;
44

5-
use Omnipay\Common\Exception\InvalidResponseException;
5+
use Omnipay\Common\Exception\InvalidRequestException;
66
use Omnipay\Common\Message\AbstractRequest;
77
use Omnipay\MyCash\Traits\HasMyCash;
88

@@ -13,18 +13,16 @@ class CompletePurchaseRequest extends AbstractRequest
1313
/**
1414
* @return array
1515
*
16-
* @throws InvalidResponseException
16+
* @throws InvalidRequestException
1717
*/
1818
public function getData()
1919
{
2020
$data = $this->httpRequest->request->all();
21-
$validate = $data['Validate'];
22-
23-
if ($this->makeHash($data) !== $validate) {
24-
throw new InvalidResponseException('Incorrect hash');
21+
if (! hash_equals($this->makeHash($data), $this->httpRequest->request->get('Validate', ''))) {
22+
throw new InvalidRequestException('Incorrect hash');
2523
}
2624

27-
return $data;
25+
return $this->httpRequest->request->all();
2826
}
2927

3028
/**

src/Message/GetPaymentInfoRequest.php

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

33
namespace Omnipay\MyCash\Message;
44

5-
use Omnipay\Common\Exception\InvalidResponseException;
5+
use Omnipay\Common\Exception\InvalidRequestException;
66
use Omnipay\Common\Message\AbstractRequest;
77
use Omnipay\MyCash\Traits\HasMyCash;
88

@@ -13,14 +13,13 @@ class GetPaymentInfoRequest extends AbstractRequest
1313
/**
1414
* @return array
1515
*
16-
* @throws InvalidResponseException
16+
* @throws InvalidRequestException
1717
*/
1818
public function getData()
1919
{
2020
$data = $this->httpRequest->request->all();
21-
22-
if (! hash_equals($this->httpRequest->request->get('Validate'), $this->makeHash($data))) {
23-
throw new InvalidResponseException('Incorrect hash');
21+
if (! hash_equals($this->makeHash($data), $this->httpRequest->request->get('Validate', ''))) {
22+
throw new InvalidRequestException('Incorrect hash');
2423
}
2524

2625
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)