<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('payment_gateways', function (Blueprint $table) {
            $table->id();
            $table->string('name'); // PayPal, Stripe, etc.
            $table->string('slug')->unique(); // paypal, stripe, etc.
            $table->string('display_name'); // PayPal, Stripe
            $table->text('description')->nullable();
            $table->boolean('is_active')->default(false);
            $table->boolean('is_default')->default(false);
            $table->enum('mode', ['sandbox', 'live'])->default('sandbox');
            $table->json('credentials')->nullable(); // Store encrypted credentials
            $table->json('settings')->nullable(); // Additional settings
            $table->boolean('requires_saas')->default(false); // If true, only available with SaaS plugin
            $table->integer('sort_order')->default(0);
            $table->timestamps();
            $table->softDeletes();

            $table->index('slug');
            $table->index('is_active');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('payment_gateways');
    }
};
