Skip to content

Commit 1113512

Browse files
committed
fix
1 parent f58707c commit 1113512

File tree

5 files changed

+9
-18
lines changed

5 files changed

+9
-18
lines changed

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/AcceptNotificationRequest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Omnipay\Gomypay\Message;
44

55
use Omnipay\Common\Exception\InvalidRequestException;
6-
use Omnipay\Common\Exception\InvalidResponseException;
76
use Omnipay\Common\Message\NotificationInterface;
87
use Omnipay\Gomypay\Traits\HasGomypay;
98

@@ -18,14 +17,12 @@ public function getData()
1817

1918
/**
2019
* @throws InvalidRequestException
21-
* @throws InvalidResponseException
2220
*/
2321
public function sendData($data)
2422
{
2523
$data = array_merge(['Amount' => (int) $this->getAmount()], $data);
26-
27-
if (! hash_equals($this->makeHash($data), $data['str_check'])) {
28-
throw new InvalidResponseException('Invalid hash');
24+
if (! hash_equals($this->makeHash($data), $data['str_check'] ?: '')) {
25+
throw new InvalidRequestException('Incorrect hash');
2926
}
3027

3128
return $this->response = new AcceptNotificationResponse($this, $data);

src/Message/CompletePurchaseRequest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Omnipay\Gomypay\Message;
44

55
use Omnipay\Common\Exception\InvalidRequestException;
6-
use Omnipay\Common\Exception\InvalidResponseException;
76
use Omnipay\Gomypay\Traits\HasGomypay;
87

98
class CompletePurchaseRequest extends AbstractRequest
@@ -17,18 +16,17 @@ public function getData()
1716

1817
/**
1918
* @throws InvalidRequestException
20-
* @throws InvalidResponseException
2119
*/
2220
public function sendData($data)
2321
{
2422
$data = array_merge(['Amount' => (int) $this->getAmount()], $data);
2523

2624
if (! array_key_exists('e_orderno', $data)) {
27-
throw new InvalidResponseException($data['ret_msg']);
25+
throw new InvalidRequestException($data['ret_msg']);
2826
}
2927

30-
if (! hash_equals($this->makeHash($data), $data['str_check'])) {
31-
throw new InvalidResponseException('Invalid hash');
28+
if (! hash_equals($this->makeHash($data), $data['str_check'] ?: '')) {
29+
throw new InvalidRequestException('Invalid hash');
3230
}
3331

3432
return $this->response = new CompletePurchaseResponse($this, $data);

src/Message/GetPaymentInfoRequest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Omnipay\Gomypay\Message;
44

55
use Omnipay\Common\Exception\InvalidRequestException;
6-
use Omnipay\Common\Exception\InvalidResponseException;
76
use Omnipay\Gomypay\Traits\HasGomypay;
87

98
class GetPaymentInfoRequest extends AbstractRequest
@@ -17,14 +16,12 @@ public function getData()
1716

1817
/**
1918
* @throws InvalidRequestException
20-
* @throws InvalidResponseException
2119
*/
2220
public function sendData($data)
2321
{
2422
$data = array_merge(['Amount' => (int) $this->getAmount()], $data);
25-
26-
if (! hash_equals($this->makeHash($data), $data['str_check'])) {
27-
throw new InvalidResponseException('Invalid hash');
23+
if (! hash_equals($this->makeHash($data), $data['str_check'] ?: '')) {
24+
throw new InvalidRequestException('Invalid hash');
2825
}
2926

3027
return $this->response = new GetPaymentInfoResponse($this, $data);

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\Gomypay\Tests\Message;
44

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

@@ -71,7 +71,7 @@ public function testGetUnionPayData()
7171

7272
public function testInvalidResponse()
7373
{
74-
$this->expectException(InvalidResponseException::class);
74+
$this->expectException(InvalidRequestException::class);
7575
$this->expectExceptionMessage('此特店未啟用信用卡交易功能');
7676
$this->getHttpRequest()->query->replace([
7777
'result' => '0',

0 commit comments

Comments
 (0)