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

Anotheruser's avatar

Cashier - 502 bad gateway

Hi.

When signed in to my application as a user, when the following is called, Stripe cancels the subscription fine and the database Company->stripe_active is updated.


Auth::user()->company->subscription()->cancel();

However, as an Admin user I need to be able to cancel user accounts in the same way. When I use the following code I get a 502 bad gateway error.

public function adminCancel( $company_id )
{
    $company = Company::find( $company_id );
    $company->subscription()->cancel();

    return Redirect::route('companies'); //
}

Is there something obvious that i'm missing?

Thanks

0 likes
2 replies
ericlbarnes's avatar

Are you positive $company is actually what you think it is? Maybe dd($company) before the cancel call to double check that or use findOrFail().

Anotheruser's avatar

Yes its a Company. I just noticed in the db the stripe_subscription field was empty! problem solved.

On a slightly related note, by default cashier uses the User model. Is there an way to set that to use Company model instead. Im thinking for things such as webhooks, so when an event happens on the Stripe server my Company model will be updated as apposed to the default User model.

Thanks.

Please or to participate in this conversation.