Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripe - PHP Fatal error: Class 'Stripe\Charge' not found

Tags:

php

class

I've been following the Stripe documentation and I am unable to create a "charge".

Charge.php

require('/var/www/stripe-php-2.1.1/lib/Stripe.php');
\Stripe\Stripe::setApiKey("KEY_HERE");

\Stripe\Charge::create(array(
  "amount" => 400,
  "currency" => "usd",
  "source" => "TOKEN_HERE", // obtained with Stripe.js
  "description" => "Charge for [email protected]"
));
?>

I'm able to process the first command "\Stripe\Stripe::setApiKey("KEY_HERE");" but receive an error when processing the next and receive the following error: "Class 'Stripe\Charge' not found in /var/www/charge.php"

like image 515
Coyney Avatar asked Mar 04 '15 03:03

Coyney


1 Answers

Here is an updated answer to this question.

From Dana at Stripe:

If you prefer not to use Composer, our latest PHP bindings (>=2.x) include a init.php file that you can add to your project. Download and unzip the folder whereever you'd like, then include this init.php at the top of your scripts you use to communicate with the Stripe API, changing the path to the location of this file. Just like this: require_once('/path/to/stripe-php/init.php')

And that's what worked for me.

like image 56
CWill Avatar answered Oct 28 '22 20:10

CWill