Skip to content

Commit

Permalink
PagBank 😍 Magento
Browse files Browse the repository at this point in the history
- Consulta de status: Destrava filas por algum pedido inválido.
- Consulta de status: Informa via notificação o administrador sobre
 pedidos com status não podem ser consultados.
  • Loading branch information
elisei committed Oct 25, 2023
1 parent 7fa049d commit 1812b22
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
48 changes: 45 additions & 3 deletions Cron/GetStatusUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace PagBank\PaymentMagento\Cron;

use Magento\Framework\Notification\NotifierInterface;
use Magento\Payment\Model\Method\Logger;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
Expand Down Expand Up @@ -40,6 +41,11 @@ class GetStatusUpdate
*/
protected $logger;

/**
* @var NotifierInterface
*/
protected $notifierInterface;

/**
* @var Update
*/
Expand All @@ -54,15 +60,18 @@ class GetStatusUpdate
* Constructor.
*
* @param Logger $logger
* @param NotifierInterface $notifierInterface
* @param Update $update
* @param CollectionFactory $collectionFactory
*/
public function __construct(
Logger $logger,
NotifierInterface $notifierInterface,
Update $update,
CollectionFactory $collectionFactory
) {
$this->logger = $logger;
$this->notifierInterface = $notifierInterface;
$this->update = $update;
$this->collectionFactory = $collectionFactory;
}
Expand Down Expand Up @@ -107,7 +116,12 @@ public function findPix()
foreach ($orders as $order) {
$incrementId = $order->getIncrementId();

$this->update->getUpdate($incrementId);
try {
$this->update->getUpdate($incrementId);
} catch (\Throwable $th) {
$this->errorNotificationManager($order);
continue;
}
}
}

Expand All @@ -123,7 +137,12 @@ public function findBoleto()
foreach ($orders as $order) {
$incrementId = $order->getIncrementId();

$this->update->getUpdate($incrementId);
try {
$this->update->getUpdate($incrementId);
} catch (\Throwable $th) {
$this->errorNotificationManager($order);
continue;
}
}
}

Expand All @@ -139,7 +158,30 @@ public function findCc()
foreach ($orders as $order) {
$incrementId = $order->getIncrementId();

$this->update->getUpdate($incrementId);
try {
$this->update->getUpdate($incrementId);
} catch (\Throwable $th) {
$this->errorNotificationManager($order);
continue;
}
}
}

/**
* Error Notification Manager.
*
* @param Order $order
* @return void
*/
public function errorNotificationManager($order)
{
$header = __('PagBank, error when checking order status.');

$detail = __(
'It is not possible to check the status of order %1, please perform a manual verification.',
$order->getIncrementId()
);

$this->notifierInterface->addCritical($header, $detail);
}
}
4 changes: 3 additions & 1 deletion i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Production,Production
"You are connected to PagBank. =)","You are connected to PagBank. =)"
"Unable to get the code, try again. =(","Unable to get the code, try again. =("
"You should not be here...","You should not be here..."
"PagBank, error when checking order status.","PagBank, error when checking order status."
"It is not possible to check the status of order %1, please perform a manual verification.","It is not possible to check the status of order %1, please perform a manual verification."
"Transaction has been declined. Please try again later.","Transaction has been declined. Please try again later."
"15 minutes","15 minutes"
"30 minutes","30 minutes"
Expand Down Expand Up @@ -167,7 +169,7 @@ Title,Title
"Number of interest-free installments","Number of interest-free installments"
"Number of installments you want to accept without applying interest","Number of installments you want to accept without applying interest"
"The minimum installment price","The minimum installment price"
"It is the minimum value that the installment can have,"It is the minimum value that the installment can have"
"It is the minimum value that the installment can have","It is the minimum value that the installment can have"
Developers,Developers
"Meet our <a href='https://github.com/pagseguro/payment-magento/wiki'>Wiki</a>.","Meet our <a href='https://github.com/pagseguro/payment-magento/wiki'>Wiki</a>."
Debug,Debug
Expand Down
2 changes: 2 additions & 0 deletions i18n/pt_BR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Production,Produção
"You are connected to PagBank. =)","Você foi conectado ao PagBank. =)"
"Unable to get the code, try again. =(","Não foi possível obter o código, tente novamente. =("
"You should not be here...","Não é para você estar aqui..."
"PagBank, error when checking order status.","PagBank, erro ao verificar o status do pedido."
"It is not possible to check the status of order %1, please perform a manual verification.","Não é possível verificar o status do pedido %1, por favor, realize uma verificação manual."
"Transaction has been declined. Please try again later.","Pedido recusado, por favor, tente mais tarde."
"15 minutes","15 minutos"
"30 minutes","30 minutos"
Expand Down

0 comments on commit 1812b22

Please sign in to comment.