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 733bd419 authored by cyattilakiss's avatar cyattilakiss Committed by GitHub

Merge pull request #324 from Adyen/develop

Release 2.3.3
parents 24df1cac c7bd96bd
...@@ -60,25 +60,7 @@ class TransactionAuthorization implements ClientInterface ...@@ -60,25 +60,7 @@ class TransactionAuthorization implements ClientInterface
$this->_recurringType = $recurringType; $this->_recurringType = $recurringType;
$this->_appState = $context->getAppState(); $this->_appState = $context->getAppState();
// initialize client $this->_client = $this->_adyenHelper->initializeAdyenClient();
$webserviceUsername = $this->_adyenHelper->getWsUsername();
$webservicePassword = $this->_adyenHelper->getWsPassword();
$client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
if ($this->_adyenHelper->isDemoMode()) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
$client->setEnvironment(\Adyen\Environment::LIVE);
}
// assign magento log
$client->setLogger($adyenLogger);
$this->_client = $client;
} }
/** /**
......
...@@ -55,25 +55,7 @@ class TransactionCancel implements ClientInterface ...@@ -55,25 +55,7 @@ class TransactionCancel implements ClientInterface
$this->_recurringType = $recurringType; $this->_recurringType = $recurringType;
$this->_appState = $context->getAppState(); $this->_appState = $context->getAppState();
// initialize client $this->_client = $this->_adyenHelper->initializeAdyenClient();
$webserviceUsername = $this->_adyenHelper->getWsUsername();
$webservicePassword = $this->_adyenHelper->getWsPassword();
$client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
if ($this->_adyenHelper->isDemoMode()) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
$client->setEnvironment(\Adyen\Environment::LIVE);
}
// assign magento log
$client->setLogger($adyenLogger);
$this->_client = $client;
} }
/** /**
......
...@@ -55,25 +55,7 @@ class TransactionCapture implements ClientInterface ...@@ -55,25 +55,7 @@ class TransactionCapture implements ClientInterface
$this->_recurringType = $recurringType; $this->_recurringType = $recurringType;
$this->_appState = $context->getAppState(); $this->_appState = $context->getAppState();
// initialize client $this->_client = $this->_adyenHelper->initializeAdyenClient();
$webserviceUsername = $this->_adyenHelper->getWsUsername();
$webservicePassword = $this->_adyenHelper->getWsPassword();
$client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
if ($this->_adyenHelper->isDemoMode()) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
$client->setEnvironment(\Adyen\Environment::LIVE);
}
// assign magento log
$client->setLogger($adyenLogger);
$this->_client = $client;
} }
/** /**
......
...@@ -55,25 +55,7 @@ class TransactionRefund implements ClientInterface ...@@ -55,25 +55,7 @@ class TransactionRefund implements ClientInterface
$this->_recurringType = $recurringType; $this->_recurringType = $recurringType;
$this->_appState = $context->getAppState(); $this->_appState = $context->getAppState();
// initialize client $this->_client = $this->_adyenHelper->initializeAdyenClient();
$webserviceUsername = $this->_adyenHelper->getWsUsername();
$webservicePassword = $this->_adyenHelper->getWsPassword();
$client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
if ($this->_adyenHelper->isDemoMode()) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
$client->setEnvironment(\Adyen\Environment::LIVE);
}
// assign magento log
$client->setLogger($adyenLogger);
$this->_client = $client;
} }
/** /**
......
...@@ -62,15 +62,33 @@ class AddressDataBuilder implements BuilderInterface ...@@ -62,15 +62,33 @@ class AddressDataBuilder implements BuilderInterface
$billingAddress = $order->getBillingAddress(); $billingAddress = $order->getBillingAddress();
if ($billingAddress) { if ($billingAddress) {
// filter housenumber from streetLine1 $requestBilling = ["street" => "N/A",
$requestBilling = ["street" => $billingAddress->getStreetLine1(), "postalCode" => '',
"postalCode" => $billingAddress->getPostcode(), "city" => "N/A",
"city" => $billingAddress->getCity(),
"houseNumberOrName" => '', "houseNumberOrName" => '',
"stateOrProvince" => $billingAddress->getRegionCode(), "stateOrProvince" => '',
"country" => $billingAddress->getCountryId() "country" => "ZZ"
]; ];
if ($billingAddress->getStreetLine1()) {
$requestBilling["street"] = $billingAddress->getStreetLine1();
}
if ($billingAddress->getPostcode()) {
$requestBilling["postalCode"] = $billingAddress->getPostcode();
}
if ($billingAddress->getCity()) {
$requestBilling["city"] = $billingAddress->getCity();
}
if ($billingAddress->getRegionCode()) {
$requestBilling["stateOrProvince"] = $billingAddress->getRegionCode();
}
if ($billingAddress->getCountryId()) {
$requestBilling["country"] = $billingAddress->getCountryId();
}
$result['billingAddress'] = $requestBilling; $result['billingAddress'] = $requestBilling;
} }
......
...@@ -30,7 +30,7 @@ use Magento\Framework\App\Helper\AbstractHelper; ...@@ -30,7 +30,7 @@ use Magento\Framework\App\Helper\AbstractHelper;
*/ */
class Data extends AbstractHelper class Data extends AbstractHelper
{ {
const MODULE_NAME = 'adyen-magento2';
const TEST = 'test'; const TEST = 'test';
const LIVE = 'live'; const LIVE = 'live';
...@@ -84,6 +84,16 @@ class Data extends AbstractHelper ...@@ -84,6 +84,16 @@ class Data extends AbstractHelper
*/ */
protected $_taxCalculation; protected $_taxCalculation;
/**
* @var \Magento\Framework\App\ProductMetadataInterface
*/
protected $productMetadata;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $adyenLogger;
/** /**
* Data constructor. * Data constructor.
* *
...@@ -95,6 +105,8 @@ class Data extends AbstractHelper ...@@ -95,6 +105,8 @@ class Data extends AbstractHelper
* @param \Adyen\Payment\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory * @param \Adyen\Payment\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
* @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\Asset\Source $assetSource * @param \Magento\Framework\View\Asset\Source $assetSource
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Helper\Context $context,
...@@ -107,7 +119,10 @@ class Data extends AbstractHelper ...@@ -107,7 +119,10 @@ class Data extends AbstractHelper
\Magento\Framework\View\Asset\Source $assetSource, \Magento\Framework\View\Asset\Source $assetSource,
\Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory $notificationFactory, \Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory $notificationFactory,
\Magento\Tax\Model\Config $taxConfig, \Magento\Tax\Model\Config $taxConfig,
\Magento\Tax\Model\Calculation $taxCalculation \Magento\Tax\Model\Calculation $taxCalculation,
\Magento\Framework\App\ProductMetadataInterface $productMetadata,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
) { ) {
parent::__construct($context); parent::__construct($context);
$this->_encryptor = $encryptor; $this->_encryptor = $encryptor;
...@@ -120,6 +135,8 @@ class Data extends AbstractHelper ...@@ -120,6 +135,8 @@ class Data extends AbstractHelper
$this->_notificationFactory = $notificationFactory; $this->_notificationFactory = $notificationFactory;
$this->_taxConfig = $taxConfig; $this->_taxConfig = $taxConfig;
$this->_taxCalculation = $taxCalculation; $this->_taxCalculation = $taxCalculation;
$this->productMetadata = $productMetadata;
$this->adyenLogger = $adyenLogger;
} }
/** /**
...@@ -729,6 +746,21 @@ class Data extends AbstractHelper ...@@ -729,6 +746,21 @@ class Data extends AbstractHelper
return $sepaCountries; return $sepaCountries;
} }
/**
* Get adyen magento module's name sent to Adyen
*
* @return string
*/
public function getModuleName()
{
return (string)self::MODULE_NAME;
}
/**
* Get adyen magento module's version
*
* @return string
*/
public function getModuleVersion() public function getModuleVersion()
{ {
return (string)$this->_moduleList->getOne("Adyen_Payment")['setup_version']; return (string)$this->_moduleList->getOne("Adyen_Payment")['setup_version'];
...@@ -1131,4 +1163,37 @@ class Data extends AbstractHelper ...@@ -1131,4 +1163,37 @@ class Data extends AbstractHelper
} }
return $formFields; return $formFields;
} }
}
\ No newline at end of file /**
* Initializes and returns Adyen Client and sets the required parameters of it
*
* @param $storeId
* @return \Adyen\Client
* @throws \Adyen\AdyenException
*/
public function initializeAdyenClient($storeId = null)
{
// initialize client
$webserviceUsername = $this->getWsUsername($storeId);
$webservicePassword = $this->getWsPassword($storeId);
$client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
$client->setAdyenPaymentSource($this->getModuleName(), $this->getModuleVersion());
$client->setExternalPlatform($this->productMetadata->getName(), $this->productMetadata->getVersion());
if ($this->isDemoMode($storeId)) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
$client->setEnvironment(\Adyen\Environment::LIVE);
}
$client->setLogger($this->adyenLogger);
return $client;
}
}
...@@ -78,25 +78,13 @@ class PaymentRequest extends DataObject ...@@ -78,25 +78,13 @@ class PaymentRequest extends DataObject
$this->_appState = $context->getAppState(); $this->_appState = $context->getAppState();
} }
/**
* @param $storeId
* @return mixed
* @throws \Adyen\AdyenException
*/
private function createClient($storeId) { private function createClient($storeId) {
// initialize client $client = $this->_adyenHelper->initializeAdyenClient($storeId);
$webserviceUsername = $this->_adyenHelper->getWsUsername($storeId);
$webservicePassword = $this->_adyenHelper->getWsPassword($storeId);
$client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
if ($this->_adyenHelper->isDemoMode($storeId)) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
$client->setEnvironment(\Adyen\Environment::LIVE);
}
// assign magento log
$client->setLogger($this->_adyenLogger);
return $client; return $client;
} }
......
...@@ -1076,19 +1076,15 @@ class Cron ...@@ -1076,19 +1076,15 @@ class Cron
$lastTransactionId = $this->_order->getPayment()->getLastTransId(); $lastTransactionId = $this->_order->getPayment()->getLastTransId();
if ($lastTransactionId != $this->_pspReference) { if ($lastTransactionId != $this->_pspReference) {
// refund is done through adyen backoffice so create an invoice // refund is done through adyen backoffice so create a credit memo
$order = $this->_order; $order = $this->_order;
if ($order->canCreditmemo()) { if ($order->canCreditmemo()) {
// there is a bug in this function of Magento see #2656 magento\magento2 repo
// Invalid method Magento\Sales\Model\Order\Creditmemo::register
/*
$currency = $this->_order->getOrderCurrencyCode(); $currency = $this->_order->getOrderCurrencyCode();
$amount = $this->_adyenHelper->originalAmount($this->_value, $currency); $amount = $this->_adyenHelper->originalAmount($this->_value, $currency);
$order->getPayment()->registerRefundNotification($amount); $order->getPayment()->registerRefundNotification($amount);
*/
$this->_adyenLogger->addAdyenNotificationCronjob('Please create your credit memo inside magento'); $this->_adyenLogger->addAdyenNotificationCronjob('Created credit memo for order');
} else { } else {
$this->_adyenLogger->addAdyenNotificationCronjob('Could not create a credit memo for order'); $this->_adyenLogger->addAdyenNotificationCronjob('Could not create a credit memo for order');
} }
......
...@@ -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": "2.3.2", "version": "2.3.3",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
} }
], ],
"require": { "require": {
"adyen/php-api-library": "*", "adyen/php-api-library": ">=1.5.2",
"magento/framework": ">=100.1.0" "magento/framework": ">=100.1.0"
}, },
"autoload": { "autoload": {
......
...@@ -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="2.3.2"> <module name="Adyen_Payment" setup_version="2.3.3">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
...@@ -152,7 +152,6 @@ define( ...@@ -152,7 +152,6 @@ define(
fullScreenLoader.stopLoader(); fullScreenLoader.stopLoader();
} }
).fail(function (error) { ).fail(function (error) {
console.log(JSON.stringify(error));
fullScreenLoader.stopLoader(); fullScreenLoader.stopLoader();
}); });
}, },
...@@ -193,7 +192,19 @@ define( ...@@ -193,7 +192,19 @@ define(
return 4; return 4;
} }
}; };
if (value.brandCode == "ideal") { result.isIssuerListAvailable = function () {
if (value.hasOwnProperty("issuers") && value.issuers.length > 0) {
return true;
}
return false;
};
if (value.hasOwnProperty("issuers")) {
if (value.issuers.length == 0) {
return false;
}
result.issuerIds = value.issuers; result.issuerIds = value.issuers;
result.issuerId = ko.observable(null); result.issuerId = ko.observable(null);
} else if (value.isPaymentMethodOpenInvoiceMethod) { } else if (value.isPaymentMethodOpenInvoiceMethod) {
...@@ -228,8 +239,10 @@ define( ...@@ -228,8 +239,10 @@ define(
return false; return false;
}; };
} }
return result; return result;
}); });
return paymentList; return paymentList;
}, },
getGenderTypes: function () { getGenderTypes: function () {
...@@ -260,7 +273,7 @@ define( ...@@ -260,7 +273,7 @@ define(
additionalData.brand_code = self.value; additionalData.brand_code = self.value;
additionalData.df_value = dfValue(); additionalData.df_value = dfValue();
if (brandCode() == "ideal") { if (self.isIssuerListAvailable()) {
additionalData.issuer_id = this.issuerId(); additionalData.issuer_id = this.issuerId();
} }
else if (self.isPaymentMethodOpenInvoiceMethod()) { else if (self.isPaymentMethodOpenInvoiceMethod()) {
...@@ -360,4 +373,4 @@ define( ...@@ -360,4 +373,4 @@ define(
} }
}); });
} }
); );
\ No newline at end of file
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
<form class="form" data-role="adyen-hpp-form" action="#" method="post" data-bind="mageInit: { 'validation':[]}, attr: {id: 'payment_form_' + $parent.getCode() + '_' + value}"> <form class="form" data-role="adyen-hpp-form" action="#" method="post" data-bind="mageInit: { 'validation':[]}, attr: {id: 'payment_form_' + $parent.getCode() + '_' + value}">
<fieldset class="fieldset" data-bind='attr: {id: "payment_fieldset_" + $parent.getCode() + "_" + value}'> <fieldset class="fieldset" data-bind='attr: {id: "payment_fieldset_" + $parent.getCode() + "_" + value}'>
<!-- ko if: value == 'ideal' --> <!-- ko if: isIssuerListAvailable() -->
<label data-bind="attr: {'for': 'issuerId'}" class="label"> <label data-bind="attr: {'for': 'issuerId'}" class="label">
<span><!-- ko text: $t('Select Your Bank') --><!-- /ko --></span> <span><!-- ko text: $t('Select Your Bank') --><!-- /ko --></span>
</label> </label>
......
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