Skip to content

Commit

Permalink
Refactor PaymentNotFoundException constructor parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
damms005 committed Jul 24, 2024
1 parent 5f225c4 commit 5ef8c1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Exceptions/PaymentNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@

class PaymentNotFoundException extends Exception
{
public function __construct(
public \Illuminate\Http\Request $webhookRequest,
?string $message = null,
) {
$message = $message ?? 'Payment not found in Paystack\'s charge.success event. Payload: ' . json_encode($webhookRequest->all());

parent::__construct($message);
}
}
2 changes: 1 addition & 1 deletion src/Webhooks/Paystack/ChargeSuccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function handle(Request $webhookRequest): Payment
->first();

if (!$payment) {
throw new PaymentNotFoundException(get_class(app(PaymentHandlerInterface::class)) . ' - Payment not found in Paystack\'s charge.success event. Payload: ' . json_encode($webhookRequest->all()));
throw new PaymentNotFoundException($webhookRequest, get_class(app(PaymentHandlerInterface::class)) . ' - Payment not found in Paystack\'s charge.success event. Payload: ' . json_encode($webhookRequest->all()));
}

$metadata = [...$payment->metadata ?? []];
Expand Down

0 comments on commit 5ef8c1a

Please sign in to comment.