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 1a3da231 authored by Ángel Campos's avatar Ángel Campos Committed by GitHub

Merge pull request #636 from Adyen/develop

Release 5.3.0
parents 0773826f a0f0e8af
...@@ -24,9 +24,10 @@ ...@@ -24,9 +24,10 @@
namespace Adyen\Payment\Gateway\Http\Client; namespace Adyen\Payment\Gateway\Http\Client;
use Magento\Payment\Gateway\Http\ClientInterface; use Magento\Payment\Gateway\Http\ClientInterface;
use Adyen\Payment\Model\ApplicationInfo;
/** /**
* Class TransactionSale * Class TransactionAuthorization
*/ */
class TransactionAuthorization implements ClientInterface class TransactionAuthorization implements ClientInterface
{ {
...@@ -34,37 +35,31 @@ class TransactionAuthorization implements ClientInterface ...@@ -34,37 +35,31 @@ class TransactionAuthorization implements ClientInterface
/** /**
* @var \Adyen\Client * @var \Adyen\Client
*/ */
protected $_client; protected $client;
/** /**
* PaymentRequest constructor. * @var ApplicationInfo
* */
* @param \Magento\Framework\Model\Context $context private $applicationInfo;
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
/**
* TransactionAuthorization constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger * @param ApplicationInfo $applicationInfo
* @param \Adyen\Payment\Model\RecurringType $recurringType * @throws \Adyen\AdyenException
* @param array $data
*/ */
public function __construct( public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\RecurringType $recurringType, \Adyen\Payment\Model\ApplicationInfo $applicationInfo
array $data = []
) { ) {
$this->_encryptor = $encryptor; $this->applicationInfo = $applicationInfo;
$this->_adyenHelper = $adyenHelper; $this->client = $adyenHelper->initializeAdyenClient();
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
$this->_client = $this->_adyenHelper->initializeAdyenClient();
} }
/** /**
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject * @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
* @return mixed * @return array|mixed
* @throws ClientException * @throws \Adyen\AdyenException
*/ */
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject) public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{ {
...@@ -78,7 +73,9 @@ class TransactionAuthorization implements ClientInterface ...@@ -78,7 +73,9 @@ class TransactionAuthorization implements ClientInterface
} }
// call lib // call lib
$service = new \Adyen\Service\Payment($this->_client); $service = new \Adyen\Service\Payment($this->client);
$request = $this->applicationInfo->addMerchantApplicationIntoRequest($request);
try { try {
$response = $service->authorise($request, $requestOptions); $response = $service->authorise($request, $requestOptions);
......
...@@ -24,9 +24,10 @@ ...@@ -24,9 +24,10 @@
namespace Adyen\Payment\Gateway\Http\Client; namespace Adyen\Payment\Gateway\Http\Client;
use Magento\Payment\Gateway\Http\ClientInterface; use Magento\Payment\Gateway\Http\ClientInterface;
use Adyen\Payment\Model\ApplicationInfo;
/** /**
* Class TransactionSale * Class TransactionPayment
*/ */
class TransactionPayment implements ClientInterface class TransactionPayment implements ClientInterface
{ {
...@@ -36,21 +37,28 @@ class TransactionPayment implements ClientInterface ...@@ -36,21 +37,28 @@ class TransactionPayment implements ClientInterface
*/ */
private $adyenHelper; private $adyenHelper;
/**
* @var ApplicationInfo
*/
private $applicationInfo;
/** /**
* TransactionPayment constructor. * TransactionPayment constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param ApplicationInfo $applicationInfo
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\ApplicationInfo $applicationInfo
) { ) {
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->applicationInfo = $applicationInfo;
} }
/** /**
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject * @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
* @return mixed * @return array|mixed|string
* @throws ClientException * @throws \Adyen\AdyenException
*/ */
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject) public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{ {
...@@ -73,6 +81,8 @@ class TransactionPayment implements ClientInterface ...@@ -73,6 +81,8 @@ class TransactionPayment implements ClientInterface
$requestOptions['idempotencyKey'] = $headers['idempotencyKey']; $requestOptions['idempotencyKey'] = $headers['idempotencyKey'];
} }
$request = $this->applicationInfo->addMerchantApplicationIntoRequest($request);
try { try {
$response = $service->payments($request, $requestOptions); $response = $service->payments($request, $requestOptions);
} catch (\Adyen\AdyenException $e) { } catch (\Adyen\AdyenException $e) {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
namespace Adyen\Payment\Helper; namespace Adyen\Payment\Helper;
use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\AbstractHelper;
use Adyen\Payment\Model\ApplicationInfo;
/** /**
* @SuppressWarnings(PHPMD.LongVariable) * @SuppressWarnings(PHPMD.LongVariable)
...@@ -881,7 +882,8 @@ class Data extends AbstractHelper ...@@ -881,7 +882,8 @@ class Data extends AbstractHelper
*/ */
public function getModuleVersion() public function getModuleVersion()
{ {
$moduleDir = $this->componentRegistrar->getPath(\Magento\Framework\Component\ComponentRegistrar::MODULE, 'Adyen_Payment'); $moduleDir = $this->componentRegistrar->getPath(\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Adyen_Payment');
$composerJson = file_get_contents($moduleDir . '/composer.json'); $composerJson = file_get_contents($moduleDir . '/composer.json');
$composerJson = json_decode($composerJson, true); $composerJson = json_decode($composerJson, true);
...@@ -1470,11 +1472,10 @@ class Data extends AbstractHelper ...@@ -1470,11 +1472,10 @@ class Data extends AbstractHelper
$client = $this->createAdyenClient(); $client = $this->createAdyenClient();
$client->setApplicationName("Magento 2 plugin"); $client->setApplicationName("Magento 2 plugin");
$client->setXApiKey($apiKey); $client->setXApiKey($apiKey);
$moduleVersion = $this->getModuleVersion();
$client->setAdyenPaymentSource($this->getModuleName(), $this->getModuleVersion()); $client->setAdyenPaymentSource($this->getModuleName(), $moduleVersion);
$client->setExternalPlatform($this->productMetadata->getName(), $this->productMetadata->getVersion()); $client->setExternalPlatform($this->productMetadata->getName(), $this->productMetadata->getVersion());
if ($this->isDemoMode($storeId)) { if ($this->isDemoMode($storeId)) {
$client->setEnvironment(\Adyen\Environment::TEST); $client->setEnvironment(\Adyen\Environment::TEST);
} else { } else {
...@@ -1761,6 +1762,7 @@ class Data extends AbstractHelper ...@@ -1761,6 +1762,7 @@ class Data extends AbstractHelper
return in_array(strtolower($country), $countryList); return in_array(strtolower($country), $countryList);
} }
/** /**
* Check if 3DS2.0 is enabled for credit cards * Check if 3DS2.0 is enabled for credit cards
* *
......
...@@ -26,7 +26,6 @@ namespace Adyen\Payment\Model; ...@@ -26,7 +26,6 @@ namespace Adyen\Payment\Model;
use Adyen\Payment\Api\AdyenInitiateTerminalApiInterface; use Adyen\Payment\Api\AdyenInitiateTerminalApiInterface;
use Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider; use Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider;
use Adyen\Util\Util;
use Magento\Quote\Model\Quote; use Magento\Quote\Model\Quote;
class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
...@@ -263,10 +262,10 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -263,10 +262,10 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
} }
} }
$saleToAcquirerData['applicationInfo']['merchantApplication']['version'] = $this->adyenHelper->getModuleVersion(); $saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::MERCHANT_APPLICATION][ApplicationInfo::VERSION] = $this->adyenHelper->getModuleVersion();
$saleToAcquirerData['applicationInfo']['merchantApplication']['name'] = $this->adyenHelper->getModuleName(); $saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::MERCHANT_APPLICATION][ApplicationInfo::NAME] = $this->adyenHelper->getModuleName();
$saleToAcquirerData['applicationInfo']['externalPlatform']['version'] = $this->productMetadata->getVersion(); $saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::EXTERNAL_PLATFORM][ApplicationInfo::VERSION] = $this->productMetadata->getVersion();
$saleToAcquirerData['applicationInfo']['externalPlatform']['name'] = $this->productMetadata->getName(); $saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::EXTERNAL_PLATFORM][ApplicationInfo::NAME] = $this->productMetadata->getName();
$saleToAcquirerDataBase64 = base64_encode(json_encode($saleToAcquirerData)); $saleToAcquirerDataBase64 = base64_encode(json_encode($saleToAcquirerData));
$request['SaleToPOIRequest']['PaymentRequest']['SaleData']['SaleToAcquirerData'] = $saleToAcquirerDataBase64; $request['SaleToPOIRequest']['PaymentRequest']['SaleData']['SaleToAcquirerData'] = $saleToAcquirerDataBase64;
return $request; return $request;
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2020 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model;
class ApplicationInfo
{
const APPLICATION_INFO = 'applicationInfo';
const MERCHANT_APPLICATION = 'merchantApplication';
const EXTERNAL_PLATFORM = 'externalPlatform';
const NAME = 'name';
const VERSION = 'version';
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* ApplicationInfo constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->adyenHelper = $adyenHelper;
}
/**
* Add this application into request as we are missing the client function in the current library version
* when we upgrade to latest version we can use the client method instead
*
* @param $request
* @return mixed
*/
public function addMerchantApplicationIntoRequest($request)
{
// add applicationInfo into request
$request[self::APPLICATION_INFO][self::MERCHANT_APPLICATION][self::NAME] = $this->adyenHelper->getModuleName();
$request[self::APPLICATION_INFO][self::MERCHANT_APPLICATION][self::VERSION] = $this->adyenHelper->getModuleVersion();
return $request;
}
}
...@@ -225,6 +225,11 @@ class Cron ...@@ -225,6 +225,11 @@ class Cron
*/ */
private $serializer; private $serializer;
/**
* @var \Magento\Framework\Notification\NotifierInterface
*/
private $notifierPool;
/** /**
* Cron constructor. * Cron constructor.
* *
...@@ -270,7 +275,8 @@ class Cron ...@@ -270,7 +275,8 @@ class Cron
OrderRepository $orderRepository, OrderRepository $orderRepository,
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel, \Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel,
\Magento\Sales\Model\Order\Payment\Transaction\Builder $transactionBuilder, \Magento\Sales\Model\Order\Payment\Transaction\Builder $transactionBuilder,
\Magento\Framework\Serialize\SerializerInterface $serializer \Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Framework\Notification\NotifierInterface $notifierPool
) { ) {
$this->_scopeConfig = $scopeConfig; $this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
...@@ -293,6 +299,7 @@ class Cron ...@@ -293,6 +299,7 @@ class Cron
$this->agreementResourceModel = $agreementResourceModel; $this->agreementResourceModel = $agreementResourceModel;
$this->transactionBuilder = $transactionBuilder; $this->transactionBuilder = $transactionBuilder;
$this->serializer = $serializer; $this->serializer = $serializer;
$this->notifierPool = $notifierPool;
} }
/** /**
...@@ -434,6 +441,10 @@ class Cron ...@@ -434,6 +441,10 @@ class Cron
'Order is already processed so ignore this notification state is:' . $this->_order->getState() 'Order is already processed so ignore this notification state is:' . $this->_order->getState()
); );
} }
//Trigger admin notice for unsuccessful REFUND notifications
if ($this->_eventCode == Notification::REFUND){
$this->addRefundFailedNotice();
}
} else { } else {
// Notification is successful // Notification is successful
$this->_processNotification(); $this->_processNotification();
...@@ -512,8 +523,9 @@ class Cron ...@@ -512,8 +523,9 @@ class Cron
$this->_eventCode = $notification->getEventCode(); $this->_eventCode = $notification->getEventCode();
$this->_success = $notification->getSuccess(); $this->_success = $notification->getSuccess();
$this->_paymentMethod = $notification->getPaymentMethod(); $this->_paymentMethod = $notification->getPaymentMethod();
$this->_reason = $notification->getPaymentMethod(); $this->_reason = $notification->getReason();
$this->_value = $notification->getAmountValue(); $this->_value = $notification->getAmountValue();
$this->_live = $notification->getLive();
$additionalData = !empty($notification->getAdditionalData()) ? $this->serializer->unserialize($notification->getAdditionalData()) : ""; $additionalData = !empty($notification->getAdditionalData()) ? $this->serializer->unserialize($notification->getAdditionalData()) : "";
...@@ -853,7 +865,8 @@ class Cron ...@@ -853,7 +865,8 @@ class Cron
switch ($this->_eventCode) { switch ($this->_eventCode) {
case Notification::REFUND_FAILED: case Notification::REFUND_FAILED:
// do nothing only inform the merchant with order comment history //Trigger admin notice for REFUND_FAILED notifications
$this->addRefundFailedNotice();
break; break;
case Notification::REFUND: case Notification::REFUND:
$ignoreRefundNotification = $this->_getConfigData( $ignoreRefundNotification = $this->_getConfigData(
...@@ -1867,4 +1880,17 @@ class Cron ...@@ -1867,4 +1880,17 @@ class Cron
$path = 'payment/' . $paymentMethodCode . '/' . $field; $path = 'payment/' . $paymentMethodCode . '/' . $field;
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId); return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} }
/**
* Add admin notice message for refund failed notification
*
* @return void
*/
protected function addRefundFailedNotice(){
$this->notifierPool->addNotice(
__("Adyen: Refund for order #%1 has failed", $this->_merchantReference),
__("Reason: %1 | PSPReference: %2 | You can go to Adyen Customer Area and trigger this refund manually or contact our support.", $this->_reason, $this->_pspReference),
sprintf("https://ca-%s.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%s", $this->_live === 'true' ? 'live' : 'test', $this->_pspReference)
);
}
} }
...@@ -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": "5.2.0", "version": "5.3.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
......
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