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 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 @@
namespace Adyen\Payment\Gateway\Http\Client;
use Magento\Payment\Gateway\Http\ClientInterface;
use Adyen\Payment\Model\ApplicationInfo;
/**
* Class TransactionSale
* Class TransactionAuthorization
*/
class TransactionAuthorization implements ClientInterface
{
......@@ -34,37 +35,31 @@ class TransactionAuthorization implements ClientInterface
/**
* @var \Adyen\Client
*/
protected $_client;
protected $client;
/**
* PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @var ApplicationInfo
*/
private $applicationInfo;
/**
* TransactionAuthorization constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
* @param ApplicationInfo $applicationInfo
* @throws \Adyen\AdyenException
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\RecurringType $recurringType,
array $data = []
\Adyen\Payment\Model\ApplicationInfo $applicationInfo
) {
$this->_encryptor = $encryptor;
$this->_adyenHelper = $adyenHelper;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
$this->_client = $this->_adyenHelper->initializeAdyenClient();
$this->applicationInfo = $applicationInfo;
$this->client = $adyenHelper->initializeAdyenClient();
}
/**
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
* @return mixed
* @throws ClientException
* @return array|mixed
* @throws \Adyen\AdyenException
*/
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
......@@ -78,7 +73,9 @@ class TransactionAuthorization implements ClientInterface
}
// call lib
$service = new \Adyen\Service\Payment($this->_client);
$service = new \Adyen\Service\Payment($this->client);
$request = $this->applicationInfo->addMerchantApplicationIntoRequest($request);
try {
$response = $service->authorise($request, $requestOptions);
......
......@@ -24,9 +24,10 @@
namespace Adyen\Payment\Gateway\Http\Client;
use Magento\Payment\Gateway\Http\ClientInterface;
use Adyen\Payment\Model\ApplicationInfo;
/**
* Class TransactionSale
* Class TransactionPayment
*/
class TransactionPayment implements ClientInterface
{
......@@ -36,21 +37,28 @@ class TransactionPayment implements ClientInterface
*/
private $adyenHelper;
/**
* @var ApplicationInfo
*/
private $applicationInfo;
/**
* TransactionPayment constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param ApplicationInfo $applicationInfo
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\ApplicationInfo $applicationInfo
) {
$this->adyenHelper = $adyenHelper;
$this->applicationInfo = $applicationInfo;
}
/**
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
* @return mixed
* @throws ClientException
* @return array|mixed|string
* @throws \Adyen\AdyenException
*/
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
......@@ -73,6 +81,8 @@ class TransactionPayment implements ClientInterface
$requestOptions['idempotencyKey'] = $headers['idempotencyKey'];
}
$request = $this->applicationInfo->addMerchantApplicationIntoRequest($request);
try {
$response = $service->payments($request, $requestOptions);
} catch (\Adyen\AdyenException $e) {
......
......@@ -24,6 +24,7 @@
namespace Adyen\Payment\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Adyen\Payment\Model\ApplicationInfo;
/**
* @SuppressWarnings(PHPMD.LongVariable)
......@@ -881,7 +882,8 @@ class Data extends AbstractHelper
*/
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 = json_decode($composerJson, true);
......@@ -1470,11 +1472,10 @@ class Data extends AbstractHelper
$client = $this->createAdyenClient();
$client->setApplicationName("Magento 2 plugin");
$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());
if ($this->isDemoMode($storeId)) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
......@@ -1761,6 +1762,7 @@ class Data extends AbstractHelper
return in_array(strtolower($country), $countryList);
}
/**
* Check if 3DS2.0 is enabled for credit cards
*
......
......@@ -26,7 +26,6 @@ namespace Adyen\Payment\Model;
use Adyen\Payment\Api\AdyenInitiateTerminalApiInterface;
use Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider;
use Adyen\Util\Util;
use Magento\Quote\Model\Quote;
class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
......@@ -263,10 +262,10 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
}
}
$saleToAcquirerData['applicationInfo']['merchantApplication']['version'] = $this->adyenHelper->getModuleVersion();
$saleToAcquirerData['applicationInfo']['merchantApplication']['name'] = $this->adyenHelper->getModuleName();
$saleToAcquirerData['applicationInfo']['externalPlatform']['version'] = $this->productMetadata->getVersion();
$saleToAcquirerData['applicationInfo']['externalPlatform']['name'] = $this->productMetadata->getName();
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::MERCHANT_APPLICATION][ApplicationInfo::VERSION] = $this->adyenHelper->getModuleVersion();
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::MERCHANT_APPLICATION][ApplicationInfo::NAME] = $this->adyenHelper->getModuleName();
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::EXTERNAL_PLATFORM][ApplicationInfo::VERSION] = $this->productMetadata->getVersion();
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::EXTERNAL_PLATFORM][ApplicationInfo::NAME] = $this->productMetadata->getName();
$saleToAcquirerDataBase64 = base64_encode(json_encode($saleToAcquirerData));
$request['SaleToPOIRequest']['PaymentRequest']['SaleData']['SaleToAcquirerData'] = $saleToAcquirerDataBase64;
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
*/
private $serializer;
/**
* @var \Magento\Framework\Notification\NotifierInterface
*/
private $notifierPool;
/**
* Cron constructor.
*
......@@ -270,7 +275,8 @@ class Cron
OrderRepository $orderRepository,
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel,
\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->_adyenLogger = $adyenLogger;
......@@ -293,6 +299,7 @@ class Cron
$this->agreementResourceModel = $agreementResourceModel;
$this->transactionBuilder = $transactionBuilder;
$this->serializer = $serializer;
$this->notifierPool = $notifierPool;
}
/**
......@@ -434,6 +441,10 @@ class Cron
'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 {
// Notification is successful
$this->_processNotification();
......@@ -512,8 +523,9 @@ class Cron
$this->_eventCode = $notification->getEventCode();
$this->_success = $notification->getSuccess();
$this->_paymentMethod = $notification->getPaymentMethod();
$this->_reason = $notification->getPaymentMethod();
$this->_reason = $notification->getReason();
$this->_value = $notification->getAmountValue();
$this->_live = $notification->getLive();
$additionalData = !empty($notification->getAdditionalData()) ? $this->serializer->unserialize($notification->getAdditionalData()) : "";
......@@ -853,7 +865,8 @@ class Cron
switch ($this->_eventCode) {
case Notification::REFUND_FAILED:
// do nothing only inform the merchant with order comment history
//Trigger admin notice for REFUND_FAILED notifications
$this->addRefundFailedNotice();
break;
case Notification::REFUND:
$ignoreRefundNotification = $this->_getConfigData(
......@@ -1867,4 +1880,17 @@ class Cron
$path = 'payment/' . $paymentMethodCode . '/' . $field;
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 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "5.2.0",
"version": "5.3.0",
"license": [
"OSL-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