Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Class 'Stripe' not found in C:\wamp\www\

Tags:

php

I'm getting an error that class is not found, but I clearly have the right path for where it is located:

<?php

require_once('stripe-php-2.1.0/stripe/lib/Stripe.php');



Stripe::setApiKey('my_key');

var_dump($_POST['stripe-token']);

?>

Every article I've come across all claim that the problem is (not including the right path) in the require_one, include, or require. (I've tried all 3). But still no luck. My database calls follow the same format and my WAMP server has no problem creating my database class.

This is copied directly from my file explore (copy paste)

website\stripe-php-2.1.0\stripe\lib\Stripe.php

My php file that I am using to try and access Stripe sits in the same place as 'website'.

PHP version 5.5.12

tutorial references: http://www.larryullman.com/2013/01/09/writing-the-php-code-to-process-payments-with-stripe/

Other reference: http://www.youtube.com/watch?v=Lka_JBM9bbY

enter image description here

like image 291
AD6 Avatar asked Dec 25 '22 22:12

AD6


2 Answers

It's because it uses a namespace. Try:

\Stripe\Stripe::setApiKey('my_key');
like image 177
Bitwise Creative Avatar answered Jan 12 '23 04:01

Bitwise Creative


It is better to initialize all classes.

require_once ("stripe_folder/init.php");

then use namespaces:

\Stripe\Stripe::setApiKey('key_key_key_key_key_key');
like image 22
Serhii Avatar answered Jan 12 '23 02:01

Serhii