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 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 ...@@ -42,6 +42,16 @@ class Cc extends \Magento\Payment\Block\Form
*/ */
protected $_adyenHelper; 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\Framework\View\Element\Template\Context $context
* @param \Magento\Payment\Model\Config $paymentConfig * @param \Magento\Payment\Model\Config $paymentConfig
...@@ -51,11 +61,14 @@ class Cc extends \Magento\Payment\Block\Form ...@@ -51,11 +61,14 @@ class Cc extends \Magento\Payment\Block\Form
\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\View\Element\Template\Context $context,
\Magento\Payment\Model\Config $paymentConfig, \Magento\Payment\Model\Config $paymentConfig,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Checkout\Model\Session $checkoutSession,
array $data = [] array $data = []
) { ) {
parent::__construct($context, $data); parent::__construct($context, $data);
$this->_paymentConfig = $paymentConfig; $this->_paymentConfig = $paymentConfig;
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_appState = $context->getAppState();
$this->_checkoutSession = $checkoutSession;
} }
...@@ -142,6 +155,16 @@ class Cc extends \Magento\Payment\Block\Form ...@@ -142,6 +155,16 @@ class Cc extends \Magento\Payment\Block\Form
*/ */
public function hasVerification() 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; return true;
} }
......
...@@ -62,6 +62,11 @@ class PaymentRequest extends DataObject ...@@ -62,6 +62,11 @@ class PaymentRequest extends DataObject
*/ */
protected $_recurringType; protected $_recurringType;
/**
* @var \Magento\Framework\App\State
*/
protected $_appState;
const GUEST_ID = 'customer_'; const GUEST_ID = 'customer_';
/** /**
...@@ -74,6 +79,7 @@ class PaymentRequest extends DataObject ...@@ -74,6 +79,7 @@ class PaymentRequest extends DataObject
* @param array $data * @param array $data
*/ */
public function __construct( public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Psr\Log\LoggerInterface $logger, \Psr\Log\LoggerInterface $logger,
\Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Encryption\EncryptorInterface $encryptor,
...@@ -88,6 +94,7 @@ class PaymentRequest extends DataObject ...@@ -88,6 +94,7 @@ class PaymentRequest extends DataObject
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
$this->_recurringType = $recurringType; $this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
// initialize client // initialize client
$webserviceUsername = $this->_adyenHelper->getWsUsername(); $webserviceUsername = $this->_adyenHelper->getWsUsername();
...@@ -113,13 +120,18 @@ class PaymentRequest extends DataObject ...@@ -113,13 +120,18 @@ class PaymentRequest extends DataObject
public function fullApiRequest($payment, $paymentMethodCode) 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(); $order = $payment->getOrder();
$amount = $order->getGrandTotal(); $amount = $order->getGrandTotal();
$customerEmail = $order->getCustomerEmail(); $customerEmail = $order->getCustomerEmail();
$shopperIp = $order->getRemoteIp(); $shopperIp = $order->getRemoteIp();
$orderCurrencyCode = $order->getOrderCurrencyCode(); $orderCurrencyCode = $order->getOrderCurrencyCode();
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account"); $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$recurringType = $this->_adyenHelper->getAdyenAbstractConfigData('recurring_type'); $recurringType = $this->_adyenHelper->getAdyenAbstractConfigData('recurring_type', $storeId);
$realOrderId = $order->getRealOrderId(); $realOrderId = $order->getRealOrderId();
$customerId = $order->getCustomerId(); $customerId = $order->getCustomerId();
...@@ -217,8 +229,18 @@ class PaymentRequest extends DataObject ...@@ -217,8 +229,18 @@ class PaymentRequest extends DataObject
$request = array_merge($request, $requestDelivery); $request = array_merge($request, $requestDelivery);
} }
$enableMoto = $this->_adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId);
$recurringDetailReference = null;
// define the shopper interaction // 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"); $recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference");
if($payment->getAdditionalInformation('customer_interaction')) { if($payment->getAdditionalInformation('customer_interaction')) {
$shopperInteraction = "Ecommerce"; $shopperInteraction = "Ecommerce";
...@@ -233,7 +255,6 @@ class PaymentRequest extends DataObject ...@@ -233,7 +255,6 @@ class PaymentRequest extends DataObject
} }
} }
} else { } else {
$recurringDetailReference = null;
$shopperInteraction = "Ecommerce"; $shopperInteraction = "Ecommerce";
} }
......
...@@ -62,6 +62,18 @@ ...@@ -62,6 +62,18 @@
<depends><field id="cse_enabled">1</field></depends> <depends><field id="cse_enabled">1</field></depends>
<config_path>payment/adyen_cc/cse_publickey_live</config_path> <config_path>payment/adyen_cc/cse_publickey_live</config_path>
</field> </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"> <group id="adyen_cc_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200">
<label>Country Specific Settings</label> <label>Country Specific Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model> <frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
<cctypes>AE,VI,MC,DI</cctypes> <cctypes>AE,VI,MC,DI</cctypes>
<useccv>1</useccv> <useccv>1</useccv>
<cse_enabled>1</cse_enabled> <cse_enabled>1</cse_enabled>
<enable_moto>0</enable_moto>
<payment_action>authorize</payment_action> <payment_action>authorize</payment_action>
<group>adyen</group> <group>adyen</group>
</adyen_cc> </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