Skip to content
Advertisement

Stripe Class ‘StripeCharge

I want to implement a Stripe payment form but I get a fatal error Class ‘StripeCharge. The class is there (see my folder tree), I tried :

$charge =  StripeCharge::create(array(

$charge =  Charge::create(array(

but both no working. my php code:

require_once('Stripe/lib/Stripe.php');
StripeStripe::setApiKey("my_key"); //Replace with your Secret Key

$charge =  StripeCharge::create(array(
    "amount" => 1500,
    "currency" => "usd",
    "card" => $_POST['stripeToken'],
    "description" => "Charge for Facebook Login code."
));

enter image description here

Advertisement

Answer

You are using an older (1.x) version of the Stripe PHP library. In that version, all the classes were named Stripe_Class.

In version 2.0.0, the syntax was changed to use a namespace, and now all the classes are named StripeClass.

If it’s possible, I recommend you upgrade to the latest version (3.13.0). You can find it here: https://github.com/stripe/stripe-php/releases. All the examples in Stripe’s documentation and API reference use the newer syntax.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement