Symfony2控制器中的条纹的错误使用语句



我正在使用Stripe为我的Symfony2 Web应用程序付款,并获得尝试使用条纹方法的错误。

Attempted to load class "Stripe_Charge" from namespace "UserBundleController".
Did you forget a "use" statement for another namespace?

我使用作曲家像这样包括条纹库:

作曲家:

"require": {
    "php": ">=5.3.9",
    "symfony/symfony": "2.8.*",
    [...]
    "stripe/stripe-php": "dev-master"
}

在我的控制器中,我具有执行epaymentAction函数,但是使用条纹中有一个错误。

这是我的控制器:

<?
namespace UserBundleController;
use StripeStripe;
class RegistrationSellerController extends Controller
{
    public function executePaymentAction(Request $request){
        $data = $request->request->all();
        Stripe::setApiKey('pk_test_***');
        try {
            Stripe_Charge::create([
                'amount' => 2000, // this is in cents: $20
                'currency' => 'usd',
                'card' => $_POST['stripeToken'],
                'description' => 'product description'
            ]);
        } catch (Stripe_CardError $e) {
            // Declined. Don't process their purchase.
            // Go back, and tell the user to try a new card
        }
    }
}

错误消息很明显:您忘记了类Stripe_Charge

的使用语句

最新更新