braintree / braintree_php

Braintree PHP library

Home Page:https://developer.paypal.com/braintree/docs/start/overview

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP lib throwing error on Google App Engine due to cUrl

ilDon opened this issue · comments

commented

General information

  • SDK/Library version: "braintree/braintree_php": "3.23.1"
  • Environment: Production
  • Language, language version, and OS: PHP, 5.5 on Google App Engine Standard

Issue description

I'm deploying an app to Google App Engine standard environment, PHP 5.5, but I'm encountering the following issue when making any request through the Braintree PHP library:

PHP Fatal error:  Uncaught exception 'google\appengine\runtime\CurlLiteOptionNotSupportedException' with message     'Option 10065 is not supported by this curl implementation.' in /base/php_experiment_runtime/sdk/google/appengine/runtime/CurlLite.php:487
Stack trace:
#0 /base/php_experiment_runtime/sdk/google/appengine/runtime/CurlLite.php(215): google\appengine\runtime\CurlLite->setOption(10065, '/base/data/home...')
#1 /base/php_experiment_runtime/sdk/google/appengine/runtime/CurlLiteStub.php(1325): google\appengine\runtime\CurlLite->setOptionsArray(Array)
#2 /base/php_experiment_runtime/sdk/google/appengine/runtime/CurlLiteStub.php(1319): curl_setopt_array(Object(google\appengine\runtime\CurlLite), Array)
#3 /base/data/home/apps/s~enoronbackend/20170630t135950.402337515471573447/vendor/braintree/braintree_php/lib/Braintree/Http.php(135): curl_setopt(Object(google\appengine\runtime\CurlLite), 10065, '/base/data/home...')
#4 /base/data/home/apps/s~enoronbackend/20170630t135950.402337515471573447/vendor/braintree/braintree_php/li in /base/php_experiment_runtime/sdk/google/appengine/runtime/CurlLite.php on line 487

I did set up the library specifying no gzip responses, as indicated here.

Braintree\Configuration::environment('production');
Braintree\Configuration::merchantId('XXX');
Braintree\Configuration::publicKey('XXX');
Braintree\Configuration::privateKey('XXX');
Braintree\Configuration::acceptGzipEncoding(false);

It appears however that the problem is caused by line 133 in Braintree\Http:

curl_setopt($curl, CURLOPT_CAINFO, $this->getCaFile());

The cUrl lite implementation provided by GAE does not support CURLOPT_CAINFO. I did try to use CURLOPT_CAPATH instead, as suggested in the PHP documentation on [cUrl][2], but then I got an Authorization error from Braintree.

Also commenting out the line where CURLOPT_CAINFO is results in an Authorization error.

I've also submitted a question on Stackoverflow.

commented

Turns out that we need to use the full cUrl library (requires billing being enabled on GAE).

I suggest that in the readme of the library it is specified that, on GAE, in the php.ini file the following line must be included extension = "curl.so".

It would also be worth mentioning in the readme of the library that the following line won't work: google_app_engine.enable_curl_lite = “1”, even if commenting out the line CURLOPT_CAINFO in Braintree\Http.

Thanks for the feedback @ghego1! I've updated the README to include this information with a link to this issue.