cashier-stripe icon indicating copy to clipboard operation
cashier-stripe copied to clipboard

Potential Bug: trial_ends_at not updated in webhook due to mass assignment protection

Open woodjme opened this issue 5 months ago • 0 comments

Cashier Stripe Version

15.4

Laravel Version

11.9

PHP Version

8.3.9

Database Driver & Version

No response

Description

Hi there,

I believe I've encountered a potential bug related to how the trial_ends_at attribute is handled during webhook processing for subscription creation.

Issue Description

In the SubscriptionCreated webhook handler, the following code attempts to set the trial_ends_at attribute to null:

https://github.com/laravel/cashier-stripe/blob/67f3625f2fb3674532f8bbd446ab53b33d7eab22/src/Http/Controllers/WebhookController.php#L103-L107

However, unless trial_ends_at is included in the $fillable array of the billable model, this update will silently fail due to Laravel's mass assignment protection. This behavior is not documented, and developers may not realize that trial_ends_at needs to be included in $fillable for this update to succeed.

Expected Behavior

  • Laravel Cashier should update the trial_ends_at attribute successfully without requiring additional configuration or at least document this requirement.

Steps To Reproduce

My scenario:

  • The billable model is on a Team
  • Create a new trial for Team (without a payment method)
  • Create a subscription using Stripe Checkout
  • A new subscription starts but $team->onGenericTrial() still returns true

woodjme avatar Aug 28 '24 13:08 woodjme