Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripe - undefined method Stripe\Subscription::create()

So I am having a problem creating a stripe payment and keep getting this error.

<br />↵<b>Fatal error</b>: Call to undefined method Stripe\Subscription::create() in <b>D:\username\Programs\xampp\htdocs\myapp\services\sec.php</b> on line <b>219</b><br />

Here is the code.

} else if($stripetoken != "") {
    $customer = \Stripe\Customer::create(array(
        "email" => $email,
        "source" => $stripetoken,
    ));


    if ($term == "1") {
        \Stripe\Subscription::create(array(    <-- line 219
            "customer" => $customer->id,
            "plan" => "monthly-sub-test",
        ));                        
    }

I believe I have set up the code to what the documentation says

https://stripe.com/docs/subscriptions/quickstart

like image 668
luckyging3r Avatar asked Feb 04 '26 16:02

luckyging3r


1 Answers

You are using an older version of Stripe's PHP library. The \Stripe\Subscription::create() method was added in version 3.13.0. Make sure you're using this version or a more recent one.

like image 131
Ywain Avatar answered Feb 07 '26 17:02

Ywain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!