Skip to content

Commit

Permalink
Merge pull request #7 from solverat/ignore_captured_error
Browse files Browse the repository at this point in the history
Do not track TRANSACTION_ALREADY_CAPTURED Error
  • Loading branch information
solverat authored Nov 10, 2020
2 parents 5a3c202 + 73e849b commit 9e9d192
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 9e9d192

Please sign in to comment.