Skip to content

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

@geoidesic

Description

@geoidesic

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

    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions