Skip to content

Commit

Permalink
Merge pull request #38 from Adyen/develop
Browse files Browse the repository at this point in the history
Merge branch 'develop'
  • Loading branch information
rikterbeek committed May 23, 2016
2 parents f38de7c + 866863b commit a822b36
Show file tree
Hide file tree
Showing 66 changed files with 2,501 additions and 1,172 deletions.
8 changes: 4 additions & 4 deletions Api/Data/NotificationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ public function getAmountValue();
public function setAmountValue($amountValue);

/**
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
*/
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
*/
public function getAmountCurency();

/**
Expand Down
17 changes: 15 additions & 2 deletions Block/Adminhtml/System/Config/Field/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,33 @@ class Version extends \Magento\Config\Block\System\Config\Form\Field
{

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

/**
* 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,
\Magento\Backend\Block\Template\Context $context,
array $data = []
)
{
) {
parent::__construct($context, $data);
$this->_moduleList = $moduleList;
}

/**
* Retrieve the setup version of the extension
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
return (string) $this->_moduleList->getOne("Adyen_Payment")['setup_version'];
Expand Down
137 changes: 32 additions & 105 deletions Block/Form/Cc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace Adyen\Payment\Block\Form;

class Cc extends \Magento\Payment\Block\Form
class Cc extends \Magento\Payment\Block\Form\Cc
{
/**
* @var string
Expand All @@ -43,22 +43,42 @@ class Cc extends \Magento\Payment\Block\Form
protected $_adyenHelper;

/**
* @var \Magento\Framework\App\State
*/
protected $_appState;

/**
* @var \Magento\Checkout\Model\Session
*/
protected $_checkoutSession;

/**
* Cc constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Payment\Model\Config $paymentConfig
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Payment\Model\Config $paymentConfig,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Checkout\Model\Session $checkoutSession,
array $data = []
) {
parent::__construct($context, $data);
$this->_paymentConfig = $paymentConfig;
parent::__construct($context, $paymentConfig);
$this->_adyenHelper = $adyenHelper;
$this->_appState = $context->getAppState();
$this->_checkoutSession = $checkoutSession;
}


/**
* @return mixed
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getCsePublicKey()
{
// get storeId for admin
Expand All @@ -77,62 +97,6 @@ public function getCsePublicKey()
}

return $cseKey;

}

/**
* Retrieve availables credit card types
*
* @return array
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public function getCcAvailableTypes()
{
$types = $this->_paymentConfig->getCcTypes();
if ($method = $this->getMethod()) {
$availableTypes = $method->getConfigData('cctypes');
if ($availableTypes) {
$availableTypes = explode(',', $availableTypes);
foreach ($types as $code => $name) {
if (!in_array($code, $availableTypes)) {
unset($types[$code]);
}
}
}
}
return $types;
}

/**
* Retrieve credit card expire months
*
* @return array
*/
public function getCcMonths()
{
$months = $this->getData('cc_months');
if ($months === null) {
$months[0] = __('Month');
$months = array_merge($months, $this->_paymentConfig->getMonths());
$this->setData('cc_months', $months);
}
return $months;
}

/**
* Retrieve credit card expire years
*
* @return array
*/
public function getCcYears()
{
$years = $this->getData('cc_years');
if ($years === null) {
$years = $this->_paymentConfig->getYears();
$years = [0 => __('Year')] + $years;
$this->setData('cc_years', $years);
}
return $years;
}

/**
Expand All @@ -142,52 +106,15 @@ public function getCcYears()
*/
public function hasVerification()
{
return true;
}

/**
* Whether switch/solo card type available
*
* @return bool
*/
public function hasSsCardType()
{
$availableTypes = explode(',', $this->getMethod()->getConfigData('cctypes'));
$ssPresenations = array_intersect(['SS', 'SM', 'SO'], $availableTypes);
if ($availableTypes && count($ssPresenations) > 0) {
return true;
}
return false;
}

/**
* Solo/switch card start year
*
* @return array
*/
public function getSsStartYears()
{
$years = [];
$first = date("Y");

for ($index = 5; $index >= 0; $index--) {
$year = $first - $index;
$years[$year] = $year;
// if backend order and moto payments is turned on don't show cvc
if ($this->_appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
$this->getCheckoutSession();
$store = $this->_checkoutSession->getQuote()->getStore();
$enableMoto = $this->_adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $store->getId());
if($enableMoto) {
return false;
}
}
$years = [0 => __('Year')] + $years;
return $years;
}

/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
{
$this->_eventManager->dispatch('payment_form_block_to_html_before', ['block' => $this]);
return parent::_toHtml();
return true;
}


}
13 changes: 11 additions & 2 deletions Block/Info/AbstractInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class AbstractInfo extends \Magento\Payment\Block\Info
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;

/**
* Constructor
*
* AbstractInfo constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param Template\Context $context
* @param array $data
*/
Expand All @@ -49,12 +51,19 @@ public function __construct(
$this->_adyenHelper = $adyenHelper;
}


/**
* @return mixed
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getAdyenPspReference()
{
return $this->getInfo()->getAdyenPspReference();
}

/**
* @return mixed
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function isDemoMode()
{
$storeId = $this->getInfo()->getOrder()->getStoreId();
Expand Down
5 changes: 5 additions & 0 deletions Block/Info/Hpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class Hpp extends AbstractInfo
*/
protected $_template = 'Adyen_Payment::info/adyen_hpp.phtml';

/**
* Check if Payment method selection is configured on Adyen or Magento
*
* @return mixed
*/
public function isPaymentSelectionOnAdyen()
{
return $this->_adyenHelper->getAdyenHppConfigDataFlag('payment_selection_on_adyen');
Expand Down
12 changes: 9 additions & 3 deletions Block/Redirect/Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Pos extends \Magento\Payment\Block\Form
protected $_order;

/**
* Pos constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param array $data
* @param \Magento\Sales\Model\OrderFactory $orderFactory
Expand All @@ -50,20 +52,24 @@ public function __construct(
array $data = [],
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Checkout\Model\Session $checkoutSession
)
{
) {
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $checkoutSession;
parent::__construct($context, $data);
$this->_getOrder();
}


/**
* @return $this
*/
public function _prepareLayout()
{
return parent::_prepareLayout();
}

/**
* @return string
*/
public function getLaunchLink()
{
$result = "";
Expand Down
14 changes: 12 additions & 2 deletions Block/Redirect/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Redirect extends \Magento\Payment\Block\Form
protected $_order;

/**
* Redirect constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param array $data
* @param \Magento\Sales\Model\OrderFactory $orderFactory
Expand All @@ -50,20 +52,25 @@ public function __construct(
array $data = [],
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Checkout\Model\Session $checkoutSession
)
{
) {
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $checkoutSession;
parent::__construct($context, $data);
$this->_getOrder();
}


/**
* @return $this
*/
public function _prepareLayout()
{
return parent::_prepareLayout();
}

/**
* @return string
*/
public function getFormUrl()
{
$result = "";
Expand All @@ -81,6 +88,9 @@ public function getFormUrl()
return $result;
}

/**
* @return array
*/
public function getFormFields()
{
$result = array();
Expand Down
Loading

0 comments on commit a822b36

Please sign in to comment.