Ok, so I am attempting to integrate PayPal's Rest API. I have installed their SDK through composer using the following:
php composer.phar require paypal/rest-api-sdk-php:*
My composer.json file in the required section is as follows:
"paypal/rest-api-sdk-php" : "*",
"paypal/sdk-core-php": "*"
The versions that are installed for both components are:
paypal/sdk-core-php (v2.4.3)
paypal/rest-api-sdk-php (v0.14.2)
So the problem that I am getting is that these two don't seem to line up. I am getting a lot of "undefined method" errors. In example:
Call to undefined method PayPal\Core\PPConfigManager::addConfigs()
Seems as if their documentation is outdated as it is saying to install version 0.5.* of the rest-api-sdk-php package. Even though they are in version 0.14.2
Can anyone tell me for sure what version of sdk-core-php is compatible with version 0.14.2 of rest-api-sdk-php??? Thanks in advanced!
EDIT So it seems that removing sdk-core-api fixes the issue... I still get the following response from PayPal when the call is made:
stdClass Object
(
[name] => UNKNOWN_ERROR
[message] => An unknown error has occurred
[information_link] => https://developer.paypal.com/webapps/developer/docs/api/#UNKNOWN_ERROR
[debug_id] => 77ae828d89ba7
)
Have no idea yet, but will update this post when I find out. (Might have to contact PayPal...)
Rest API SDH PHP has removed its dependency from SDK Core PHP, to make breaking changes and optimizations in future, as SDK Core PHP was shared with Classic APIs.
If you just add the rest-api-sdk-php, the latest version, you should be able to get the code working.
To verify if things are working fine or not, you can checkout the samples. They should be ready to go, once you host them on your localhost.
And if you dont have a hosting setup in your local computer(which I highly doubt), you can run the samples (most of them) on command line.
e.g.
LM-AUN-00876403:PayPal-PHP-SDK japatel$ php -f sample/payments/CreatePaymentUsingSavedCard.php
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(1) CREATE CREDIT CARD
-------------------------------------------------------------
Object with ID: CARD-1FP81708B3755801TKRWMOPI
-------------------------------------------------------------
REQUEST:
{"type":"visa","number":"4417119669820331","expire_month":"11","expire_year":"2019","cvv2":"012","first_name":"Joe","last_name":"Shopper"}
RESPONSE:
{"type":"visa","number":"xxxxxxxxxxxx0331","expire_month":"11","expire_year":"2019","cvv2":"012","first_name":"Joe","last_name":"Shopper","id":"CARD-1FP81708B3755801TKRWMOPI","state":"ok","valid_until":"2017-11-18T00:00:00Z","create_time":"2014-11-19T16:37:17Z","update_time":"2014-11-19T16:37:17Z","links":[{"href":"https://api.sandbox.paypal.com/v1/vault/credit-card/CARD-1FP81708B3755801TKRWMOPI","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/vault/credit-card/CARD-1FP81708B3755801TKRWMOPI","rel":"delete","method":"DELETE"},{"href":"https://api.sandbox.paypal.com/v1/vault/credit-card/CARD-1FP81708B3755801TKRWMOPI","rel":"patch","method":"PATCH"}]}
-------------------------------------------------------------
Let me know if you are still getting this error. Let me know what exactly you are trying to do, and I could help you with that.