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 d1635b1e authored by Giorgos Adam's avatar Giorgos Adam Committed by GitHub

Merge pull request #300 from Adyen/develop

Release 2.3.1
parents 527ab731 dee1944e
......@@ -261,8 +261,6 @@ class Redirect extends \Magento\Payment\Block\Form
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK);
$formFields['resURL'] = $baseUrl . 'adyen/process/result';
$hmacKey = $this->_adyenHelper->getHmac();
if ($brandCode) {
$formFields['brandCode'] = $brandCode;
......@@ -307,15 +305,9 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['dfValue'] = $this->_order->getPayment()->getAdditionalInformation("df_value");
}
// Sort the array by key using SORT_STRING order
ksort($formFields, SORT_STRING);
// Generate the signing data string
$signData = implode(":", array_map([$this, 'escapeString'],
array_merge(array_keys($formFields), array_values($formFields))));
$merchantSig = base64_encode(hash_hmac('sha256', $signData, pack("H*", $hmacKey), true));
// Sign request using secret key
$hmacKey = $this->_adyenHelper->getHmac();
$merchantSig = \Adyen\Util\Util::calculateSha256Signature($hmacKey, $formFields);
$formFields['merchantSig'] = $merchantSig;
$this->_adyenLogger->addAdyenDebug(print_r($formFields, true));
......
......@@ -99,7 +99,7 @@ class Json extends \Magento\Framework\App\Action\Action
$notificationMode = isset($notificationItems['live']) ? $notificationItems['live'] : "";
if ($notificationMode != "" && $this->_validateNotificationMode($notificationMode)) {
if ($notificationMode !== "" && $this->_validateNotificationMode($notificationMode)) {
foreach ($notificationItems['notificationItems'] as $notificationItem) {
......@@ -154,7 +154,8 @@ class Json extends \Magento\Framework\App\Action\Action
{
$mode = $this->_adyenHelper->getAdyenAbstractConfigData('demo_mode');
if (($mode == '1' && $notificationMode == "false") || ($mode == '0' && $notificationMode == 'true')) {
// Notification mode can be a string or a boolean
if (($mode == '1' && ($notificationMode == "false" || $notificationMode == false)) || ($mode == '0' && ($notificationMode == 'true' || $notificationMode == true))) {
return true;
}
return false;
......
......@@ -279,7 +279,6 @@ class Result extends \Magento\Framework\App\Action\Action
*/
protected function _authenticate($response) {
$hmacKey = $this->_adyenHelper->getHmac();
$merchantSigNotification = $response['merchantSig'];
// do it like this because $_GET is converting dot to underscore
......@@ -297,14 +296,9 @@ class Result extends \Magento\Framework\App\Action\Action
// do not include the merchantSig in the merchantSig calculation
unset($result['merchantSig']);
// Sort the array by key using SORT_STRING order
ksort($result, SORT_STRING);
// Generate the signing data string
$signData = implode(":", array_map([$this, 'escapeString'],
array_merge(array_keys($result), array_values($result))));
$merchantSig = base64_encode(hash_hmac('sha256', $signData, pack("H*", $hmacKey), true));
// Sign request using secret key
$hmacKey = $this->_adyenHelper->getHmac();
$merchantSig = \Adyen\Util\Util::calculateSha256Signature($hmacKey, $result);
if (strcmp($merchantSig, $merchantSigNotification) === 0) {
return true;
......
......@@ -199,15 +199,8 @@ class PayByMailCommand implements CommandInterface
$formFields['shopperReference'] = $customerId;
}
// Sort the array by key using SORT_STRING order
ksort($formFields, SORT_STRING);
// Generate the signing data string
$signData = implode(":", array_map([$this, 'escapeString'],
array_merge(array_keys($formFields), array_values($formFields))));
$merchantSig = base64_encode(hash_hmac('sha256', $signData, pack("H*", $hmacKey), true));
// Sign request using secret key
$merchantSig = \Adyen\Util\Util::calculateSha256Signature($hmacKey, $formFields);
$formFields['merchantSig'] = $merchantSig;
$this->_adyenLogger->addAdyenDebug(print_r($formFields, true));
......
......@@ -187,6 +187,11 @@ class Cron
*/
protected $_areaList;
/**
* @var \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory
*/
protected $_orderStatusCollection;
/**
* Cron constructor.
*
......@@ -203,7 +208,9 @@ class Cron
* @param Api\PaymentRequest $paymentRequest
* @param Order\PaymentFactory $adyenOrderPaymentFactory
* @param ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory
* @param InvoiceFactory $adyenInvoiceFactory
* @param AreaList $areaList
* @param \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
......@@ -220,8 +227,10 @@ class Cron
\Adyen\Payment\Model\Order\PaymentFactory $adyenOrderPaymentFactory,
\Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
\Adyen\Payment\Model\InvoiceFactory $adyenInvoiceFactory,
AreaList $areaList
) {
AreaList $areaList,
\Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection
)
{
$this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger;
$this->_notificationFactory = $notificationFactory;
......@@ -237,6 +246,7 @@ class Cron
$this->_adyenOrderPaymentCollectionFactory = $adyenOrderPaymentCollectionFactory;
$this->_adyenInvoiceFactory = $adyenInvoiceFactory;
$this->_areaList = $areaList;
$this->_orderStatusCollection = $orderStatusCollection;
}
/**
......@@ -645,6 +655,8 @@ class Cron
$acquirerReference = (isset($additionalData['acquirerReference'])) ?
$additionalData['acquirerReference'] : "";
$authCode = (isset($additionalData['authCode'])) ? $additionalData['authCode'] : "";
$cardBin = (isset($additionalData['cardBin'])) ? $additionalData['cardBin'] : "";
$expiryDate = (isset($additionalData['expiryDate'])) ? $additionalData['expiryDate'] : "";
}
// if there is no server communication setup try to get last4 digits from reason field
......@@ -685,6 +697,12 @@ class Cron
if (isset($authCode) && $authCode != "") {
$this->_order->getPayment()->setAdditionalInformation('adyen_auth_code', $authCode);
}
if (!empty($cardBin)) {
$this->_order->getPayment()->setAdditionalInformation('adyen_card_bin', $cardBin);
}
if (!empty($expiryDate)) {
$this->_order->getPayment()->setAdditionalInformation('adyen_expiry_date', $expiryDate);
}
}
/**
......@@ -1137,6 +1155,8 @@ class Cron
// only do this if status in configuration is set
if (!empty($status)) {
$this->_order->addStatusHistoryComment(__('Payment is authorised waiting for capture'), $status);
$this->_setState($status);
$this->_adyenLogger->addAdyenNotificationCronjob(
'Order status is changed to Pre-authorised status, status is ' . $status
);
......@@ -1594,14 +1614,30 @@ class Cron
$comment = "Adyen Payment is in Manual Review check the Adyen platform";
}
}
$status = (!empty($status)) ? $status : $this->_order->getStatus();
$this->_order->addStatusHistoryComment(__($comment), $status);
$this->_setState($status);
$this->_adyenLogger->addAdyenNotificationCronjob(
'Order status is changed to authorised status, status is ' . $status
);
}
/**
* Set State from Status
*/
protected function _setState($status)
{
$statusObject = $this->_orderStatusCollection->create()
->addFieldToFilter('main_table.status', $status)
->addFieldToFilter('state_table.is_default', true)
->joinStates()
->getFirstItem();
$this->_order->setState($statusObject->getState());
$this->_adyenLogger->addAdyenNotificationCronjob('State is changed to ' . $statusObject->getState());
}
/**
* Create shipment
......
......@@ -48,9 +48,22 @@ class DataTest extends \PHPUnit\Framework\TestCase
$assetRepo = $this->getSimpleMock(\Magento\Framework\View\Asset\Repository::class);
$assetSource = $this->getSimpleMock(\Magento\Framework\View\Asset\Source::class);
$notificationFactory = $this->getSimpleMock(\Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory::class);
$taxConfig = $this->getSimpleMock(\Magento\Tax\Model\Config::class);
$taxCalculation = $this->getSimpleMock(\Magento\Tax\Model\Calculation::class);
$this->dataHelper = new \Adyen\Payment\Helper\Data($context, $encryptor, $dataStorage, $country, $moduleList,
$billingAgreementCollectionFactory, $assetRepo, $assetSource, $notificationFactory);
$this->dataHelper = new \Adyen\Payment\Helper\Data(
$context,
$encryptor,
$dataStorage,
$country,
$moduleList,
$billingAgreementCollectionFactory,
$assetRepo,
$assetSource,
$notificationFactory,
$taxConfig,
$taxCalculation
);
}
public function testFormatAmount()
......
......@@ -2,7 +2,7 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "2.3.0",
"version": "2.3.1",
"license": [
"OSL-3.0",
"AFL-3.0"
......
......@@ -24,7 +24,7 @@
-->
<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="2.3.0">
<module name="Adyen_Payment" setup_version="2.3.1">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
......
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