<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void {
        Schema::create('pagos', function (Blueprint $table) {
            $table->id();
            $table->foreignId('factura_id')->constrained()->onDelete('cascade');
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->enum('metodo', ['paypal','payphone','transferencia']);
            $table->decimal('monto', 10, 2);
            $table->enum('estado', ['pendiente','completado','fallido','reembolsado'])->default('pendiente');
            $table->string('referencia_externa')->nullable();
            $table->json('datos_respuesta')->nullable();
            $table->timestamps();
        });
    }
    public function down(): void { Schema::dropIfExists('pagos'); }
};
