Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Client.php constructor is problematic as it doesn't allow (e.g.) the TLS cert path to be set in an extension. #194

Open
geoidesic opened this issue Sep 5, 2024 · 0 comments

Comments

@geoidesic
Copy link

geoidesic commented Sep 5, 2024

See inline comments about Client.php

    public function __construct($config)
    {
        $this->validate_config($config);   //<-- this is private, so I can't fully override this method

        $access_token = $config['access_token'];

        if (isset($config['base_url'])) {
            $endpoint_url = $config['base_url'];
        } else if (isset($config['environment'])) {
            $endpoint_url = $this->getUrlForEnvironment($config['environment']);  //<--  this is also private
        } else {
            throw new \InvalidArgumentException("Please specify an environment");
        }

        if (isset($config['http_client'])) {
            $http_client = $config['http_client'];
        } else {
            $stack = \GuzzleHttp\HandlerStack::create();
            $stack->push(RetryMiddlewareFactory::buildMiddleware());

            $timeout = 0;
            if(isset($config['timeout'])) {
                $timeout = $config['timeout'];
            }

            $http_client = new \GuzzleHttp\Client(
                [
                'base_uri' => $endpoint_url,
                'timeout' => $timeout,
                'headers' => array(
                'GoCardless-Version' => '2015-07-06',
                'Accept' => 'application/json',
                'Content-Type' => 'application/json',
                'Authorization' => "Bearer " . $access_token,
                'GoCardless-Client-Library' => 'gocardless-pro-php',
                'GoCardless-Client-Version' => '4.28.0',
                'User-Agent' => $this->getUserAgent()
                ),
                'http_errors' => false,
                'verify' => true,                        //<--  this is hard-coded, there's no way to edit this value.
                'handler' => $stack
                ]
            );
        }
        $this->api_client = new \GoCardlessPro\Core\ApiClient($http_client, $config);
    }

    ```
    
The reason I would like to be able to set the `verify` property of the `$http_client` is because of this error when trying to use GoCardless via Guzzle:
    

Deprecated: Creation of dynamic property GoCardlessPro\Core\ApiClient::$http_client is deprecated in /var/www/html/SportchLegacyApp/support/vendor/gocardless/gocardless-pro/lib/Core/ApiClient.php on line 24

Deprecated: Creation of dynamic property GoCardlessPro\Core\ApiClient::$error_on_idempotency_conflict is deprecated in /var/www/html/SportchLegacyApp/support/vendor/gocardless/gocardless-pro/lib/Core/ApiClient.php on line 25

Deprecated: Creation of dynamic property GoCardlessBridge::$redirect_flows is deprecated in /var/www/html/SportchLegacyApp/support/vendor/gocardless/gocardless-pro/lib/Client.php on line 404

Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api-sandbox.gocardless.com/redirect_flows in

    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant