Skip to content

Commit

Permalink
Merge pull request #52 from elisei/Magento@2.4.6
Browse files Browse the repository at this point in the history
Tratamento de erro
  • Loading branch information
elisei committed Feb 1, 2024
2 parents 6e27e11 + 4fc5195 commit 296d2fb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Gateway/Http/Client/Card/CreateClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,25 @@ public function placeRequest(TransferInterface $transferObject)
{
$request = $transferObject->getBody();

$denied = 0;

$responseBody = $this->api->sendPostRequest(
$transferObject,
'v2/payments',
$request,
);

$status = isset($responseBody['payment_id']) ? 1 : 0;
$denied = ($responseBody['status'] !== 'DENIED') ? 1 : 0;

if (isset($responseBody['status'])) {
if ($responseBody['status'] === 'DENIED') {
$denied = 1;
}
}

$response = array_merge(
[
self::RESULT_CODE => (!$denied) ? $status : 0,
self::RESULT_CODE => ($denied) ? 0 : $status,
self::EXT_ORD_ID => isset($responseBody['payment_id']) ? $responseBody['payment_id'] : null,
],
$responseBody
Expand Down

0 comments on commit 296d2fb

Please sign in to comment.