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 test@example.com"
));
?>
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"
If you don't use composer to install the Stripe library you will need to manually include all of the Stripe classes.
Composer is the preferred way as it will handle the autoloading of classes. Here is a sample composer file:
And then from a command line you would need to run
composer update
while in the directory for your project. Afterwards, just addrequire 'vendor/autoload.php';
to the top of your php file.Otherwise, replace
require('/var/www/stripe-php-2.1.1/lib/Stripe.php');
with this code to include all of the classes:Here is an updated answer to this question.
From Dana at Stripe:
And that's what worked for me.