Commit 03ca72fd authored by Marcos Garcia's avatar Marcos Garcia Committed by GitHub

PW-2062 Split option for local payment methods (#684)

Co-authored-by: default avataralexandros <alexandros.moraitis@adyen.com>
parent cf9cfdc3
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
namespace Adyen\Payment\Setup; namespace Adyen\Payment\Setup;
use Adyen\Payment\Model\RecurringType;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface; use Magento\Framework\Setup\UpgradeDataInterface;
...@@ -47,7 +49,7 @@ class UpgradeData implements UpgradeDataInterface ...@@ -47,7 +49,7 @@ class UpgradeData implements UpgradeDataInterface
private $reinitableConfig; private $reinitableConfig;
/** /**
* @var configDataTable * @var string configDataTable
*/ */
private $configDataTable; private $configDataTable;
...@@ -105,7 +107,7 @@ class UpgradeData implements UpgradeDataInterface ...@@ -105,7 +107,7 @@ class UpgradeData implements UpgradeDataInterface
$scope = $configRecurringTypeValue['scope']; $scope = $configRecurringTypeValue['scope'];
$scopeId = $configRecurringTypeValue['scope_id']; $scopeId = $configRecurringTypeValue['scope_id'];
switch ($configRecurringTypeValue['value']) { switch ($configRecurringTypeValue['value']) {
case \Adyen\Payment\Model\RecurringType::ONECLICK: case RecurringType::ONECLICK:
$this->configWriter->save( $this->configWriter->save(
$pathEnableOneclick, $pathEnableOneclick,
'1', '1',
...@@ -119,7 +121,7 @@ class UpgradeData implements UpgradeDataInterface ...@@ -119,7 +121,7 @@ class UpgradeData implements UpgradeDataInterface
$scopeId $scopeId
); );
break; break;
case \Adyen\Payment\Model\RecurringType::ONECLICK_RECURRING: case RecurringType::ONECLICK_RECURRING:
$this->configWriter->save( $this->configWriter->save(
$pathEnableOneclick, $pathEnableOneclick,
'1', '1',
...@@ -133,7 +135,7 @@ class UpgradeData implements UpgradeDataInterface ...@@ -133,7 +135,7 @@ class UpgradeData implements UpgradeDataInterface
$scopeId $scopeId
); );
break; break;
case \Adyen\Payment\Model\RecurringType::RECURRING: case RecurringType::RECURRING:
$this->configWriter->save( $this->configWriter->save(
$pathEnableOneclick, $pathEnableOneclick,
'0', '0',
...@@ -147,7 +149,7 @@ class UpgradeData implements UpgradeDataInterface ...@@ -147,7 +149,7 @@ class UpgradeData implements UpgradeDataInterface
$scopeId $scopeId
); );
break; break;
case \Adyen\Payment\Model\RecurringType::NONE: case RecurringType::NONE:
$this->configWriter->save( $this->configWriter->save(
$pathEnableOneclick, $pathEnableOneclick,
'0', '0',
...@@ -187,6 +189,8 @@ class UpgradeData implements UpgradeDataInterface ...@@ -187,6 +189,8 @@ class UpgradeData implements UpgradeDataInterface
$this->setShopperCountry($connection); $this->setShopperCountry($connection);
$this->setLocalPaymentMethodsRecurringInformation($connection);
$this->reinitableConfig->reinit(); $this->reinitableConfig->reinit();
} }
...@@ -194,9 +198,9 @@ class UpgradeData implements UpgradeDataInterface ...@@ -194,9 +198,9 @@ class UpgradeData implements UpgradeDataInterface
/** /**
* Sets terminal_selection configuration by checking the value of pos_store_id * Sets terminal_selection configuration by checking the value of pos_store_id
* *
* @param Magento\Framework\DB\Adapter\Pdo\Mysql $connection * @param AdapterInterface $connection
*/ */
private function setTerminalSelection($connection) private function setTerminalSelection(AdapterInterface $connection)
{ {
$pathTerminalSelection = "payment/adyen_pos_cloud/terminal_selection"; $pathTerminalSelection = "payment/adyen_pos_cloud/terminal_selection";
$pathPosStoreId = "payment/adyen_pos_cloud/pos_store_id"; $pathPosStoreId = "payment/adyen_pos_cloud/pos_store_id";
...@@ -239,9 +243,9 @@ class UpgradeData implements UpgradeDataInterface ...@@ -239,9 +243,9 @@ class UpgradeData implements UpgradeDataInterface
/** /**
* Sets kar_capture_mode configuration by checking the values of capture_on_shipment and auto_capture_openinvoice * Sets kar_capture_mode configuration by checking the values of capture_on_shipment and auto_capture_openinvoice
* *
* @param Magento\Framework\DB\Adapter\Pdo\Mysql $connection * @param AdapterInterface $connection
*/ */
private function setKarCaptureMode($connection) private function setKarCaptureMode(AdapterInterface $connection)
{ {
$pathKarCaptureMode = "payment/adyen_abstract/kar_capture_mode"; $pathKarCaptureMode = "payment/adyen_abstract/kar_capture_mode";
...@@ -308,12 +312,13 @@ class UpgradeData implements UpgradeDataInterface ...@@ -308,12 +312,13 @@ class UpgradeData implements UpgradeDataInterface
); );
} }
} }
/** /**
* Sets shoppercountry configuration by checking the value of payment/adyen_hpp/country_code * Sets shoppercountry configuration by checking the value of payment/adyen_hpp/country_code
* *
* @param Magento\Framework\DB\Adapter\Pdo\Mysql $connection * @param AdapterInterface $connection
*/ */
private function setShopperCountry($connection) private function setShopperCountry(AdapterInterface $connection)
{ {
$countryCode = "payment/adyen_hpp/country_code"; $countryCode = "payment/adyen_hpp/country_code";
$shoppercountry = "payment/adyen_hpp/shopper_country"; $shoppercountry = "payment/adyen_hpp/shopper_country";
...@@ -338,4 +343,26 @@ class UpgradeData implements UpgradeDataInterface ...@@ -338,4 +343,26 @@ class UpgradeData implements UpgradeDataInterface
} }
/**
* On version 6.1.0 we created a new field for recurring information for Local Payment Methods.
*
* @param AdapterInterface $connection
*/
private function setLocalPaymentMethodsRecurringInformation(AdapterInterface $connection)
{
$select = $connection->select()
->from($this->configDataTable)
->where('path = ?', 'payment/adyen_abstract/enable_recurring')
->where('value <> "" AND value IS NOT NULL');
$recurringConfigurationList = $connection->fetchAll($select);
foreach ($recurringConfigurationList as $aRecurringConfiguration) {
$this->configWriter->save(
'payment/adyen_abstract/stored_local_payments_active',
$aRecurringConfiguration['value'],
$aRecurringConfiguration['scope'],
$aRecurringConfiguration['scope_id']
);
}
}
} }
...@@ -25,5 +25,10 @@ ...@@ -25,5 +25,10 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<label>Stored payment method details options</label> <label>Stored payment method details options</label>
<comment><![CDATA[Adyen can securely store shoppers' local payment method details to enable recurring payments. See which local payment methods support recurring on <a href="https://docs.adyen.com/payment-methods#cash-and-atm-payment-methods" target="_blank">Adyen documentation</a>.]]]></comment> <comment><![CDATA[Adyen can securely store shoppers' local payment method details to enable recurring payments. See which local payment methods support recurring on <a href="https://docs.adyen.com/payment-methods#cash-and-atm-payment-methods" target="_blank">Adyen documentation</a>.]]]></comment>
<!--TODO: GRANTC Define new fields about Store Recurring Payments-->
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_abstract/stored_local_payments_active</config_path>
</field>
</config> </config>
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
<send_email_bank_sepa_on_pending>0</send_email_bank_sepa_on_pending> <send_email_bank_sepa_on_pending>0</send_email_bank_sepa_on_pending>
<ignore_refund_notification>0</ignore_refund_notification> <ignore_refund_notification>0</ignore_refund_notification>
<kar_capture_mode>capture_manually</kar_capture_mode> <kar_capture_mode>capture_manually</kar_capture_mode>
<!-- etc/adminhtml/system/payment_methods/local_payment_methods/stored_payment_method_details.xml -->
<stored_local_payments_active>0</stored_local_payments_active>
</adyen_abstract> </adyen_abstract>
<adyen_cc> <adyen_cc>
<active>1</active> <active>1</active>
......
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