Skip to content

Commit

Permalink
PagBank 😍 Magento
Browse files Browse the repository at this point in the history
  • Loading branch information
elisei committed Jan 2, 2024
1 parent abbf6f5 commit 4cce128
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Gateway/Response/FetchPaymentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

namespace PagBank\PaymentMagento\Gateway\Response;

use InvalidArgumentException;
use Magento\Framework\Exception\InvalidArgumentException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
use Magento\Payment\Gateway\Response\HandlerInterface;
use Magento\Payment\Model\InfoInterface;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;

/**
Expand Down Expand Up @@ -116,6 +118,14 @@ public function handle(array $handlingSubject, array $response)

$amount = $order->getBaseGrandTotal();

$state = $order->getState();

if ($state !== Order::STATE_NEW && $state !== Order::STATE_PAYMENT_REVIEW) {
throw new LocalizedException(
__('Update not available because the initial state is incompatible: %1', $order->getState())
);
}

if (isset($response[self::RESPONSE_CHARGES])) {
$charges = $response[self::RESPONSE_CHARGES];
$pagbankPayId = $charges[0][self::RESPONSE_PAGBANK_ID];
Expand Down
1 change: 1 addition & 0 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"Update not available because the initial state is incompatible: %1","Update not available because the initial state is incompatible: %1"
"Installments Interest","Installments Interest"
"Discount in cash","Discount in cash"
"Default Config","Default Config"
Expand Down
1 change: 1 addition & 0 deletions i18n/pt_BR.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"Update not available because the initial state is incompatible: %1","Atualização não disponível pois state inicial é incompativel: %1"
"Installments Interest","Juros de Parcelamento"
"Discount in cash","Desconto à vista"
"Default Config","Configuração Padrão"
Expand Down

0 comments on commit 4cce128

Please sign in to comment.