paypal / PayPal-PHP-SDK

PHP SDK for PayPal RESTful APIs
https://developer.paypal.com/docs/api/
Other
27 stars 100 forks source link

sample bootstrap mentions non-existent function: PayPal\Rest\ApiContext::setConfig() #20

Closed tmsimont closed 10 years ago

tmsimont commented 11 years ago
// ### Api Context
// Pass in a `PayPal\Rest\ApiContext` object to authenticate 
// the call. You can also send a unique request id 
// (that ensures idempotency). The SDK generates
// a request id if you do not pass one explicitly. 
$apiContext = new ApiContext(new OAuthTokenCredential(
        'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM',
        'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'));
// Uncomment this step if you want to use per request 
// dynamic configuration instead of using sdk_config.ini
/*
$apiContext->setConfig(array(
    'mode' => 'sandbox',
    'http.ConnectionTimeOut' => 30,
    'log.LogEnabled' => true,
    'log.FileName' => '../PayPal.log',
    'log.LogLevel' => 'FINE'
));
*/

When you uncomment the setConfig() function below the comment that reads "Uncomment this step if you want to use per request dynamic configuration instead of using sdk_config.ini"

An error is thrown:

Fatal error: Call to undefined method PayPal\Rest\ApiContext::setConfig()

Is there no way to set the configuration outside of the .ini file?

ericrosas commented 11 years ago

I too am getting a similar error! I followed the instructions exactly as they are stated(see my stack overflow here: http://stackoverflow.com/questions/18282483/server-500-error-when-implementing-paypals-rest-api-sdk-in-php).

This SDK seems pretty complicated for those just trying to implement a quick plugin code. Has anyone else had this issue?

tmsimont commented 11 years ago

@ericrosas that is not the same issue.

The problem you are having is related to this issue: https://github.com/paypal/rest-api-sdk-php/issues/18

My issue here is that the PayPal\Rest\ApiContext::setConfig() function does not exist. The class is found, but if you look at the ApiContext source code, there is no setConfig() function.

How does one set config in PHP?

aydiv commented 11 years ago

@ericrosas there was a comment asking for more info on your stackoverflow post. Also, I would say this is probably because you a re using a older version of the SDK. Can you post the SDK version from your composer.json?