Skip to content

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed May 23, 2024
1 parent 34090d0 commit 0ac3b69
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Listeners/CaptureAuthorizedPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@
use Igniter\Admin\Models\StatusHistory;
use Igniter\Cart\Models\Order;
use Igniter\Flame\Database\Model;
use Igniter\Flame\Exception\ApplicationException;
use Igniter\PayRegister\Concerns\WithAuthorizedPayment;

class CaptureAuthorizedPayment
{
public function handle(Model $order, StatusHistory $statusHistory)
{
if (!$order instanceof Order) {
if (!$order instanceof Order || !$paymentMethod = $order->payment_method) {
return;
}

throw_unless(
$paymentMethod = $order->payment_method,
new ApplicationException('No valid payment method found')
);

if (!in_array(WithAuthorizedPayment::class, class_uses($paymentMethod->getGatewayClass()))) {
return;
}
Expand All @@ -31,4 +25,4 @@ public function handle(Model $order, StatusHistory $statusHistory)

$paymentMethod->captureAuthorizedPayment($order);
}
}
}

0 comments on commit 0ac3b69

Please sign in to comment.