diff --git a/app/Events/PaidMessageEvent.php b/app/Events/PaidMessageEvent.php new file mode 100644 index 00000000..1716621e --- /dev/null +++ b/app/Events/PaidMessageEvent.php @@ -0,0 +1,33 @@ + 'required|string|max:255', + ]; + } + + public function mount() + { + try { + // {"url":"","wallet_id":"","read_key":""} + $invoice = $this->createInvoice( + sats: 21, + memo: 'Payment for: Bitcoin im Ländle 2023 - Code is Speech', + lnbits: [ + 'url' => 'https://legend.lnbits.com', + 'wallet_id' => 'b9b095edd0db4bf8995f1bbc90b195c5', + 'read_key' => '67e6d7f94f5345119d6c799d768a029e', + ], + ); + } catch (\Exception $e) { + $this->notification() + ->error('LNBits error: '.$e->getMessage()); + + return; + } + + $this->paymentHash = $invoice['payment_hash']; + $this->qrCode = base64_encode(QrCode::format('png') + ->size(300) + ->merge('/public/img/einundzwanzig.png', .3) + ->errorCorrection('H') + ->generate($invoice['payment_request'])); + $this->invoice = $invoice['payment_request']; + $this->checkid = $invoice['checking_id']; + } + + public function checkPaymentHash() + { + try { + $invoice = $this->check($this->checkid, [ + 'url' => 'https://legend.lnbits.com', + 'wallet_id' => 'b9b095edd0db4bf8995f1bbc90b195c5', + 'read_key' => '67e6d7f94f5345119d6c799d768a029e', + ]); + } catch (\Exception $e) { + $this->notification() + ->error('LNBits error: '.$e->getMessage()); + + return; + } + if (isset($invoice['paid']) && $invoice['paid']) { + $this->invoicePaid = true; + event(new PaidMessageEvent($this->message, $this->checkid)); + } else { + Log::error(json_encode($invoice, JSON_THROW_ON_ERROR)); + } + } + + public function render() + { + return view('livewire.hello')->layout('layouts.guest'); + } +} diff --git a/docker-compose.yml b/docker-compose.yml index e6a4b8e1..f510c2bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: args: WWWGROUP: '${WWWGROUP}' NOSTR_PRIVATE_KEY: '${NOSTR_PRIVATE_KEY}' - image: sail-8.2/app + image: sail-8.2/einundzwanzig extra_hosts: - 'host.docker.internal:host-gateway' ports: diff --git a/resources/views/livewire/hello.blade.php b/resources/views/livewire/hello.blade.php new file mode 100644 index 00000000..1fa9e9ab --- /dev/null +++ b/resources/views/livewire/hello.blade.php @@ -0,0 +1,31 @@ +
+
+ @if(!$invoicePaid) +
+ Deine Nachricht wird live vorgelesen. +
+
+ +
+
+ {{ __('Click QR-Code to open your wallet') }} +
+
+ + qrcode + +
+
+ 21 sats +
+
+ @else +
+ Danke für deine Nachricht. Wenn alles klappt, dann werden wir die Nachricht gleich hören. +
+ @endif +
+
diff --git a/routes/web.php b/routes/web.php index de7468e1..add37a98 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,6 +7,10 @@ Route::middleware([]) ->get('/', \App\Http\Livewire\Frontend\Welcome::class) ->name('welcome'); +Route::middleware([]) + ->get('/hello', \App\Http\Livewire\Hello::class) + ->name('hello'); + Route::get('/img/{path}', \App\Http\Controllers\ImageController::class) ->where('path', '.*') ->name('img');