From 600be16cbb00ae4384626e5f7d493b7622d950a2 Mon Sep 17 00:00:00 2001 From: Giorgos Adam Date: Fri, 26 May 2017 09:56:46 +0200 Subject: [PATCH 1/7] Cancel order on 3D secure failure --- Controller/Process/Validate3d.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Controller/Process/Validate3d.php b/Controller/Process/Validate3d.php index bf54653d3..582cb5dd3 100755 --- a/Controller/Process/Validate3d.php +++ b/Controller/Process/Validate3d.php @@ -136,6 +136,9 @@ public function execute() $this->_redirect('checkout/onepage/success', ['utm_nooverride' => '1']); } else { $order->addStatusHistoryComment(__('3D-secure validation was unsuccessful.'))->save(); + + // Move the order from PAYMENT_REVIEW to NEW, so that can be cancelled + $order->setState(\Magento\Sales\Model\Order::STATE_NEW); $this->_adyenHelper->cancelOrder($order); $this->messageManager->addErrorMessage("3D-secure validation was unsuccessful"); From 546e04a6e570cd7140b6374b35d9e6d2467c6188 Mon Sep 17 00:00:00 2001 From: Giorgos Adam Date: Wed, 31 May 2017 15:35:42 +0200 Subject: [PATCH 2/7] Fixes #118 Show "unionpay" as alternative payment method Consider "cup" as CC method --- etc/adyen_payment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/adyen_payment.xml b/etc/adyen_payment.xml index 8386e7c1e..8152a052a 100644 --- a/etc/adyen_payment.xml +++ b/etc/adyen_payment.xml @@ -59,7 +59,7 @@ - unionpay + cup From 3f20623e2507534e54d2207a7c384f3210a14596 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Thu, 15 Jun 2017 14:48:11 +0200 Subject: [PATCH 3/7] #116 Billing Agreement can now be cancelled --- Model/Method/Adapter.php | 106 +++++++++++++++++++++++++++++++++++++++ etc/di.xml | 2 +- 2 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 Model/Method/Adapter.php diff --git a/Model/Method/Adapter.php b/Model/Method/Adapter.php new file mode 100644 index 000000000..13676298f --- /dev/null +++ b/Model/Method/Adapter.php @@ -0,0 +1,106 @@ + + */ + +namespace Adyen\Payment\Model\Method; + +use Magento\Payment\Model\Method; +use Magento\Framework\DataObject; +use Magento\Framework\Event\ManagerInterface; +use Magento\Payment\Gateway\Command\CommandManagerInterface; +use Magento\Payment\Gateway\Command\CommandPoolInterface; +use Magento\Payment\Gateway\Data\PaymentDataObjectFactory; +use Magento\Payment\Gateway\Config\ValueHandlerPoolInterface; +use Magento\Payment\Gateway\Validator\ValidatorPoolInterface; + +class Adapter extends Method\Adapter +{ + /** + * @var \Adyen\Payment\Model\Api\PaymentRequest + */ + protected $_paymentRequest; + + + /** + * Adapter constructor. + * @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest + * @param ManagerInterface $eventManager + * @param ValueHandlerPoolInterface $valueHandlerPool + * @param PaymentDataObjectFactory $paymentDataObjectFactory + * @param string $code + * @param string $formBlockType + * @param CommandPoolInterface $infoBlockType + * @param CommandPoolInterface|null $commandPool + * @param ValidatorPoolInterface|null $validatorPool + * @param CommandManagerInterface|null $commandExecutor + */ + public function __construct( + \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest, + ManagerInterface $eventManager, + ValueHandlerPoolInterface $valueHandlerPool, + PaymentDataObjectFactory $paymentDataObjectFactory, + $code, + $formBlockType, + $infoBlockType, + CommandPoolInterface $commandPool = null, + ValidatorPoolInterface $validatorPool = null, + \Magento\Payment\Gateway\Command\CommandManagerInterface $commandExecutor = null + ) { + parent::__construct( + $eventManager, + $valueHandlerPool, + $paymentDataObjectFactory, + $code, + $formBlockType, + $infoBlockType, + $commandPool, + $validatorPool, + $commandExecutor + ); + + $this->_paymentRequest = $paymentRequest; + } + + + /** + * @param \Adyen\Payment\Model\Billing\Agreement $agreement + * @return $this + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function updateBillingAgreementStatus(\Adyen\Payment\Model\Billing\Agreement $agreement) + { + $targetStatus = $agreement->getStatus(); + if ($targetStatus == \Magento\Paypal\Model\Billing\Agreement::STATUS_CANCELED) { + try { + $this->_paymentRequest->disableRecurringContract( + $agreement->getReferenceId(), + $agreement->getCustomerReference(), + $agreement->getStoreId() + ); + } catch(Exception $e) { + throw new \Magento\Framework\Exception\LocalizedException(__('Failed to disable this contract')); + } + } + return $this; + } + +} diff --git a/etc/di.xml b/etc/di.xml index 9e2c6fd18..cc05463b0 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -44,7 +44,7 @@ AdyenPaymentCcCommandPool - + Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider::CODE Adyen\Payment\Block\Form\Oneclick From f867a6fc5eb3063b618ead3862bf5f76c37b78b3 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Thu, 15 Jun 2017 16:09:23 +0200 Subject: [PATCH 4/7] make merchant_account and capture_mode configurable on store level --- etc/adminhtml/system/adyen_required_settings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/adminhtml/system/adyen_required_settings.xml b/etc/adminhtml/system/adyen_required_settings.xml index 7b43159fa..ff5262130 100755 --- a/etc/adminhtml/system/adyen_required_settings.xml +++ b/etc/adminhtml/system/adyen_required_settings.xml @@ -26,7 +26,7 @@ Magento\Config\Block\System\Config\Form\Fieldset - + payment/adyen_abstract/merchant_account [YourMerchantAccount] . Please note that the merchant account is different from the company account; a company account can have one or more merchant accounts.]]> @@ -71,7 +71,7 @@ Magento\Config\Model\Config\Backend\Encrypted payment/adyen_abstract/ws_password_live - + Immediate is the default. Set to manual if you want to perform the capture of funds manually later (only affects credit cards and a few alternative payment methods). You need to change this setting as well in Adyen Customer Area => Settings => Merchant Settings => Capture Delay. If you have selected a capture delay of a couple of days in Adyen keep it here on immediate Adyen\Payment\Model\Config\Source\CaptureMode From ef980fc796a0bda81f923b82a01dcadac1b9fa84 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Thu, 15 Jun 2017 16:50:16 +0200 Subject: [PATCH 5/7] #123 fix isssue for paypal recurring contracts --- Model/Billing/Agreement.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Model/Billing/Agreement.php b/Model/Billing/Agreement.php index 5d05dc005..61d5408e8 100644 --- a/Model/Billing/Agreement.php +++ b/Model/Billing/Agreement.php @@ -119,8 +119,17 @@ public function parseRecurringContractData($data) } if ($data['variant'] == 'paypal') { + + $email = ""; + + if (isset($data['tokenDetails']['tokenData']['EmailId'])) { + $email = $data['tokenDetails']['tokenData']['EmailId']; + } elseif (isset($data['lastKnownShopperEmail'])) { + $email = $data['lastKnownShopperEmail']; + } + $label = __('PayPal %1', - $data['lastKnownShopperEmail'] + $email ); $this->setAgreementLabel($label); } From 7247e1157d6d4917705dfca11bb3350039914dd7 Mon Sep 17 00:00:00 2001 From: Giorgos Adam Date: Fri, 16 Jun 2017 11:02:29 +0200 Subject: [PATCH 6/7] Use the correct credentials when creating billing agreements from cron job in case of multi-store configuration --- Helper/Data.php | 34 ++++++++++------------------------ Model/Api/PaymentRequest.php | 26 +++++++++++++------------- 2 files changed, 23 insertions(+), 37 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f99d7b4ee..61638d5f3 100755 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -480,9 +480,9 @@ public function getHmacPayByMail() * @desc Check if configuration is set to demo mode * @return mixed */ - public function isDemoMode() + public function isDemoMode($storeId = null) { - return $this->getAdyenAbstractConfigDataFlag('demo_mode'); + return $this->getAdyenAbstractConfigDataFlag('demo_mode', $storeId); } /** @@ -498,12 +498,12 @@ public function getNotificationPassword() * @desc Retrieve the webserver username * @return string */ - public function getWsUsername() + public function getWsUsername($storeId = null) { - if ($this->isDemoMode()) { - $wsUsername = trim($this->getAdyenAbstractConfigData('ws_username_test')); + if ($this->isDemoMode($storeId)) { + $wsUsername = trim($this->getAdyenAbstractConfigData('ws_username_test', $storeId)); } else { - $wsUsername = trim($this->getAdyenAbstractConfigData('ws_username_live')); + $wsUsername = trim($this->getAdyenAbstractConfigData('ws_username_live', $storeId)); } return $wsUsername; } @@ -512,30 +512,16 @@ public function getWsUsername() * @desc Retrieve the webserver password * @return string */ - public function getWsPassword() + public function getWsPassword($storeId = null) { - if ($this->isDemoMode()) { - $wsPassword = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData('ws_password_test'))); + if ($this->isDemoMode($storeId)) { + $wsPassword = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData('ws_password_test', $storeId))); } else { - $wsPassword = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData('ws_password_live'))); + $wsPassword = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData('ws_password_live', $storeId))); } return $wsPassword; } - /** - * @desc Retrieve the webserver url defined in the config.xlm only - * @return string - */ - public function getWsUrl() - { - if ($this->isDemoMode()) { - $url = $this->getAdyenAbstractConfigData('ws_url_test'); - } else { - $url = $this->getAdyenAbstractConfigData('ws_url_live'); - } - return $url; - } - /** * @desc Cancels the order * @param $order diff --git a/Model/Api/PaymentRequest.php b/Model/Api/PaymentRequest.php index f6af3947d..f877fbdd8 100755 --- a/Model/Api/PaymentRequest.php +++ b/Model/Api/PaymentRequest.php @@ -43,11 +43,6 @@ class PaymentRequest extends DataObject */ protected $_adyenLogger; - /** - * @var \Adyen\Client - */ - protected $_client; - /** * @var \Adyen\Payment\Model\RecurringType */ @@ -81,26 +76,28 @@ public function __construct( $this->_adyenLogger = $adyenLogger; $this->_recurringType = $recurringType; $this->_appState = $context->getAppState(); + } + private function createClient($storeId) { // initialize client - $webserviceUsername = $this->_adyenHelper->getWsUsername(); - $webservicePassword = $this->_adyenHelper->getWsPassword(); + $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()) { + if ($this->_adyenHelper->isDemoMode($storeId)) { $client->setEnvironment(\Adyen\Environment::TEST); } else { $client->setEnvironment(\Adyen\Environment::LIVE); } // assign magento log - $client->setLogger($adyenLogger); + $client->setLogger($this->_adyenLogger); - $this->_client = $client; + return $client; } /** @@ -128,7 +125,8 @@ public function authorise3d($payment) ]; try { - $service = new \Adyen\Service\Payment($this->_client); + $client = $this->createClient($storeId); + $service = new \Adyen\Service\Payment($client); $result = $service->authorise3D($request); } catch(\Adyen\AdyenException $e) { throw new \Magento\Framework\Exception\LocalizedException(__('3D secure failed')); @@ -203,7 +201,8 @@ public function listRecurringContractByType($shopperReference, $storeId, $recurr ]; // call lib - $service = new \Adyen\Service\Recurring($this->_client); + $client = $this->createClient($storeId); + $service = new \Adyen\Service\Recurring($client); $result = $service->listRecurringDetails($request); return $result; @@ -229,7 +228,8 @@ public function disableRecurringContract($recurringDetailReference, $shopperRefe ]; // call lib - $service = new \Adyen\Service\Recurring($this->_client); + $client = $this->createClient($storeId); + $service = new \Adyen\Service\Recurring($client); try { $result = $service->disable($request); From 97ee5834885f702279438d402603376a354044a6 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Fri, 23 Jun 2017 08:37:51 +0200 Subject: [PATCH 7/7] New version (#129) * Update version to release 2.0.6 and remove some unused parameters * update version --- composer.json | 2 +- etc/config.xml | 4 ---- etc/module.xml | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 79f6567d0..def42e65c 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "adyen/module-payment", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "type": "magento2-module", - "version": "2.0.5", + "version": "2.0.6", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/config.xml b/etc/config.xml index 251345297..683ca3485 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -97,8 +97,6 @@ 5 0 3 - adyen/process/redirect - adyen/process/redirect order 1 1 @@ -138,8 +136,6 @@ Adyen POS 0 5 - adyen/process/redirect - adyen/process/redirect order 1 1 diff --git a/etc/module.xml b/etc/module.xml index 635eca68a..7a770d98d 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -24,7 +24,7 @@ --> - +