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 1201e022 authored by Rik ter Beek's avatar Rik ter Beek Committed by GitHub

Merge pull request #130 from Adyen/develop

Merge from 'develop'
parents a01f9d94 97ee5834
......@@ -136,6 +136,9 @@ class Validate3d extends \Magento\Framework\App\Action\Action
$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");
......
......@@ -480,9 +480,9 @@ class Data extends AbstractHelper
* @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 @@ class Data extends AbstractHelper
* @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 @@ class Data extends AbstractHelper
* @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
......
......@@ -43,11 +43,6 @@ class PaymentRequest extends DataObject
*/
protected $_adyenLogger;
/**
* @var \Adyen\Client
*/
protected $_client;
/**
* @var \Adyen\Payment\Model\RecurringType
*/
......@@ -81,26 +76,28 @@ class PaymentRequest extends DataObject
$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 @@ class PaymentRequest extends DataObject
];
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 @@ class PaymentRequest extends DataObject
];
// 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 @@ class PaymentRequest extends DataObject
];
// call lib
$service = new \Adyen\Service\Recurring($this->_client);
$client = $this->createClient($storeId);
$service = new \Adyen\Service\Recurring($client);
try {
$result = $service->disable($request);
......
......@@ -119,8 +119,17 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
}
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);
}
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
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;
}
}
......@@ -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"
......
......@@ -26,7 +26,7 @@
<group id="adyen_required_settings" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Required Settings]]></label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="merchant_account" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="merchant_account" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Merchant Account</label>
<config_path>payment/adyen_abstract/merchant_account</config_path>
<tooltip><![CDATA[The merchant account identifier you want to process the (transaction) request with. Find this at the top of the screen in the Adyen Customer Area, where you will see [YourCompanyAccount] > [YourMerchantAccount] . Please note that the merchant account is different from the company account; a company account can have one or more merchant accounts.]]></tooltip>
......@@ -71,7 +71,7 @@
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/ws_password_live</config_path>
</field>
<field id="capture_mode" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="capture_mode" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Capture Delay</label>
<tooltip>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</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\CaptureMode</source_model>
......
......@@ -59,7 +59,7 @@
</type>
<type id="UN" order="80">
<label>UnionPay</label>
<code_alt>unionpay</code_alt>
<code_alt>cup</code_alt>
</type>
</adyen_credit_cards>
</payment>
......@@ -97,8 +97,6 @@
<delivery_days>5</delivery_days>
<allowspecific>0</allowspecific>
<sort_order>3</sort_order>
<place_order_url>adyen/process/redirect</place_order_url>
<order_place_redirect_url>adyen/process/redirect</order_place_redirect_url>
<payment_action>order</payment_action>
<can_initialize>1</can_initialize>
<is_gateway>1</is_gateway>
......@@ -138,8 +136,6 @@
<title>Adyen POS</title>
<allowspecific>0</allowspecific>
<sort_order>5</sort_order>
<place_order_url>adyen/process/redirect</place_order_url>
<order_place_redirect_url>adyen/process/redirect</order_place_redirect_url>
<payment_action>order</payment_action>
<can_initialize>1</can_initialize>
<is_gateway>1</is_gateway>
......
......@@ -44,7 +44,7 @@
<argument name="commandPool" xsi:type="object">AdyenPaymentCcCommandPool</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentOneclickFacade" type="Magento\Payment\Model\Method\Adapter">
<virtualType name="AdyenPaymentOneclickFacade" type="Adyen\Payment\Model\Method\Adapter">
<arguments>
<argument name="code" xsi:type="const">Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider::CODE</argument>
<argument name="formBlockType" xsi:type="string">Adyen\Payment\Block\Form\Oneclick</argument>
......
......@@ -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.0.5">
<module name="Adyen_Payment" setup_version="2.0.6">
<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