[]]); state(['events' => []]); state(['payments' => []]); state(['amountToPay' => config('app.env') === 'production' ? 21000 : 1]); state(['currentYearIsPaid' => false]); state(['currentPubkey' => null]); state(['currentPleb' => null]); form(\App\Livewire\Forms\ApplicationForm::class); on([ 'nostrLoggedIn' => function ($pubkey) { $this->currentPubkey = $pubkey; $this->currentPleb = \App\Models\EinundzwanzigPleb::query() ->with([ 'paymentEvents' => fn($query) => $query->where('year', date('Y')), ]) ->where('pubkey', $pubkey)->first(); if ($this->currentPleb->association_status === \App\Enums\AssociationStatus::ACTIVE) { $this->amountToPay = config('app.env') === 'production' ? 21000 : 1; } if ($this->currentPleb->paymentEvents->count() < 1) { $this->createPaymentEvent(); $this->currentPleb->load('paymentEvents'); } $this->loadEvents(); $this->listenForPayment(); }, 'nostrLoggedOut' => function () { $this->currentPubkey = null; $this->currentPleb = null; $this->yearsPaid = []; $this->events = []; $this->payments = []; $this->qrCode = null; $this->amountToPay = config('app.env') === 'production' ? 21000 : 1; $this->currentYearIsPaid = false; }, ]); $pay = function ($comment) { $paymentEvent = $this->currentPleb ->paymentEvents() ->where('year', date('Y')) ->first(); if ($paymentEvent->btc_pay_invoice) { return redirect('https://pay.einundzwanzig.space/i/' . $paymentEvent->btc_pay_invoice); } try { $response = Http::withHeaders([ 'Authorization' => 'token ' . config('services.btc_pay.api_key'), ])->post( 'https://pay.einundzwanzig.space/api/v1/stores/98PF86BoMd3C8P1nHHyFdoeznCwtcm5yehcAgoCYDQ2a/invoices', [ 'amount' => $this->amountToPay, 'metadata' => [ 'orderId' => $comment, 'orderUrl' => url()->route('association.profile'), 'itemDesc' => 'Mitgliedsbeitrag ' . date('Y') . ' von nostr:' . $this->currentPleb->npub, 'posData' => [ 'event' => $paymentEvent->event_id, 'pubkey' => $this->currentPleb->pubkey, 'npub' => $this->currentPleb->npub, ], ], 'checkout' => [ 'expirationMinutes' => 60 * 24 * 356, 'redirectURL' => url()->route('association.profile'), 'redirectAutomatically' => true, 'defaultLanguage' => 'de', ], ], )->throw(); $paymentEvent->btc_pay_invoice = $response->json()['id']; $paymentEvent->save(); return redirect($response->json()['checkoutLink']); } catch (Exception $e) { $notification = new Notification($this); $notification->error( 'Fehler beim Erstellen der Rechnung. Bitte versuche es später erneut: ' . $e->getMessage(), ); } }; $listenForPayment = function () { $paymentEvent = $this->currentPleb ->paymentEvents() ->where('year', date('Y')) ->first(); if ($paymentEvent->btc_pay_invoice) { $response = Http::withHeaders([ 'Authorization' => 'token ' . config('services.btc_pay.api_key'), ]) ->get( 'https://pay.einundzwanzig.space/api/v1/stores/98PF86BoMd3C8P1nHHyFdoeznCwtcm5yehcAgoCYDQ2a/invoices/' . $paymentEvent->btc_pay_invoice, ); if ($response->json()['status'] === 'Settled') { $paymentEvent->paid = true; $paymentEvent->save(); $this->payments = $this->currentPleb ->paymentEvents() ->get(); $this->currentYearIsPaid = true; } } }; $save = function ($type) { $this->form->validate(); $this->currentPleb ->update([ 'association_status' => $type, ]); }; $createPaymentEvent = function () { $note = new NostrEvent(); $note->setKind(32121); $note->setContent( 'Dieses Event dient der Zahlung des Mitgliedsbeitrags für das Jahr ' . date( 'Y', ) . '. Bitte bezahle den Betrag von ' . number_format($this->amountToPay, 0, ',', '.') . ' Satoshis.', ); $note->setTags([ ['d', $this->currentPleb->pubkey . ',' . date('Y')], ['zap', 'daf83d92768b5d0005373f83e30d4203c0b747c170449e02fea611a0da125ee6', config('services.relay'), '1'], ]); $signer = new Sign(); $signer->signEvent($note, config('services.nostr')); $eventMessage = new EventMessage($note); $relayUrl = config('services.relay'); $relay = new Relay($relayUrl); $relay->setMessage($eventMessage); $result = $relay->send(); $this->currentPleb->paymentEvents()->create([ 'year' => date('Y'), 'event_id' => $result->eventId, 'amount' => $this->amountToPay, ]); }; $loadEvents = function () { $subscription = new Subscription(); $subscriptionId = $subscription->setId(); $filter1 = new Filter(); $filter1->setKinds([32121]); $filter1->setAuthors(['daf83d92768b5d0005373f83e30d4203c0b747c170449e02fea611a0da125ee6']); $filters = [$filter1]; $requestMessage = new RequestMessage($subscriptionId, $filters); $relays = [ new Relay(config('services.relay')), ]; $relaySet = new RelaySet(); $relaySet->setRelays($relays); $request = new Request($relaySet, $requestMessage); $response = $request->send(); $this->events = collect($response[config('services.relay')]) ->map(fn($event) => [ 'id' => $event->event->id, 'kind' => $event->event->kind, 'content' => $event->event->content, 'pubkey' => $event->event->pubkey, 'tags' => $event->event->tags, 'created_at' => $event->event->created_at, ]) ->unique('id') ->toArray(); }; ?> @volt

