Skip to content

Commit

Permalink
fix(notify): disable authorization_number and error_code check in not…
Browse files Browse the repository at this point in the history
…ify action
  • Loading branch information
thislg committed Jun 27, 2024
1 parent 53f9faa commit 4d43f7b
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/Action/NotifyAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Marem\PayumPaybox\Action;

use Marem\PayumPaybox\Api;
use Marem\PayumPaybox\PayboxRetour;
use Payum\Core\Action\ActionInterface;
use Payum\Core\ApiAwareInterface;
use Payum\Core\ApiAwareTrait;
Expand Down Expand Up @@ -51,30 +50,24 @@ public function execute($request): void
'httpRequestQuery' => $httpRequest->query,
];

// check eletronic signature is valid
// check electronic signature is valid
if (false === $this->api->verify($httpRequest)) {
throw new HttpResponse('The notification is invalid. Code 1', 400);
}
// check authorization number is existing
if (false === isset($httpRequest->query['authorization_number'])) {
$message = 'Notification invalid: authorization number invalid.';
$this->logger->error($message, $context);
throw new HttpResponse($message, 400);
}
// check error code equals to 00000
$errorCode = $httpRequest->query['error_code'] ?? null;
if ('00000' !== $errorCode) {
$message = 'Notification invalid: transaction rejected, '.PayboxRetour::get($errorCode)->getReadable();
$this->logger->error($message, $context);
throw new HttpResponse($message, 400);
}

// check the amount equals the original amount
$queryAmount = $httpRequest->query['amount'] ?? null;
if ($details['amount'] !== $queryAmount) {

if (isset($details['amount']) && $details['amount'] !== $queryAmount) {
$message = 'Notification invalid: transaction invalid, amount differs from original';
$this->logger->error($message, $context);
$this->logger->notice($message, array_merge($context, [
'query_amount' => $queryAmount,
'amount' => $details['amount'],
]));

throw new HttpResponse($message, 400);
}

$this->logger->info('Notification valid', $context);

$details->replace($httpRequest->query);
Expand Down

0 comments on commit 4d43f7b

Please sign in to comment.