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 72ea16e7 authored by Alessio Zampatti's avatar Alessio Zampatti Committed by GitHub

PW-1413 Store details for backend orders (#551)

* PW-1413 Remove the setting for moto, to always allow moto on backend, updated CcBackendAuthorizationDataBuilder to store recurring

* PW-1413 Add enableRecurring false if checkbox not checked, paymentmethod storedetails for consistency

* PW-1413 Remove storeDetails since it triggers OneClick
parent 1ac0ec9c
......@@ -99,14 +99,9 @@ class Cc extends \Magento\Payment\Block\Form\Cc
*/
public function hasVerification()
{
// if backend order and moto payments is turned on don't show cvc
// On Backend always use MOTO
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 false;
}
return true;
}
......@@ -120,7 +115,7 @@ class Cc extends \Magento\Payment\Block\Form\Cc
}
/**
* Retrieve availables credit card type codes by alt code
* Retrieve available credit card type codes by alt code
*
* @return array
*/
......@@ -141,4 +136,26 @@ class Cc extends \Magento\Payment\Block\Form\Cc
return $types;
}
/**
* Allow checkbox for MOTO payments to be saved as RECURRING
*
* @return bool
*/
public function allowRecurring()
{
if ($this->adyenHelper->getAdyenAbstractConfigData('enable_recurring', null)) {
return true;
}
return false;
}
/**
* @return mixed
*/
public function isVaultEnabled()
{
return $this->adyenHelper->isCreditCardVaultEnabled();
}
}
......@@ -61,9 +61,8 @@ class CcBackendAuthorizationDataBuilder implements BuilderInterface
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
$order = $paymentDataObject->getOrder();
$storeId = $order->getStoreId();
$request = [];
// If ccType is set use this. For bcmc you need bcmc otherwise it will fail
$request['paymentMethod']['type'] = 'scheme';
if ($cardNumber = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER)) {
......@@ -88,20 +87,25 @@ class CcBackendAuthorizationDataBuilder implements BuilderInterface
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::HOLDER_NAME);
/**
* if MOTO for backend is enabled use MOTO as shopper interaction type
* On Backend always use MOTO
*/
$enableMoto = $this->adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId);
if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE &&
$enableMoto
) {
$request['shopperInteraction'] = "Moto";
}
$request['shopperInteraction'] = "Moto";
// if installments is set add it into the request
if ($payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) &&
$payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) > 0
) {
$request['installments']['value'] = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS);
}
// Flow for Billing agreements, for Vault check VaultDataBuilder
if (!$this->adyenHelper->isCreditCardVaultEnabled()) {
if ($payment->getAdditionalInformation(AdyenCcDataAssignObserver::STORE_CC)) {
$request['enableRecurring'] = true;
} else {
$request['enableRecurring'] = false;
}
}
return $request;
}
}
......@@ -439,7 +439,9 @@ class Requests extends AbstractHelper
{
if ($this->adyenHelper->isCreditCardVaultEnabled()) {
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][VaultConfigProvider::IS_ACTIVE_CODE]) &&
$payload[PaymentInterface::KEY_ADDITIONAL_DATA][VaultConfigProvider::IS_ACTIVE_CODE] === true
$payload[PaymentInterface::KEY_ADDITIONAL_DATA][VaultConfigProvider::IS_ACTIVE_CODE] === true ||
!empty($payload[VaultConfigProvider::IS_ACTIVE_CODE]) &&
$payload[VaultConfigProvider::IS_ACTIVE_CODE] === true
) {
// store it only as oneclick otherwise we store oneclick tokens (maestro+bcmc) that will fail
$request['enableRecurring'] = true;
......
......@@ -10,7 +10,6 @@
<item name="address" xsi:type="string">Adyen\Payment\Gateway\Request\AddressDataBuilder</item>
<item name="payment" xsi:type="string">Adyen\Payment\Gateway\Request\PaymentDataBuilder</item>
<item name="browserinfo" xsi:type="string">Adyen\Payment\Gateway\Request\BrowserInfoDataBuilder</item>
<item name="recurring" xsi:type="string">Adyen\Payment\Gateway\Request\RecurringDataBuilder</item>
<item name="transaction" xsi:type="string">Adyen\Payment\Gateway\Request\CcBackendAuthorizationDataBuilder</item>
<item name="vault" xsi:type="string">Adyen\Payment\Gateway\Request\VaultDataBuilder</item>
</argument>
......
......@@ -70,14 +70,6 @@
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>
<field id="enable_installments" translate="label" type="select" sortOrder="219" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Enable Installments</label>
......
......@@ -47,7 +47,6 @@
<sort_order>2</sort_order>
<cctypes>AE,VI,MC,DI</cctypes>
<useccv>1</useccv>
<enable_moto>0</enable_moto>
<payment_action>authorize</payment_action>
<is_gateway>1</is_gateway>
<can_use_checkout>1</can_use_checkout>
......@@ -91,7 +90,6 @@
<recurring_payment_type>ONECLICK</recurring_payment_type>
<payment_action>authorize</payment_action>
<useccv>1</useccv>
<enable_moto>0</enable_moto>
<is_gateway>1</is_gateway>
<can_use_checkout>1</can_use_checkout>
<can_authorize>1</can_authorize>
......
......@@ -61,6 +61,23 @@ echo $code; ?>" style="display:none">
echo $code; ?>-expiryYear" type="hidden" name="payment[expiryYear]">
<input id="<?php /* @noEscape */
echo $code; ?>-cc_type" type="hidden" name="payment[cc_type]">
<input id="<?php /* @noEscape */
echo $code; ?>-store_cc" type="hidden" name="payment[store_cc]">
<?php if ($block->isVaultEnabled()): ?>
<div class="field choice">
<input type="checkbox"
id="<?php /* @noEscape */
echo $code; ?>_vault"
name="payment[is_active_payment_token_enabler]"
class="checkbox"/>
<label class="label" for="<?php /* @noEscape */
echo $code; ?>_vault">
<span><?php echo $block->escapeHtml('Save for later use.'); ?></span>
</label>
</div>
<?php endif; ?>
<script>
require(
......@@ -93,7 +110,7 @@ echo $code; ?>" style="display:none">
/*
* Initialize secure fields and set up the onChange callback to
* - fill the input fields with the encrypted data
* - show the heklper text when necessary
* - show the helper text when necessary
*/
var secureFieldsInitialize = function () {
......@@ -117,7 +134,8 @@ echo $code; ?>" style="display:none">
type: 'card',
groupTypes: ccTypes,
hideCVC: hideCVC,
enableStoreDetails: "<?php echo $block->allowRecurring() && !$block->isVaultEnabled();?>",
onChange: function (state) {
// When the state is valid update the input fields
if (state.isValid) {
......@@ -126,6 +144,7 @@ echo $code; ?>" style="display:none">
jQuery("#<?php /* @noEscape */ echo $code; ?>-expiryMonth").val(state.data.paymentMethod.encryptedExpiryMonth);
jQuery("#<?php /* @noEscape */ echo $code; ?>-expiryYear").val(state.data.paymentMethod.encryptedExpiryYear);
jQuery("#<?php /* @noEscape */ echo $code; ?>-cvc").val(state.data.paymentMethod.encryptedSecurityCode);
jQuery("#<?php /* @noEscape */ echo $code; ?>-store_cc").val(state.data.storePaymentMethod);
}
},
onBrand: function (state) {
......
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