Skip to content

Commit 986a3c7

Browse files
Clean code AllInOne gateway.
1 parent 97b3bb2 commit 986a3c7

File tree

7 files changed

+22
-23
lines changed

7 files changed

+22
-23
lines changed

src/Message/AbstractResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ abstract class AbstractResponse extends BaseAbstractResponse
1919
* Phương thức hổ trợ tạo các thuộc tính của đối tượng từ dữ liệu gửi về từ MoMo.
2020
*
2121
* @param string $name
22-
* @return |null
22+
* @return null|string
2323
*/
2424
public function __get($name)
2525
{

src/Message/AllInOne/AbstractIncomingRequest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@
1616
abstract class AbstractIncomingRequest extends BaseAbstractIncomingRequest
1717
{
1818
use Concerns\IncomingRequestParameters;
19+
20+
/**
21+
* {@inheritdoc}
22+
* @throws \Omnipay\Common\Exception\InvalidResponseException
23+
*/
24+
public function sendData($data): IncomingResponse
25+
{
26+
return $this->response = new IncomingResponse($this, $data);
27+
}
1928
}

src/Message/AllInOne/CompletePurchaseRequest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,4 @@ protected function getIncomingParametersBag(): ParameterBag
2222
{
2323
return $this->httpRequest->query;
2424
}
25-
26-
/**
27-
* {@inheritdoc}
28-
* @throws \Omnipay\Common\Exception\InvalidResponseException
29-
*/
30-
public function sendData($data): IncomingResponse
31-
{
32-
return $this->response = new IncomingResponse($this, $data);
33-
}
3425
}

src/Message/AllInOne/IncomingResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class IncomingResponse extends Response
1616
/**
1717
* {@inheritdoc}
1818
*/
19-
protected function getSignatureParameters(string $requestType): array
19+
protected function getSignatureParameters(): array
2020
{
2121
return [
2222
'partnerCode', 'accessKey', 'requestId', 'amount', 'orderId', 'orderInfo', 'orderType',

src/Message/AllInOne/NotificationRequest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,4 @@ protected function getIncomingParametersBag(): ParameterBag
2525

2626
return new ParameterBag($data);
2727
}
28-
29-
/**
30-
* {@inheritdoc}
31-
* @throws \Omnipay\Common\Exception\InvalidResponseException
32-
*/
33-
public function sendData($data): IncomingResponse
34-
{
35-
return $this->response = new IncomingResponse($this, $data);
36-
}
3728
}

src/Message/AllInOne/PurchaseResponse.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@
1515
*/
1616
class PurchaseResponse extends Response implements RedirectResponseInterface
1717
{
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
public function isSuccessful(): bool
22+
{
23+
return false;
24+
}
25+
1826
/**
1927
* {@inheritdoc}
2028
*/
2129
public function isRedirect(): bool
2230
{
23-
return $this->isSuccessful();
31+
return parent::isSuccessful();
2432
}
2533

2634
/**

src/Message/AllInOne/Response.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(RequestInterface $request, $data)
2929
{
3030
parent::__construct($request, $data);
3131

32-
if ($this->isSuccessful()) {
32+
if ('0' === $this->getCode()) {
3333
$this->validateSignature();
3434
}
3535
}
@@ -41,7 +41,7 @@ public function __construct(RequestInterface $request, $data)
4141
*/
4242
public function isSuccessful(): bool
4343
{
44-
return '0' === $this->getCode() ;
44+
return '0' === $this->getCode();
4545
}
4646

4747
/**

0 commit comments

Comments
 (0)