Files
einundzwanzig-portal/app/Traits/LNBitsTrait.php
HolgerHatGarKeineNode 639e17080c lnbits paid articles added
2023-03-13 16:35:20 +01:00

37 lines
816 B
PHP

<?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();
}
}