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

lamarlaing's avatar

Subscription won't update in database after subscription is updated in Stripe using Laravel Cashier and Jenssegers MongoDB

I am having trouble getting my new subscription to be updated in MongoDB Database. Im using Laravel Cashier, Stripe, and Jenssegers MongoDB.

In the stripe dashboard, users have been successfully added as customers and subscribers.

Here is the ERROR: [23:24:17] LOG.error: Call to a member function prepare() on null {"userId":"4ec1b45d36623t2269477d0...

Here is where the ERROR lives:

            return true;
    }

    $statement = $this->getPdo()->prepare($query);

    $this->bindValues($statement, $this->prepareBindings($bindings));

Here is my controller:

namespace App\Http\Controllers;

use App\Plan;
use App\User;  
use Exception;
use Illuminate\Http\Request;





 class CheckoutController extends Controller
 {
 /**
 * The collection name
 *
 * @var array
 */

public function checkout($plan_id)
{
$plan = Plan::findOrFail($plan_id);
$intent = auth()->user()->createSetupIntent();
return view('billing.checkout', compact('plan', 'intent'));
}

public function process(Request $request)
{
$plan = Plan::findOrFail($request->input('billing_plan_id'));
try {
    auth()->user()->newSubscription($plan->name, $plan->stripe_plan_id)- 
>create($request->input('payment-method'));
    return redirect()->route('billing')->withMessage('Subscribed Successfully');
} catch (Exception $e) {
    return redirect()->back()->withError($e->getMessage());
}
}

Please help me figure out the source of this issue and how to solve it.

0 likes
0 replies

Please or to participate in this conversation.