Skip to content

Commit

Permalink
Merge pull request #142 from pagarme/stg
Browse files Browse the repository at this point in the history
Stg
  • Loading branch information
mauriciohaygert authored Feb 2, 2023
2 parents f197297 + a4720d6 commit d419141
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Block/Payment/Info/Billet.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private function getBoletoLinkFromOrder($info)

$orderRepository = new OrderRepository();
$order = $orderRepository->findByPagarmeId(new OrderId($orderId));
$boletoUrl = null;

if ($order !== null) {
$charges = $order->getCharges();
Expand Down Expand Up @@ -145,6 +146,11 @@ public function getTransactionInfo()
* @var \Pagarme\Core\Kernel\Aggregates\Order orderObject
*/
$orderObject = $orderService->getOrderByPagarmeId(new OrderId($orderPagarmeId));

if ($orderObject === null) {
return [];
}

return $orderObject->getCharges()[0]->getLastTransaction();
}
}
7 changes: 6 additions & 1 deletion Block/Payment/Info/BilletCreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private function getBoletoLinkFromOrder($info)

$orderRepository = new OrderRepository();
$order = $orderRepository->findByPagarmeId(new OrderId($orderId));
$boletoUrl = null;

if ($order !== null) {
$charges = $order->getCharges();
Expand Down Expand Up @@ -194,11 +195,15 @@ public function getTransactionInfo()
* @var \Pagarme\Core\Kernel\Aggregates\Order orderObject
*/
$orderObject = $orderService->getOrderByPagarmeId(new OrderId($orderPagarmeId));
$transactionList = [];

if ($orderObject === null) {
return [];
}

$lastTransaction = $orderObject->getCharges()[0]->getLastTransaction();
$secondLastTransaction = $orderObject->getCharges()[1]->getLastTransaction();

$transactionList = [];
foreach ([$lastTransaction, $secondLastTransaction] as $item) {
if ($item->getAcquirerNsu() != 0) {
$transactionList['creditCard'] =
Expand Down
4 changes: 4 additions & 0 deletions Block/Payment/Info/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public function getTransactionInfo()
*/
$orderObject = $orderService->getOrderByPagarmeId(new OrderId($orderPagarmeId));

if ($orderObject === null) {
return [];
}

return array_merge(
$orderObject->getCharges()[0]->getAcquirerTidCapturedAndAutorize(),
['tid' => $this->getTid($orderObject->getCharges()[0])]
Expand Down
5 changes: 5 additions & 0 deletions Block/Payment/Info/Pix.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public function getTransactionInfo()
* @var Order orderObject
*/
$orderObject = $orderService->getOrderByPagarmeId(new OrderId($orderPagarmeId));

if ($orderObject === null) {
return [];
}

return $orderObject->getCharges()[0]->getLastTransaction();
}
}
4 changes: 4 additions & 0 deletions Block/Payment/Info/TwoCreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public function getTransactionInfo()
*/
$orderObject = $orderService->getOrderByPagarmeId(new OrderId($orderPagarmeId));

if ($orderObject === null) {
return [];
}

return [
'card1' => array_merge(
$orderObject->getCharges()[0]->getAcquirerTidCapturedAndAutorize(),
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pagarme/pagarme-magento2-module",
"license": "MIT",
"version": "1.2.0",
"version": "1.2.1",
"type": "magento2-module",
"description": "Magento 2 Module Pagar.me",
"require": {
Expand Down
2 changes: 2 additions & 0 deletions etc/csp_whitelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
<policy id="connect-src">
<values>
<value id="mundipagg-api" type="host">https://api.mundipagg.com</value>
<value id="pagarme-api" type="host">https://api.pagar.me</value>
</values>
</policy>
<policy id="img-src">
<values>
<value id="mundipagg-img" type="host">https://cdn.mundipagg.com</value>
<value id="pagarme-img" type="host">https://api.pagar.me</value>
</values>
</policy>
</policies>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Pagarme_Pagarme" setup_version="1.1.6">
<module name="Pagarme_Pagarme" setup_version="1.2.1">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down
9 changes: 7 additions & 2 deletions view/adminhtml/templates/info/billetCreditCard.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* @var \Pagarme\Core\Kernel\Aggregates\Transaction $lastTransaction
*/
$lastTransactions = $this->getTransactionInfo();
$postDataBillet = (json_decode($lastTransactions['billet']->getPostData()->tran_data, true));
$postDataBillet = null;
if (array_key_exists('billet', $lastTransactions)) {
$postDataBillet = (json_decode($lastTransactions['billet']->getPostData()->tran_data, true));
}
?>
<?php if ($this->getCcType()): ?>
<span><?php echo __($this->getTitle()); ?></span>
Expand Down Expand Up @@ -32,7 +35,9 @@ $postDataBillet = (json_decode($lastTransactions['billet']->getPostData()->tran_
<span><b><?= __('NSU from capture'); ?>: </b><?= $lastTransactions['creditCard']['captured'] ?></span>
<br/>
<?php } ?>
<span><b><?= __('TID'); ?>: </b><?= $lastTransactions['creditCard']['tid'] ?></span>
<?php if (!empty($lastTransactions['creditCard']['tid'])) {?>
<span><b><?= __('TID'); ?>: </b><?= $lastTransactions['creditCard']['tid'] ?></span>
<?php } ?>
<?php endif ?>

<br/>
Expand Down

0 comments on commit d419141

Please sign in to comment.