Einundzwanzig ist, was du draus machst

Meine Mitgliedschaft
{{--
Experience
--}}

Aktueller Status

{{-- https://v.nostr.build/bomfuwLnOTIDrP4y.mp4 --}} @if($currentPubkey && $currentPleb->association_status->value < 2)
Profil in der Datenbank vorhanden.
@endif

Nsec.app Tutorial (sicheres Anmelden mit Nsec)

{{--
@if($currentPubkey && !$currentPleb->application_for && $currentPleb->association_status->value < 2)

passives Mitglied werden

Passivmitglieder haben kein Stimmrecht. Firmen können nur Passivmitglieder werden und zahlen das 100-fache des festgelegten Beitrags.

@endif
--}}
@if($currentPubkey && !$currentPleb->application_for && $currentPleb->association_status->value < 2)

Einundzwanzig Mitglied werden

Nur Personen können Mitglied werden und zahlen 21.000 Satoshis im Jahr (Die Zahlung ist noch in der Entwicklung).
Firmen melden sich bitte direkt an den Vorstand.

@endif
@if($currentPubkey && $currentPleb->application_for)
Du hast dich erfolgreich mit folgendem Grund beworben:
{{ $currentPleb->application_text }}
Schaue später vorbei, denn nun muss jemand aus dem Vorstand deine Bewerbung prüfen.
@endif
@if($currentPleb && $currentPleb->association_status->value > 1)
Du bist derzeit ein Mitglied des Vereins.
@endif
@if($currentPleb && $currentPleb->association_status->value > 1)

Nostr Event für die Zahlung des Mitgliedsbeitrags: {{ $currentPleb->paymentEvents->first()->event_id }}

@if(isset($events[0]))

{{ $events[0]['content'] }}

@if(!$currentYearIsPaid)
@else @if($currentYearIsPaid)
@endif @endif
@else
@endif

bisherige Zahlungen

@foreach($payments as $payment) @endforeach
Sats: {{ $payment->amount }}
Jahr:{{ $payment->year }}
{{ $payment->event_id }}
@endif
@endvolt