File tree Expand file tree Collapse file tree 5 files changed +9
-18
lines changed Expand file tree Collapse file tree 5 files changed +9
-18
lines changed Original file line number Diff line number Diff line change 18
18
"omnipay/common" : " ^3.0"
19
19
},
20
20
"require-dev" : {
21
- "roave/security-advisories" : " dev-latest" ,
22
21
"omnipay/tests" : " ^3.0|^4.0" ,
23
22
"squizlabs/php_codesniffer" : " ^3"
24
23
},
Original file line number Diff line number Diff line change 3
3
namespace Omnipay \Gomypay \Message ;
4
4
5
5
use Omnipay \Common \Exception \InvalidRequestException ;
6
- use Omnipay \Common \Exception \InvalidResponseException ;
7
6
use Omnipay \Common \Message \NotificationInterface ;
8
7
use Omnipay \Gomypay \Traits \HasGomypay ;
9
8
@@ -18,14 +17,12 @@ public function getData()
18
17
19
18
/**
20
19
* @throws InvalidRequestException
21
- * @throws InvalidResponseException
22
20
*/
23
21
public function sendData ($ data )
24
22
{
25
23
$ 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 ' );
29
26
}
30
27
31
28
return $ this ->response = new AcceptNotificationResponse ($ this , $ data );
Original file line number Diff line number Diff line change 3
3
namespace Omnipay \Gomypay \Message ;
4
4
5
5
use Omnipay \Common \Exception \InvalidRequestException ;
6
- use Omnipay \Common \Exception \InvalidResponseException ;
7
6
use Omnipay \Gomypay \Traits \HasGomypay ;
8
7
9
8
class CompletePurchaseRequest extends AbstractRequest
@@ -17,18 +16,17 @@ public function getData()
17
16
18
17
/**
19
18
* @throws InvalidRequestException
20
- * @throws InvalidResponseException
21
19
*/
22
20
public function sendData ($ data )
23
21
{
24
22
$ data = array_merge (['Amount ' => (int ) $ this ->getAmount ()], $ data );
25
23
26
24
if (! array_key_exists ('e_orderno ' , $ data )) {
27
- throw new InvalidResponseException ($ data ['ret_msg ' ]);
25
+ throw new InvalidRequestException ($ data ['ret_msg ' ]);
28
26
}
29
27
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 ' );
32
30
}
33
31
34
32
return $ this ->response = new CompletePurchaseResponse ($ this , $ data );
Original file line number Diff line number Diff line change 3
3
namespace Omnipay \Gomypay \Message ;
4
4
5
5
use Omnipay \Common \Exception \InvalidRequestException ;
6
- use Omnipay \Common \Exception \InvalidResponseException ;
7
6
use Omnipay \Gomypay \Traits \HasGomypay ;
8
7
9
8
class GetPaymentInfoRequest extends AbstractRequest
@@ -17,14 +16,12 @@ public function getData()
17
16
18
17
/**
19
18
* @throws InvalidRequestException
20
- * @throws InvalidResponseException
21
19
*/
22
20
public function sendData ($ data )
23
21
{
24
22
$ 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 ' );
28
25
}
29
26
30
27
return $ this ->response = new GetPaymentInfoResponse ($ this , $ data );
Original file line number Diff line number Diff line change 2
2
3
3
namespace Omnipay \Gomypay \Tests \Message ;
4
4
5
- use Omnipay \Common \Exception \InvalidResponseException ;
5
+ use Omnipay \Common \Exception \InvalidRequestException ;
6
6
use Omnipay \Gomypay \Message \CompletePurchaseRequest ;
7
7
use Omnipay \Tests \TestCase ;
8
8
@@ -71,7 +71,7 @@ public function testGetUnionPayData()
71
71
72
72
public function testInvalidResponse ()
73
73
{
74
- $ this ->expectException (InvalidResponseException ::class);
74
+ $ this ->expectException (InvalidRequestException ::class);
75
75
$ this ->expectExceptionMessage ('此特店未啟用信用卡交易功能 ' );
76
76
$ this ->getHttpRequest ()->query ->replace ([
77
77
'result ' => '0 ' ,
You can’t perform that action at this time.
0 commit comments