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 7a7741c9 authored by Rik ter Beek's avatar Rik ter Beek

#78 Do not store card if user is not loggedin

parent 164a2b06
...@@ -27,10 +27,6 @@ use Symfony\Component\Config\Definition\Exception\Exception; ...@@ -27,10 +27,6 @@ use Symfony\Component\Config\Definition\Exception\Exception;
class Pos extends \Magento\Payment\Block\Form class Pos extends \Magento\Payment\Block\Form
{ {
/**
* quest prefix
*/
const GUEST_ID = 'customer_';
protected $_orderFactory; protected $_orderFactory;
/** /**
...@@ -118,13 +114,13 @@ class Pos extends \Magento\Payment\Block\Form ...@@ -118,13 +114,13 @@ class Pos extends \Magento\Payment\Block\Form
$currencyCode = $orderCurrencyCode; $currencyCode = $orderCurrencyCode;
$paymentAmount = $amount; $paymentAmount = $amount;
$merchantReference = $realOrderId; $merchantReference = $realOrderId;
$shopperReference = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId;
$shopperEmail = $shopperEmail;
$recurringParams = ""; $recurringParams = "";
if ($this->_order->getPayment()->getAdditionalInformation("store_cc") != "") { if ($this->_order->getPayment()->getAdditionalInformation("store_cc") != ""
&& $customerId > 0
) {
$recurringParams = "&recurringContract=" . urlencode($recurringContract) . "&shopperReference=" . $recurringParams = "&recurringContract=" . urlencode($recurringContract) . "&shopperReference=" .
urlencode($shopperReference) . "&shopperEmail=" . urlencode($shopperEmail); urlencode($customerId) . "&shopperEmail=" . urlencode($shopperEmail);
} }
$receiptOrderLines = ""; $receiptOrderLines = "";
......
...@@ -28,11 +28,6 @@ use Symfony\Component\Config\Definition\Exception\Exception; ...@@ -28,11 +28,6 @@ use Symfony\Component\Config\Definition\Exception\Exception;
class Redirect extends \Magento\Payment\Block\Form class Redirect extends \Magento\Payment\Block\Form
{ {
/**
* quest prefix
*/
const GUEST_ID = 'customer_';
/** /**
* @var \Magento\Sales\Model\OrderFactory * @var \Magento\Sales\Model\OrderFactory
*/ */
...@@ -233,8 +228,11 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -233,8 +228,11 @@ class Redirect extends \Magento\Payment\Block\Form
$recurringType = "RECURRING"; $recurringType = "RECURRING";
} }
if ($customerId > 0) {
$formFields['recurringContract'] = $recurringType; $formFields['recurringContract'] = $recurringType;
$formFields['shopperReference'] = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId; $formFields['shopperReference'] = $customerId;
}
//blocked methods //blocked methods
$formFields['blockedMethods'] = ""; $formFields['blockedMethods'] = "";
......
...@@ -29,11 +29,6 @@ use Magento\Payment\Gateway\CommandInterface; ...@@ -29,11 +29,6 @@ use Magento\Payment\Gateway\CommandInterface;
class PayByMailCommand implements CommandInterface class PayByMailCommand implements CommandInterface
{ {
/**
* quest prefix
*/
const GUEST_ID = 'customer_';
/** /**
* @var \Adyen\Payment\Helper\Data * @var \Adyen\Payment\Helper\Data
*/ */
...@@ -191,9 +186,6 @@ class PayByMailCommand implements CommandInterface ...@@ -191,9 +186,6 @@ class PayByMailCommand implements CommandInterface
// recurring // recurring
$recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData('recurring_type')); $recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData('recurring_type'));
$formFields['recurringContract'] = $recurringType;
$sessionValidity = $this->_adyenHelper->getAdyenPayByMailConfigData('session_validity'); $sessionValidity = $this->_adyenHelper->getAdyenPayByMailConfigData('session_validity');
if ($sessionValidity == "") { if ($sessionValidity == "") {
...@@ -201,7 +193,11 @@ class PayByMailCommand implements CommandInterface ...@@ -201,7 +193,11 @@ class PayByMailCommand implements CommandInterface
} }
$formFields['sessionValidity'] = date("c", strtotime("+". $sessionValidity. " days")); $formFields['sessionValidity'] = date("c", strtotime("+". $sessionValidity. " days"));
$formFields['shopperReference'] = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId;
if ($customerId > 0) {
$formFields['recurringContract'] = $recurringType;
$formFields['shopperReference'] = $customerId;
}
// Sort the array by key using SORT_STRING order // Sort the array by key using SORT_STRING order
ksort($formFields, SORT_STRING); ksort($formFields, SORT_STRING);
......
...@@ -29,10 +29,6 @@ use Magento\Payment\Gateway\Request\BuilderInterface; ...@@ -29,10 +29,6 @@ use Magento\Payment\Gateway\Request\BuilderInterface;
*/ */
class CustomerDataBuilder implements BuilderInterface class CustomerDataBuilder implements BuilderInterface
{ {
/**
* quest prefix
*/
const GUEST_ID = 'customer_';
/** /**
* Add shopper data into request * Add shopper data into request
...@@ -42,19 +38,22 @@ class CustomerDataBuilder implements BuilderInterface ...@@ -42,19 +38,22 @@ class CustomerDataBuilder implements BuilderInterface
*/ */
public function build(array $buildSubject) public function build(array $buildSubject)
{ {
$result = [];
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */ /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder(); $order = $paymentDataObject->getOrder();
$billingAddress = $order->getBillingAddress(); $billingAddress = $order->getBillingAddress();
$customerEmail = $billingAddress->getEmail(); $customerEmail = $billingAddress->getEmail();
$realOrderId = $order->getOrderIncrementId();
$customerId = $order->getCustomerId(); $customerId = $order->getCustomerId();
$shopperReference = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId;
return [ if ($customerId > 0) {
"shopperEmail" => $customerEmail, $result['shopperReference'] = $customerId;
"shopperReference" => $shopperReference }
];
$result ['shopperEmail'] = $customerEmail;
return $result;
} }
} }
...@@ -63,6 +63,7 @@ class RecurringDataBuilder implements BuilderInterface ...@@ -63,6 +63,7 @@ class RecurringDataBuilder implements BuilderInterface
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
// Needs to change when oneclick,cc using facade impl. // Needs to change when oneclick,cc using facade impl.
$paymentMethodCode = $payment->getMethodInstance()->getCode(); $paymentMethodCode = $payment->getMethodInstance()->getCode();
$customerId = $payment->getOrder()->getCustomerId();
$storeId = null; $storeId = null;
if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) { if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
...@@ -95,7 +96,8 @@ class RecurringDataBuilder implements BuilderInterface ...@@ -95,7 +96,8 @@ class RecurringDataBuilder implements BuilderInterface
} }
} }
if ($recurringContractType) { // only when recurringContractType is set and when a customer is loggedIn
if ($recurringContractType && $customerId > 0) {
$recurring = ['contract' => $recurringContractType]; $recurring = ['contract' => $recurringContractType];
$result['recurring'] = $recurring; $result['recurring'] = $recurring;
} }
......
...@@ -58,8 +58,6 @@ class PaymentRequest extends DataObject ...@@ -58,8 +58,6 @@ class PaymentRequest extends DataObject
*/ */
protected $_appState; protected $_appState;
const GUEST_ID = 'customer_';
/** /**
* PaymentRequest constructor. * PaymentRequest constructor.
* *
......
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