mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
lnbits paid articles added
This commit is contained in:
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Http\Livewire\Profile;
|
||||
|
||||
use App\Traits\LNBitsTrait;
|
||||
use Livewire\Component;
|
||||
use WireUi\Traits\Actions;
|
||||
|
||||
class LNBits extends Component
|
||||
{
|
||||
use Actions;
|
||||
use LNBitsTrait;
|
||||
|
||||
public array $settings = [
|
||||
'url' => 'https://legend.lnbits.com',
|
||||
@@ -34,6 +36,12 @@ class LNBits extends Component
|
||||
public function save()
|
||||
{
|
||||
$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->lnbits = $this->settings;
|
||||
$user->save();
|
||||
|
||||
@@ -6,6 +6,16 @@ use Illuminate\Support\Facades\Http;
|
||||
|
||||
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)
|
||||
{
|
||||
$lnbits = auth()->user()->lnbits;
|
||||
|
||||
Reference in New Issue
Block a user