Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions Block/Adminhtml/System/Config/Form/Field/UpaWebhookSetting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Omise\Payment\Block\Adminhtml\System\Config\Form\Field;

use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Store\Model\ScopeInterface;

class UpaWebhookSetting extends Field
{
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @param Context $context
* @param ScopeConfigInterface $scopeConfig
* @param array $data
*/
public function __construct(
Context $context,
ScopeConfigInterface $scopeConfig,
array $data = []
) {
$this->scopeConfig = $scopeConfig;
parent::__construct($context, $data);
}

/**
* @param AbstractElement $element
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
{
$request = $this->getRequest();
$website = $request->getParam('website');
$store = $request->getParam('store');

if ($store) {
$scope = ScopeInterface::SCOPE_STORE;
$scopeId = $store;
} elseif ($website) {
$scope = ScopeInterface::SCOPE_WEBSITE;
$scopeId = $website;
} else {
$scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
$scopeId = null;
}

if ($this->scopeConfig->isSetFlag('payment/omise/is_upa_feature_flag_enabled', $scope, $scopeId)) {
$element->setValue('1');
$element->setDisabled(true);
$html = parent::_getElementHtml($element)
. '<input type="hidden" name="' . $element->getName() . '" value="1" />';
} else {
$html = parent::_getElementHtml($element);
}

return '<div data-mage-init="{&quot;Omise_Payment/js/upa-webhook-setting&quot;:{}}">'
. $html . '</div>';
}
}
Loading
Loading