HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
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/html/wpmuhibbah_err/wp-content/plugins/give/src/API/Endpoints/Reports/PaymentStatuses.php
<?php

/**
 * Reports base endpoint
 *
 * @package Give
 */

namespace Give\API\Endpoints\Reports;

class PaymentStatuses extends Endpoint
{

    public function __construct()
    {
        $this->endpoint = 'payment-statuses';
    }

    public function getReport($request)
    {
        $start = date_create($request->get_param('start'));
        $end = date_create($request->get_param('end'));

        $gatewayObjects = give_get_payment_gateways();
        $paymentModeKeyCompare = '!=';

        if ($this->testMode === false) {
            unset($gatewayObjects['manual']);
            $paymentModeKeyCompare = '=';
        }

        $gateway = array_keys($gatewayObjects);

        $args = [
            'number' => -1,
            'paged' => 1,
            'orderby' => 'date',
            'order' => 'DESC',
            'start_date' => $request->get_param('start'),
            'end_date' => $request->get_param('end'),
            'gateway' => $gateway,
            'meta_query' => [
                [
                    'key' => '_give_payment_currency',
                    'value' => $this->currency,
                    'compare' => '=',
                ],
                [
                    'key' => '_give_payment_mode',
                    'value' => 'live',
                    'compare' => $paymentModeKeyCompare,
                ],
            ],
        ];

        // Use give_count_payments logic to get payments
        $payments = give_count_payments($args);
        $completed = property_exists(
            $payments,
            'give_subscription'
        ) ? $payments->publish + $payments->give_subscription : $payments->publish;

        return [
            'labels' => [
                'Completed',
                'Pending',
                'Refunded',
                'Abandoned',
                'Cancelled',
                'Failed',
            ],
            'datasets' => [
                [
                    'data' => [
                        $completed,
                        $payments->pending,
                        $payments->refunded,
                        $payments->abandoned,
                        $payments->cancelled,
                        $payments->failed,
                    ],
                    'tooltips' => [
                        [
                            'title' => $completed . ' ' . __('Payments', 'give'),
                            'body' => __('Completed', 'give'),
                            'footer' => '',
                        ],
                        [
                            'title' => $payments->pending . ' ' . __('Payments', 'give'),
                            'body' => __('Pending', 'give'),
                            'footer' => '',
                        ],
                        [
                            'title' => $payments->refunded . ' ' . __('Payments', 'give'),
                            'body' => __('Refunded', 'give'),
                            'footer' => '',
                        ],
                        [
                            'title' => $payments->abandoned . ' ' . __('Payments', 'give'),
                            'body' => __('Abandoned', 'give'),
                            'footer' => '',
                        ],
                        [
                            'title' => $payments->cancelled . ' ' . __('Payments', 'give'),
                            'body' => __('Cancelled', 'give'),
                            'footer' => '',
                        ],
                        [
                            'title' => $payments->failed . ' ' . __('Payments', 'give'),
                            'body' => __('Failed', 'give'),
                            'footer' => '',
                        ],
                    ],
                ],
            ],
        ];
    }
}