public static function isOffsite($gateway)
    {
        $configValue = self::getConfigSetting($gateway, 'is_offsite');
        // If the value from config is set, return it
        if (is_bool($configValue)) {
            return $configValue;
        }

        $factory = new GatewayFactory();
        $gateway = $factory->create($gateway);

        // Some offsite gateways don't separate between authorize and complete requests,
        // so we need a different way to determine they're off site in the first place
        // without kicking off a purchase request within Omnipay.
        if (method_exists($gateway, 'isOffsite')) {
            return !!$gateway->isOffsite();
        }

        if ($gateway instanceof AbstractGateway) {
            return ($gateway->supportsCompletePurchase() || $gateway->supportsCompleteAuthorize());
        }

        return false;
    }