We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday 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;
class Pos extends \Magento\Payment\Block\Form
{
/**
* quest prefix
*/
const GUEST_ID = 'customer_';
protected $_orderFactory;
/**
......@@ -118,13 +114,13 @@ class Pos extends \Magento\Payment\Block\Form
$currencyCode = $orderCurrencyCode;
$paymentAmount = $amount;
$merchantReference = $realOrderId;
$shopperReference = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId;
$shopperEmail = $shopperEmail;
$recurringParams = "";
if ($this->_order->getPayment()->getAdditionalInformation("store_cc") != "") {
if ($this->_order->getPayment()->getAdditionalInformation("store_cc") != ""
&& $customerId > 0
) {
$recurringParams = "&recurringContract=" . urlencode($recurringContract) . "&shopperReference=" .
urlencode($shopperReference) . "&shopperEmail=" . urlencode($shopperEmail);
urlencode($customerId) . "&shopperEmail=" . urlencode($shopperEmail);
}
$receiptOrderLines = "";
......
......@@ -28,11 +28,6 @@ use Symfony\Component\Config\Definition\Exception\Exception;
class Redirect extends \Magento\Payment\Block\Form
{
/**
* quest prefix
*/
const GUEST_ID = 'customer_';
/**
* @var \Magento\Sales\Model\OrderFactory
*/
......@@ -233,8 +228,11 @@ class Redirect extends \Magento\Payment\Block\Form
$recurringType = "RECURRING";
}
$formFields['recurringContract'] = $recurringType;
$formFields['shopperReference'] = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId;
if ($customerId > 0) {
$formFields['recurringContract'] = $recurringType;
$formFields['shopperReference'] = $customerId;
}
//blocked methods
$formFields['blockedMethods'] = "";
......
......@@ -29,11 +29,6 @@ use Magento\Payment\Gateway\CommandInterface;
class PayByMailCommand implements CommandInterface
{
/**
* quest prefix
*/
const GUEST_ID = 'customer_';
/**
* @var \Adyen\Payment\Helper\Data
*/
......@@ -190,10 +185,7 @@ class PayByMailCommand implements CommandInterface
$formFields['shopperEmail'] = $shopperEmail;
// recurring
$recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData('recurring_type'));
$formFields['recurringContract'] = $recurringType;
$sessionValidity = $this->_adyenHelper->getAdyenPayByMailConfigData('session_validity');
if ($sessionValidity == "") {
......@@ -201,7 +193,11 @@ class PayByMailCommand implements CommandInterface
}
$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
ksort($formFields, SORT_STRING);
......
......@@ -29,10 +29,6 @@ use Magento\Payment\Gateway\Request\BuilderInterface;
*/
class CustomerDataBuilder implements BuilderInterface
{
/**
* quest prefix
*/
const GUEST_ID = 'customer_';
/**
* Add shopper data into request
......@@ -42,19 +38,22 @@ class CustomerDataBuilder implements BuilderInterface
*/
public function build(array $buildSubject)
{
$result = [];
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder();
$billingAddress = $order->getBillingAddress();
$customerEmail = $billingAddress->getEmail();
$realOrderId = $order->getOrderIncrementId();
$customerId = $order->getCustomerId();
$shopperReference = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId;
return [
"shopperEmail" => $customerEmail,
"shopperReference" => $shopperReference
];
if ($customerId > 0) {
$result['shopperReference'] = $customerId;
}
$result ['shopperEmail'] = $customerEmail;
return $result;
}
}
......@@ -63,6 +63,7 @@ class RecurringDataBuilder implements BuilderInterface
$payment = $paymentDataObject->getPayment();
// Needs to change when oneclick,cc using facade impl.
$paymentMethodCode = $payment->getMethodInstance()->getCode();
$customerId = $payment->getOrder()->getCustomerId();
$storeId = null;
if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
......@@ -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];
$result['recurring'] = $recurring;
}
......
......@@ -58,8 +58,6 @@ class PaymentRequest extends DataObject
*/
protected $_appState;
const GUEST_ID = 'customer_';
/**
* 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