lnbits paid articles added

This commit is contained in:
HolgerHatGarKeineNode
2023-03-13 20:35:23 +01:00
parent 0fbc57a192
commit 70bda06360
15 changed files with 77 additions and 17 deletions

View File

@@ -2,12 +2,14 @@
namespace App\Http\Livewire\Profile; namespace App\Http\Livewire\Profile;
use App\Traits\LNBitsTrait;
use Livewire\Component; use Livewire\Component;
use WireUi\Traits\Actions; use WireUi\Traits\Actions;
class LNBits extends Component class LNBits extends Component
{ {
use Actions; use Actions;
use LNBitsTrait;
public array $settings = [ public array $settings = [
'url' => 'https://legend.lnbits.com', 'url' => 'https://legend.lnbits.com',
@@ -34,6 +36,12 @@ class LNBits extends Component
public function save() public function save()
{ {
$this->validate(); $this->validate();
if ($this->checkLnbitsSettings($this->settings['read_key'], $this->settings['url'], $this->settings['wallet_id']) === false) {
$this->notification()
->error(__('LNBits settings are not valid!'));
return;
}
$user = auth()->user(); $user = auth()->user();
$user->lnbits = $this->settings; $user->lnbits = $this->settings;
$user->save(); $user->save();

View File

@@ -6,6 +6,16 @@ use Illuminate\Support\Facades\Http;
trait LNBitsTrait trait LNBitsTrait
{ {
public function checkLnbitsSettings($read_key, $uri, $id)
{
$response = Http::withHeaders([
'X-Api-Key' => $read_key,
])
->get($uri.'/api/v1/wallet');
return $response->status() === 200;
}
public function createInvoice($sats, $memo) public function createInvoice($sats, $memo)
{ {
$lnbits = auth()->user()->lnbits; $lnbits = auth()->user()->lnbits;

View File

@@ -837,8 +837,11 @@
"Payment hash copied!": "Payment Hash kopiert!", "Payment hash copied!": "Payment Hash kopiert!",
"Copy payment hash": "Kopiere Payment Hash", "Copy payment hash": "Kopiere Payment Hash",
"Enter the data of your LNBits instance here to receive sats for articles, for example.": "Gib hier die Daten deiner LNBits-Instanz ein, um sats für zum Beispiel Artikel zu erhalten.", "Enter the data of your LNBits instance here to receive sats for articles, for example.": "Gib hier die Daten deiner LNBits-Instanz ein, um sats für zum Beispiel Artikel zu erhalten.",
"LNBits Url": "", "LNBits Url": "LNBits Url",
"Wallet ID": "", "Wallet ID": "Wallet ID",
"Invoice\/read key": "", "Invoice\/read key": "Invoice\/read key",
"paid": "zu bezahlen" "paid": "zu bezahlen",
"Setup LNBits for paid articles": "Setze LNBits für bezahlte Artikel ein",
"Click QR-Code to open your wallet": "Klicke auf den QR-Code, um deine Wallet zu öffnen",
"LNBits settings are not valid!": "LNBits-Einstellungen sind nicht gültig!"
} }

View File

@@ -838,5 +838,8 @@
"LNBits Url": "", "LNBits Url": "",
"Wallet ID": "", "Wallet ID": "",
"Invoice\/read key": "", "Invoice\/read key": "",
"paid": "" "paid": "",
"Setup LNBits for paid articles": "",
"Click QR-Code to open your wallet": "",
"LNBits settings are not valid!": ""
} }

View File

@@ -838,5 +838,8 @@
"LNBits Url": "", "LNBits Url": "",
"Wallet ID": "", "Wallet ID": "",
"Invoice\/read key": "", "Invoice\/read key": "",
"paid": "" "paid": "",
"Setup LNBits for paid articles": "",
"Click QR-Code to open your wallet": "",
"LNBits settings are not valid!": ""
} }

View File

@@ -839,5 +839,8 @@
"LNBits Url": "", "LNBits Url": "",
"Wallet ID": "", "Wallet ID": "",
"Invoice\/read key": "", "Invoice\/read key": "",
"paid": "" "paid": "",
"Setup LNBits for paid articles": "",
"Click QR-Code to open your wallet": "",
"LNBits settings are not valid!": ""
} }

View File

@@ -839,5 +839,8 @@
"LNBits Url": "", "LNBits Url": "",
"Wallet ID": "", "Wallet ID": "",
"Invoice\/read key": "", "Invoice\/read key": "",
"paid": "" "paid": "",
"Setup LNBits for paid articles": "",
"Click QR-Code to open your wallet": "",
"LNBits settings are not valid!": ""
} }

