Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add or improve logs #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Controller/Checkout/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public function execute()
'error' => true,
'message' => $e->getMessage()
]);

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $result;
Expand Down
9 changes: 8 additions & 1 deletion Controller/Notification/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ class Status extends \Magento\Framework\App\Action\Action
protected $resultJsonFactory;
protected $ebanxHelper;
protected $priceCurrency;
protected $_logger;

public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
\DigitalHub\Ebanx\Helper\Data $ebanxHelper,
\Magento\Framework\Event\Manager $eventManager
\Magento\Framework\Event\Manager $eventManager,
\DigitalHub\Ebanx\Logger\Logger $logger
)
{
parent::__construct($context);
$this->resultJsonFactory = $resultJsonFactory;
$this->ebanxHelper = $ebanxHelper;
$this->_eventManager = $eventManager;
$this->_logger = $logger;

if (interface_exists('\Magento\Framework\App\CsrfAwareActionInterface')) {
$request = $this->getRequest();
Expand Down Expand Up @@ -66,12 +69,16 @@ public function execute()
$result->setData([
'success' => true
]);

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
} catch (\Exception $e){
$result->setHttpResponseCode(\Magento\Framework\Webapi\Exception::HTTP_BAD_REQUEST);
$result->setData([
'error' => true,
'message' => $e->getMessage()
]);

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
2 changes: 2 additions & 0 deletions Gateway/Http/Client/Brazil/CreditCard/TransactionCancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
2 changes: 2 additions & 0 deletions Gateway/Http/Client/Brazil/CreditCard/TransactionCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
2 changes: 2 additions & 0 deletions Gateway/Http/Client/Brazil/CreditCard/TransactionRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
2 changes: 2 additions & 0 deletions Gateway/Http/Client/Brazil/Pix/TransactionAuthorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
2 changes: 2 additions & 0 deletions Gateway/Http/Client/Colombia/CreditCard/TransactionCancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
2 changes: 2 additions & 0 deletions Gateway/Http/Client/Colombia/CreditCard/TransactionRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
2 changes: 2 additions & 0 deletions Gateway/Http/Client/Mexico/CreditCard/TransactionCancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
2 changes: 2 additions & 0 deletions Gateway/Http/Client/Mexico/CreditCard/TransactionCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
2 changes: 2 additions & 0 deletions Gateway/Http/Client/Mexico/CreditCard/TransactionRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr

} catch (\Exception $e){
$response['error'] = $e->getMessage();

$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
$this->_logger->info('EBANX Result Authorization :: placeRequest', [$payment_result]);

} catch (\Exception $e){
$this->_logger->info('EBANX ERROR :: placeRequest', [$e->getMessage()]);
$this->_logger->info(sprintf('EBANX Exception `%s` :: `%s`', get_class($e), __METHOD__), [$e->getMessage()]);
$response['error'] = $e->getMessage();
}

Expand Down
2 changes: 2 additions & 0 deletions Gateway/Request/Colombia/CreditCard/PaymentDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public function build(array $buildSubject)
$tokenObject = $this->tokenModel->getTokenByIdAndCustomer($additionalData[DataAssignObserver::USE_SAVED_CC], (int)$this->_session->getQuote()->getCustomerId());

if(!$tokenObject){
$this->_logger->info(sprintf('`%s` :: The requested saved credit card not exists', __METHOD__));

throw new \Exception('The requested saved credit card not exists');
}

Expand Down
2 changes: 2 additions & 0 deletions Gateway/Request/CreditCardUtils/GenericPaymentDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public function build(array $buildSubject)
$tokenObject = $this->tokenModel->getTokenByIdAndCustomer($additionalData[GenericDataAssignObserver::USE_SAVED_CC], (int)$this->_session->getQuote()->getCustomerId());

if(!$tokenObject){
$this->_logger->info(sprintf('`%s` :: The requested saved credit card not exists', __METHOD__));

throw new \Exception('The requested saved credit card not exists');
}

Expand Down
2 changes: 2 additions & 0 deletions Gateway/Request/CustomerDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function build(array $buildSubject)

$documentNumber = false;
if(in_array($countryId, ['BR','CL','AR','CO'])){
$this->_logger->info(sprintf('Country id is `%s` and its not one of [BR, CL, AR, CO]', $countryId));

$documentNumberField = $this->_ebanxHelper->getCustomerDocumentNumberField($this->_session->getQuote());
$documentNumber = $this->_ebanxHelper->getCustomerDocumentNumber($this->_session->getQuote(), $documentNumberField);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function handle(array $handlingSubject, array $response)

$payment_result_data = (array)$response['payment_result'];

$this->_logger->info(__METHOD__, [$response['payment_result']??null]);

$payment->setTransactionId($payment_result_data['payment']['hash']);
$payment->setAdditionalInformation('transaction_data', $payment_result_data);

Expand Down
2 changes: 1 addition & 1 deletion Gateway/Response/Argentina/CreditCard/CancelHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function handle(array $handlingSubject, array $response)
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
$payment = $payment->getPayment();

$this->_logger->info('CancelHandler :: handle');
$this->_logger->info(__METHOD__, [$response['payment_result']??null]);

$payment->setIsTransactionPending(false);
$payment->setIsTransactionClosed(true);
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Response/Argentina/CreditCard/CaptureHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function handle(array $handlingSubject, array $response)
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
$payment = $payment->getPayment();

$this->_logger->info('CaptureHandler :: handle');
$this->_logger->info(__METHOD__, [$response['payment_result']??null]);

$payment->setIsTransactionPending(false);
$payment->setIsTransactionClosed(true);
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Response/Argentina/CreditCard/RefundHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function handle(array $handlingSubject, array $response)
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
$payment = $payment->getPayment();

$this->_logger->info('RefundHandler :: handle');
$this->_logger->info(__METHOD__, [$response['payment_result']??null]);

$payment->setIsTransactionPending(false);
$payment->setIsTransactionClosed(true);
Expand Down
Loading