Skip to content

Commit 0c07b0f

Browse files
committed
2 parents 690385a + 96afb0d commit 0c07b0f

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

Controller/Payment/AbstractPaystackStandard.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ abstract class AbstractPaystackStandard extends \Magento\Framework\App\Action\Ac
6666
* @var \Psr\Log\LoggerInterface
6767
*/
6868
protected $logger;
69+
70+
/**
71+
*
72+
* @var \Magento\Framework\App\Request\Http
73+
*/
74+
protected $request;
6975

7076
/**
7177
* Constructor
@@ -83,6 +89,7 @@ public function __construct(
8389
\Magento\Framework\Message\ManagerInterface $messageManager,
8490
\Pstk\Paystack\Model\Ui\ConfigProvider $configProvider,
8591
\Magento\Framework\Event\Manager $eventManager,
92+
\Magento\Framework\App\Request\Http $request,
8693
\Psr\Log\LoggerInterface $logger
8794
) {
8895
$this->resultPageFactory = $resultPageFactory;
@@ -93,6 +100,7 @@ public function __construct(
93100
$this->messageManager = $messageManager;
94101
$this->configProvider = $configProvider;
95102
$this->eventManager = $eventManager;
103+
$this->request = $request;
96104
$this->logger = $logger;
97105

98106
$this->paystack = $this->initPaystackPHP();

Controller/Payment/Callback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Callback extends AbstractPaystackStandard {
3131
*/
3232
public function execute() {
3333

34-
$reference = isset($_GET['reference']) ? $_GET['reference'] : '';
34+
$reference = $this->request->get('reference');
3535
$message = "";
3636

3737
if (!$reference) {

Controller/Payment/Webhook.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public function execute() {
3333
// Retrieve the request's body and parse it as JSON
3434
$event = \Yabacon\Paystack\Event::capture();
3535
http_response_code(200);
36+
37+
$resultFactory = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
3638

3739
/* It is a important to log all events received. Add code *
3840
* here to log the signature and body to db or file */
@@ -44,7 +46,8 @@ public function execute() {
4446

4547
if (!$owner) {
4648
// None of the keys matched the event's signature
47-
die("auth failed");
49+
$resultFactory->setContents("auth failed");
50+
return $resultFactory;
4851
}
4952

5053
// Do something with $event->obj
@@ -81,20 +84,23 @@ public function execute() {
8184
$this->eventManager->dispatch('paystack_payment_verify_after', [
8285
"paystack_order" => $order,
8386
]);
84-
die("success");
87+
88+
$resultFactory->setContents("success");
89+
return $resultFactory;
8590
}
8691
}
8792
break;
8893
}
8994

90-
die("failed");
95+
$resultFactory->setContents("failed");
96+
return $resultFactory;
9197
}
9298

93-
public function createCsrfValidationException(\Magento\Framework\App\RequestInterface $request): ?\Magento\Framework\App\Request\InvalidRequestException {
99+
public function createCsrfValidationException(\Magento\Framework\App\RequestInterface $request) {
94100
return null;
95101
}
96102

97-
public function validateForCsrf(\Magento\Framework\App\RequestInterface $request): ?bool {
103+
public function validateForCsrf(\Magento\Framework\App\RequestInterface $request) {
98104
return true;
99105
}
100106

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "pstk/paystack-magento2-module",
33
"description": "Paystack Magento2 Module using \\Magento\\Payment\\Model\\Method\\AbstractMethod",
4+
"version": "2.3.0",
45
"require": {
56
"yabacon/paystack-php": "2.*"
67
},

0 commit comments

Comments
 (0)