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 3ae61736 authored by Aleffio's avatar Aleffio

Remove customer prefix, re-add 1 minute delay on notifications, re-add...

Remove customer prefix, re-add 1 minute delay on notifications, re-add store_id on query Billing Agreements
parent 91e097a4
...@@ -247,7 +247,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -247,7 +247,7 @@ class Redirect extends \Magento\Payment\Block\Form
if ($customerId > 0) { if ($customerId > 0) {
$formFields['recurringContract'] = $recurringType; $formFields['recurringContract'] = $recurringType;
$formFields['shopperReference'] = $this->_adyenHelper->getCustomerReference($customerId); $formFields['shopperReference'] = $customerId;
} else { } else {
// required for openinvoice payment methods use unique id // required for openinvoice payment methods use unique id
$uniqueReference = "guest_" . $realOrderId . "_" . $this->_order->getStoreId(); $uniqueReference = "guest_" . $realOrderId . "_" . $this->_order->getStoreId();
......
...@@ -196,7 +196,7 @@ class PayByMailCommand implements CommandInterface ...@@ -196,7 +196,7 @@ class PayByMailCommand implements CommandInterface
if ($customerId > 0) { if ($customerId > 0) {
$formFields['recurringContract'] = $recurringType; $formFields['recurringContract'] = $recurringType;
$formFields['shopperReference'] = $this->_adyenHelper->getCustomerReference($customerId); $formFields['shopperReference'] = $customerId;
} }
// Sign request using secret key // Sign request using secret key
......
...@@ -30,20 +30,6 @@ use Magento\Payment\Gateway\Request\BuilderInterface; ...@@ -30,20 +30,6 @@ use Magento\Payment\Gateway\Request\BuilderInterface;
class CustomerDataBuilder implements BuilderInterface class CustomerDataBuilder implements BuilderInterface
{ {
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* CustomerDataBuilder constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->adyenHelper = $adyenHelper;
}
/** /**
* Add shopper data into request * Add shopper data into request
* *
...@@ -63,7 +49,7 @@ class CustomerDataBuilder implements BuilderInterface ...@@ -63,7 +49,7 @@ class CustomerDataBuilder implements BuilderInterface
$customerId = $order->getCustomerId(); $customerId = $order->getCustomerId();
if ($customerId > 0) { if ($customerId > 0) {
$result['shopperReference'] = $this->adyenHelper->getCustomerReference($customerId); $result['shopperReference'] = $customerId;
} }
$result ['shopperEmail'] = $customerEmail; $result ['shopperEmail'] = $customerEmail;
......
...@@ -825,6 +825,7 @@ class Data extends AbstractHelper ...@@ -825,6 +825,7 @@ class Data extends AbstractHelper
$baCollection = $this->_billingAgreementCollectionFactory->create(); $baCollection = $this->_billingAgreementCollectionFactory->create();
$baCollection->addFieldToFilter('customer_id', $customerId); $baCollection->addFieldToFilter('customer_id', $customerId);
$baCollection->addFieldToFilter('store_id', $storeId);
$baCollection->addFieldToFilter('method_code', 'adyen_oneclick'); $baCollection->addFieldToFilter('method_code', 'adyen_oneclick');
$baCollection->addActiveFilter(); $baCollection->addActiveFilter();
...@@ -1241,19 +1242,6 @@ class Data extends AbstractHelper ...@@ -1241,19 +1242,6 @@ class Data extends AbstractHelper
return $formatted; return $formatted;
} }
/**
* @param $customerId int|string the numerice ID of the customer
* @return string customer ID, prefixed by customer_reference_prefix if that is set
*/
public function getCustomerReference($customerId)
{
$prefix = $this->getAdyenOneclickConfigData('customer_reference_prefix');
if (empty($prefix)) {
return strval($customerId);
}
return $prefix . strval($customerId);
}
/** /**
* Initializes and returns Adyen Client and sets the required parameters of it * Initializes and returns Adyen Client and sets the required parameters of it
* *
......
...@@ -144,19 +144,6 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -144,19 +144,6 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
], ],
]; ];
if (empty($customerId)) {
// No customer ID in quote but the customer might still exist; so find him/her by email address
$shopperEmail = $quote->getCustomerEmail();
$collection = $this->_customerCollectionFactory->create();
$collection->addAttributeToSelect('*');
$collection->addFieldToFilter('email', ['eq' => $shopperEmail]);
$customer = $collection->getFirstItem();
if ($customer && !empty($customer->getId())) {
$customerId = $customer->getId();
}
}
// If customer exists add it into the request to store request // If customer exists add it into the request to store request
if (!empty($customerId)) { if (!empty($customerId)) {
$shopperEmail = $quote->getCustomerEmail(); $shopperEmail = $quote->getCustomerEmail();
...@@ -165,7 +152,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -165,7 +152,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
if (!empty($recurringContract) && !empty($shopperEmail) && !empty($customerId)) { if (!empty($recurringContract) && !empty($shopperEmail) && !empty($customerId)) {
$recurringDetails = [ $recurringDetails = [
'shopperEmail' => $shopperEmail, 'shopperEmail' => $shopperEmail,
'shopperReference' => $this->_adyenHelper->getCustomerReference($customerId), 'shopperReference' => strval($customerId),
'recurringContract' => $recurringContract 'recurringContract' => $recurringContract
]; ];
$request['SaleToPOIRequest']['PaymentRequest']['SaleData']['SaleToAcquirerData'] = http_build_query($recurringDetails); $request['SaleToPOIRequest']['PaymentRequest']['SaleData']['SaleToAcquirerData'] = http_build_query($recurringDetails);
......
...@@ -70,11 +70,11 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -70,11 +70,11 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
/** /**
* Not yet possible to set different reference on customer level like magento 1.x version * Not yet possible to set different reference on customer level like magento 1.x version
* *
* @return string * @return int
*/ */
public function getCustomerReference() public function getCustomerReference()
{ {
return $this->_adyenHelper->getCustomerReference($this->getCustomerId()); return $this->getCustomerId();
} }
/** /**
......
...@@ -300,7 +300,7 @@ class Cron ...@@ -300,7 +300,7 @@ class Cron
$dateStart = new \DateTime(); $dateStart = new \DateTime();
$dateStart->modify('-5 day'); $dateStart->modify('-5 day');
$dateEnd = new \DateTime(); $dateEnd = new \DateTime();
// $dateEnd->modify('-1 minute'); $dateEnd->modify('-1 minute');
$dateRange = ['from' => $dateStart, 'to' => $dateEnd, 'datetime' => true]; $dateRange = ['from' => $dateStart, 'to' => $dateEnd, 'datetime' => true];
// create collection // create collection
...@@ -929,8 +929,7 @@ class Cron ...@@ -929,8 +929,7 @@ class Cron
$recurringDetailReference = $this->_pspReference; $recurringDetailReference = $this->_pspReference;
$storeId = $this->_order->getStoreId(); $storeId = $this->_order->getStoreId();
$customerId = $this->_order->getCustomerId(); $customerReference = $this->_order->getCustomerId();
$customerReference = $this->_adyenHelper->getCustomerReference($customerId);
$listRecurringContracts = null; $listRecurringContracts = null;
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
__('CustomerReference is: %1 and storeId is %2 and RecurringDetailsReference is %3', __('CustomerReference is: %1 and storeId is %2 and RecurringDetailsReference is %3',
...@@ -967,7 +966,7 @@ class Cron ...@@ -967,7 +966,7 @@ class Cron
} }
$billingAgreements = $this->_billingAgreementCollectionFactory->create(); $billingAgreements = $this->_billingAgreementCollectionFactory->create();
$billingAgreements->addFieldToFilter('customer_id', $customerId); $billingAgreements->addFieldToFilter('customer_id', $customerReference);
// Get collection and update existing agreements // Get collection and update existing agreements
......
...@@ -49,10 +49,5 @@ ...@@ -49,10 +49,5 @@
<source_model>Adyen\Payment\Model\Config\Source\RecurringPaymentType</source_model> <source_model>Adyen\Payment\Model\Config\Source\RecurringPaymentType</source_model>
<config_path>payment/adyen_oneclick/recurring_payment_type</config_path> <config_path>payment/adyen_oneclick/recurring_payment_type</config_path>
</field> </field>
<field id="customer_reference_prefix" translate="label" type="text" sortOrder="50" showInDefault="1">
<label>Customer Reference Prefix</label>
<tooltip>This optional prefix is used for the customer reference showing on payments. If you change this later then card details of earlier payments can't be retrieved.</tooltip>
<config_path>payment/adyen_oneclick/customer_reference_prefix</config_path>
</field>
</group> </group>
</include> </include>
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