mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
try catch added
This commit is contained in:
@@ -9,9 +9,11 @@ use Illuminate\Support\Facades\Log;
|
|||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use RalphJSmit\Laravel\SEO\Support\SEOData;
|
use RalphJSmit\Laravel\SEO\Support\SEOData;
|
||||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||||
|
use WireUi\Traits\Actions;
|
||||||
|
|
||||||
class InternArticleView extends Component
|
class InternArticleView extends Component
|
||||||
{
|
{
|
||||||
|
use Actions;
|
||||||
use LNBitsTrait;
|
use LNBitsTrait;
|
||||||
|
|
||||||
public LibraryItem $libraryItem;
|
public LibraryItem $libraryItem;
|
||||||
@@ -44,11 +46,18 @@ class InternArticleView extends Component
|
|||||||
|
|
||||||
public function pay()
|
public function pay()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$invoice = $this->createInvoice(
|
$invoice = $this->createInvoice(
|
||||||
sats: $this->libraryItem->sats,
|
sats: $this->libraryItem->sats,
|
||||||
memo: 'Payment for: "'.$this->libraryItem->slug.'" on Einundzwanzig Portal.',
|
memo: 'Payment for: "'.$this->libraryItem->slug.'" on Einundzwanzig Portal.',
|
||||||
lnbits: $this->libraryItem->createdBy->lnbits,
|
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']);
|
session('payment_hash_article_'.$this->libraryItem->id, $invoice['payment_hash']);
|
||||||
$this->paymentHash = $invoice['payment_hash'];
|
$this->paymentHash = $invoice['payment_hash'];
|
||||||
$this->qrCode = base64_encode(QrCode::format('png')
|
$this->qrCode = base64_encode(QrCode::format('png')
|
||||||
@@ -71,7 +80,15 @@ class InternArticleView extends Component
|
|||||||
|
|
||||||
public function checkPaymentHash()
|
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']) {
|
if (isset($invoice['paid']) && $invoice['paid']) {
|
||||||
$this->invoicePaid = true;
|
$this->invoicePaid = true;
|
||||||
if (auth()->check()) {
|
if (auth()->check()) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ trait LNBitsTrait
|
|||||||
'out' => false,
|
'out' => false,
|
||||||
'amount' => $sats,
|
'amount' => $sats,
|
||||||
'memo' => $memo,
|
'memo' => $memo,
|
||||||
]);
|
])->throw();
|
||||||
|
|
||||||
return $response->json();
|
return $response->json();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user