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

jgravois's avatar

Using Stripe & Cashier for companies instead of users

I have a use case where a "company admin" registers and sets in a profile authorized users within his company to access the site. I want to offer a trial as well as Free, Monthly and Annual Billing levels of the service and need each authorized user of that company constrained by the "master".

I have explored Stripe and Cashier but all appears to be ingrained into using the users table and I can't see a work around for my use case.

I would appreciate any and all suggestions ... I am certainly willing to do the research needed but I don't see a solution that I can explore.

Thanks in advance!

0 likes
5 replies
richardbishopme's avatar

Hi @jgravois,

In the setup for Cashier in Laravel 5.*, did you try applying the migration and config to an account/company table? Then any user associated with the account could access resources based on the subscription.

Something like this for 5.2. Please modify if you are using a previous version:

Schema::table('account', function ($table) {
    $table->string('stripe_id')->nullable();
    $table->string('card_brand')->nullable();
    $table->string('card_last_four')->nullable();
});

Schema::create('subscriptions', function ($table) {
    $table->increments('id');
    $table->integer('account_id');
    $table->string('name');
    $table->string('stripe_id');
    $table->string('stripe_plan');
    $table->integer('quantity');
    $table->timestamp('trial_ends_at')->nullable();
    $table->timestamp('ends_at')->nullable();
    $table->timestamps();
});
use Laravel\Cashier\Billable;

class Account extends Authenticatable
{
    use Billable;
}
'stripe' => [
    'model'  => App\Account::class,
    'secret' => env('STRIPE_API_SECRET'),
],
vladstanca's avatar

@desloc I'm having some trouble with your suggestion. When I try $account->subscribed() it comes back with a SQL error because it checks for subscriptions.user_id instead of subscriptions.account_id. Any thoughts on how to fix that?

paulbarker's avatar

I don't know if you found your solution to this or not, but for future reference, to fix that error, simply change the model Stripe is linked to in app\config\services.php:

Original:

'stripe' => [
        'model' => App\User::class,
        'key' => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET'),
],

Change to:

'stripe' => [
        'model' => App\Account::class, // or whatever model you like
        'key' => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET'),
],

*Laravel 5.3

Segomox's avatar

Late to the party but for those looking for a solution. If you override the Billing trait with your own you can override the Subscriptions method.

public function subscriptions() 
{
     return $this->hasMany(Subscription::class, 'other_id')
                 ->orderBy('created_at', 'desc');
}

Since this is the Relationship the rest of Cashier uses. This only relates to Laravel 5.2 and maybe 5.3. I believe it has been since addressed.

Please or to participate in this conversation.