Skip to content

Commit

Permalink
handel case when transaction is already capture (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 authored Jun 7, 2024
1 parent 7b067ca commit 52e24a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/Filament/Resources/DonationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public static function table(Table $table): Table
),
DateFilter::make('created_at'),
])
->defaultSort('created_at', 'desc')
->actions([
ViewAction::make()->iconButton(),
]);
Expand Down
8 changes: 7 additions & 1 deletion app/Services/EuPlatescService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class EuPlatescService
{
public const CAPTURE_METHOD = 'capture';

private const ErrCodeForAlreadyCaptured = 8;

private string $merchantId;

private string $privateKey;
Expand Down Expand Up @@ -134,7 +136,7 @@ public function recipeTransaction(Donation $donation): bool
{
$data = [
'method' => self::CAPTURE_METHOD,
'ukey' => $this->userKey,
'mid' => $this->userKey,
'epid' => $donation->ep_id,
'timestamp' => gmdate('YmdHis'),
'nonce' => md5(mt_rand() . time()),
Expand All @@ -144,6 +146,10 @@ public function recipeTransaction(Donation $donation): bool
$response = $this->callMethod($data);

if (isset($response['error'])) {
if ($response['ecode'] == self::ErrCodeForAlreadyCaptured) {
return true;
}

return false;
}

Expand Down

0 comments on commit 52e24a0

Please sign in to comment.