HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/qas.sports-crowd.com/app/Http/Controllers/TicketMainController.php
<?php

namespace App\Http\Controllers;

use Carbon\Carbon;
use App\TicketMain;
use App\Core\Ticket\Application\TicketService;

class TicketMainController extends Controller
{
    private $ticketService;
    public function __construct()
    {
        $this->ticketService = new TicketService();
    }

    public function validatePayments($validateHistoricalPayments = false)
    {
        $now = Carbon::now();
        $ticketMains = TicketMain::select([
            'ticket_mains.*'
        ])
            ->distinct()
            ->join('ticket_user_block_backups', 'ticket_user_block_backups.ticket_main_id', '=', 'ticket_mains.id')
            ->where('ticket_mains.payment_state', '!=', 'CONFIRMED')
            ->whereNotNull('ticket_mains.gateway_payments_id')
            ->where('ticket_user_block_backups.active', true)
            ->where(function ($query) use ($validateHistoricalPayments, $now) {
                if ($validateHistoricalPayments) {
                    $query->where('ticket_mains.created_at', '>', $now->subDays(3)->startOfDay());
                } else {
                    $query->where(function ($query) use ($now) {
                        $query->where('ticket_mains.payment_attempts', '<', config('payment_gateway.attempts'))
                            ->orWhere('ticket_mains.created_at', '>', $now->subHours(3));
                    });
                }
            })
            ->orderBy('ticket_mains.created_at', 'DESC')
            ->get();

        foreach ($ticketMains as $ticketMain) {
            try {
                $this->ticketService->validatePayment($ticketMain);
            } catch (\Throwable $th) {
                $error = [
                    'ticketMain'            => $ticketMain,
                    'message'               => $th->getMessage(),
                    'getFile'               => $th->getFile(),
                    'getLine'               => $th->getLine(),
                ];
                $util = new UtilController;
                $util->logFile(json_encode($error));
            }
        }

        return array(
            'r' => true,
            'data' => null,
            'm' => 'Se validaron ' . count($ticketMains) . ' pagos pendientes.'
        );
    }

    public function validatePayment($ticketMain)
    {
        $ticketMain->payment_attempts = $ticketMain->payment_attempts + 1;
        $ticketMain->update();

        $this->ticketService->validatePayment($ticketMain);
    }
}