Skip to content

Commit

Permalink
PagBank 😍 Magento
Browse files Browse the repository at this point in the history
- Fixed acentos
- Status aplicado pelo cron
  • Loading branch information
elisei committed Nov 9, 2023
1 parent 2da650e commit 90b0de8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
40 changes: 39 additions & 1 deletion Gateway/Request/ItemsDataRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 3 additions & 1 deletion Gateway/Response/FetchPaymentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public function handle(array $handlingSubject, array $response)

if ($this->finalStatus === 'CANCEL') {
$this->setPaymentDeny($payment, $paymentParentId, $pagbankPayId, $amount);
$order->isPaymentReview(0);
}
}
}
Expand Down Expand Up @@ -224,6 +225,7 @@ public function setPaymentPay($payment, $paymentParentId, $pagbankPayId, $amount
if ($invoice && !$invoice->getEmailSent()) {
$this->invoiceSender->send($invoice, false);
}
$order->save();
}
}

Expand All @@ -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);
Expand Down

0 comments on commit 90b0de8

Please sign in to comment.