diff --git a/app/Http/Livewire/News/InternArticleView.php b/app/Http/Livewire/News/InternArticleView.php index 7095b3f4..ca59bfdf 100644 --- a/app/Http/Livewire/News/InternArticleView.php +++ b/app/Http/Livewire/News/InternArticleView.php @@ -9,9 +9,11 @@ use Illuminate\Support\Facades\Log; use Livewire\Component; use RalphJSmit\Laravel\SEO\Support\SEOData; use SimpleSoftwareIO\QrCode\Facades\QrCode; +use WireUi\Traits\Actions; class InternArticleView extends Component { + use Actions; use LNBitsTrait; public LibraryItem $libraryItem; @@ -44,11 +46,18 @@ class InternArticleView extends Component public function pay() { - $invoice = $this->createInvoice( - sats: $this->libraryItem->sats, - memo: 'Payment for: "'.$this->libraryItem->slug.'" on Einundzwanzig Portal.', - lnbits: $this->libraryItem->createdBy->lnbits, - ); + try { + $invoice = $this->createInvoice( + sats: $this->libraryItem->sats, + memo: 'Payment for: "'.$this->libraryItem->slug.'" on Einundzwanzig Portal.', + lnbits: $this->libraryItem->createdBy->lnbits, + ); + } catch (\Exception $e) { + $this->notification() + ->error('LNBits error: '.$e->getMessage()); + + return; + } session('payment_hash_article_'.$this->libraryItem->id, $invoice['payment_hash']); $this->paymentHash = $invoice['payment_hash']; $this->qrCode = base64_encode(QrCode::format('png') @@ -71,7 +80,15 @@ class InternArticleView extends Component public function checkPaymentHash() { - $invoice = $this->check($this->checkid ?? $this->checkThisPaymentHash, $this->libraryItem->createdBy->lnbits); + try { + $invoice = $this->check($this->checkid ?? $this->checkThisPaymentHash, + $this->libraryItem->createdBy->lnbits); + } catch (\Exception $e) { + $this->notification() + ->error('LNBits error: '.$e->getMessage()); + + return; + } if (isset($invoice['paid']) && $invoice['paid']) { $this->invoicePaid = true; if (auth()->check()) { diff --git a/app/Traits/LNBitsTrait.php b/app/Traits/LNBitsTrait.php index 22da8499..b83c35c8 100644 --- a/app/Traits/LNBitsTrait.php +++ b/app/Traits/LNBitsTrait.php @@ -25,7 +25,7 @@ trait LNBitsTrait 'out' => false, 'amount' => $sats, 'memo' => $memo, - ]); + ])->throw(); return $response->json(); }