Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rikterbeek committed Jun 2, 2016
2 parents a822b36 + 6c6b5b9 commit 1427ab4
Show file tree
Hide file tree
Showing 32 changed files with 1,270 additions and 77 deletions.
13 changes: 5 additions & 8 deletions Block/Adminhtml/System/Config/Field/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,22 @@ class Version extends \Magento\Config\Block\System\Config\Form\Field
{

/**
* Contains list of modules
*
* @var \Magento\Framework\Module\ModuleListInterface
* @var \Adyen\Payment\Helper\Data
*/
protected $_moduleList;

protected $_adyenHelper;
/**
* Version constructor.
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
*/
public function __construct(
\Magento\Framework\Module\ModuleListInterface $moduleList,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Backend\Block\Template\Context $context,
array $data = []
) {
parent::__construct($context, $data);
$this->_moduleList = $moduleList;
$this->_adyenHelper = $adyenHelper;
}

/**
Expand All @@ -59,6 +56,6 @@ public function __construct(
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
return (string) $this->_moduleList->getOne("Adyen_Payment")['setup_version'];
return $this->_adyenHelper->getModuleVersion();
}
}
35 changes: 35 additions & 0 deletions Block/Form/PayByMail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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 <[email protected]>
*/

namespace Adyen\Payment\Block\Form;

class PayByMail extends \Magento\Payment\Block\Form
{

/**
* @var string
*/
protected $_template = 'Adyen_Payment::form/pay_by_mail.phtml';


}
62 changes: 62 additions & 0 deletions Block/Form/Sepa.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?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 <[email protected]>
*/

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();
}
}
33 changes: 33 additions & 0 deletions Block/Info/PayByMail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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 <[email protected]>
*/

namespace Adyen\Payment\Block\Info;

class PayByMail extends AbstractInfo
{
/**
* @var string
*/
protected $_template = 'Adyen_Payment::info/adyen_pay_by_mail.phtml';

}
33 changes: 33 additions & 0 deletions Block/Info/Sepa.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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 <[email protected]>
*/

namespace Adyen\Payment\Block\Info;

class Sepa extends AbstractInfo
{
/**
* @var string
*/
protected $_template = 'Adyen_Payment::info/adyen_sepa.phtml';

}
13 changes: 13 additions & 0 deletions Controller/Process/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ public function __construct(
*/
public function execute()
{

// if version is in the notification string show the module version
$response = $this->getRequest()->getParams();
if (isset($response['version'])) {

$this->getResponse()
->clearHeader('Content-Type')
->setHeader('Content-Type', 'text/html')
->setBody($this->_adyenHelper->getModuleVersion());

return;
}

try {
$notificationItems = json_decode(file_get_contents('php://input'), true);

Expand Down
80 changes: 79 additions & 1 deletion Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ class Data extends AbstractHelper
*/
protected $_dataStorage;

/**
* @var \Magento\Directory\Model\Config\Source\Country
*/
protected $_country;

/**
* @var \Magento\Framework\Module\ModuleListInterface
*/
protected $_moduleList;

/**
* Data constructor.
*
Expand All @@ -51,11 +61,15 @@ 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,
\Magento\Framework\Module\ModuleListInterface $moduleList
) {
parent::__construct($context);
$this->_encryptor = $encryptor;
$this->_dataStorage = $dataStorage;
$this->_country = $country;
$this->_moduleList = $moduleList;
}

/**
Expand Down Expand Up @@ -350,6 +364,28 @@ public function getAdyenPosConfigDataFlag($field, $storeId = null)
return $this->getConfigData($field, 'adyen_pos', $storeId, true);
}

/**
* @desc Gives back adyen_pay_by_mail configuration values
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenPayByMailConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_pay_by_mail', $storeId);
}

/**
* @desc Gives back adyen_pay_by_mail configuration values as flag
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenPayByMailConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_pay_by_mail', $storeId, true);
}

/**
* @desc Retrieve decrypted hmac key
* @return string
Expand All @@ -367,6 +403,19 @@ public function getHmac()
return $secretWord;
}

public function getHmacPayByMail()
{
switch ($this->isDemoMode()) {
case true:
$secretWord = $this->_encryptor->decrypt(trim($this->getAdyenPayByMailConfigData('hmac_test')));
break;
default:
$secretWord = $this->_encryptor->decrypt(trim($this->getAdyenPayByMailConfigData('hmac_live')));
break;
}
return $secretWord;
}

/**
* @desc Check if configuration is set to demo mode
* @return mixed
Expand Down Expand Up @@ -507,4 +556,33 @@ public function getConfigData($field, $paymentMethodCode, $storeId, $flag = fals
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;
}

public function getModuleVersion()
{
return (string) $this->_moduleList->getOne("Adyen_Payment")['setup_version'];
}
}
Loading

0 comments on commit 1427ab4

Please sign in to comment.