laravel-paystack: Any body experience this exception "URI must be a string or UriInterface"

The app has been throwing this error for a while. If I comment out this line in the form <input type="hidden" name="reference" value="{{ Paystack::genTranxRef() }}"> it works fine but throws that same error on the PaymentController@redirectToGateway controller.

I search and realized it has to do with Guzzle, anyway to bypass this exception?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 24 (4 by maintainers)

Most upvoted comments

Hi guys … so i used dis package worked perfectly on my local server buh when i deployed it i get the “URI must be a string or UriInterface”… i currently dont know how to fix it …

@Pauloo101 i experienced this same issue and it took me three days to discover that i didn’t update my .env with paystack details in production server (in deployment) as shown below. hope this help someone.

PAYSTACK_PUBLIC_KEY=xxxxxxxxxxxxxxxx PAYSTACK_SECRET_KEY=xxxxxxxxxxxxxxxxx PAYSTACK_PAYMENT_URL=https://api.paystack.co MERCHANT_EMAIL=unicodeveloper@gmail.com

You will most likely experience this issue on a live server. Here is how to fix

  1. Remove ‘.env’ from .gitignore file
  2. Update your Paystack details in .env
  3. Add, Commit and Push the updates to your live server
  4. Readd ‘.env’ to .gitignore
  5. Add, Commit and Push the changes to your live server

Explanation The reason you are seeing this error is due to the fact that you added Paystack details after publishing your website to a live server since .env is in gitignore file, it means that the changes you make are not tracked on the live server. So by removing .env from the gitignore file, the changes can now be tracked an effected. You can also decide to readd .env to gitignore after your changes take effect.

@Emmanuel96 and @nensok , I updated my packages using composer update (this is after I added "unicodeveloper/laravel-paystack": "1.0.*" to my composer.json file of course) and it worked.

Try that and let’s see

I assume you have already done the installation of the package and added paystack.php manually and populated config:app, with the provider and alliases to get this error, if not do so. now this is what worked for me:

  1. run composer update
  2. after the update run config:cache and you are good to go