Skip to content

Commit 48de326

Browse files
Clean code
1 parent aa58a2d commit 48de326

File tree

8 files changed

+15
-16
lines changed

8 files changed

+15
-16
lines changed

src/Message/AbstractResponse.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Omnipay\Common\Message\AbstractResponse as BaseAbstractResponse;
1111

1212
/**
13+
* @method AbstractRequest getRequest()
14+
*
1315
* @author Vuong Minh <vuongxuongminh@gmail.com>
1416
* @since 1.0.0
1517
*/

src/Message/Concerns/RequestHash.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ trait RequestHash
2424
protected function generateHash(): string
2525
{
2626
$data = [];
27-
$rsa = new RSAEncrypt($this->getParameter('publicKey'));
27+
$rsa = new RSAEncrypt(
28+
$this->getPublicKey()
29+
);
2830
$parameters = $this->getParameters();
2931

3032
foreach ($this->getHashParameters() as $pos => $parameter) {

src/Message/Concerns/RequestSignature.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ trait RequestSignature
2424
protected function generateSignature(): string
2525
{
2626
$data = [];
27-
$signature = new Signature($this->getParameter('secretKey'));
27+
$signature = new Signature(
28+
$this->getSecretKey()
29+
);
2830
$parameters = $this->getParameters();
2931

3032
foreach ($this->getSignatureParameters() as $pos => $parameter) {

src/Message/Concerns/ResponseSignatureValidation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ trait ResponseSignatureValidation
2525
protected function validateSignature(): void
2626
{
2727
$data = [];
28-
$requestParameters = $this->getRequest()->getParameters();
29-
$signature = new Signature($requestParameters['secretKey']);
28+
$signature = new Signature(
29+
$this->getRequest()->getSecretKey()
30+
);
3031

3132
foreach ($this->getSignatureParameters() as $pos => $parameter) {
3233
if (! is_string($pos)) {

tests/AllInOne/Message/PurchaseResponseTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public function testPurchaseSuccess()
3030
{
3131
$httpResponse = $this->getMockHttpResponse('PurchaseSuccess.txt');
3232
$request = $this->getMockRequest();
33-
$request->shouldReceive('getParameters')->once()->andReturn([
34-
'secretKey' => 'fj00YKnJhmYqahaFWUgkg75saNTzMrbO',
35-
]);
33+
$request->shouldReceive('getSecretKey')->once()->andReturn('fj00YKnJhmYqahaFWUgkg75saNTzMrbO');
3634
$response = new PurchaseResponse(
3735
$request,
3836
json_decode($httpResponse->getBody()->getContents(), true)

tests/AppInApp/Message/PurchaseResponseTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public function testResponse()
3030
{
3131
$httpResponse = $this->getMockHttpResponse('PurchaseSuccess.txt');
3232
$request = $this->getMockRequest();
33-
$request->shouldReceive('getParameters')->once()->andReturn([
34-
'secretKey' => 'fj00YKnJhmYqahaFWUgkg75saNTzMrbO',
35-
]);
33+
$request->shouldReceive('getSecretKey')->once()->andReturn('fj00YKnJhmYqahaFWUgkg75saNTzMrbO');
3634
$response = new PurchaseResponse(
3735
$request,
3836
json_decode($httpResponse->getBody()->getContents(), true)

tests/Message/PayConfirmResponseTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public function testResponse()
3030
{
3131
$httpResponse = $this->getMockHttpResponse('PayConfirmResponse.txt');
3232
$request = $this->getMockRequest();
33-
$request->shouldReceive('getParameters')->once()->andReturn([
34-
'secretKey' => 'fj00YKnJhmYqahaFWUgkg75saNTzMrbO',
35-
]);
33+
$request->shouldReceive('getSecretKey')->once()->andReturn('fj00YKnJhmYqahaFWUgkg75saNTzMrbO');
3634
$response = new PayConfirmResponse(
3735
$request,
3836
json_decode($httpResponse->getBody()->getContents(), true)

tests/QRCode/Message/NotificationResponseTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public function testConstruct()
2929
public function testResponse()
3030
{
3131
$request = $this->getMockRequest();
32-
$request->shouldReceive('getParameters')->once()->andReturn([
33-
'secretKey' => 'fj00YKnJhmYqahaFWUgkg75saNTzMrbO',
34-
]);
32+
$request->shouldReceive('getSecretKey')->once()->andReturn('fj00YKnJhmYqahaFWUgkg75saNTzMrbO');
3533
$response = new NotificationResponse(
3634
$request,
3735
[

0 commit comments

Comments
 (0)