stripe / stripe-php

PHP library for the Stripe API.
https://stripe.com
MIT License
3.74k stars 849 forks source link

Can't use Stripe class #296

Closed ghost closed 8 years ago

ghost commented 8 years ago

Yii2 Framework.

Downloaded Stripe (https://github.com/stripe/stripe-php) by composer:

composer require stripe/stripe-php

And inserted to the view:

\Stripe\Stripe::setApiKey('d8e8fca2dc0f896fd7cb4cb0031ba249'); $myCard = array('number' => '4242424242424242', 'exp_month' => 8, 'exp_year' => 2018); $charge = \Stripe\Charge::create(array('card' => $myCard, 'amount' => 2000, 'currency' => 'usd')); echo $charge;

And now PHP can't find Class:

Error Class 'Stripe\Stripe' not found

What should I do?

olivierbellone commented 8 years ago

Hey @EvaldasAlcauskis. You very likely failed to include the library correctly in your code. If using Composer, you should have a require statement similar to this at the beginning of your code:

require_once('vendor/autoload.php');

See the README for more information.

If you need more help, I recommend you reach out to Stripe's support using this form. GitHub issues are specifically for bugs and feature requests in the library.