Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

theUnforgiven's avatar

Call to a member function create() on null [Cashier 7.0]

Although I'm getting the Stripe Token like so:

in Billable.php line 385
at User->updateCard(object(Token)) in SubscriptionBuilder.php line 212
at SubscriptionBuilder->getStripeCustomer('tok_19oWykA5zF9kYK3AAOoQP6YM', array('email' => '[email protected]')) in SubscriptionBuilder.php line 177

By doing the following:

$user = Auth::loginUsingId(1);
        try {
            // Setup new subscription
            $user->newSubscription('main', 'monthly')->create($request->stripeToken, [
                'email' => $user->email,
            ]);
        } catch (Exception $e) {            
            // do something
        }

I'm getting the above error, the stripe_id is saving within the users table but nothing else. Is cashier up to date with new changes at Stripe?

0 likes
8 replies
theUnforgiven's avatar

Yes, I removed Cashier from the composer.json file uninstalled everything, then re-installed and all works fine.

devnco's avatar

Hello @tealiedie did you solve this issue ? I'm having this too.

I've removede and re-installed Cashier from composer as @theUnforgiven propose but it didn't solve my case.

devnco's avatar

Hi again guys,

I figure it out. In fact I first register / charge one customer and after that delete it in stripe admin interface.

After that I try to charge the same customer and I experienced that error in Billable.php line 385

In fact the first time I charge the client a stripe_id was added in the row of the user in my DB. When I've deleted and try to charge the same client, the stripe_id stored in my DB and the new ID genereted by stripe doesn't match and create that issue.

You can simulate this error also if you try to charge a user which doest exist in you DB.

Ex :

$user = User::find(99999); // Fake ID
$user->newSubscription('main', 'main')->create(Input::get('stripeToken'));
upkareno's avatar

Hi , I think it ,ay help you :)

    // Using a default user as geust
    $user = User::find(1);
    $paymentMethod = $request->input('payment_method');
    $service = ServicePost::where('id',$id)->first();
    try {
        $user->createOrGetStripeCustomer();
        $user->updateDefaultPaymentMethod($paymentMethod);
        $user->charge($service->price * 100, $paymentMethod);   
        
        // save pyment request
        $payment = new Payment();
        $payment->name = $request->card_holder_name;
        $payment->email = $request->email;
        $payment->phone = $request->phone;
        $payment->service_id = $service->id;
        $payment->price = $service->price;
        $payment->save();
           
    } catch (\Exception $exception) {
        return back()->with('error', $exception->getMessage());
    }

Please or to participate in this conversation.