Skip to content

Commit c18bc11

Browse files
MFTF Vendor Supplied test passed
1 parent bf21195 commit c18bc11

6 files changed

Lines changed: 379 additions & 37 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ composer.phar
1616
# Environment
1717
.env
1818
dev/.env
19+
docs/

Block/System/Config/Form/Field/Webhook.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,13 @@
2323
namespace Pstk\Paystack\Block\System\Config\Form\Field;
2424

2525
use Magento\Framework\Data\Form\Element\AbstractElement;
26-
use Magento\Store\Model\Store as Store;
2726

2827
/**
29-
* Backend system config datetime field renderer
30-
*
31-
* @api
32-
* @since 100.0.2
28+
* Backend system config field renderer for displaying the Paystack webhook URL.
3329
*/
3430
class Webhook extends \Magento\Config\Block\System\Config\Form\Field
3531
{
3632

37-
/**
38-
* @param \Magento\Backend\Block\Template\Context $context
39-
* @param Store $store
40-
* @param array $data
41-
*/
42-
public function __construct(
43-
\Magento\Backend\Block\Template\Context $context,
44-
Store $store,
45-
array $data = []
46-
) {
47-
$this->store = $store;
48-
49-
parent::__construct($context, $data);
50-
}
51-
5233
/**
5334
* Returns element html
5435
*
@@ -57,10 +38,15 @@ public function __construct(
5738
*/
5839
protected function _getElementHtml(AbstractElement $element)
5940
{
60-
$webhookUrl = $this->store->getBaseUrl() . 'paystack/payment/webhook';
41+
try {
42+
$webhookUrl = $this->_storeManager->getStore()->getBaseUrl() . 'paystack/payment/webhook';
43+
} catch (\Exception $e) {
44+
$webhookUrl = '{{store_base_url}}paystack/payment/webhook';
45+
}
46+
6147
$value = "You may login to <a target=\"_blank\" href=\"https://dashboard.paystack.co/#/settings/developer\">Paystack Developer Settings</a> to update your Webhook URL to:<br><br>"
6248
. "<strong style='color:red;'>$webhookUrl</strong>";
63-
49+
6450
$element->setValue($webhookUrl);
6551

6652
return $value;

0 commit comments

Comments
 (0)