Skip to content

Commit

Permalink
check invoice status using payins
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Jun 25, 2024
1 parent d450dd2 commit db00daf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/Livewire/Modals/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Livewire\Modals;

use App\Http\Controllers\LnAddressController;
use App\Models\Payin;
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
Expand Down Expand Up @@ -42,9 +42,14 @@ public function mount($invoice = null)

public function checkInvoiceStatus()
{
$controller = new LnAddressController();
$invoiceStatus = $controller->getInvoiceStatus($this->invoice);
if ($invoiceStatus && $invoiceStatus['settled']) {

$payin = Payin::where('payment_request', $this->invoice)->first();
if (! $payin) {
$this->alert('error', 'Invoice not found');

return;
}
if ($payin->status == 'settled') {
$this->alert('success', 'Payment received');
$this->closeModal();
}
Expand Down

0 comments on commit db00daf

Please sign in to comment.