We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 9d8740c5 authored by rikterbeek's avatar rikterbeek

reomved unused index controller and added phpDocs

parent b3a741d5
...@@ -30,7 +30,7 @@ class Version extends \Magento\Config\Block\System\Config\Form\Field ...@@ -30,7 +30,7 @@ class Version extends \Magento\Config\Block\System\Config\Form\Field
{ {
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{ {
// TODO: make dynamic // make this dynamic
//$configVer = $this->moduleList->getOne($moduleName)['setup_version']; //$configVer = $this->moduleList->getOne($moduleName)['setup_version'];
return (string) "0.1.0"; return (string) "0.1.0";
} }
......
...@@ -41,6 +41,7 @@ class Cc extends \Magento\Payment\Block\Form ...@@ -41,6 +41,7 @@ class Cc extends \Magento\Payment\Block\Form
/** /**
* @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Payment\Model\Config $paymentConfig * @param \Magento\Payment\Model\Config $paymentConfig
* @param \Psr\Log\LoggerInterface $logger
* @param array $data * @param array $data
*/ */
public function __construct( public function __construct(
......
...@@ -31,12 +31,4 @@ class Hpp extends \Magento\Payment\Block\Info ...@@ -31,12 +31,4 @@ class Hpp extends \Magento\Payment\Block\Info
*/ */
protected $_template = 'Adyen_Payment::info/adyen_hpp.phtml'; protected $_template = 'Adyen_Payment::info/adyen_hpp.phtml';
/**
* @return string
*/
// public function toPdf()
// {
// $this->setTemplate('Magento_OfflinePayments::info/pdf/checkmo.phtml');
// return $this->toHtml();
// }
} }
...@@ -34,13 +34,16 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -34,13 +34,16 @@ class Redirect extends \Magento\Payment\Block\Form
*/ */
protected $_checkoutSession; protected $_checkoutSession;
/**
* @var \Magento\Checkout\Model\Order
*/
protected $_order; protected $_order;
/** /**
* Constructor * @param \Magento\Framework\View\Element\Template\Context $context
*
* @param \\Magento\Framework\View\Element\Template\Context $context
* @param array $data * @param array $data
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Checkout\Model\Session $checkoutSession
*/ */
public function __construct( public function __construct(
\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\View\Element\Template\Context $context,
......
...@@ -34,13 +34,16 @@ class Validate3d extends \Magento\Payment\Block\Form ...@@ -34,13 +34,16 @@ class Validate3d extends \Magento\Payment\Block\Form
*/ */
protected $_checkoutSession; protected $_checkoutSession;
/**
* @var \Magento\Checkout\Model\Order
*/
protected $_order; protected $_order;
/** /**
* Constructor * @param \Magento\Framework\View\Element\Template\Context $context
*
* @param \\Magento\Framework\View\Element\Template\Context $context
* @param array $data * @param array $data
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Checkout\Model\Session $checkoutSession
*/ */
public function __construct( public function __construct(
\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\View\Element\Template\Context $context,
......
<?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\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action
{
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
{
$this->_objectManager = $objectManager;
}
public function execute()
{
echo 'test';die();
$this->_view->loadLayout();
$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
}
}
\ No newline at end of file
...@@ -32,7 +32,6 @@ use Symfony\Component\Config\Definition\Exception\Exception; ...@@ -32,7 +32,6 @@ use Symfony\Component\Config\Definition\Exception\Exception;
class Cron extends \Magento\Framework\App\Action\Action class Cron extends \Magento\Framework\App\Action\Action
{ {
/** /**
* @var \Magento\Framework\ObjectManagerInterface * @var \Magento\Framework\ObjectManagerInterface
*/ */
...@@ -43,7 +42,6 @@ class Cron extends \Magento\Framework\App\Action\Action ...@@ -43,7 +42,6 @@ class Cron extends \Magento\Framework\App\Action\Action
*/ */
protected $_resultFactory; protected $_resultFactory;
/** /**
* @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Action\Context $context
*/ */
......
...@@ -45,8 +45,10 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -45,8 +45,10 @@ class Json extends \Magento\Framework\App\Action\Action
* @var \Adyen\Payment\Helper\Data * @var \Adyen\Payment\Helper\Data
*/ */
protected $_adyenHelper; protected $_adyenHelper;
/** /**
* @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Action\Context $context
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Action\Context $context,
......
...@@ -31,25 +31,15 @@ class Redirect extends \Magento\Framework\App\Action\Action ...@@ -31,25 +31,15 @@ class Redirect extends \Magento\Framework\App\Action\Action
*/ */
protected $_quote = false; protected $_quote = false;
/** /**
* @var \Magento\Checkout\Model\Session * @var \Magento\Checkout\Model\Session
*/ */
protected $_checkoutSession; protected $_checkoutSession;
protected $checkoutFactory;
/** /**
* @var \Magento\Customer\Model\Session * @var \Magento\Sales\Model\Order
*/ */
protected $_customerSession;
protected $_order; protected $_order;
/** /**
...@@ -60,14 +50,11 @@ class Redirect extends \Magento\Framework\App\Action\Action ...@@ -60,14 +50,11 @@ class Redirect extends \Magento\Framework\App\Action\Action
/** /**
* @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Customer\Model\Session $customerSession
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Action\Context $context \Magento\Framework\App\Action\Context $context
// \Magento\Customer\Model\Session $customerSession
) { ) {
parent::__construct($context); parent::__construct($context);
// $this->_customerSession = $customerSession;
} }
...@@ -83,69 +70,9 @@ class Redirect extends \Magento\Framework\App\Action\Action ...@@ -83,69 +70,9 @@ class Redirect extends \Magento\Framework\App\Action\Action
public function execute() public function execute()
{ {
// $session->clearQuote();
$this->_view->loadLayout(); $this->_view->loadLayout();
$this->_view->getLayout()->initMessages(); $this->_view->getLayout()->initMessages();
$this->_view->renderLayout(); $this->_view->renderLayout();
// \Magento\Quote\Model\QuoteManagement $quoteManagement
//$this->_checkout->place($this->_initToken());
// $order = $this->quoteManagement->submit($this->_quote);
// $orderId = $this->_getCheckout()->getLastOrderId();
//
// $order = $this->_getOrder();
//
// $payment = $order->getPayment()->getMethodInstance();
//
// echo $payment->getCode();die();
//
//
//echo $order->getId();
// die();
//
// $quote->collectTotals();
//
//// print_r($quote->getPayment());die();
//
// //$this->_quote->collectTotals();
//// $order = $this->quoteManagement->submit($this->_quote);
////\Magento\Quote\Model\QuoteManagement $quoteManagement
//
//// $this->_getQuoteManagement()->submit($quote);
//
//
////echo 'test';
//// print_r($this->_getQuote()->getBillingAddress()->getFirstname());die();
//
//// echo $quote->getBillingAddress()->getFirstname();
////// echo $quote->getShippingAddress()->getFirstname();
//// die();
//
// $this->_getQuoteManagement()->placeOrder($quote->getId());
//
// // $this->cartManagement->placeOrder($this->_getCheckout()->getQuote()->getId());
//
//
//// $this->getOrder();
//
//// echo $quote->getId();
//// echo 'hier;';die();
//// $this->_quote->collectTotals();
////
////echo 'hier';die();
// $url = "http://www.google.com";
// $this->getResponse()->setRedirect($url);
// return;
// $this->_view->loadLayout();
// $this->_view->getLayout()->initMessages();
// $this->_view->renderLayout();
} }
/** /**
......
...@@ -28,11 +28,19 @@ use Magento\Customer\Api\CustomerRepositoryInterface; ...@@ -28,11 +28,19 @@ use Magento\Customer\Api\CustomerRepositoryInterface;
class Result extends \Magento\Framework\App\Action\Action class Result extends \Magento\Framework\App\Action\Action
{ {
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper; protected $_adyenHelper;
/**
* @var \Magento\Sales\Model\OrderFactory
*/
protected $_orderFactory; protected $_orderFactory;
/**
* @var \Magento\Sales\Model\Order
*/
protected $_order; protected $_order;
/** /**
...@@ -40,13 +48,17 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -40,13 +48,17 @@ class Result extends \Magento\Framework\App\Action\Action
*/ */
protected $_orderHistoryFactory; protected $_orderHistoryFactory;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $_session; protected $_session;
/** /**
* @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Customer\Model\Session $customerSession * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param CustomerRepositoryInterface $customerRepository * @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param AccountManagementInterface $accountManagement * @param \Magento\Sales\Model\Order\Status\HistoryFactory $orderHistoryFactory
* @param \Magento\Checkout\Model\Session $session
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Action\Context $context,
......
...@@ -30,15 +30,25 @@ class Validate3d extends \Magento\Framework\App\Action\Action ...@@ -30,15 +30,25 @@ class Validate3d extends \Magento\Framework\App\Action\Action
*/ */
protected $_orderFactory; protected $_orderFactory;
/**
* @var \Magento\Sales\Model\Order
*/
protected $_order; protected $_order;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $_adyenLogger; protected $_adyenLogger;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper; protected $_adyenHelper;
/** /**
* @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Customer\Model\Session $customerSession * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Action\Context $context,
...@@ -52,7 +62,6 @@ class Validate3d extends \Magento\Framework\App\Action\Action ...@@ -52,7 +62,6 @@ class Validate3d extends \Magento\Framework\App\Action\Action
public function execute() public function execute()
{ {
$this->_adyenLogger->critical("IN Execute validate3d:");
// check if 3d is active // check if 3d is active
$order = $this->_getOrder(); $order = $this->_getOrder();
...@@ -62,9 +71,12 @@ class Validate3d extends \Magento\Framework\App\Action\Action ...@@ -62,9 +71,12 @@ class Validate3d extends \Magento\Framework\App\Action\Action
// check if 3D secure is active. If not just go to success page // check if 3D secure is active. If not just go to success page
if($active) { if($active) {
$this->_adyenLogger->info("3D secure is active");
// check if it is already processed // check if it is already processed
if ($this->getRequest()->isPost()) { if ($this->getRequest()->isPost()) {
$this->_adyenLogger->info("Process 3D secure payment");
$requestMD = $this->getRequest()->getPost('MD'); $requestMD = $this->getRequest()->getPost('MD');
$requestPaRes = $this->getRequest()->getPost('PaRes'); $requestPaRes = $this->getRequest()->getPost('PaRes');
...@@ -89,6 +101,7 @@ class Validate3d extends \Magento\Framework\App\Action\Action ...@@ -89,6 +101,7 @@ class Validate3d extends \Magento\Framework\App\Action\Action
} }
} }
} else { } else {
$this->_adyenLogger->info("Customer was redirected to bank for 3D-secure validation.");
$order->addStatusHistoryComment(__('Customer was redirected to bank for 3D-secure validation.'))->save(); $order->addStatusHistoryComment(__('Customer was redirected to bank for 3D-secure validation.'))->save();
$this->_view->loadLayout(); $this->_view->loadLayout();
......
...@@ -38,6 +38,9 @@ class Data extends AbstractHelper ...@@ -38,6 +38,9 @@ class Data extends AbstractHelper
*/ */
protected $_scopeConfig; protected $_scopeConfig;
/**
* @var \Magento\Framework\Encryption\EncryptorInterface
*/
protected $_encryptor; protected $_encryptor;
...@@ -56,6 +59,10 @@ class Data extends AbstractHelper ...@@ -56,6 +59,10 @@ class Data extends AbstractHelper
} }
/**
* @desc return recurring types for configuration setting
* @return array
*/
public function getRecurringTypes() { public function getRecurringTypes() {
return [ return [
...@@ -65,6 +72,10 @@ class Data extends AbstractHelper ...@@ -65,6 +72,10 @@ class Data extends AbstractHelper
]; ];
} }
/**
* @desc return recurring types for configuration setting
* @return array
*/
public function getModes() { public function getModes() {
return [ return [
'1' => 'Test Mode', '1' => 'Test Mode',
...@@ -72,6 +83,10 @@ class Data extends AbstractHelper ...@@ -72,6 +83,10 @@ class Data extends AbstractHelper
]; ];
} }
/**
* @desc return recurring types for configuration setting
* @return array
*/
public function getCaptureModes() { public function getCaptureModes() {
return [ return [
'auto' => 'immediate', 'auto' => 'immediate',
...@@ -79,6 +94,10 @@ class Data extends AbstractHelper ...@@ -79,6 +94,10 @@ class Data extends AbstractHelper
]; ];
} }
/**
* @desc return recurring types for configuration setting
* @return array
*/
public function getPaymentRoutines() { public function getPaymentRoutines() {
return [ return [
'single' => 'Single Page Payment Routine', 'single' => 'Single Page Payment Routine',
...@@ -86,6 +105,7 @@ class Data extends AbstractHelper ...@@ -86,6 +105,7 @@ class Data extends AbstractHelper
]; ];
} }
/** /**
* Return the formatted currency. Adyen accepts the currency in multiple formats. * Return the formatted currency. Adyen accepts the currency in multiple formats.
* @param $amount * @param $amount
...@@ -172,36 +192,76 @@ class Data extends AbstractHelper ...@@ -172,36 +192,76 @@ class Data extends AbstractHelper
} }
/**
* @desc gives back global configuration values
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenAbstractConfigData($field, $storeId = null) public function getAdyenAbstractConfigData($field, $storeId = null)
{ {
return $this->getConfigData($field, 'adyen_abstract', $storeId); return $this->getConfigData($field, 'adyen_abstract', $storeId);
} }
/**
* @desc gives back global configuration values as boolean
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenAbstractConfigDataFlag($field, $storeId = null) public function getAdyenAbstractConfigDataFlag($field, $storeId = null)
{ {
return $this->getConfigData($field, 'adyen_abstract', $storeId, true); return $this->getConfigData($field, 'adyen_abstract', $storeId, true);
} }
/**
* @desc Gives back adyen_cc configuration values
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenCcConfigData($field, $storeId = null) public function getAdyenCcConfigData($field, $storeId = null)
{ {
return $this->getConfigData($field, 'adyen_cc', $storeId); return $this->getConfigData($field, 'adyen_cc', $storeId);
} }
/**
* @desc Gives back adyen_cc configuration values as flag
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenCcConfigDataFlag($field, $storeId = null) public function getAdyenCcConfigDataFlag($field, $storeId = null)
{ {
return $this->getConfigData($field, 'adyen_cc', $storeId, true); return $this->getConfigData($field, 'adyen_cc', $storeId, true);
} }
/**
* @desc Gives back adyen_hpp configuration values
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenHppConfigData($field, $storeId = null) public function getAdyenHppConfigData($field, $storeId = null)
{ {
return $this->getConfigData($field, 'adyen_hpp', $storeId); return $this->getConfigData($field, 'adyen_hpp', $storeId);
} }
/**
* @desc Gives back adyen_hpp configuration values as flag
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenHppConfigDataFlag($field, $storeId = null) public function getAdyenHppConfigDataFlag($field, $storeId = null)
{ {
return $this->getConfigData($field, 'adyen_hpp', $storeId, true); return $this->getConfigData($field, 'adyen_hpp', $storeId, true);
} }
/**
* @desc Retrieve decrypted hmac key
* @return string
*/
public function getHmac() public function getHmac()
{ {
switch ($this->isDemoMode()) { switch ($this->isDemoMode()) {
...@@ -215,16 +275,70 @@ class Data extends AbstractHelper ...@@ -215,16 +275,70 @@ class Data extends AbstractHelper
return $secretWord; return $secretWord;
} }
/**
* @desc Check if configuration is set to demo mode
* @return mixed
*/
public function isDemoMode() public function isDemoMode()
{ {
return $this->getAdyenAbstractConfigDataFlag('demo_mode'); return $this->getAdyenAbstractConfigDataFlag('demo_mode');
} }
/**
* @desc Retrieve the decrypted notification password
* @return string
*/
public function getNotificationPassword() public function getNotificationPassword()
{ {
return $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData('notification_password'))); return $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData('notification_password')));
} }
/**
* @desc Retrieve the webserver username
* @return string
*/
public function getWsUsername()
{
if($this->isDemoMode()) {
$wsUsername = trim($this->getAdyenAbstractConfigData('ws_username_test'));
} else {
$wsUsername = trim($this->getAdyenAbstractConfigData('ws_username_live'));
}
return $wsUsername;
}
/**
* @desc Retrieve the webserver password
* @return string
*/
public function getWsPassword()
{
if($this->isDemoMode()) {
$wsPassword = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData('ws_password_test')));
} else {
$wsPassword = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData('ws_password_live')));
}
return $wsPassword;
}
/**
* @desc Retrieve the webserver url defined in the config.xlm only
* @return string
*/
public function getWsUrl()
{
if($this->isDemoMode()) {
$url = $this->getAdyenAbstractConfigData('ws_url_test');
} else {
$url = $this->getAdyenAbstractConfigData('ws_url_live');
}
return $url;
}
/**
* @desc Cancels the order
* @param $order
*/
public function cancelOrder($order) public function cancelOrder($order)
{ {
$orderStatus = $this->getAdyenAbstractConfigData('payment_cancelled'); $orderStatus = $this->getAdyenAbstractConfigData('payment_cancelled');
...@@ -245,12 +359,12 @@ class Data extends AbstractHelper ...@@ -245,12 +359,12 @@ class Data extends AbstractHelper
} }
/** /**
* Retrieve information from payment configuration * @desc Retrieve information from payment configuration
* * @param $field
* @param string $field * @param $paymentMethodCode
* @param int|string|null|\Magento\Store\Model\Store $storeId * @param $storeId
* * @param bool|false $flag
* @return mixed * @return bool|mixed
*/ */
public function getConfigData($field, $paymentMethodCode, $storeId, $flag = false) public function getConfigData($field, $paymentMethodCode, $storeId, $flag = false)
{ {
......
...@@ -51,12 +51,15 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider ...@@ -51,12 +51,15 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider
*/ */
protected $paymentHelper; protected $paymentHelper;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $adyenHelper; protected $adyenHelper;
/** /**
* @param CcConfig $ccConfig * @param \Magento\Payment\Model\CcConfig $ccConfig
* @param PaymentHelper $paymentHelper * @param PaymentHelper $paymentHelper
* @param array $methodCodes * @param \Adyen\Payment\Helper\Data $adyenHelper
*/ */
public function __construct( public function __construct(
\Magento\Payment\Model\CcConfig $ccConfig, \Magento\Payment\Model\CcConfig $ccConfig,
......
...@@ -25,43 +25,52 @@ namespace Adyen\Payment\Model\Api; ...@@ -25,43 +25,52 @@ namespace Adyen\Payment\Model\Api;
class PaymentRequest extends \Magento\Framework\Object class PaymentRequest extends \Magento\Framework\Object
{ {
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $_scopeConfig; protected $_scopeConfig;
protected $_code;
/**
* @var \Psr\Log\LoggerInterface
*/
protected $_logger; protected $_logger;
/**
* @var \Magento\Framework\Encryption\EncryptorInterface
*/
protected $_encryptor; protected $_encryptor;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper; protected $_adyenHelper;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $_adyenLogger;
/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param array $data
*/
public function __construct( public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Psr\Log\LoggerInterface $logger, \Psr\Log\LoggerInterface $logger,
\Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
array $data = [] array $data = []
) { ) {
$this->_scopeConfig = $scopeConfig; $this->_scopeConfig = $scopeConfig;
$this->_logger = $logger; $this->_logger = $logger;
$this->_encryptor = $encryptor; $this->_encryptor = $encryptor;
$this->_code = "adyen_cc";
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
} $this->_adyenLogger = $adyenLogger;
/**
* Retrieve information from payment configuration
*
* @param string $field
* @param int|string|null|\Magento\Store\Model\Store $storeId
*
* @return mixed
*/
public function getConfigData($field, $paymentMethodCode = "adyen_abstract", $storeId = null)
{
if (null === $storeId) {
$storeId = $this->getStore();
}
// $this->_code to get current methodcode
$path = 'payment/' . $paymentMethodCode . '/' . $field;
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} }
public function fullApiRequest($payment) public function fullApiRequest($payment)
...@@ -71,7 +80,7 @@ class PaymentRequest extends \Magento\Framework\Object ...@@ -71,7 +80,7 @@ class PaymentRequest extends \Magento\Framework\Object
$customerEmail = $order->getCustomerEmail(); $customerEmail = $order->getCustomerEmail();
$shopperIp = $order->getRemoteIp(); $shopperIp = $order->getRemoteIp();
$orderCurrencyCode = $order->getOrderCurrencyCode(); $orderCurrencyCode = $order->getOrderCurrencyCode();
$merchantAccount = $this->getConfigData("merchant_account"); $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account");
$request = array( $request = array(
"action" => "Payment.authorise", "action" => "Payment.authorise",
...@@ -118,9 +127,8 @@ class PaymentRequest extends \Magento\Framework\Object ...@@ -118,9 +127,8 @@ class PaymentRequest extends \Magento\Framework\Object
} }
// TODO get CSE setting // If cse is enabled add encrypted card date into request
$cseEnabled = true; if($this->_adyenHelper->getAdyenCcConfigDataFlag('cse_enabled')) {
if($cseEnabled) {
$request['paymentRequest.additionalData.card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data"); $request['paymentRequest.additionalData.card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data");
} else { } else {
$requestCreditCardDetails = array("paymentRequest.card.expiryMonth" => $payment->getCcExpMonth(), $requestCreditCardDetails = array("paymentRequest.card.expiryMonth" => $payment->getCcExpMonth(),
...@@ -137,17 +145,13 @@ class PaymentRequest extends \Magento\Framework\Object ...@@ -137,17 +145,13 @@ class PaymentRequest extends \Magento\Framework\Object
protected function _apiRequest($request) protected function _apiRequest($request)
{ {
// log the request
$this->_adyenLogger->info('The request to adyen: ' . print_r($request, true));
// Use test or live credentials depends on demo mode
if($this->_adyenHelper->isDemoMode()) { $webserviceUsername = $this->_adyenHelper->getWsUsername();
$webserviceUsername = $this->getConfigData("ws_username_test"); $webservicePassword = $this->_adyenHelper->getWsPassword();
$webservicePassword = $this->decryptPassword($this->getConfigData("ws_password_test")); $url = $this->_adyenHelper->getWsUrl();
$url = "https://pal-test.adyen.com/pal/adapter/httppost";
} else {
$webserviceUsername = $this->getConfigData("ws_username_live");
$webservicePassword = $this->decryptPassword($this->getConfigData("ws_password_live"));
$url = "https://pal-live.adyen.com/pal/adapter/httppost";
}
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
...@@ -169,16 +173,20 @@ class PaymentRequest extends \Magento\Framework\Object ...@@ -169,16 +173,20 @@ class PaymentRequest extends \Magento\Framework\Object
throw new \Magento\Framework\Exception\LocalizedException(__('HTTP Status code' . $results)); throw new \Magento\Framework\Exception\LocalizedException(__('HTTP Status code' . $results));
} }
parse_str($results, $results); parse_str($results, $resultArr);
curl_close($ch); curl_close($ch);
return $results; // log the result
$this->_adyenLogger->info('The response to adyen: ' . print_r($resultArr, true));
return $resultArr;
} }
public function authorise3d($payment) public function authorise3d($payment)
{ {
$order = $payment->getOrder(); $order = $payment->getOrder();
$merchantAccount = $this->getConfigData("merchant_account"); $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account");
$shopperIp = $order->getRemoteIp(); $shopperIp = $order->getRemoteIp();
$md = $payment->getAdditionalInformation('md'); $md = $payment->getAdditionalInformation('md');
......
...@@ -31,12 +31,15 @@ class CaptureMode implements \Magento\Framework\Option\ArrayInterface ...@@ -31,12 +31,15 @@ class CaptureMode implements \Magento\Framework\Option\ArrayInterface
*/ */
protected $_orderConfig; protected $_orderConfig;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper; protected $_adyenHelper;
/** /**
* @param \Magento\Sales\Model\Order\Config $orderConfig * @param \Magento\Sales\Model\Order\Config $orderConfig
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/ */
public function __construct( public function __construct(
\Magento\Sales\Model\Order\Config $orderConfig, \Magento\Sales\Model\Order\Config $orderConfig,
......
...@@ -31,12 +31,14 @@ class DemoMode implements \Magento\Framework\Option\ArrayInterface ...@@ -31,12 +31,14 @@ class DemoMode implements \Magento\Framework\Option\ArrayInterface
*/ */
protected $_orderConfig; protected $_orderConfig;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper; protected $_adyenHelper;
/** /**
* @param \Magento\Sales\Model\Order\Config $orderConfig * @param \Magento\Sales\Model\Order\Config $orderConfig
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/ */
public function __construct( public function __construct(
\Magento\Sales\Model\Order\Config $orderConfig, \Magento\Sales\Model\Order\Config $orderConfig,
......
...@@ -31,12 +31,14 @@ class PaymentRoutine implements \Magento\Framework\Option\ArrayInterface ...@@ -31,12 +31,14 @@ class PaymentRoutine implements \Magento\Framework\Option\ArrayInterface
*/ */
protected $_orderConfig; protected $_orderConfig;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper; protected $_adyenHelper;
/** /**
* @param \Magento\Sales\Model\Order\Config $orderConfig * @param \Magento\Sales\Model\Order\Config $orderConfig
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/ */
public function __construct( public function __construct(
\Magento\Sales\Model\Order\Config $orderConfig, \Magento\Sales\Model\Order\Config $orderConfig,
......
...@@ -32,12 +32,14 @@ class RecurringType implements \Magento\Framework\Option\ArrayInterface ...@@ -32,12 +32,14 @@ class RecurringType implements \Magento\Framework\Option\ArrayInterface
*/ */
protected $_orderConfig; protected $_orderConfig;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper; protected $_adyenHelper;
/** /**
* @param \Magento\Sales\Model\Order\Config $orderConfig * @param \Magento\Sales\Model\Order\Config $orderConfig
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/ */
public function __construct( public function __construct(
\Magento\Sales\Model\Order\Config $orderConfig, \Magento\Sales\Model\Order\Config $orderConfig,
......
...@@ -34,10 +34,19 @@ class Cron ...@@ -34,10 +34,19 @@ class Cron
*/ */
protected $_logger; protected $_logger;
/**
* @var Resource\Notification\CollectionFactory
*/
protected $_notificationFactory; protected $_notificationFactory;
/**
* @var \Magento\Framework\Stdlib\DateTime
*/
protected $_datetime; protected $_datetime;
/**
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
*/
protected $_localeDate; protected $_localeDate;
/** /**
...@@ -57,6 +66,9 @@ class Cron ...@@ -57,6 +66,9 @@ class Cron
*/ */
protected $_scopeConfig; protected $_scopeConfig;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper; protected $_adyenHelper;
/** /**
...@@ -69,8 +81,9 @@ class Cron ...@@ -69,8 +81,9 @@ class Cron
*/ */
protected $_transactionFactory; protected $_transactionFactory;
/**
// notification attributes * notification attributes
*/
protected $_pspReference; protected $_pspReference;
protected $_merchantReference; protected $_merchantReference;
protected $_eventCode; protected $_eventCode;
...@@ -91,10 +104,16 @@ class Cron ...@@ -91,10 +104,16 @@ class Cron
*/ */
protected $_debugData = array(); protected $_debugData = array();
/** /**
* Constructor * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Adyen\Payment\Logger\Logger $logger * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param Resource\Notification\CollectionFactory $notificationFactory
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param OrderSender $orderSender
* @param \Magento\Framework\DB\TransactionFactory $transactionFactory
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
......
...@@ -38,6 +38,10 @@ class AdyenAbstract extends \Magento\Payment\Model\Method\AbstractMethod impleme ...@@ -38,6 +38,10 @@ class AdyenAbstract extends \Magento\Payment\Model\Method\AbstractMethod impleme
* @var string * @var string
*/ */
protected $_code = self::METHOD_CODE; protected $_code = self::METHOD_CODE;
/**
* @var bool
*/
protected $_isGateway = false; protected $_isGateway = false;
protected $_canAuthorize = false; protected $_canAuthorize = false;
protected $_isInitializeNeeded = false; protected $_isInitializeNeeded = false;
......
...@@ -49,16 +49,16 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -49,16 +49,16 @@ class Cc extends \Magento\Payment\Model\Method\Cc
* @var string * @var string
*/ */
protected $_formBlockType = 'Adyen\Payment\Block\Form\Cc'; protected $_formBlockType = 'Adyen\Payment\Block\Form\Cc';
protected $_infoBlockType = 'Adyen\Payment\Block\Info\Cc'; protected $_infoBlockType = 'Adyen\Payment\Block\Info\Cc';
//
// /**
// * @var string
// */
// protected $_infoBlockType = 'Adyen\Payment\Block\Info\Cc';
/**
* @var \Adyen\Payment\Model\Api\PaymentRequest
*/
protected $_paymentRequest; protected $_paymentRequest;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $_adyenLogger; protected $_adyenLogger;
/** /**
...@@ -66,22 +66,33 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -66,22 +66,33 @@ class Cc extends \Magento\Payment\Model\Method\Cc
*/ */
protected $_checkoutSession; protected $_checkoutSession;
/**
* @var \Magento\Framework\UrlInterface
*/
protected $_urlBuilder; protected $_urlBuilder;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper; protected $_adyenHelper;
/** /**
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
* @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory
* @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Payment\Model\Method\Logger $logger
* @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Module\ModuleListInterface $moduleList
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Model\Resource\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data * @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList) * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/ */
...@@ -141,7 +152,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -141,7 +152,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
parent::assignData($data); parent::assignData($data);
$infoInstance = $this->getInfoInstance(); $infoInstance = $this->getInfoInstance();
if($this->_adyenHelper->getAdyenAbstractConfigDataFlag('cse_enabled')) { if($this->_adyenHelper->getAdyenCcConfigDataFlag('cse_enabled')) {
if(isset($data['encrypted_data'])) { if(isset($data['encrypted_data'])) {
$infoInstance->setAdditionalInformation('encrypted_data', $data['encrypted_data']); $infoInstance->setAdditionalInformation('encrypted_data', $data['encrypted_data']);
} else { } else {
...@@ -183,7 +194,6 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -183,7 +194,6 @@ class Cc extends \Magento\Payment\Model\Method\Cc
protected function _processResponse(\Magento\Payment\Model\InfoInterface $payment, $response) protected function _processResponse(\Magento\Payment\Model\InfoInterface $payment, $response)
{ {
$payment->setAdditionalInformation('3dActive', false); $payment->setAdditionalInformation('3dActive', false);
switch ($response['paymentResult_resultCode']) { switch ($response['paymentResult_resultCode']) {
...@@ -193,18 +203,19 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -193,18 +203,19 @@ class Cc extends \Magento\Payment\Model\Method\Cc
$payment->setAdditionalInformation('pspReference', $response['paymentResult_pspReference']); $payment->setAdditionalInformation('pspReference', $response['paymentResult_pspReference']);
break; break;
case "RedirectShopper": case "RedirectShopper":
// 3d is active so set the param to true checked in Controller/Validate3d
$payment->setAdditionalInformation('3dActive', true); $payment->setAdditionalInformation('3dActive', true);
$IssuerUrl = $response['paymentResult_issuerUrl']; $issuerUrl = $response['paymentResult_issuerUrl'];
$PaReq = $response['paymentResult_paRequest']; $PaReq = $response['paymentResult_paRequest'];
$MD = $response['paymentResult_md']; $md = $response['paymentResult_md'];
$payment->setAdditionalInformation('issuerUrl', $response['paymentResult_issuerUrl']);
$payment->setAdditionalInformation('paRequest', $response['paymentResult_paRequest']);
$payment->setAdditionalInformation('md', $response['paymentResult_md']);
$result = $this->getResponse();
if(!empty($PaReq) && !empty($md) && !empty($issuerUrl)) {
$payment->setAdditionalInformation('issuerUrl', $response['paymentResult_issuerUrl']);
$payment->setAdditionalInformation('paRequest', $response['paymentResult_paRequest']);
$payment->setAdditionalInformation('md', $response['paymentResult_md']);
} else {
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure is not valid'));
}
break; break;
case "Refused": case "Refused":
// paymentResult_refusalReason // paymentResult_refusalReason
......
...@@ -59,6 +59,9 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -59,6 +59,9 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
protected $_canAuthorize = true; protected $_canAuthorize = true;
protected $_isInitializeNeeded = true; protected $_isInitializeNeeded = true;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper; protected $_adyenHelper;
...@@ -67,6 +70,9 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -67,6 +70,9 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
*/ */
protected $storeManager; protected $storeManager;
/**
* @var \Magento\Framework\UrlInterface
*/
protected $_urlBuilder; protected $_urlBuilder;
/** /**
...@@ -74,17 +80,20 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -74,17 +80,20 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
*/ */
protected $resolver; protected $resolver;
/** /**
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Locale\ResolverInterface $resolver
* @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
* @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory
* @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param Logger $logger * @param \Magento\Payment\Model\Method\Logger $logger
* @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Model\Resource\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data * @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList) * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/ */
......
...@@ -30,6 +30,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel ...@@ -30,6 +30,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel
implements NotificationInterface implements NotificationInterface
{ {
const AUTHORISATION = 'AUTHORISATION'; const AUTHORISATION = 'AUTHORISATION';
const PENDING = 'PENDING'; const PENDING = 'PENDING';
const AUTHORISED = 'AUTHORISED'; const AUTHORISED = 'AUTHORISED';
......
...@@ -25,6 +25,7 @@ namespace Adyen\Payment\Model\Resource; ...@@ -25,6 +25,7 @@ namespace Adyen\Payment\Model\Resource;
class Notification extends \Magento\Framework\Model\Resource\Db\AbstractDb class Notification extends \Magento\Framework\Model\Resource\Db\AbstractDb
{ {
public function _construct() public function _construct()
{ {
$this->_init('adyen_notification', 'entity_id'); $this->_init('adyen_notification', 'entity_id');
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
<demo_mode>0</demo_mode> <demo_mode>0</demo_mode>
<debug>1</debug> <debug>1</debug>
<group>adyen</group> <group>adyen</group>
<ws_url_test>https://pal-test.adyen.com/pal/adapter/httppost</ws_url_test>
<ws_url_live>https://pal-live.adyen.com/pal/adapter/httppost</ws_url_live>
</adyen_abstract> </adyen_abstract>
<adyen_cc> <adyen_cc>
<active>1</active> <active>1</active>
...@@ -43,6 +45,7 @@ ...@@ -43,6 +45,7 @@
<cctypes>AE,VI,MC,DI</cctypes> <cctypes>AE,VI,MC,DI</cctypes>
<useccv>1</useccv> <useccv>1</useccv>
<cse_enabled>1</cse_enabled> <cse_enabled>1</cse_enabled>
<payment_action>authorize</payment_action>
<group>adyen</group> <group>adyen</group>
</adyen_cc> </adyen_cc>
<adyen_hpp> <adyen_hpp>
...@@ -57,7 +60,6 @@ ...@@ -57,7 +60,6 @@
<sort_order>10</sort_order> <sort_order>10</sort_order>
<place_order_url>adyen/process/redirect</place_order_url> <place_order_url>adyen/process/redirect</place_order_url>
<order_place_redirect_url>adyen/process/redirect</order_place_redirect_url> <order_place_redirect_url>adyen/process/redirect</order_place_redirect_url>
<payment_action>authorize</payment_action>
<group>adyen</group> <group>adyen</group>
</adyen_hpp> </adyen_hpp>
</payment> </payment>
......
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