We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit b8c2a0bc authored by rikterbeek's avatar rikterbeek

Fixes #30 added option to do moto transaction in backend

parent 1c0d3249
......@@ -42,6 +42,16 @@ class Cc extends \Magento\Payment\Block\Form
*/
protected $_adyenHelper;
/**
* @var \Magento\Framework\App\State
*/
protected $_appState;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $_checkoutSession;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Payment\Model\Config $paymentConfig
......@@ -51,11 +61,14 @@ class Cc extends \Magento\Payment\Block\Form
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Payment\Model\Config $paymentConfig,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Checkout\Model\Session $checkoutSession,
array $data = []
) {
parent::__construct($context, $data);
$this->_paymentConfig = $paymentConfig;
$this->_adyenHelper = $adyenHelper;
$this->_appState = $context->getAppState();
$this->_checkoutSession = $checkoutSession;
}
......@@ -142,6 +155,16 @@ class Cc extends \Magento\Payment\Block\Form
*/
public function hasVerification()
{
// if backend order and moto payments is turned on don't show cvc
if ($this->_appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
$this->getCheckoutSession();
$store = $this->_checkoutSession->getQuote()->getStore();
$enableMoto = $this->_adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $store->getId());
if($enableMoto) {
return false;
}
}
return true;
}
......
......@@ -62,6 +62,11 @@ class PaymentRequest extends DataObject
*/
protected $_recurringType;
/**
* @var \Magento\Framework\App\State
*/
protected $_appState;
const GUEST_ID = 'customer_';
/**
......@@ -74,6 +79,7 @@ class PaymentRequest extends DataObject
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
......@@ -88,6 +94,7 @@ class PaymentRequest extends DataObject
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
// initialize client
$webserviceUsername = $this->_adyenHelper->getWsUsername();
......@@ -113,13 +120,18 @@ class PaymentRequest extends DataObject
public function fullApiRequest($payment, $paymentMethodCode)
{
$storeId = null;
if( $this->_appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
$storeId = $payment->getOrder()->getStoreId();
}
$order = $payment->getOrder();
$amount = $order->getGrandTotal();
$customerEmail = $order->getCustomerEmail();
$shopperIp = $order->getRemoteIp();
$orderCurrencyCode = $order->getOrderCurrencyCode();
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account");
$recurringType = $this->_adyenHelper->getAdyenAbstractConfigData('recurring_type');
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$recurringType = $this->_adyenHelper->getAdyenAbstractConfigData('recurring_type', $storeId);
$realOrderId = $order->getRealOrderId();
$customerId = $order->getCustomerId();
......@@ -217,8 +229,18 @@ class PaymentRequest extends DataObject
$request = array_merge($request, $requestDelivery);
}
$enableMoto = $this->_adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId);
$recurringDetailReference = null;
// define the shopper interaction
if($paymentMethodCode == \Adyen\Payment\Model\Method\Oneclick::METHOD_CODE) {
if( $this->_appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE &&
$paymentMethodCode == \Adyen\Payment\Model\Method\Cc::METHOD_CODE &&
$enableMoto)
{
// if MOTO for backend is enabled use MOTO as shopper interaction type
$shopperInteraction = "Moto";
} else if($paymentMethodCode == \Adyen\Payment\Model\Method\Oneclick::METHOD_CODE) {
$recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference");
if($payment->getAdditionalInformation('customer_interaction')) {
$shopperInteraction = "Ecommerce";
......@@ -233,7 +255,6 @@ class PaymentRequest extends DataObject
}
}
} else {
$recurringDetailReference = null;
$shopperInteraction = "Ecommerce";
}
......
......@@ -62,6 +62,18 @@
<depends><field id="cse_enabled">1</field></depends>
<config_path>payment/adyen_cc/cse_publickey_live</config_path>
</field>
<group id="adyen_cc_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" sortOrder="150">
<label>Advanced Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="enable_moto" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable MOTO</label>
<tooltip><![CDATA[Important you have to activate MOTO for your account contact magento@adyen.com.]]></tooltip>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_cc/enable_moto</config_path>
</field>
</group>
<group id="adyen_cc_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200">
<label>Country Specific Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
......
......@@ -45,6 +45,7 @@
<cctypes>AE,VI,MC,DI</cctypes>
<useccv>1</useccv>
<cse_enabled>1</cse_enabled>
<enable_moto>0</enable_moto>
<payment_action>authorize</payment_action>
<group>adyen</group>
</adyen_cc>
......
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