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:
36
app/Traits/LNBitsTrait.php
Normal file
36
app/Traits/LNBitsTrait.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
trait LNBitsTrait
|
||||
{
|
||||
public function createInvoice($sats, $memo)
|
||||
{
|
||||
$lnbits = auth()->user()->lnbits;
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'X-Api-Key' => $lnbits['read_key'],
|
||||
])
|
||||
->post($lnbits['url'].'/api/v1/payments', [
|
||||
'out' => false,
|
||||
'amount' => $sats,
|
||||
'memo' => $memo,
|
||||
]);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
public function check($paymentHash)
|
||||
{
|
||||
$lnbits = auth()->user()->lnbits;
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'X-Api-Key' => $lnbits['read_key'],
|
||||
])
|
||||
->get($lnbits['url'].'/api/v1/payments/' . $paymentHash);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user