View File

@@ -839,5 +839,8 @@
"LNBits Url": "", "LNBits Url": "",
"Wallet ID": "", "Wallet ID": "",
"Invoice\/read key": "", "Invoice\/read key": "",
"paid": "" "paid": "",
"Setup LNBits for paid articles": "",
"Click QR-Code to open your wallet": "",
"LNBits settings are not valid!": ""
} }

View File

@@ -839,5 +839,8 @@
"LNBits Url": "", "LNBits Url": "",
"Wallet ID": "", "Wallet ID": "",
"Invoice\/read key": "", "Invoice\/read key": "",
"paid": "" "paid": "",
"Setup LNBits for paid articles": "",
"Click QR-Code to open your wallet": "",
"LNBits settings are not valid!": ""
} }

View File

@@ -839,5 +839,8 @@
"LNBits Url": "", "LNBits Url": "",
"Wallet ID": "", "Wallet ID": "",
"Invoice\/read key": "", "Invoice\/read key": "",
"paid": "" "paid": "",
"Setup LNBits for paid articles": "",
"Click QR-Code to open your wallet": "",
"LNBits settings are not valid!": ""
} }

View File

@@ -839,5 +839,8 @@
"LNBits Url": "", "LNBits Url": "",
"Wallet ID": "", "Wallet ID": "",
"Invoice\/read key": "", "Invoice\/read key": "",
"paid": "" "paid": "",
"Setup LNBits for paid articles": "",
"Click QR-Code to open your wallet": "",
"LNBits settings are not valid!": ""
} }

View File

@@ -801,5 +801,8 @@
"LNBits Url": "", "LNBits Url": "",
"Wallet ID": "", "Wallet ID": "",
"Invoice\/read key": "", "Invoice\/read key": "",
"paid": "" "paid": "",
"Setup LNBits for paid articles": "",
"Click QR-Code to open your wallet": "",
"LNBits settings are not valid!": ""
} }

View File

@@ -813,5 +813,8 @@
"LNBits Url": "", "LNBits Url": "",
"Wallet ID": "", "Wallet ID": "",
"Invoice\/read key": "", "Invoice\/read key": "",
"paid": "" "paid": "",
"Setup LNBits for paid articles": "",
"Click QR-Code to open your wallet": "",
"LNBits settings are not valid!": ""
} }

View File

@@ -30,6 +30,15 @@
{{ __('Submit paid news article') }} {{ __('Submit paid news article') }}
<i class="fa fa-thin fa-coins"></i> <i class="fa fa-thin fa-coins"></i>
</x-button> </x-button>
@else
<x-button
class="whitespace-nowrap"
:href="route('profile.lnbits')"
black>
<i class="fa fa-thin fa-gear"></i>
{{ __('Setup LNBits for paid articles') }}
<i class="fa fa-thin fa-coins"></i>
</x-button>
@endif @endif
@endauth @endauth
</div> </div>

View File

@@ -22,9 +22,9 @@
</div> </div>
</div> </div>
<div class="ml-3"> <div class="ml-3">
<p class="text-sm font-medium text-gray-200"> <div class="text-sm font-medium text-gray-200">
<div class="text-gray-200">{{ $libraryItem->lecturer->name }}</div> <div class="text-gray-200">{{ $libraryItem->lecturer->name }}</div>
</p> </div>
<div class="flex space-x-1 text-sm text-gray-500"> <div class="flex space-x-1 text-sm text-gray-500">
<time datetime="2020-03-16">{{ $libraryItem->created_at->asDateTime() }}</time> <time datetime="2020-03-16">{{ $libraryItem->created_at->asDateTime() }}</time>
@if($libraryItem->read_time) @if($libraryItem->read_time)