From 73e849b05b0f866455d4b4f8b7de60b263ac2025 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Tue, 10 Nov 2020 11:10:10 +0100 Subject: [PATCH] do not track TRANSACTION_ALREADY_CAPTURED error --- Action/Api/CaptureTransactionAction.php | 9 +++++++-- Constants.php | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Action/Api/CaptureTransactionAction.php b/Action/Api/CaptureTransactionAction.php index 9a82846..fd18e96 100644 --- a/Action/Api/CaptureTransactionAction.php +++ b/Action/Api/CaptureTransactionAction.php @@ -34,8 +34,13 @@ public function execute($request) 'Date' => $response['Date'], ])]); } catch (SaferpayHttpException $e) { - $model['Error'] = $e->toArray(); - $model->replace(['Transaction' => array_merge($model['Transaction'], ['Status' => Constants::STATUS_FAILED])]); + $error = $e->toArray(); + $errorName = $error['Data']['ErrorName'] ?? null; + // do not raise any errors if transaction already has been captured + if ($errorName !== Constants::ERROR_NAME_TRANSACTION_ALREADY_CAPTURED) { + $model['Error'] = $error; + $model->replace(['Transaction' => array_merge($model['Transaction'], ['Status' => Constants::STATUS_FAILED])]); + } } } diff --git a/Constants.php b/Constants.php index 56ac4be..d3f9dec 100644 --- a/Constants.php +++ b/Constants.php @@ -29,4 +29,6 @@ interface Constants const LS_IF_ALLOWED_BY_SCHEME = 'IF_ALLOWED_BY_SCHEME'; const LS_WITH_LIABILITY_SHIFT = 'WITH_LIABILITY_SHIFT'; + + const ERROR_NAME_TRANSACTION_ALREADY_CAPTURED = 'TRANSACTION_ALREADY_CAPTURED'; }