Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMister Moody
48,333 PointsStripe API Issue: Fatal Error Class 'Stripe' Not Found
When creating the 'config.php' file, I get the following error when viewing the project in the browser: Fatal error: Class 'Stripe' not found in C:\xampp\htdocs\stripAPI_ecommerce\web\config.php on line 9.
To my knowledge there are no errors with the code as provided via instructions. The code looks like this: <?php require_once('../vendor/stripe/lib/Stripe.php');
$stripe = array( "secret_key" => "sk_test_8NRp5ouPi5C33nOPLmCFnUgI", "publishable_key" => "pk_test_zto0L6WmmWw53sVufSZZhHe9" );
Stripe::setApiKey($stripe['secret_key']);
All things considered, what is the issue here?? Although I was able to follow along with the tutorial, from the 8:00 mark, I could not work on the project and view if my work was correct.
4 Answers
Jake Shasteen
15,985 PointsStripe has updated their platform since the tutorial came out.
You actually want to include require_once('../vendor/stripe/init.php') instead of /lib/Stripe.php, or use Composer to install stripe and autoload the libraries.
It also now uses a namespace, so you have to use
\Stripe\Stripe::setApiKey($stripe['secret_key']);
tanveer ahmed
254 Pointscan we update the tutorial?
Laurie Shuck
1,773 PointsThanks, Jake. Your reply was very helpful! Here is the code that I used on the config.php:
<?php require_once('../vendor/stripe/init.php');
$stripe = array( "secret_key" => "add your secret key here", "publishable_key" => "add your publishable key here" );
\Stripe\Stripe::setApiKey($stripe['secret_key']);
mala basry
Courses Plus Student 76 PointsFatal error: Class 'Stripe_Customer' not found in C:\xampp\htdocs\PHP\charge.php on line 6, i got a problem when popup successfully. help me
curtis allen
28,800 PointsIf you run into this issue it means that Stripe API can't find the customer class. The best way to fix this issue is to install the Stripe API using Composer. Below is a link to how to install the API using Composer. https://stripe.com/docs/libraries#php-library