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/PaymentGateways/Stripe/ApplicationFee.php
<?php

namespace Give\PaymentGateways\Stripe;

use Give\License\Repositories\LicenseRepository;
use Give\PaymentGateways\Stripe\Models\AccountDetail as AccountDetailModel;

/**
 * Class ApplicationFee
 * @package Give\PaymentGateways\Stripe
 *
 * @see https://github.com/impress-org/givewp/issues/5555#issuecomment-759596226
 *
 * @since 2.10.2
 */
class ApplicationFee
{
    /**
     * @since 2.10.2
     */
    protected AccountDetailModel $accountDetail;

    /**
     * @since 4.3.0
     */
    protected LicenseRepository $licenseRepository;

    /**
     * @since 4.3.0 added LicenseRepository
     * @since 2.10.2
     */
    public function __construct(AccountDetailModel $accountDetail)
    {
        $this->accountDetail = $accountDetail;
        $this->licenseRepository = give(LicenseRepository::class);
    }

    /**
     * Returns true or false based on whether the Stripe fee should be applied or not
     *
     * @since 4.3.0 updated logic to check license for gateway fee
     * @since 2.10.2
     */
    public static function canAddFee(): bool
    {
        /* @var self $gate */
        $gate = give(static::class);

        if (!$gate->doesCountrySupportApplicationFee()) {
            return false;
        }

        return $gate->licenseRepository->hasPlatformFeePercentage();
    }

    /**
     * Return whether country support application fee.
     *
     * @since 4.5.0 Add India, Malaysia, Mexico, Singapore, Thailand to the list of unsupported countries
     * @since 2.10.2
     */
    public function doesCountrySupportApplicationFee(): bool
    {
        $unsupportedCountries = [
            'BR', // Brazil
            'IN', // India
            'MY', // Malaysia
            'MX', // Mexico
            'SG', // Singapore
            'TH', // Thailand
        ];

        return !in_array($this->accountDetail->accountCountry, $unsupportedCountries);
    }
}