We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit bdc15957 authored by rikterbeek's avatar rikterbeek

#40

parent 8b30e606
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Block\Form;
class Sepa extends \Magento\Payment\Block\Form
{
/**
* @var string
*/
protected $_template = 'Adyen_Payment::form/sepa.phtml';
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* Sepa constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Payment\Model\Config $paymentConfig
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Adyen\Payment\Helper\Data $adyenHelper,
array $data = []
) {
parent::__construct($context, $data);
$this->_adyenHelper = $adyenHelper;
}
/**
* @return mixed
*/
public function getCountries()
{
return $this->_adyenHelper->getSepaCountries();
}
}
\ No newline at end of file
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Block\Info;
class Sepa extends AbstractInfo
{
/**
* @var string
*/
protected $_template = 'Adyen_Payment::info/adyen_sepa.phtml';
}
......@@ -41,6 +41,11 @@ class Data extends AbstractHelper
*/
protected $_dataStorage;
/**
* @var \Magento\Directory\Model\Config\Source\Country
*/
protected $_country;
/**
* Data constructor.
*
......@@ -51,11 +56,13 @@ class Data extends AbstractHelper
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Magento\Framework\Config\DataInterface $dataStorage
\Magento\Framework\Config\DataInterface $dataStorage,
\Magento\Directory\Model\Config\Source\Country $country
) {
parent::__construct($context);
$this->_encryptor = $encryptor;
$this->_dataStorage = $dataStorage;
$this->_country = $country;
}
/**
......@@ -542,4 +549,28 @@ class Data extends AbstractHelper
return $this->scopeConfig->isSetFlag($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
}
/**
* @return array
*/
public function getSepaCountries()
{
$sepaCountriesAllowed = [
"AT", "BE", "BG", "CH", "CY", "CZ", "DE", "DK", "EE", "ES", "FI", "FR", "GB", "GF", "GI", "GP", "GR", "HR",
"HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MQ", "MT", "NL", "NO", "PL", "PT", "RE", "RO", "SE",
"SI", "SK"
];
$countryList = $this->_country->toOptionArray();
$sepaCountries = [];
foreach ($countryList as $key => $country) {
$value = $country['value'];
if (in_array($value, $sepaCountriesAllowed)) {
$sepaCountries[$value] = $country['label'];
}
}
return $sepaCountries;
}
}
\ No newline at end of file
......@@ -48,22 +48,22 @@ class AdyenSepaConfigProvider implements ConfigProviderInterface
protected $_paymentHelper;
/**
* @var \Magento\Directory\Model\Config\Source\Country
* @var \Adyen\Payment\Helper\Data
*/
protected $_country;
protected $_adyenHelper;
/**
* AdyenSepaConfigProvider constructor.
*
* @param PaymentHelper $paymentHelper
* @param \Magento\Directory\Model\Config\Source\Country $country
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
PaymentHelper $paymentHelper,
\Magento\Directory\Model\Config\Source\Country $country
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->_paymentHelper = $paymentHelper;
$this->_country = $country;
$this->_adyenHelper = $adyenHelper;
foreach ($this->_methodCodes as $code) {
$this->_methods[$code] = $this->_paymentHelper->getMethodInstance($code);
......@@ -78,34 +78,10 @@ class AdyenSepaConfigProvider implements ConfigProviderInterface
$config = [
'payment' => [
'adyenSepa' => [
'countries' => $this->getCountries()
'countries' => $this->_adyenHelper->getSepaCountries()
]
]
];
return $config;
}
/**
* @return array
*/
public function getCountries()
{
$sepaCountriesAllowed = [
"AT", "BE", "BG", "CH", "CY", "CZ", "DE", "DK", "EE", "ES", "FI", "FR", "GB", "GF", "GI", "GP", "GR", "HR",
"HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MQ", "MT", "NL", "NO", "PL", "PT", "RE", "RO", "SE",
"SI", "SK"
];
$countryList = $this->_country->toOptionArray();
$sepaCountries = [];
foreach ($countryList as $key => $country) {
$value = $country['value'];
if (in_array($value, $sepaCountriesAllowed)) {
$sepaCountries[$value] = $country['label'];
}
}
return $sepaCountries;
}
}
\ No newline at end of file
......@@ -47,6 +47,9 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
*/
const GUEST_ID = 'customer_';
/**
* @var string
*/
protected $_infoBlockType = 'Adyen\Payment\Block\Info\Hpp';
/**
......
......@@ -37,6 +37,16 @@ class Sepa extends \Magento\Payment\Model\Method\AbstractMethod
*/
protected $_code = self::METHOD_CODE;
/**
* @var string
*/
protected $_formBlockType = 'Adyen\Payment\Block\Form\Sepa';
/**
* @var string
*/
protected $_infoBlockType = 'Adyen\Payment\Block\Info\Sepa';
/**
* @var \Adyen\Payment\Model\Api\PaymentRequest
*/
......@@ -186,14 +196,13 @@ class Sepa extends \Magento\Payment\Model\Method\AbstractMethod
}
/**
* Validate IBAN
*
* @param $iban
* @return bool
*/
public function validateIban($iban)
{
public function validateIban($iban) {
$iban = strtolower(str_replace(' ', '', $iban));
$countries = ['al'=>28,'ad'=>24,'at'=>20,'az'=>28,'bh'=>22,'be'=>16,'ba'=>20,'br'=>29,'bg'=>22,'cr'=>21,
'hr'=>21,'cy'=>28,'cz'=>24,'dk'=>18,'do'=>28,'ee'=>20,'fo'=>18,'fi'=>18,'fr'=>27,'ge'=>22,
'de'=>22,'gi'=>23,'gr'=>27,'gl'=>18,'gt'=>28,'hu'=>28,'is'=>26,'ie'=>22,'il'=>23,'it'=>27,
......@@ -206,14 +215,17 @@ class Sepa extends \Magento\Payment\Model\Method\AbstractMethod
'm'=>22,'n'=>23,'o'=>24,'p'=>25,'q'=>26,'r'=>27,'s'=>28,'t'=>29,'u'=>30,'v'=>31,'w'=>32,'x'=>33,
'y'=>34,'z'=>35];
if (isset($countries[substr($iban, 0, 2)]) && strlen($iban) == $countries[substr($iban, 0, 2)]) {
if (isset($countries[substr($iban, 0, 2)]) &&
strlen($iban) == $countries[substr($iban, 0, 2)]) {
$movedChar = substr($iban, 4).substr($iban, 0, 4);
$movedCharArray = str_split($movedChar);
$newString = "";
foreach ($movedChar AS $key => $value) {
foreach ($movedCharArray AS $key => $value) {
if (!is_numeric($movedCharArray[$key])) {
$movedChar[$key] = $chars[$movedChar[$key]];
$movedCharArray[$key] = $chars[$movedCharArray[$key]];
}
$newString .= $movedCharArray[$key];
}
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
// @codingStandardsIgnoreFile
/**
* @var \Magento\Payment\Block\Adminhtml\Transparent\Form $block
*/
$code = $block->escapeHtml($block->getMethodCode());
$currentCountry = $block->getInfoData('country');
?>
<fieldset class="admin__fieldset payment-method" id="payment_form_<?php /* @noEscape */ echo $code; ?>"
style="display:none">
<div class="field admin__field _required">
<label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_account_name">
<span><?php echo $block->escapeHtml(__('Bank account holder name')); ?></span>
</label>
<div class="admin__field-control">
<input type="text"
id="<?php /* @noEscape */ echo $code; ?>_account_name"
name="payment[account_name]"
title="<?php echo $block->escapeHtml(__('Bank account holder name')); ?>" class="admin__control-text"
value="<?php /* @noEscape */ echo $block->getInfoData('holder_name'); ?>"/>
</div>
</div>
<div class="field admin__field _required">
<label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_iban">
<span><?php echo $block->escapeHtml(__('IBAN')); ?></span>
</label>
<div class="admin__field-control">
<input type="text"
id="<?php /* @noEscape */ echo $code; ?>_account_name"
name="payment[iban]"
title="<?php echo $block->escapeHtml(__('IBAN')); ?>" class="admin__control-text"
value="<?php /* @noEscape */ echo $block->getInfoData('iban'); ?>"/>
</div>
</div>
<div class="field-type admin__field _required">
<label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_cc_type">
<span><?php echo $block->escapeHtml(__('country')); ?></span>
</label>
<div class="admin__field-control">
<select id="<?php /* @noEscape */ echo $code; ?>_cc_type" name="payment[country]"
class="required-entry admin__control-select">
<option value=""></option>
<?php foreach ($block->getCountries() as $countryCode => $countryName): ?>
<option value="<?php echo $block->escapeHtml($countryCode); ?>" <?php if ($countryCode == $currentCountry): ?>selected="selected"<?php endif ?>>
<?php echo $block->escapeHtml($countryName); ?>
</option>
<?php endforeach ?>
</select>
</div>
</div>
<div class="field-type admin__field _required">
<div class="admin__field-control">
<input id="<?php /* @noEscape */ echo $code; ?>_accept_sepa"
name="payment[accept_sepa]"
type="checkbox"
title="<?php echo $block->escapeHtml(__('I agree that the above amount will be debited from my bank account.')); ?>"
class=""
value="<?php /* @noEscape */ echo $block->getInfoData('accept_sepa'); ?>"/>
<label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_accept_sepa">
<span><?php echo $block->escapeHtml(__('I agree that the above amount will be debited from my bank account.')); ?></span>
</label>
</div>
</div>
</fieldset>
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
// @codingStandardsIgnoreFile
?>
<?php
/**
* @see \Magento\Payment\Block\Info
*/
?>
<?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?>
<?php
$_info = $this->getInfo();
$_isDemoMode = $block->isDemoMode();
?>
<?php if ($_pspReference = $_info->getAdditionalInformation('pspReference')):?>
<div>
<?php if($_isDemoMode): ?>
<?php echo __('Adyen PSP Reference: <a href="https://ca-test.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>', $block->escapeHtml($_pspReference), $block->escapeHtml($_pspReference)) ?>
<?php else: ?>
<?php echo __('Adyen PSP Reference: <a href="https://ca-live.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>', $block->escapeHtml($_pspReference), $block->escapeHtml($_pspReference)) ?>
<?php endif; ?>
</div>
<?php endif;?>
<?php if ($_brandCode = $_info->getAdditionalInformation('brand_code')):?>
<div><?php echo __('Payment Method: %1', $_brandCode); ?>
</div>
<?php endif;?>
<?php if($_info->getAdditionalInformation('adyen_total_fraud_score') != ""): ?>
<?php echo __('Total fraud score: %1', $_info->getAdditionalInformation('adyen_total_fraud_score')) ?><br/>
<?php endif; ?>
<?php if ($_specificInfo = $block->getSpecificInformation()):?>
<table class="data-table admin__table-secondary">
<?php foreach ($_specificInfo as $_label => $_value):?>
<tr>
<th><?php echo $block->escapeHtml($_label)?>:</th>
<td><?php echo nl2br(implode("\n", $block->getValueAsArray($_value, true)))?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif;?>
<?php echo $block->getChildHtml()?>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment