-
Notifications
You must be signed in to change notification settings - Fork 12
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
Showing
15 changed files
with
277 additions
and
224 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
Block/Adminhtml/System/Config/Form/Field/Standard/CardInfoMode.php
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,59 @@ | ||
<?php | ||
/** | ||
* Copyright © Lyra Network. | ||
* This file is part of PayZen plugin for Magento 2. See COPYING.md for license details. | ||
* | ||
* @author Lyra Network (https://www.lyra.com/) | ||
* @copyright Lyra Network | ||
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
namespace Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\Standard; | ||
|
||
/** | ||
* Custom renderer for the card info mode field. | ||
*/ | ||
|
||
class CardInfoMode extends \Magento\Config\Block\System\Config\Form\Field | ||
{ | ||
/** | ||
* Retrieve element HTML markup. | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @return string | ||
*/ | ||
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
{ | ||
return parent::_getElementHtml($element) . "\n" . $this->renderScript($element); | ||
} | ||
|
||
/** | ||
* Render element JavaScript code. | ||
* | ||
* @return string | ||
*/ | ||
protected function renderScript(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
{ | ||
$warningMessage = __('Warning, some payment means are not compatible with an integration by iframe. Please consult the documentation for more details.'); | ||
|
||
$script = ' | ||
<script> | ||
require([ | ||
"prototype" | ||
], function () { | ||
var element = $("' . $element->getId() . '"); | ||
Event.observe(element, "change", function() { | ||
var cardDataMode = element.options[element.selectedIndex].value; | ||
if (cardDataMode == 3) { | ||
if (! confirm("' . $warningMessage . '")) { | ||
element.value = "' . $element->getValue(). '"; | ||
} | ||
} | ||
}); | ||
}); | ||
</script>'; | ||
|
||
return $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
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
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.