8 months ago

Laravel Cashier - Undefined variable: token

Posted 8 months ago by WallyJ

I'm setting up Cashier for Braintree.

I have the following code:

$user = Auth::user();
            //Check if user has subscribed with their credit card to Braintree
            if ($user->subscribedToPlan('main', 'annual')) {
                //Go to User home page
                // $user = Auth::user();
                return view('home', ['user' => $user]);
            } else {
                //For a user that has not put in their credit card info through Braintree yet
                $user->newSubscription('main', 'annual')
                ->create($token, [
                    'email' => $user->email,
                    'phone' => $user->phone,


This is in my HomeController. When I go to /home, I get "Undefined variable: token".

I see that I don't declare the variable anywhere else, but I thought that was handled by Cashier.

What am I missing?

Please sign in or create an account to participate in this conversation.