<?php

namespace App\Filament\Admin\Pages;

use Filament\Pages\Page;
use Illuminate\Http\Request;
use Stripe\Stripe;
use Stripe\Checkout\Session;

use Stripe\Checkout\Session as StripeSession;

class StripeSuccess extends Page
{
    protected static bool $shouldRegisterNavigation = false;
    protected string $view = 'filament.admin.pages.stripe-success';
    public string $sessionId;

public array $session = [];

public function mount(Request $request): void
{
    $sessionId = $request->query('session_id');

    if (! $sessionId) {
        abort(400, 'Missing session_id');
    }

    Stripe::setApiKey(config('services.stripe.secret'));

    $stripeSession = StripeSession::retrieve($sessionId);

    // ✅ Convert to Livewire-safe array
    $this->session = $stripeSession->toArray();
}

}
