Search code examples
phppaypalpaypal-sandbox

Paypal Sandbox Access Token not Found in Cache


I am having a persisting issue with the Paypal access token for the sandbox environment where I continually get the error,

Client error: `POST https://api.sandbox.paypal.com/v1/payments/billing- 
agreements` resulted in a `401 Unauthorized` response: 
{"error":"invalid_token","error_description":"Access Token not found in cache"}

I am not sure where to go as this is a new token that is being generated and used just prior to running the API call. Everything was working normal until this began giving me issues a couple of nights ago. It seems to return this error for about 30 minutes or so until the token begins working. My issue is that once I switch to the live version, I do not want there to be this error while the new token is "processing" as the tokens are going to automatically update (or doing whatever the issue is).

Any suggestions?


Solution

  • The issue ended up being with Laravel's configuration caching from the env file. I just ran php artisan config:cache and it fixed itself. I added to the command

    Artisan::call('config:cache');
    

    and this fixed all of my issues.