Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Feb 20, 2024
1 parent d224632 commit 0394035
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/StripeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Stripe\Event;
use Stripe\StripeClient;
use Stripe\Webhook;
use Throwable;

class StripeDriver extends Driver
{
Expand Down Expand Up @@ -225,15 +224,16 @@ public function handleIpn(Event $event): void
{
$order = $this->resolveOrderForNotification($event);

try {
$transaction = Transaction::proxy()->newQuery()->where('key', $event->data['object']['id'])->firstOrFail();
} catch (Throwable $exception) {
$transaction = $this->pay(
$order,
$event->data['object']['amount'] / 100,
['key' => $event->data['object']['id']]
);
}
$transaction = Transaction::proxy()
->newQuery()
->where('key', $event->data['object']['id'])
->firstOr(function () use ($order, $event): Transaction {
return $this->pay(
$order,
$event->data['object']['amount'] / 100,
['key' => $event->data['object']['id']]
);
});

$transaction->markAsCompleted();
}
Expand Down

0 comments on commit 0394035

Please sign in to comment.