From 90b0de85eefa5120ef2552fa4a1cb0dc7e82667d Mon Sep 17 00:00:00 2001 From: Elisei Date: Thu, 9 Nov 2023 10:43:18 -0300 Subject: [PATCH] =?UTF-8?q?PagBank=20=F0=9F=98=8D=20Magento=20-=20Fixed=20?= =?UTF-8?q?acentos=20-=20Status=20aplicado=20pelo=20cron?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gateway/Request/ItemsDataRequest.php | 40 +++++++++++++++++++++++- Gateway/Response/FetchPaymentHandler.php | 4 ++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Gateway/Request/ItemsDataRequest.php b/Gateway/Request/ItemsDataRequest.php index 14c3849..e0271c0 100644 --- a/Gateway/Request/ItemsDataRequest.php +++ b/Gateway/Request/ItemsDataRequest.php @@ -98,8 +98,46 @@ public function getPurchaseItems( if ($item->getParentItem()) { continue; } + + $replacements = [ + 'á' => 'a', + 'à' => 'a', + 'â' => 'a', + 'ã' => 'a', + 'é' => 'e', + 'è' => 'e', + 'ê' => 'e', + 'í' => 'i', + 'ì' => 'i', + 'ó' => 'o', + 'ò' => 'o', + 'ô' => 'o', + 'õ' => 'o', + 'ú' => 'u', + 'ù' => 'u', + 'ç' => 'c', + 'ñ' => 'n', + 'Á' => 'A', + 'À' => 'A', + 'Â' => 'A', + 'Ã' => 'A', + 'É' => 'E', + 'È' => 'E', + 'Ê' => 'E', + 'Í' => 'I', + 'Ì' => 'I', + 'Ó' => 'O', + 'Ò' => 'O', + 'Ô' => 'O', + 'Õ' => 'O', + 'Ú' => 'U', + 'Ù' => 'U', + 'Ç' => 'C', + 'Ñ' => 'N' + ]; - $productName = preg_replace('/[^a-zA-Z0-9áàâãéèêíìóòôõúùçñÁÀÂÃÉÈÊÍÌÓÒÔÕÚÙÇ ]/u', '', $item->getName()); + $productName = strtr($item->getName(), $replacements); + $productName = preg_replace('/[^a-zA-Z0-9 ]/u', '', $productName); $result[] = [ self::ITEM_REFERENCE_ID => substr($item->getSku(), 0, 55), diff --git a/Gateway/Response/FetchPaymentHandler.php b/Gateway/Response/FetchPaymentHandler.php index fbec426..668b23e 100644 --- a/Gateway/Response/FetchPaymentHandler.php +++ b/Gateway/Response/FetchPaymentHandler.php @@ -137,6 +137,7 @@ public function handle(array $handlingSubject, array $response) if ($this->finalStatus === 'CANCEL') { $this->setPaymentDeny($payment, $paymentParentId, $pagbankPayId, $amount); + $order->isPaymentReview(0); } } } @@ -224,6 +225,7 @@ public function setPaymentPay($payment, $paymentParentId, $pagbankPayId, $amount if ($invoice && !$invoice->getEmailSent()) { $this->invoiceSender->send($invoice, false); } + $order->save(); } } @@ -246,7 +248,7 @@ public function setPaymentDeny($payment, $paymentParentId, $pagbankPayId, $amoun $payment->setIsTransactionApproved(false); $payment->setIsTransactionDenied(true); $payment->setIsTransactionPending(false); - $payment->setIsInProcess(true); + $payment->setIsInProcess(false); $payment->setIsTransactionClosed(true); $payment->setShouldCloseParentTransaction(true); $payment->setAmountCanceled($amount);