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 7874697e authored by Rik ter Beek's avatar Rik ter Beek

Merge pull request #21 from Adyen/develop

Merge branch 'develop'
parents fd68c68f 9266c372
...@@ -28,10 +28,24 @@ namespace Adyen\Payment\Block\Adminhtml\System\Config\Field; ...@@ -28,10 +28,24 @@ namespace Adyen\Payment\Block\Adminhtml\System\Config\Field;
class Version extends \Magento\Config\Block\System\Config\Form\Field class Version extends \Magento\Config\Block\System\Config\Form\Field
{ {
/**
* @var \Magento\Framework\Module\ModuleListInterface
*/
protected $_moduleList;
public function __construct(
\Magento\Framework\Module\ModuleListInterface $moduleList,
\Magento\Backend\Block\Template\Context $context,
array $data = []
)
{
parent::__construct($context, $data);
$this->_moduleList = $moduleList;
}
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{ {
// make this dynamic return (string) $this->_moduleList->getOne("Adyen_Payment")['setup_version'];
//$configVer = $this->moduleList->getOne($moduleName)['setup_version'];
return (string) "0.1.0";
} }
} }
\ 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 Pos extends AbstractInfo
{
/**
* @var string
*/
protected $_template = 'Adyen_Payment::info/adyen_pos.phtml';
}
<?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\Redirect;
use Symfony\Component\Config\Definition\Exception\Exception;
class Pos extends \Magento\Payment\Block\Form
{
protected $_orderFactory;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $_checkoutSession;
/**
* @var \Magento\Checkout\Model\Order
*/
protected $_order;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param array $data
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Checkout\Model\Session $checkoutSession
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
array $data = [],
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Checkout\Model\Session $checkoutSession
)
{
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $checkoutSession;
parent::__construct($context, $data);
$this->_getOrder();
}
public function _prepareLayout()
{
return parent::_prepareLayout();
}
public function getLaunchLink()
{
$result = "";
try {
$order = $this->_order;
if($order->getPayment())
{
$result = $this->_order->getPayment()->getMethodInstance()->getLaunchLink();
}
} catch(Exception $e) {
// do nothing for now
throw($e);
}
return $result;
}
/**
* Get order object
*
* @return \Magento\Sales\Model\Order
*/
protected function _getOrder()
{
if (!$this->_order) {
$incrementId = $this->_getCheckout()->getLastRealOrderId();
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
}
return $this->_order;
}
/**
* Get frontend checkout session object
*
* @return \Magento\Checkout\Model\Session
*/
protected function _getCheckout()
{
return $this->_checkoutSession;
}
}
\ No newline at end of file
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Block; namespace Adyen\Payment\Block\Redirect;
use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\Config\Definition\Exception\Exception;
......
...@@ -21,9 +21,7 @@ ...@@ -21,9 +21,7 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Block; namespace Adyen\Payment\Block\Redirect;
use Symfony\Component\Config\Definition\Exception\Exception;
class Validate3d extends \Magento\Payment\Block\Form class Validate3d extends \Magento\Payment\Block\Form
{ {
......
...@@ -86,11 +86,11 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -86,11 +86,11 @@ class Json extends \Magento\Framework\App\Action\Action
foreach($notificationItems['notificationItems'] as $notificationItem) foreach($notificationItems['notificationItems'] as $notificationItem)
{ {
$status = $this->_processNotification($notificationItem['NotificationRequestItem'], $notificationMode); $status = $this->_processNotification($notificationItem['NotificationRequestItem'], $notificationMode);
if($status == "401"){ if($status != true) {
$this->_return401(); $this->_return401();
return; return;
} }
} }
$this->_adyenLogger->addAdyenNotification("The result is accepted"); $this->_adyenLogger->addAdyenNotification("The result is accepted");
...@@ -138,9 +138,7 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -138,9 +138,7 @@ class Json extends \Magento\Framework\App\Action\Action
{ {
// check if notificaiton already exists // check if notificaiton already exists
if(!$this->_isDuplicate($response)) { if(!$this->_isDuplicate($response)) {
try { try {
$notification = $this->_objectManager->create('Adyen\Payment\Model\Notification'); $notification = $this->_objectManager->create('Adyen\Payment\Model\Notification');
if (isset($response['pspReference'])) { if (isset($response['pspReference'])) {
...@@ -182,14 +180,16 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -182,14 +180,16 @@ class Json extends \Magento\Framework\App\Action\Action
$notification->save(); $notification->save();
return true;
} catch (Exception $e) { } catch (Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage())); throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()));
} }
} else {
// duplicated so do nothing but return accepted to Adyen
return true;
} }
} else {
return "401";
} }
return true; return false;
} }
......
<?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\Process;
class RedirectPos extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Quote\Model\Quote
*/
protected $_quote = false;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $_checkoutSession;
/**
* @var \Magento\Sales\Model\Order
*/
protected $_order;
/**
* @var \Magento\Sales\Model\OrderFactory
*/
protected $_orderFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
*/
public function __construct(
\Magento\Framework\App\Action\Context $context
) {
parent::__construct($context);
}
/**
* Return checkout session object
*
* @return \Magento\Checkout\Model\Session
*/
protected function _getCheckoutSession()
{
return $this->_checkoutSession;
}
public function execute()
{
$this->_view->loadLayout();
$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
}
/**
* Get order object
*
* @return \Magento\Sales\Model\Order
*/
protected function _getOrder()
{
if (!$this->_order) {
$incrementId = $this->_getCheckout()->getLastRealOrderId();
$this->_orderFactory = $this->_objectManager->get('Magento\Sales\Model\OrderFactory');
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
}
return $this->_order;
}
/**
* @return \Magento\Checkout\Model\Session
*/
protected function _getCheckout()
{
return $this->_objectManager->get('Magento\Checkout\Model\Session');
}
protected function _getQuote()
{
return $this->_objectManager->get('Magento\Quote\Model\Quote');
}
protected function _getQuoteManagement()
{
return $this->_objectManager->get('\Magento\Quote\Model\QuoteManagement');
}
}
\ No newline at end of file
...@@ -87,14 +87,19 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -87,14 +87,19 @@ class Result extends \Magento\Framework\App\Action\Action
$response = $this->getRequest()->getParams(); $response = $this->getRequest()->getParams();
$this->_adyenLogger->addAdyenResult(print_r($response, true)); $this->_adyenLogger->addAdyenResult(print_r($response, true));
$result = $this->validateResponse($response); if($response) {
$result = $this->validateResponse($response);
if ($result) { if ($result) {
$session = $this->_session; $session = $this->_session;
$session->getQuote()->setIsActive(false)->save(); $session->getQuote()->setIsActive(false)->save();
$this->_redirect('checkout/onepage/success'); $this->_redirect('checkout/onepage/success');
} else {
$this->_cancel($response);
$this->_redirect('checkout/cart');
}
} else { } else {
$this->_cancel($response); // redirect to checkout page
$this->_redirect('checkout/cart'); $this->_redirect('checkout/cart');
} }
} }
......
<?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\Process;
class ResultPos extends \Magento\Framework\App\Action\Action
{
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* @var \Magento\Sales\Model\OrderFactory
*/
protected $_orderFactory;
/**
* @var \Magento\Sales\Model\Order
*/
protected $_order;
/**
* @var \Magento\Sales\Model\Order\Status\HistoryFactory
*/
protected $_orderHistoryFactory;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $_session;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $_adyenLogger;
/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Sales\Model\Order\Status\HistoryFactory $orderHistoryFactory
* @param \Magento\Checkout\Model\Session $session
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Sales\Model\Order\Status\HistoryFactory $orderHistoryFactory,
\Magento\Checkout\Model\Session $session,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
) {
$this->_adyenHelper = $adyenHelper;
$this->_orderFactory = $orderFactory;
$this->_orderHistoryFactory = $orderHistoryFactory;
$this->_session = $session;
$this->_adyenLogger = $adyenLogger;
parent::__construct($context);
}
public function execute()
{
$response = $this->getRequest()->getParams();
$this->_adyenLogger->addAdyenResult(print_r($response, true));
$result = $this->_validateResponse($response);
if ($result) {
$session = $this->_session;
$session->getQuote()->setIsActive(false)->save();
$this->_redirect('checkout/onepage/success');
} else {
$this->_cancel($response);
$this->_redirect('checkout/cart');
}
}
private function _validateResponse($response)
{
$result = false;
if($response != null && $response['result'] != "" && $this->_validateChecksum($response)) {
$incrementId = $response['merchantReference'];
$responseResult = $response['result'];
if($incrementId) {
$order = $this->_getOrder($incrementId);
if ($order->getId()) {
$comment = __('%1 <br /> Result: %2 <br /> paymentMethod: %3', 'Adyen App Result URL Notification:', $responseResult, 'POS');
if($responseResult == 'APPROVED') {
$this->_adyenLogger->addAdyenResult('Result is approved');
$history = $this->_orderHistoryFactory->create()
//->setStatus($status)
->setComment($comment)
->setEntityName('order')
->setOrder($order)
;
$history->save();
// needed becuase then we need to save $order objects
$order->setAdyenResulturlEventCode("POS_APPROVED");
// save order
$order->save();
return true;
} else {
$this->_adyenLogger->addAdyenResult('Result is:' . $responseResult);
$history = $this->_orderHistoryFactory->create()
//->setStatus($status)
->setComment($comment)
->setEntityName('order')
->setOrder($order)
;
$history->save();
// cancel the order
if ($order->canCancel()) {
$order->cancel()->save();
$this->_adyenLogger->addAdyenResult('Order is cancelled');
} else {
$this->_adyenLogger->addAdyenResult('Order can not be cancelled');
}
}
} else {
$this->_adyenLogger->addAdyenResult('Order does not exists with increment_id: ' . $incrementId);
}
} else {
$this->_adyenLogger->addAdyenResult('Empty merchantReference');
}
} else {
$this->_adyenLogger->addAdyenResult('actionName or checksum failed or response is empty');
}
return $result;
}
protected function _validateChecksum($response)
{
$checksum = $response['cs'];
$result = $response['result'];
$amount = $response['originalCustomAmount'];
$currency = $response['originalCustomCurrency'];
$sessionId = $response['sessionId'];
// for android sessionis is with low i
if($sessionId == "") {
$sessionId = $response['sessionid'];
}
// calculate amount checksum
$amount_checksum = 0;
$amountLength = strlen($amount);
for($i=0;$i<$amountLength;$i++)
{
// ASCII value use ord
$checksumCalc = ord($amount[$i]) - 48;
$amount_checksum += $checksumCalc;
}
$currency_checksum = 0;
$currencyLength = strlen($currency);
for($i=0;$i<$currencyLength;$i++)
{
$checksumCalc = ord($currency[$i]) - 64;
$currency_checksum += $checksumCalc;
}
$result_checksum = 0;
$resultLength = strlen($result);
for($i=0;$i<$resultLength;$i++)
{
$checksumCalc = ord($result[$i]) - 64;
$result_checksum += $checksumCalc;
}
$sessionId_checksum = 0;
$sessionIdLength = strlen($sessionId);
for($i=0;$i<$sessionIdLength;$i++)
{
$checksumCalc = $this->_getAscii2Int($sessionId[$i]);
$sessionId_checksum += $checksumCalc;
}
$total_result_checksum = (($amount_checksum + $currency_checksum + $result_checksum) * $sessionId_checksum) % 100;
// check if request is valid
if($total_result_checksum == $checksum) {
$this->_adyenLogger->addAdyenResult('Checksum is valid');
return true;
}
$this->_adyenLogger->addAdyenResult('Checksum is invalid!');
return false;
}
protected function _getAscii2Int($ascii)
{
if (is_numeric($ascii)){
$int = ord($ascii) - 48;
} else {
$int = ord($ascii) - 64;
}
return $int;
}
protected function _getOrder($incrementId)
{
if (!$this->_order) {
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
}
return $this->_order;
}
protected function _cancel($response)
{
$session = $this->_session;
// restore the quote
$session->restoreQuote();
$order = $this->_order;
if($order) {
$this->_adyenHelper->cancelOrder($order);
if(isset($response['authResult']) && $response['authResult'] == \Adyen\Payment\Model\Notification::CANCELLED) {
$this->messageManager->addError(__('You have cancelled the order. Please try again'));
} else {
$this->messageManager->addError(__('Your payment failed, Please try again later'));
}
}
}
}
\ No newline at end of file
...@@ -263,7 +263,7 @@ class Data extends AbstractHelper ...@@ -263,7 +263,7 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_hpp configuration values * @desc Gives back adyen_oneclick configuration values
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -274,7 +274,7 @@ class Data extends AbstractHelper ...@@ -274,7 +274,7 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_hpp configuration values as flag * @desc Gives back adyen_oneclick configuration values as flag
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -284,6 +284,28 @@ class Data extends AbstractHelper ...@@ -284,6 +284,28 @@ class Data extends AbstractHelper
return $this->getConfigData($field, 'adyen_oneclick', $storeId, true); return $this->getConfigData($field, 'adyen_oneclick', $storeId, true);
} }
/**
* @desc Gives back adyen_pos configuration values
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenPosConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_pos', $storeId);
}
/**
* @desc Gives back adyen_pos configuration values as flag
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenPosConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_pos', $storeId, true);
}
/** /**
* @desc Retrieve decrypted hmac key * @desc Retrieve decrypted hmac key
* @return string * @return string
......
...@@ -109,26 +109,9 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider ...@@ -109,26 +109,9 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider
$config['payment']['adyenCc']['creditCardPaymentMethodIcon'] = $this->_getCreditCardPaymentMethodIcon(); $config['payment']['adyenCc']['creditCardPaymentMethodIcon'] = $this->_getCreditCardPaymentMethodIcon();
} }
foreach ($this->methodCodes as $code) {
if ($this->methods[$code]->isAvailable()) {
$config['payment']['adyenCc']['redirectUrl'][$code] = $this->getMethodRedirectUrl($code);
}
}
return $config; return $config;
} }
/**
* Return redirect URL for method
*
* @param string $code
* @return mixed
*/
protected function getMethodRedirectUrl($code)
{
return $this->methods[$code]->getCheckoutRedirectUrl();
}
protected function _getCreditCardPaymentMethodIcon() protected function _getCreditCardPaymentMethodIcon()
{ {
$asset = $this->_genericConfig->createAsset('Adyen_Payment::images/logos/img_trans.gif'); $asset = $this->_genericConfig->createAsset('Adyen_Payment::images/logos/img_trans.gif');
......
<?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\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Payment\Helper\Data as PaymentHelper;
class AdyenGenericConfigProvider implements ConfigProviderInterface
{
/**
* @var RequestInterface
*/
protected $request;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* @var \Magento\Payment\Model\Method\AbstractMethod[]
*/
protected $methods = [];
/**
* @var string[]
*/
protected $methodCodes = [
\Adyen\Payment\Model\Method\Cc::METHOD_CODE,
\Adyen\Payment\Model\Method\Hpp::METHOD_CODE,
\Adyen\Payment\Model\Method\Oneclick::METHOD_CODE,
\Adyen\Payment\Model\Method\Pos::METHOD_CODE
];
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Checkout\Model\Session $session
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param PaymentHelper $paymentHelper
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param AdyenGenericConfig $genericConfig
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Checkout\Model\Session $session,
\Magento\Store\Model\StoreManagerInterface $storeManager,
PaymentHelper $paymentHelper,
\Magento\Framework\Locale\ResolverInterface $localeResolver,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Model\AdyenGenericConfig $genericConfig
) {
$this->_appState = $context->getAppState();
$this->_session = $session;
$this->_storeManager = $storeManager;
$this->_paymentHelper = $paymentHelper;
$this->_localeResolver = $localeResolver;
$this->_config = $config;
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
$this->_genericConfig = $genericConfig;
foreach ($this->methodCodes as $code) {
$this->methods[$code] = $this->_paymentHelper->getMethodInstance($code);
}
}
/**
* Define foreach payment methods the RedirectUrl
*
* @return array
*/
public function getConfig()
{
$config = [
'payment' => []
];
foreach ($this->methodCodes as $code) {
if ($this->methods[$code]->isAvailable()) {
$config['payment'][$code] = [
'redirectUrl' => $this->getMethodRedirectUrl($code)
];
}
}
// show logos turned on by default
if($this->_genericConfig->showLogos()) {
$config['payment']['adyen']['showLogo'] = true;
} else {
$config['payment']['adyen']['showLogo'] = false;
}
return $config;
}
/**
* Return redirect URL for method
*
* @param string $code
* @return mixed
*/
protected function getMethodRedirectUrl($code)
{
return $this->methods[$code]->getCheckoutRedirectUrl();
}
}
\ No newline at end of file
...@@ -135,10 +135,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -135,10 +135,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
]; ];
foreach ($this->methodCodes as $code) { foreach ($this->methodCodes as $code) {
if ($this->methods[$code]->isAvailable()) { if ($this->methods[$code]->isAvailable()) {
$config['payment']['adyenHpp']['redirectUrl'][$code] = $this->getMethodRedirectUrl($code);
// get payment methods // get payment methods
$config['payment'] ['adyenHpp']['paymentMethods'] = $this->getAdyenHppPaymentMethods(); $config['payment'] ['adyenHpp']['paymentMethods'] = $this->getAdyenHppPaymentMethods();
} }
} }
...@@ -149,17 +146,6 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -149,17 +146,6 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
return $config; return $config;
} }
/**
* Return redirect URL for method
*
* @param string $code
* @return mixed
*/
protected function getMethodRedirectUrl($code)
{
return $this->methods[$code]->getCheckoutRedirectUrl();
}
public function getAdyenHppPaymentMethods() public function getAdyenHppPaymentMethods()
{ {
......
...@@ -144,7 +144,6 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider ...@@ -144,7 +144,6 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
foreach ($this->methodCodes as $code) { foreach ($this->methodCodes as $code) {
if ($this->methods[$code]->isAvailable()) { if ($this->methods[$code]->isAvailable()) {
$config['payment']['adyenOneclick']['redirectUrl'][$code] = $this->getMethodRedirectUrl($code);
$config['payment'] ['adyenOneclick']['billingAgreements'] = $this->getAdyenOneclickPaymentMethods(); $config['payment'] ['adyenOneclick']['billingAgreements'] = $this->getAdyenOneclickPaymentMethods();
$recurringContractType = $this->_getRecurringContractType(); $recurringContractType = $this->_getRecurringContractType();
...@@ -154,24 +153,12 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider ...@@ -154,24 +153,12 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
} else { } else {
$config['payment'] ['adyenOneclick']['hasCustomerInteraction'] = false; $config['payment'] ['adyenOneclick']['hasCustomerInteraction'] = false;
} }
$config['payment']['adyenOneclick']['redirectUrl'][$code] = $this->getMethodRedirectUrl($code);
} }
} }
return $config; return $config;
} }
/**
* Return redirect URL for method
*
* @param string $code
* @return mixed
*/
protected function getMethodRedirectUrl($code)
{
return $this->methods[$code]->getCheckoutRedirectUrl();
}
public function getAdyenOneclickPaymentMethods() public function getAdyenOneclickPaymentMethods()
{ {
...@@ -233,34 +220,6 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider ...@@ -233,34 +220,6 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
return $billingAgreements; return $billingAgreements;
} }
/**
* @param Adyen_Payment_Model_Billing_Agreement $billingAgreement
* @param Mage_Core_Model_Store $store
*
* @return bool
*/
protected function _createPaymentMethodFromBA($billingAgreement, $store)
{
$methodInstance = $billingAgreement->getPaymentMethodInstance();
if (! $methodInstance || ! $methodInstance->getConfigData('active', $store)) {
return false;
}
$methodNewCode = 'adyen_oneclick_'.$billingAgreement->getReferenceId();
$methodData = array('model' => 'adyen/adyen_oneclick')
+ $billingAgreement->getOneClickData()
+ Mage::getStoreConfig('payment/adyen_oneclick', $store);
foreach ($methodData as $key => $value) {
$store->setConfig('payment/'.$methodNewCode.'/'.$key, $value);
}
return true;
}
protected function _getRecurringContractType() protected function _getRecurringContractType()
{ {
return $this->_adyenHelper->getAdyenOneclickConfigData('recurring_payment_type'); return $this->_adyenHelper->getAdyenOneclickConfigData('recurring_payment_type');
......
...@@ -312,6 +312,9 @@ class PaymentRequest extends DataObject ...@@ -312,6 +312,9 @@ class PaymentRequest extends DataObject
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account"); $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account");
$currency = $payment->getOrder()->getBaseCurrencyCode(); $currency = $payment->getOrder()->getBaseCurrencyCode();
//format the amount to minor units
$amount = $this->_adyenHelper->formatAmount($amount, $currency);
$modificationAmount = array('currency' => $currency, 'value' => $amount); $modificationAmount = array('currency' => $currency, 'value' => $amount);
$request = array( $request = array(
...@@ -330,6 +333,12 @@ class PaymentRequest extends DataObject ...@@ -330,6 +333,12 @@ class PaymentRequest extends DataObject
throw new \Magento\Framework\Exception\LocalizedException(__('The capture action failed')); throw new \Magento\Framework\Exception\LocalizedException(__('The capture action failed'));
} }
// set pspReference as TransactionId so you can do an online refund
if(isset($result['pspReference'])) {
$payment->setTransactionId($result['pspReference'])
->setIsTransactionClosed(false);
}
return $result; return $result;
} }
...@@ -377,6 +386,9 @@ class PaymentRequest extends DataObject ...@@ -377,6 +386,9 @@ class PaymentRequest extends DataObject
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account"); $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account");
$currency = $payment->getOrder()->getBaseCurrencyCode(); $currency = $payment->getOrder()->getBaseCurrencyCode();
//format the amount to minor units
$amount = $this->_adyenHelper->formatAmount($amount, $currency);
$modificationAmount = array('currency' => $currency, 'value' => $amount); $modificationAmount = array('currency' => $currency, 'value' => $amount);
$request = array( $request = array(
......
...@@ -168,14 +168,13 @@ class Cron ...@@ -168,14 +168,13 @@ class Cron
$this->_adyenLogger->addAdyenNotificationCronjob("START OF THE CRONJOB"); $this->_adyenLogger->addAdyenNotificationCronjob("START OF THE CRONJOB");
//fixme somehow the created_at is saved in my timzone
$dateStart = new \DateTime(); $dateStart = new \DateTime();
// execute notifications from 2 minute or earlier because order could not yet been created by magento // execute notifications from 2 minute or earlier because order could not yet been created by magento
$dateStart = new \DateTime(); $dateStart = new \DateTime();
$dateStart->modify('-1 day'); $dateStart->modify('-1 day');
$dateEnd = new \DateTime(); $dateEnd = new \DateTime();
$dateEnd->modify('-2 minute'); $dateEnd->modify('-0 minute');
$dateRange = ['from' => $dateStart, 'to' => $dateEnd, 'datetime' => true]; $dateRange = ['from' => $dateStart, 'to' => $dateEnd, 'datetime' => true];
// create collection // create collection
...@@ -666,7 +665,6 @@ class Cron ...@@ -666,7 +665,6 @@ class Cron
} }
} }
if($contractDetail != null) { if($contractDetail != null) {
// update status of all the current saved agreements in magento // update status of all the current saved agreements in magento
...@@ -829,7 +827,7 @@ class Cron ...@@ -829,7 +827,7 @@ class Cron
// only do this if status in configuration is set // only do this if status in configuration is set
if(!empty($status)) { if(!empty($status)) {
$this->_order->addStatusHistoryComment(__('Payment is pre authorised waiting for capture'), $status); $this->_order->addStatusHistoryComment(__('Payment is authorised waiting for capture'), $status);
$this->_debugData['_setPrePaymentAuthorized'] = 'Order status is changed to Pre-authorised status, status is ' . $status; $this->_debugData['_setPrePaymentAuthorized'] = 'Order status is changed to Pre-authorised status, status is ' . $status;
} else { } else {
$this->_debugData['_setPrePaymentAuthorized'] = 'No pre-authorised status is used so ignore'; $this->_debugData['_setPrePaymentAuthorized'] = 'No pre-authorised status is used so ignore';
...@@ -1053,7 +1051,7 @@ class Cron ...@@ -1053,7 +1051,7 @@ class Cron
$invoice->getOrder()->setIsInProcess(true); $invoice->getOrder()->setIsInProcess(true);
// set transaction id so you can do a online refund from credit memo // set transaction id so you can do a online refund from credit memo
$invoice->setTransactionId(1); $invoice->setTransactionId($this->_pspReference);
$autoCapture = $this->_isAutoCapture(); $autoCapture = $this->_isAutoCapture();
$createPendingInvoice = (bool) $this->_getConfigData('create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId()); $createPendingInvoice = (bool) $this->_getConfigData('create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId());
......
...@@ -45,6 +45,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -45,6 +45,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
protected $_canCaptureOnce = true; protected $_canCaptureOnce = true;
protected $_canRefund = true; protected $_canRefund = true;
protected $_canRefundInvoicePartial = true; protected $_canRefundInvoicePartial = true;
protected $_isGateway = true;
/** /**
* @var string * @var string
......
...@@ -55,17 +55,14 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -55,17 +55,14 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
* *
* @var bool * @var bool
*/ */
protected $_isGateway = true;
protected $_canAuthorize = true; protected $_canAuthorize = true;
protected $_isInitializeNeeded = true; protected $_canCapture = true;
protected $_canCapturePartial = true;
protected $_canCaptureOnce = true;
protected $_canRefund = true; protected $_canRefund = true;
protected $_canRefundInvoicePartial = true; protected $_canRefundInvoicePartial = true;
protected $_isGateway = true;
/** protected $_isInitializeNeeded = true;
* Payment Method feature
*
* @var bool
*/
protected $_canUseInternal = false; protected $_canUseInternal = false;
...@@ -120,6 +117,7 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -120,6 +117,7 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
* @SuppressWarnings(PHPMD.ExcessiveParameterList) * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Adyen\Payment\Model\Api\PaymentRequest $paymentRequest, \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest,
\Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\UrlInterface $urlBuilder,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
...@@ -155,6 +153,7 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -155,6 +153,7 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
$this->storeManager = $storeManager; $this->storeManager = $storeManager;
$this->resolver = $resolver; $this->resolver = $resolver;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
$this->_request = $request;
} }
protected $_paymentMethodType = 'hpp'; protected $_paymentMethodType = 'hpp';
...@@ -211,7 +210,17 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -211,7 +210,17 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
*/ */
public function getCheckoutRedirectUrl() public function getCheckoutRedirectUrl()
{ {
return $this->_urlBuilder->getUrl('adyen/process/redirect'); return $this->_urlBuilder->getUrl('adyen/process/redirect',['_secure' => $this->_getRequest()->isSecure()]);
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected function _getRequest()
{
return $this->_request;
} }
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "adyen/module-payment", "name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module", "type": "magento2-module",
"version": "1.1.2", "version": "1.2.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
<include path="Adyen_Payment::system/adyen_cc.xml"/> <include path="Adyen_Payment::system/adyen_cc.xml"/>
<include path="Adyen_Payment::system/adyen_oneclick.xml"/> <include path="Adyen_Payment::system/adyen_oneclick.xml"/>
<include path="Adyen_Payment::system/adyen_hpp.xml"/> <include path="Adyen_Payment::system/adyen_hpp.xml"/>
<include path="Adyen_Payment::system/adyen_pos.xml"/>
</group> </group>
<group id="test" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> <group id="test" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test</label> <label>Test</label>
......
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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>
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<group id="adyen_pos" translate="label" type="text" sortOrder="300" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Point of Sale (POS) integration]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment>Process Point of Sales transactions</comment>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_pos/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
<config_path>payment/adyen_pos/title</config_path>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
<config_path>payment/adyen_pos/sort_order</config_path>
</field>
<field id="recurring_type" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Agreement Type</label>
<tooltip>You can set different value for POS because you have to have the permission of the customer</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\RecurringType</source_model>
<config_path>payment/adyen_pos/recurring_type</config_path>
</field>
<group id="adyen_pos_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200">
<label>Advanced Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="add_receipt_order_lines" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Add orderlines to receipt</label>
<tooltip>If you have the Adyen App configured to print to an external printer the orderlines can be printed on to the receipt if you turn this option on.</tooltip>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_pos/add_receipt_order_lines</config_path>
</field>
</group>
<group id="adyen_pos_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="210">
<label>Country Specific Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
<config_path>payment/adyen_pos/allowspecific</config_path>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
<config_path>payment/adyen_pos/specificcountry</config_path>
</field>
</group>
</group>
</include>
\ No newline at end of file
...@@ -50,23 +50,23 @@ ...@@ -50,23 +50,23 @@
<tooltip>Set a password of your choice and copy it over to Adyen Customer Area => Settings => Server Communication => Standard Notification => Password.</tooltip> <tooltip>Set a password of your choice and copy it over to Adyen Customer Area => Settings => Server Communication => Standard Notification => Password.</tooltip>
</field> </field>
<field id="ws_username_test" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="ws_username_test" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice username</label> <label>Webservice username for Test</label>
<tooltip>Find this in your Test Adyen Customer Area => Settings => Users => System. Normally this will be ws@Company.YourCompanyAccount. Copy and Paste the exact ws user name here.</tooltip> <tooltip>Find this in your Test Adyen Customer Area => Settings => Users => System. Normally this will be ws@Company.YourCompanyAccount. Copy and Paste the exact ws user name here.</tooltip>
<config_path>payment/adyen_abstract/ws_username_test</config_path> <config_path>payment/adyen_abstract/ws_username_test</config_path>
</field> </field>
<field id="ws_password_test" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="ws_password_test" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice Password</label> <label>Webservice Password for Test</label>
<tooltip>Find this in your Test Adyen Customer Area => Settings => Users => System. Click on your web service user and generate a new password. Copy and Paste the exact password here.</tooltip> <tooltip>Find this in your Test Adyen Customer Area => Settings => Users => System. Click on your web service user and generate a new password. Copy and Paste the exact password here.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/ws_password_test</config_path> <config_path>payment/adyen_abstract/ws_password_test</config_path>
</field> </field>
<field id="ws_username_live" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="ws_username_live" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice username</label> <label>Webservice username for Live</label>
<tooltip>This is only applicable if you have a Live account. Find this in your Live Adyen Customer Area => Settings => Users => System. Normally this will be ws@Company.YourCompanyAccount. Copy and Paste the exact ws user name here.</tooltip> <tooltip>This is only applicable if you have a Live account. Find this in your Live Adyen Customer Area => Settings => Users => System. Normally this will be ws@Company.YourCompanyAccount. Copy and Paste the exact ws user name here.</tooltip>
<config_path>payment/adyen_abstract/ws_username_live</config_path> <config_path>payment/adyen_abstract/ws_username_live</config_path>
</field> </field>
<field id="ws_password_live" translate="label" type="obscure" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="ws_password_live" translate="label" type="obscure" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice Password</label> <label>Webservice Password for Live</label>
<tooltip>This is only applicable if you have a Live account. Find this in your Live Adyen Customer Area => Settings => Users => System. Click on your web service user and generate a new password. Copy and Paste the exact password here.</tooltip> <tooltip>This is only applicable if you have a Live account. Find this in your Live Adyen Customer Area => Settings => Users => System. Click on your web service user and generate a new password. Copy and Paste the exact password here.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/ws_password_live</config_path> <config_path>payment/adyen_abstract/ws_password_live</config_path>
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<model>Adyen\Payment\Model\Method\Cc</model> <model>Adyen\Payment\Model\Method\Cc</model>
<title>Adyen CreditCard</title> <title>Adyen CreditCard</title>
<allowspecific>0</allowspecific> <allowspecific>0</allowspecific>
<sort_order>1</sort_order> <sort_order>2</sort_order>
<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>
...@@ -67,11 +67,22 @@ ...@@ -67,11 +67,22 @@
<payment_routine>single</payment_routine> <payment_routine>single</payment_routine>
<delivery_days>5</delivery_days> <delivery_days>5</delivery_days>
<allowspecific>0</allowspecific> <allowspecific>0</allowspecific>
<sort_order>10</sort_order> <sort_order>3</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>
<group>adyen</group> <group>adyen</group>
</adyen_hpp> </adyen_hpp>
<adyen_pos>
<active>0</active>
<model>Adyen\Payment\Model\Method\Pos</model>
<order_status>pending</order_status>
<title>Adyen POS</title>
<allowspecific>0</allowspecific>
<sort_order>4</sort_order>
<place_order_url>adyen/process/redirect</place_order_url>
<order_place_redirect_url>adyen/process/redirect</order_place_redirect_url>
<group>adyen</group>
</adyen_pos>
</payment> </payment>
</default> </default>
</config> </config>
...@@ -22,10 +22,12 @@ ...@@ -22,10 +22,12 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
--> -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Checkout\Model\CompositeConfigProvider"> <type name="Magento\Checkout\Model\CompositeConfigProvider">
<arguments> <arguments>
<argument name="configProviders" xsi:type="array"> <argument name="configProviders" xsi:type="array">
<item name="adyen_generic_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenGenericConfigProvider</item>
<item name="adyen_cc_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenCcConfigProvider</item> <item name="adyen_cc_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenCcConfigProvider</item>
<item name="adyen_oneclick_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenOneclickConfigProvider</item> <item name="adyen_oneclick_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenOneclickConfigProvider</item>
<item name="adyen_hpp_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenHppConfigProvider</item> <item name="adyen_hpp_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenHppConfigProvider</item>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
--> -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="1.1.2"> <module name="Adyen_Payment" setup_version="1.2.0">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
...@@ -48,4 +48,6 @@ ...@@ -48,4 +48,6 @@
"The payment is REFUSED because the saved card is removed. Please try an other payment method.","The payment is REFUSED because the saved card is removed. Please try an other payment method." "The payment is REFUSED because the saved card is removed. Please try an other payment method.","The payment is REFUSED because the saved card is removed. Please try an other payment method."
"The expiry month is not set. Please check your expiry month!","The expiry month is not set. Please check your expiry month!" "The expiry month is not set. Please check your expiry month!","The expiry month is not set. Please check your expiry month!"
"The payment is REFUSED","The payment is REFUSED" "The payment is REFUSED","The payment is REFUSED"
"Failed to disable this contract","Failed to disable this contract" "Failed to disable this contract","Failed to disable this contract"
\ No newline at end of file "You will be redirected to the Adyen App", "You will be redirected to the Adyen App"
"Continue to Adyen App", "Continue to Adyen App"
\ No newline at end of file
...@@ -24,6 +24,6 @@ ...@@ -24,6 +24,6 @@
--> -->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd"> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<container name="root"> <container name="root">
<block class="Adyen\Payment\Block\Redirect" name="adyen-form" template="form.phtml" cacheable="false"/> <block class="Adyen\Payment\Block\Redirect\Redirect" name="adyen-hpp-redirect-form" template="redirect/hpp/form.phtml" cacheable="false"/>
</container> </container>
</layout> </layout>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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>
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<container name="root">
<block class="Adyen\Payment\Block\Redirect\Pos" name="adyen-pos-redirect-form" template="redirect/pos/form.phtml" cacheable="false"/>
</container>
</layout>
\ No newline at end of file
...@@ -24,6 +24,6 @@ ...@@ -24,6 +24,6 @@
--> -->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd"> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<container name="root"> <container name="root">
<block class="Adyen\Payment\Block\Validate3d" name="adyen-form-validate3d" template="3dform.phtml" cacheable="false"/> <block class="Adyen\Payment\Block\Redirect\Validate3d" name="adyen-cc-form-validate3d" template="redirect/cc/3dform.phtml" cacheable="false"/>
</container> </container>
</layout> </layout>
\ No newline at end of file
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<!-- merge payment method renders here --> <!-- merge payment method renders here -->
<item name="children" xsi:type="array"> <item name="children" xsi:type="array">
<item name="adyen_payment" xsi:type="array"> <item name="adyen_payment" xsi:type="array">
<item name="component" xsi:type="string">Adyen_Payment/js/view/payment/cc-method</item> <item name="component" xsi:type="string">Adyen_Payment/js/view/payment/adyen-methods</item>
<item name="methods" xsi:type="array"> <item name="methods" xsi:type="array">
<item name="adyen_oneclick" xsi:type="array"> <item name="adyen_oneclick" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item> <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
......
...@@ -33,7 +33,7 @@ $_info = $this->getInfo(); ...@@ -33,7 +33,7 @@ $_info = $this->getInfo();
<dl class="payment-method adyen_hpp"> <dl class="payment-method adyen_hpp">
<?php if($paymentSelectionOnAdyen): ?> <?php if($paymentSelectionOnAdyen): ?>
<?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?><br/> <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?><br/>
<dt class="title"><?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?></dt> <dt class="title"><?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?></dt>
<?php else: ?> <?php else: ?>
......
<?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
$_info = $this->getInfo();
?>
<dl class="payment-method adyen_pos">
<?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?><br/>
<dt class="title"><?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?></dt>
</dl>
<?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>
*/
?>
<html>
<head>
</head>
<body>
<a id="adyen-pos-launchlink" href="<?php echo $block->getLaunchLink(); ?>">Continue</a>
<script>
document.getElementById('adyen-pos-launchlink').click();
</script>
</body>
</html>
...@@ -26,17 +26,31 @@ ...@@ -26,17 +26,31 @@
.checkout-payment-method .ccard .holdername .input-text { width: 225px; } .checkout-payment-method .ccard .holdername .input-text { width: 225px; }
.checkout-payment-method .payment-method-title, .checkout-payment-method .payment-method-title label { .checkout-payment-method .payment-method-title, .checkout-payment-method .payment-method-title label {
display: -webkit-flex;
display: flex; display: flex;
align-items: center; align-items: center;
-webkit-align-items: center;
} }
.checkout-payment-method .payment-method-title label img { margin-right:10px;} .checkout-payment-method .payment-method-title label img,
.checkout-payment-method .payment-method-title label div { padding-right:10px;}
.checkout-payment-method .payment-method-title label img.adyen_cc {
.checkout-payment-method .payment-method-title label div.adyen-sprite {
background:url(../images/logos/pm_gloss.png) no-repeat; background:url(../images/logos/pm_gloss.png) no-repeat;
background-position: 0 -272px; background-position: 0 -272px;
width:65px; width:65px;
height:42px; height:42px;
display: inline-block;
}
.checkout-payment-method .payment-method-title label div.adyen-sprite.adyen_cc {
background-position: 0 -272px;
}
.checkout-payment-method .payment-method-title label div.adyen-sprite.adyen_pos {
background-position: 0 -1819px;
} }
......
...@@ -66,11 +66,7 @@ define( ...@@ -66,11 +66,7 @@ define(
).done( ).done(
function () { function () {
if (redirectOnSuccess) { if (redirectOnSuccess) {
if(quote.paymentMethod().method == 'adyen_oneclick') { window.location.replace(url.build(window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl));
window.location.replace(url.build(window.checkoutConfig.payment.adyenOneclick.redirectUrl[quote.paymentMethod().method]));
} else {
window.location.replace(url.build(window.checkoutConfig.payment.adyenCc.redirectUrl[quote.paymentMethod().method]));
}
} }
} }
).fail( ).fail(
......
...@@ -81,7 +81,7 @@ define( ...@@ -81,7 +81,7 @@ define(
serviceUrl, JSON.stringify(payload) serviceUrl, JSON.stringify(payload)
).done( ).done(
function () { function () {
$.mage.redirect(window.checkoutConfig.payment.adyenHpp.redirectUrl[quote.paymentMethod().method]); $.mage.redirect(window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl);
} }
).fail( ).fail(
function (response) { function (response) {
......
...@@ -43,6 +43,10 @@ define( ...@@ -43,6 +43,10 @@ define(
{ {
type: 'adyen_hpp', type: 'adyen_hpp',
component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-hpp-method' component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-hpp-method'
},
{
type: 'adyen_pos',
component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-pos-method'
} }
); );
/** Add view logic here if needed */ /** Add view logic here if needed */
......
...@@ -170,8 +170,8 @@ define( ...@@ -170,8 +170,8 @@ define(
return true; return true;
}, },
getCreditCardPaymentMethodIcon: function() { showLogo: function() {
return window.checkoutConfig.payment.adyenCc.creditCardPaymentMethodIcon; return window.checkoutConfig.payment.adyen.showLogo;
} }
}); });
} }
......
...@@ -29,10 +29,9 @@ define( ...@@ -29,10 +29,9 @@ define(
'Adyen_Payment/js/action/set-payment-method', 'Adyen_Payment/js/action/set-payment-method',
'Magento_Checkout/js/action/select-payment-method', 'Magento_Checkout/js/action/select-payment-method',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/checkout-data', 'Magento_Checkout/js/checkout-data'
'Magento_Checkout/js/model/full-screen-loader',
], ],
function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction,quote, checkoutData, fullScreenLoader) { function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction,quote, checkoutData) {
'use strict'; 'use strict';
var brandCode = ko.observable(null); var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null); var paymentMethod = ko.observable(null);
...@@ -51,6 +50,36 @@ define( ...@@ -51,6 +50,36 @@ define(
]); ]);
return this; return this;
}, },
getAdyenHppPaymentMethods: function() {
var self = this;
// convert to list so you can iterate
var paymentList = _.map(window.checkoutConfig.payment.adyenHpp.paymentMethods, function(value, key) {
if(key == "ideal") {
return {
'value': key,
'name': value,
'method': self.item.method,
'issuerIds': value.issuers,
'issuerId': ko.observable(null),
getCode: function() {
return self.item.method;
}
}
} else {
return {
'value': key,
'name': value,
'method': self.item.method,
getCode: function() {
return self.item.method;
}
}
}
}
);
return paymentList;
},
/** Redirect to adyen */ /** Redirect to adyen */
continueToAdyen: function () { continueToAdyen: function () {
//update payment method information if additional data was changed //update payment method information if additional data was changed
...@@ -86,36 +115,6 @@ define( ...@@ -86,36 +115,6 @@ define(
setPaymentMethodAction(); setPaymentMethodAction();
return false; return false;
}, },
getAdyenHppPaymentMethods: function() {
var self = this;
// convert to list so you can iterate
var paymentList = _.map(window.checkoutConfig.payment.adyenHpp.paymentMethods, function(value, key) {
if(key == "ideal") {
return {
'value': key,
'name': value,
'method': self.item.method,
'issuerIds': value.issuers,
'issuerId': ko.observable(null),
getCode: function() {
return self.item.method;
}
}
} else {
return {
'value': key,
'name': value,
'method': self.item.method,
getCode: function() {
return self.item.method;
}
}
}
}
);
return paymentList;
},
selectPaymentMethodBrandCode: function() { selectPaymentMethodBrandCode: function() {
var self = this; var self = this;
...@@ -124,7 +123,6 @@ define( ...@@ -124,7 +123,6 @@ define(
"method": self.method, "method": self.method,
"po_number": null, "po_number": null,
"additional_data": { "additional_data": {
//brand_code: this.brandCode()
brand_code: self.value, brand_code: self.value,
} }
}; };
......
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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>
*/
/*browser:true*/
/*global define*/
define(
[
'ko',
'Magento_Checkout/js/view/payment/default',
'Adyen_Payment/js/action/set-payment-method'
],
function (ko, Component, setPaymentMethodAction) {
'use strict';
var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null);
return Component.extend({
self: this,
defaults: {
template: 'Adyen_Payment/payment/pos-form',
brandCode: ''
},
initObservable: function () {
this._super()
.observe([
]);
return this;
},
/** Redirect to adyen */
continueToAdyen: function () {
//update payment method information if additional data was changed
this.selectPaymentMethod();
setPaymentMethodAction();
return false;
},
showLogo: function() {
return window.checkoutConfig.payment.adyen.showLogo;
}
});
}
);
...@@ -29,15 +29,10 @@ ...@@ -29,15 +29,10 @@
data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/> data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/>
<label data-bind="attr: {'for': getCode()}" class="label"> <label data-bind="attr: {'for': getCode()}" class="label">
<!-- ko if: getCreditCardPaymentMethodIcon() --> <!-- ko if: showLogo() -->
<div data-bind="attr: { 'class': 'adyen-sprite ' + getCode() }"></div>
<img data-bind="attr: {
'class': getCode(),
'src': getCreditCardPaymentMethodIcon().url,
'width': '65',
'height': '42',
'border': '0'
}">
<!--/ko--> <!--/ko-->
<span data-bind="text: getTitle()"></span> <span data-bind="text: getTitle()"></span>
......
...@@ -23,14 +23,10 @@ ...@@ -23,14 +23,10 @@
--> -->
<!-- ko ifnot: (isPaymentMethodSelectionOnAdyen())--> <!-- ko ifnot: (isPaymentMethodSelectionOnAdyen())-->
<!-- ko foreach: getAdyenHppPaymentMethods() --> <!-- ko foreach: getAdyenHppPaymentMethods() -->
<div class="payment-method" data-bind="css: {'_active': (value == $parent.isBrandCodeChecked())}"> <div class="payment-method" data-bind="css: {'_active': (value == $parent.isBrandCodeChecked())}">
<div class="payment-method-title field choice"> <div class="payment-method-title field choice">
<input type="radio" <input type="radio"
name="payment[method]" name="payment[method]"
class="radio" class="radio"
...@@ -38,13 +34,11 @@ ...@@ -38,13 +34,11 @@
<label data-bind="attr: {'for': value}" class="label"> <label data-bind="attr: {'for': value}" class="label">
<!-- ko if: name.icon --> <!-- ko if: name.icon -->
<img data-bind="attr: { <img data-bind="attr: {
'src': name.icon.url, 'src': name.icon.url,
'width': name.icon.url.width, 'width': name.icon.url.width,
'height': name.icon.url.height 'height': name.icon.url.height
}"> }">
<!--/ko--> <!--/ko-->
<span data-bind="text: name.title"></span> <span data-bind="text: name.title"></span>
......
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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>
*/
-->
<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}">
<div class="payment-method-title field choice">
<input type="radio"
name="payment[method]"
class="radio"
data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/>
<label data-bind="attr: {'for': getCode()}" class="label">
<!-- ko if: showLogo() -->
<div data-bind="attr: { 'class': 'adyen-sprite ' + getCode() }"></div>
<!--/ko-->
<span data-bind="text: getTitle()"></span>
</label>
</div>
<div class="payment-method-content">
<div class="payment-method-billing-address">
<!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<fieldset class="fieldset" data-bind='attr: {id: "payment_form_" + getCode()}'>
<div class="payment-method-note">
<!-- ko text: $t('You will be redirected to the Adyen App.') --><!-- /ko -->
</div>
</fieldset>
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="click: continueToAdyen, enable: (getCode() == isChecked())"
disabled>
<span data-bind="text: $t('Continue to Adyen App')"></span>
</button>
</div>
</div>
</div>
</div>
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