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