<?php
class checkPaidAjax extends database
{
    public function userStatus($id)
    {
        $sql = ' SELECT MAX(cl_expiry_date) AS max_expiry FROM tb_payments WHERE cl_user_id=?  ';
        return $this->CallQueryRow($sql, [$id]);
    }
}

$paidObjAjax = new checkPaidAjax();
$userPayment = $paidObjAjax->userStatus($user['cl_user_id']);

if(!$userPayment || ($userPayment['max_expiry'] < date('Y-m-d')))
{
    http_response_code(401);
    echo json_encode(['error_text' => 'Something went wrong. Please contact administrator for details']);
    exit;
}
