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

optimize code and remove debugger

parent 205af285
...@@ -29,12 +29,12 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface ...@@ -29,12 +29,12 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface
/** /**
* @var \Adyen\Payment\Helper\Data * @var \Adyen\Payment\Helper\Data
*/ */
protected $_adyenHelper; protected $adyenHelper;
/** /**
* @var \Magento\AdminNotification\Model\InboxFactory * @var \Magento\AdminNotification\Model\InboxFactory
*/ */
protected $_inboxFactory; protected $inboxFactory;
/** /**
* @var \Magento\Store\Model\StoreManagerInterface * @var \Magento\Store\Model\StoreManagerInterface
...@@ -53,6 +53,8 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface ...@@ -53,6 +53,8 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface
* *
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\AdminNotification\Model\InboxFactory $inboxFactory * @param \Magento\AdminNotification\Model\InboxFactory $inboxFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManagerInterface
* @param \Magento\Backend\Model\Auth\Session $authSession
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
...@@ -60,8 +62,8 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface ...@@ -60,8 +62,8 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface
\Magento\Store\Model\StoreManagerInterface $storeManagerInterface, \Magento\Store\Model\StoreManagerInterface $storeManagerInterface,
\Magento\Backend\Model\Auth\Session $authSession \Magento\Backend\Model\Auth\Session $authSession
) { ) {
$this->_adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->_inboxFactory = $inboxFactory; $this->inboxFactory = $inboxFactory;
$this->storeManagerInterface = $storeManagerInterface; $this->storeManagerInterface = $storeManagerInterface;
$this->authSession = $authSession; $this->authSession = $authSession;
} }
...@@ -83,24 +85,29 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface ...@@ -83,24 +85,29 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface
*/ */
public function isDisplayed() public function isDisplayed()
{ {
// Only execute the query the first time you access the Admin page // Only execute the query the first time you access the Admin page
if ($this->authSession->isFirstPageAfterLogin() && !empty($this->_adyenHelper->getWsUsername()) && empty($this->_adyenHelper->getAPIKey())) { if ($this->authSession->isFirstPageAfterLogin() &&
!empty($this->adyenHelper->getWsUsername()) &&
empty($this->adyenHelper->getAPIKey())
) {
try { try {
$title = "Adyen extension requires the API KEY!222"; $title = 'Adyen extension requires the API KEY!';
$messageData[] = array( $messageData[] = [
'severity' => $this->getSeverity(), 'severity' => $this->getSeverity(),
'date_added' => date("Y-m-d"), 'date_added' => date('Y-m-d'),
'title' => $title, 'title' => $title,
'description' => $this->getText(), 'description' => $this->getText(),
'url' => "https://docs.adyen.com/developers/plug-ins-and-partners/magento-2/set-up-the-plugin-in-magento#step3configuretheplugininmagento", 'url' => 'https://docs.adyen.com/developers/plug-ins-and-partners/magento-2/' .
); 'set-up-the-plugin-in-magento#step3configuretheplugininmagento',
];
/* /*
* The parse function checks if the $versionData message exists in the inbox, * The parse function checks if the $versionData message exists in the inbox,
* otherwise it will create it and add it to the inbox. * otherwise it will create it and add it to the inbox.
*/ */
$this->_inboxFactory->create()->parse(array_reverse($messageData)); $this->inboxFactory->create()->parse($messageData);
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
...@@ -114,14 +121,16 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface ...@@ -114,14 +121,16 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface
/** /**
* Retrieve system message text * Retrieve system message text
* *
* @return \Magento\Framework\Phrase * @return string
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/ */
public function getText() public function getText()
{ {
if (!empty($this->_adyenHelper->getWsUsername())) { $message = '';
$message = "Please provide API-KEY for the webservice user " . $this->_adyenHelper->getWsUsername() . " for default/store " . $this->storeManagerInterface->getStore()->getName(); if (!empty($this->adyenHelper->getWsUsername())) {
}else{ $message = 'Please provide API-KEY for the webservice user ' .
$message = "Please provide API-KEY for default/store " . $this->storeManagerInterface->getStore()->getName(); $this->adyenHelper->getWsUsername() . ' for default/store ' .
$this->storeManagerInterface->getStore()->getName();
} }
return $message; return $message;
......
...@@ -32,11 +32,6 @@ class RecurringDataBuilder implements BuilderInterface ...@@ -32,11 +32,6 @@ class RecurringDataBuilder implements BuilderInterface
*/ */
private $adyenHelper; private $adyenHelper;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $_adyenLogger;
/** /**
* @var \Magento\Framework\App\State * @var \Magento\Framework\App\State
*/ */
...@@ -50,12 +45,10 @@ class RecurringDataBuilder implements BuilderInterface ...@@ -50,12 +45,10 @@ class RecurringDataBuilder implements BuilderInterface
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Model\Context $context, \Magento\Framework\Model\Context $context
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
) { ) {
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->appState = $context->getAppState(); $this->appState = $context->getAppState();
$this->_adyenLogger = $adyenLogger;
} }
...@@ -88,7 +81,7 @@ class RecurringDataBuilder implements BuilderInterface ...@@ -88,7 +81,7 @@ class RecurringDataBuilder implements BuilderInterface
$result['enableRecurring'] = true; $result['enableRecurring'] = true;
} }
if ($payment->getAdditionalInformation("store_cc") === "1") { if ($payment->getAdditionalInformation('store_cc') === '1') {
$result['paymentMethod']['storeDetails'] = true; $result['paymentMethod']['storeDetails'] = true;
} }
......
...@@ -27,12 +27,16 @@ use Magento\Payment\Gateway\Response\HandlerInterface; ...@@ -27,12 +27,16 @@ use Magento\Payment\Gateway\Response\HandlerInterface;
class CheckoutPaymentsDetailsHandler implements HandlerInterface class CheckoutPaymentsDetailsHandler implements HandlerInterface
{ {
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $adyenHelper;
public function __construct( public function __construct(
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Helper\Data $adyenHelper \Adyen\Payment\Helper\Data $adyenHelper
) { ) {
$this->_adyenLogger = $adyenLogger; $this->adyenHelper = $adyenHelper;
$this->_adyenHelper = $adyenHelper;
} }
/** /**
...@@ -61,15 +65,16 @@ class CheckoutPaymentsDetailsHandler implements HandlerInterface ...@@ -61,15 +65,16 @@ class CheckoutPaymentsDetailsHandler implements HandlerInterface
$payment->setTransactionId($response['pspReference']); $payment->setTransactionId($response['pspReference']);
} }
if (!empty($response['additionalData']) && !empty($response['additionalData']['recurring.recurringDetailReference'])){ if (!empty($response['additionalData']) &&
!empty($response['additionalData']['recurring.recurringDetailReference'])
) {
$order = $payment->getOrder(); $order = $payment->getOrder();
$this->_adyenHelper->createAdyenBillingAgreement($order, $response['additionalData']); $this->adyenHelper->createAdyenBillingAgreement($order, $response['additionalData']);
} }
// do not close transaction so you can do a cancel() and void // do not close transaction so you can do a cancel() and void
$payment->setIsTransactionClosed(false); $payment->setIsTransactionClosed(false);
$payment->setShouldCloseParentTransaction(false); $payment->setShouldCloseParentTransaction(false);
} }
} }
...@@ -29,7 +29,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -29,7 +29,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
/** /**
* @var \Adyen\Payment\Helper\Data * @var \Adyen\Payment\Helper\Data
*/ */
private $_adyenHelper; private $adyenHelper;
/** /**
* Agreement constructor. * Agreement constructor.
...@@ -66,7 +66,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -66,7 +66,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
$data $data
); );
$this->_adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
} }
/** /**
...@@ -105,7 +105,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -105,7 +105,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
// Billing agreement is CC // Billing agreement is CC
if (isset($data['card']['number'])) { if (isset($data['card']['number'])) {
$ccType = $data['variant']; $ccType = $data['variant'];
$ccTypes = $this->_adyenHelper->getCcTypesAltData(); $ccTypes = $this->adyenHelper->getCcTypesAltData();
if (isset($ccTypes[$ccType])) { if (isset($ccTypes[$ccType])) {
$ccType = $ccTypes[$ccType]['name']; $ccType = $ccTypes[$ccType]['name'];
...@@ -123,7 +123,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -123,7 +123,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
} }
if ($data['variant'] == 'paypal') { if ($data['variant'] == 'paypal') {
$email = ""; $email = '';
if (isset($data['tokenDetails']['tokenData']['EmailId'])) { if (isset($data['tokenDetails']['tokenData']['EmailId'])) {
$email = $data['tokenDetails']['tokenData']['EmailId']; $email = $data['tokenDetails']['tokenData']['EmailId'];
...@@ -150,9 +150,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -150,9 +150,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
public function setAgreementData($data) public function setAgreementData($data)
{ {
if (is_array($data)) { if (is_array($data)) {
unset($data['creationDate']); unset($data['creationDate'], $data['recurringDetailReference'], $data['payment_method']);
unset($data['recurringDetailReference']);
unset($data['payment_method']);
} }
$this->setData('agreement_data', json_encode($data)); $this->setData('agreement_data', json_encode($data));
...@@ -174,27 +172,20 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -174,27 +172,20 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
->setReferenceId($contractDetail['recurring.recurringDetailReference']); ->setReferenceId($contractDetail['recurring.recurringDetailReference']);
// Billing agreement is CC // Billing agreement is CC
/**
* $contractDetail['cardBin'] = $cardBin;
* $contractDetail['recurringDetailReference'] = $recurringDetailReference;
* $contractDetail['cardHolderName'] = $cardHolderName;
* $contractDetail['cardSummary'] = $cardSummary;
* $contractDetail['expiryDate'] = $expiryDate;
* $contractDetail['paymentMethod'] = $paymentMethod;
*/
if (isset($contractDetail['cardBin']) && if (isset($contractDetail['cardBin']) &&
isset($contractDetail['cardHolderName']) && isset($contractDetail['cardHolderName']) &&
isset($contractDetail['cardSummary']) && isset($contractDetail['cardSummary']) &&
isset($contractDetail['expiryDate']) && isset($contractDetail['expiryDate']) &&
isset($contractDetail['paymentMethod'])) { isset($contractDetail['paymentMethod'])) {
$ccType = $contractDetail['paymentMethod']; $ccType = $contractDetail['paymentMethod'];
$ccTypes = $this->_adyenHelper->getCcTypesAltData(); $ccTypes = $this->adyenHelper->getCcTypesAltData();
if (isset($ccTypes[$ccType])) { if (isset($ccTypes[$ccType])) {
$ccType = $ccTypes[$ccType]['name']; $ccType = $ccTypes[$ccType]['name'];
} }
$label = __('%1, %2, **** %3', $label = __(
'%1, %2, **** %3',
$ccType, $ccType,
$contractDetail['cardHolderName'], $contractDetail['cardHolderName'],
$contractDetail['cardSummary'] $contractDetail['cardSummary']
...@@ -203,7 +194,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -203,7 +194,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
} }
$expiryDate = explode('/', $contractDetail['expiryDate']); $expiryDate = explode('/', $contractDetail['expiryDate']);
$recurringType = $this->_adyenHelper->getRecurringTypeFromOneclickRecurringSetting(); $recurringType = $this->adyenHelper->getRecurringTypeFromOneclickRecurringSetting();
$agreementData = [ $agreementData = [
'card' => [ 'card' => [
...@@ -219,6 +210,5 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -219,6 +210,5 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
$this->setAgreementData($agreementData); $this->setAgreementData($agreementData);
return $this; return $this;
} }
} }
...@@ -285,7 +285,7 @@ define( ...@@ -285,7 +285,7 @@ define(
var form = 'form[data-role=' + codeValue + ']'; var form = 'form[data-role=' + codeValue + ']';
var validate = $(form).validation() && $(form).validation('isValid'); var validate = $(form).validation() && $(form).validation('isValid');
debugger;
// bcmc does not have any cvc // bcmc does not have any cvc
if (!validate || (isValid() == false && variant() != "bcmc")) { if (!validate || (isValid() == false && variant() != "bcmc")) {
return false; return false;
......
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