Skip to content

Commit

Permalink
Merge pull request #31 from limegrow/hotfix/backend-store-id-fix
Browse files Browse the repository at this point in the history
Fix Webhook URL in multistore configuration
  • Loading branch information
olegisk authored Mar 13, 2022
2 parents 388acf0 + ed5406e commit d19fec5
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 12 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,24 @@ jobs:
- name: Install dependencies
uses: shivammathur/setup-php@master
with:
php-version: '7.3'
php-version: '7.4'
extension: intl, mbstring, json, bcmath, sodium, zip
coverage: xdebug
tools: composer, php-cs-fixer, phpunit:7.5.19, phpcpd, phpmd
tools: composer, phpcs, phpunit:7.5.19, phpcpd, phpmd

- name: Install tools
run: |
cd $GITHUB_WORKSPACE/m2-payments
composer global require squizlabs/php_codesniffer
composer global require phpcompatibility/php-compatibility
composer global require magento/magento-coding-standard
composer global require phpmd/phpmd
composer global require sebastian/phpcpd
- name: Run PHPCS inspection
run: |
cd $GITHUB_WORKSPACE/m2-payments
php ~/.composer/vendor/bin/phpcs --config-set installed_paths ~/.composer/vendor/magento/magento-coding-standard/Magento2
#php ~/.composer/vendor/bin/phpcpd ./
php ~/.composer/vendor/bin/phpcs --config-set installed_paths ~/.composer/vendor/phpcompatibility/php-compatibility/PHPCompatibility
#php ~/.composer/vendor/bin/phpmd ./ text cleancode,codesize,controversial,design,naming,unusedcode --exclude vendor/
#php ~/.composer/vendor/bin/phpcs --standard=PSR1 ./ --ignore=./vendor/*
php ~/.composer/vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1 --standard=PSR2 ./ --ignore=./vendor/*
php ~/.composer/vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1 --standard=~/.composer/vendor/magento/magento-coding-standard/Magento2/ruleset.xml --extensions=php,phtml ./ --ignore=./vendor/*
php ~/.composer/vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1 --standard=~/.composer/vendor/magento/magento-coding-standard/Magento2/ruleset.xml --extensions=php,phtml ./ --ignore=./vendor/*
45 changes: 42 additions & 3 deletions Block/Adminhtml/System/Config/Connection/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,55 @@

namespace Ingenico\Payment\Block\Adminhtml\System\Config\Connection;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\UrlInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Data\Form\Element\AbstractElement;

/**
* Provides field with additional information
*/
class Webhook extends \Magento\Config\Block\System\Config\Form\Field
class Webhook extends Field
{
/**
* @var UrlInterface
*/
private $urlBuilder;

/**
* @var RequestInterface
*/
private $request;

protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
/**
* @param Context $context
* @param UrlInterface $frontUrlModel
* @param RequestInterface $request
* @param array $data
*/
public function __construct(
Context $context,
UrlInterface $frontUrlModel,
RequestInterface $request,
array $data = []
) {
parent::__construct($context, $data);

$this->urlBuilder = $frontUrlModel;
$this->request = $request;
}

protected function _getElementHtml(AbstractElement $element)
{
$storeId = $this->request->getParam('store');
if (!$storeId) {
$storeId = $this->_storeManager->getStore()->getId();
}

$id = $element->getHtmlId();
$link = $this->_storeManager->getStore()->getBaseUrl().'ingenico/payment/webhook';
$link = $this->urlBuilder->getUrl('ingenico/payment/webhook', ['_nosid' => true, '_scope' => $storeId]);

return implode('', [
'<a href="javascript:void(0);" onclick="Ogone.copyLink(\''.$link.'\', \''.$id.'\');">'.$link.'</a>',
'<div class="copy-response message message-success" data-copy="'.$id.'">'.__('form.connection.label.copied').'</div>',
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [2.11.0] - 2022-04-13
## Changed
- Fixed Store ID Magento problem
- Fix Webhook URL in multistore configuration

## [2.10.0] - 2021-11-14
## Changed
- Fixed: Undefined class constant 'CORE_CODE'
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"league/iso3166": "~2.1",
"graylog2/gelf-php": "~1.5",
"symfony/translation": ">=4.2",
"ingenico/ogone-client": "^6.0.0"
"ingenico/ogone-client": "^7.1.0"
},
"type": "magento2-module",
"version": "2.10.0",
"version": "2.11.0",
"license": [
"OSL-3.0"
],
Expand Down Expand Up @@ -42,6 +42,6 @@
}
},
"require-dev": {
"magento/magento-coding-standard": "^5.0"
"magento/magento-coding-standard": "^6.0"
}
}
5 changes: 5 additions & 0 deletions etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@
<type name="Magento\Sales\Controller\Adminhtml\Order\Creditmemo\Save">
<plugin name="intercept_creditmemo_creation" type="Ingenico\Payment\Plugin\MagentoSalesControllerAdminhtmlOrderCreditmemoSave" />
</type>
<type name="Ingenico\Payment\Block\Adminhtml\System\Config\Connection\Webhook">
<arguments>
<argument name="frontUrlModel" xsi:type="object" shared="false">Magento\Framework\Url</argument>
</arguments>
</type>
</config>

0 comments on commit d19fec5

Please sign in to comment.