lnbits paid articles added

This commit is contained in:
HolgerHatGarKeineNode
2023-03-14 13:06:22 +01:00
parent 14ee59bbd5
commit 1501a487cd
4 changed files with 16 additions and 17 deletions

View File

@@ -33,9 +33,6 @@ class InternArticleView extends Component
->count() > 0 && !auth()->check()) {
abort(403, __('Sorry! You are not authorized to perform this action.'));
}
if ($this->libraryItem->sats && !auth()->check()) {
return to_route('article.overview');
}
if (auth()->check() && auth()
->user()
->paidArticles()
@@ -77,10 +74,12 @@ class InternArticleView extends Component
$invoice = $this->check($this->checkid ?? $this->checkThisPaymentHash, $this->libraryItem->createdBy->lnbits);
if (isset($invoice['paid']) && $invoice['paid']) {
$this->invoicePaid = true;
if (auth()->check()) {
auth()
->user()
->paidArticles()
->syncWithoutDetaching($this->libraryItem->id);
}
} else {
Log::error(json_encode($invoice, JSON_THROW_ON_ERROR));
}

View File

@@ -843,5 +843,6 @@
"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!"
"LNBits settings are not valid!": "LNBits-Einstellungen sind nicht gültig!",
"As a guest, please save your payment hash so that you can unlock this article later. Unfortunately, we cannot save your purchase status permanently for guests. Please log in to use this feature.": "Bitte speichere als Gast deinen Payment Hash, damit du diesen Artikel später entsperren kannst. Leider können wir deinen Kaufstatus nicht dauerhaft speichern. Bitte melde dich an, um diese Funktion zu nutzen."
}

View File

@@ -47,11 +47,6 @@
@foreach($libraryItems as $libraryItem)
@if($libraryItem->approved || $libraryItem->created_by === auth()->id() || auth()->user()?->hasRole('news-editor'))
@php
if($libraryItem->sats && !auth()->check()) {
continue;
}
@endphp
<div wire:key="library_item_{{ $libraryItem->id }}" wire:loading.class="opacity-25"
class="relative flex flex-col overflow-hidden rounded-lg border-2 border-[#F7931A]">
@if($libraryItem->sats)

View File

@@ -174,12 +174,13 @@
</div>
@if(!$invoice)
<div class="mt-10 flex items-center justify-center gap-x-6">
<div
wire:click="pay"
class="cursor-pointer rounded-md bg-white px-3.5 py-2.5 text-sm font-semibold text-gray-900 shadow-sm hover:bg-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white">
<x-button
wire.loading.attr="disabled"
primary
wire:click="pay">
<i class="fa-thin fa-bolt"></i>
Pay with lightning
</div>
</x-button>
<div wire:click="$set('alreadyPaid', true)" class="cursor-pointer text-sm font-semibold leading-6 text-white">{{ __('already paid?') }} <span aria-hidden="true"></span></div>
</div>
@else
@@ -244,6 +245,9 @@
{{ __('Copy payment hash') }}
</x-button>
</div>
<div class="w-full my-2 flex justify-center font-mono font-bold p-4">
<p class="text-amber-500">{{ __('As a guest, please save your payment hash so that you can unlock this article later. Unfortunately, we cannot save your purchase status permanently for guests. Please log in to use this feature.') }}</p>
</div>
</div>
<div wire:poll.keep-alive="checkPaymentHash" wire:key="checkPaymentHash"></div>
</div>