Skip to content

Commit

Permalink
do not track TRANSACTION_ALREADY_CAPTURED error
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Nov 10, 2020
1 parent 5a3c202 commit 73e849b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Action/Api/CaptureTransactionAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])]);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

0 comments on commit 73e849b

Please sign in to comment.