<?php

require __DIR__.'/vendor/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();

echo "=== Checking payment_gateways table ===\n\n";

$gateways = DB::table('payment_gateways')->get();

if ($gateways->isEmpty()) {
    echo "❌ No records found in payment_gateways table!\n\n";
    echo "Need to insert a Stripe record first.\n";
} else {
    echo "Found " . $gateways->count() . " gateway(s):\n\n";
    foreach ($gateways as $gateway) {
        echo "ID: {$gateway->id}\n";
        echo "Provider: {$gateway->provider}\n";
        echo "Test Webhook Secret: " . ($gateway->test_webhook_secret ?? 'NULL') . "\n";
        echo "---\n";
    }
}

// Check subscriptions table
echo "\n=== Checking subscriptions table ===\n\n";
$subscriptions = DB::table('subscriptions')->get();
if ($subscriptions->isEmpty()) {
    echo "❌ No subscriptions found!\n";
} else {
    foreach ($subscriptions as $sub) {
        echo "ID: {$sub->id}\n";
        echo "Stripe Customer: {$sub->stripe_customer_id}\n";
        echo "Stripe Subscription: {$sub->stripe_subscription_id}\n";
        echo "Current Period End: {$sub->current_period_end}\n";
        echo "---\n";
    }
}
