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

mikebronner's avatar

Laravel Cashier: Error when setting Stripe Key

I am trying to set my Stripe Key in a Service Provider, but am getting the following error:

Call to undefined method Illuminate\Database\Query\Builder::setStripeKey()

I am trying to do this as the docs describe, and I have verified that the correct key is being pulled from the environment variables:

    public function boot()
    {
        // [...]
        User::setStripeKey(getenv('STRIPE_SECRET_KEY'));
    }

Any ideas what might be going on here?

0 likes
2 replies
mikebronner's avatar
mikebronner
OP
Best Answer
Level 16

Bah! What a morning this is starting out to be. :) Turns out I forgot to add the trait to the User class. Hope this helps someone else down the road (at least then I won't feel quite so useless).

Please or to participate in this conversation.