-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c6b5ec
commit ec7df9a
Showing
13 changed files
with
242 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Fintecture\Payment\Controller\Adminhtml\Settings; | ||
|
||
use Fintecture\Payment\Gateway\Client; | ||
use Fintecture\Payment\Helper\Fintecture as FintectureHelper; | ||
use Fintecture\Payment\Logger\Logger as FintectureLogger; | ||
use Fintecture\Payment\Model\Environment; | ||
use Fintecture\Payment\Model\Fintecture; | ||
use Magento\Backend\App\Action; | ||
use Magento\Backend\App\Action\Context; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Framework\App\Request\Http; | ||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Framework\Data\Form\FormKey\Validator; | ||
use Magento\Framework\Exception\LocalizedException; | ||
|
||
class ConnectionTest extends Action | ||
{ | ||
public const CONFIG_PREFIX = 'payment/fintecture/'; | ||
protected $fintectureModel; | ||
protected $jsonResultFactory; | ||
protected $scopeConfig; | ||
protected $environment = Environment::ENVIRONMENT_PRODUCTION; | ||
|
||
/** @var FintectureHelper */ | ||
protected $fintectureHelper; | ||
|
||
/** @var FintectureLogger */ | ||
protected $fintectureLogger; | ||
|
||
/** @var Validator*/ | ||
protected $formKeyValidator; | ||
|
||
public function __construct( | ||
Context $context, | ||
Fintecture $fintectureModel, | ||
JsonFactory $jsonResultFactory, | ||
ScopeConfigInterface $scopeConfig, | ||
FintectureHelper $fintectureHelper, | ||
FintectureLogger $fintectureLogger, | ||
Validator $formKeyValidator | ||
) { | ||
parent::__construct($context); | ||
$this->fintectureModel = $fintectureModel; | ||
$this->jsonResultFactory = $jsonResultFactory; | ||
$this->scopeConfig = $scopeConfig; | ||
$this->fintectureHelper = $fintectureHelper; | ||
$this->fintectureLogger = $fintectureLogger; | ||
$this->formKeyValidator = $formKeyValidator; | ||
} | ||
|
||
public function execute() | ||
{ | ||
/** @var Http $request */ | ||
$request = $this->getRequest(); | ||
if (!$request->isPost() || !$request->isAjax() || !$this->formKeyValidator->validate($request)) { | ||
throw new LocalizedException(__('Invalid request')); | ||
} | ||
|
||
$scope = $request->getParam('scope'); | ||
$scopeId = (int) $request->getParam('scopeId'); | ||
$fintectureConnectParameters = $request->getParams(); | ||
$environment = $fintectureConnectParameters['fintectureEnv'] ?? Environment::ENVIRONMENT_PRODUCTION; | ||
|
||
$fintectureAppId = $fintectureConnectParameters['fintectureAppId'] ?? ''; | ||
$fintectureAppSecret = $fintectureConnectParameters['fintectureAppSecret'] ?? ''; | ||
$fintecturePrivateKey = $fintectureConnectParameters['fintecturePrivateKey'] ?? ''; | ||
|
||
// Handle already saved app secret | ||
if ($fintectureAppSecret === '******') { | ||
$fintectureAppSecret = $this->fintectureModel->getAppSecret($environment, $scope, $scopeId); | ||
} | ||
|
||
// Handle already saved private key | ||
if ($fintecturePrivateKey === '') { | ||
$fintecturePrivateKey = $this->fintectureModel->getAppPrivateKey($environment, $scope, $scopeId); | ||
if (!$fintecturePrivateKey) { | ||
throw new LocalizedException(__('No private key file found')); | ||
} | ||
} | ||
|
||
$clientGateway = new Client( | ||
$this->fintectureHelper, | ||
$this->fintectureLogger, | ||
[ | ||
'fintectureApiUrl' => $this->fintectureModel->getFintectureApiUrl(), | ||
'fintecturePrivateKey' => $fintecturePrivateKey, | ||
'fintectureAppId' => $fintectureAppId, | ||
'fintectureAppSecret' => $fintectureAppSecret, | ||
] | ||
); | ||
|
||
$response = $clientGateway->testConnection(); | ||
|
||
$resultJson = $this->jsonResultFactory->create(); | ||
|
||
return $resultJson->setData($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,16 @@ | |
"email": "[email protected]" | ||
}, | ||
"type": "magento2-module", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"license": [ | ||
"GPL-3.0" | ||
], | ||
"require": { | ||
"php": ">=7.3", | ||
"ext-json": "*", | ||
"ext-openssl": "*", | ||
"magento/framework": ">=100.0", | ||
"magento/module-developer": ">=100.0" | ||
"magento/framework": ">=100", | ||
"magento/module-developer": ">=100" | ||
}, | ||
"require-dev": { | ||
"phpstan/phpstan": "^1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Fintecture_Payment" setup_version="1.4.0"> | ||
<module name="Fintecture_Payment" setup_version="1.5.0"> | ||
</module> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Fintecture\Payment\Block\System\Config\Button; | ||
|
||
/** @var Button $block */ | ||
echo $block->getButtonHtml(); | ||
?> | ||
<div id="connect-message"></div> | ||
<div id="connection-test-result" class="message"> | ||
<span class="message-text"> | ||
<strong></strong> | ||
</span> | ||
</div> | ||
<script> | ||
const configurationAjaxUrl = '<?= $block->getCustomUrl() ?>?isAjax=true&form_key=<?= $block->getFormKey() ?>'; | ||
</script> | ||
|
||
const connectionTestUrl = '<?php echo $block->getCustomUrl(); ?>'; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.