<?php

namespace App\Http\Resources\Payments;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class PaypalTransactionResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => (int) ($this->resource['id'] ?? 0),
            'transaction_id' => $this->resource['transaction_id'] ?? null,
            'order_id' => $this->resource['order_id'] ?? null,
            'parent_school_id' => $this->resource['parent_school_id'] ?? null,
            'payer_email' => $this->resource['payer_email'] ?? null,
            'amount' => (float) ($this->resource['amount'] ?? 0),
            'net_amount' => (float) ($this->resource['net_amount'] ?? 0),
            'currency' => $this->resource['currency'] ?? null,
            'status' => $this->resource['status'] ?? null,
            'event_type' => $this->resource['event_type'] ?? null,
            'created_at' => $this->resource['created_at'] ?? null,
        ];
    }
}
