I am integrating a custom payment module. I need to get the API keys in my controller. If possible in JS file also.
My Controller where I need to get the config values.
<?php
namespace vendorName\moduleName\Controller\Index;
class GetPrice extends \Magento\Framework\App\Action\Action
{
protected $customHelper;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Vendor\Module\Helper\Data $customHelper
) {
$this->customHelper = $customHelper;
parent::__construct($context);
}
public function execute(){
echo $this->customHelper->getConfig("payment/title/cmc_api_key");
}
}
system.xml
<section id="payment" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="1000" translate="label">
<group id="mypay" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
<label>MyPay</label>
<field id="title" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="20" translate="label" type="text">
<label>Title</label>
</field>
Thanks In Advance.

system.xmlwhich is used to create a configuration field. – Ranganathan Nov 14 '19 at 10:20