<?php

declare(strict_types=1);

namespace apexl\Io\modules\payment\Entity;

use apexl\entityCore\traits\HasCasts;
use apexl\Io\includes\Entity;

/**
 * Payment — a single capture against a gateway.
 *
 * One row per attempted charge. Failed / disputed / refunded states are
 * recorded here too; the full state-change audit log lives on
 * {@see PaymentLog}. Multi-currency aware (amount + currency cols).
 *
 * @property int         $id
 * @property string      $public_id              opaque short ref shown to customers
 * @property string|null $ref                    consumer-side reference (e.g. invoice id, order id)
 * @property string      $gateway                'stripe' / 'paypal' / 'gocardless' / 'revolut' / …
 * @property string|null $gateway_payment_ref
 * @property string|null $gateway_customer_ref
 * @property int|null    $payment_token_id
 * @property int         $amount_cents
 * @property int         $amount_refunded_cents
 * @property string      $currency
 * @property string      $status                 pending / processing / succeeded / failed / refunded / partially_refunded / disputed
 * @property string|null $failure_code
 * @property string|null $failure_message
 * @property string|null $remote_order_id        external integration reference (WC order id etc.)
 * @property int|null    $paid_at
 * @property int|null    $refunded_at
 * @property bool        $user_notified
 * @property array|null  $meta
 * @property int         $created
 * @property int         $created_by
 * @property int|null    $modified
 * @property int|null    $modified_by
 */
class Payment extends Entity
{
    use HasCasts;

    public final const string TABLE = 'payments';

    public function __construct()
    {
        parent::__construct(static::TABLE);
    }

    public function casts(): array
    {
        return [...parent::casts()];
    }
}
