I'm working on allowing PayPal Direct Credit Card payments in my website. I have downloaded the PayPal PHP RESTful SDK from here https://github.com/paypal/PayPal-PHP-SDK/releases and I am following instructions on setting up the direct credit card payment from here...https://devtools-paypal.com/guide/pay_creditcard/php?interactive=ON&env=sandbox.
I'm stumped. The SDK has a folder structure like the following:
composer->subfolders...
paypal->subfolders...
psr->subfolders...
autoload.php
So I include the autoload.php file in my PHP script, and when I try to perform the first step in the tutorial which is the following bit of code
$paypal = new OAuthTokenCredential($clientId, $clientSecret, $sdkConfig);
I get Fatal error: Class 'OAuthTokenCredential' not found
However, If I instead use the following code...
$paypal = new \PayPal\Auth\OAuthTokenCredential($clientId, $clientSecret, $sdkConfig);
I get a an object back which looks like the following:
PayPal\Auth\OAuthTokenCredential Object
(
[clientId:PayPal\Auth\OAuthTokenCredential:private] => CLIENT_ID
[clientSecret:PayPal\Auth\OAuthTokenCredential:private] => CLIENT_SECRET
[accessToken:PayPal\Auth\OAuthTokenCredential:private] =>
[tokenExpiresIn:PayPal\Auth\OAuthTokenCredential:private] =>
[tokenCreateTime:PayPal\Auth\OAuthTokenCredential:private] =>
[cipher:PayPal\Auth\OAuthTokenCredential:private] => PayPal\Security\Cipher Object
(
[secretKey:PayPal\Security\Cipher:private] => CLIENT_SECRET
)
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
)
)
But the accessToken which is what I need for Step 2 in the tutorial is empty.
What the heck am i doing wrong? Can anyone give a straight forward step by step guide for this? Is there one available that I'm not finding?
Thank you!