laravel / cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
https://laravel.com/docs/billing
MIT License
2.39k stars 680 forks source link

ends_at is being set to null for cancelled subscriptions #1714

Closed jamesblackwell closed 2 months ago

jamesblackwell commented 2 months ago

Cashier Stripe Version

14.8

Laravel Version

10

PHP Version

8.2

Database Driver & Version

No response

Description

This appears to be triggered by the user submitting cancellation feedback via the Stripe checkout portal

That triggers a subscription updated event

Then the Cashier webhook seems to set the ends_at to null

I guess this maybe a possible race condition

// Cancellation date... if ($data['cancel_at_period_end'] ?? false) { $subscription->ends_at = $subscription->onTrial() ? $subscription->trial_ends_at : Carbon::createFromTimestamp($data['current_period_end']); } elseif (isset($data['cancel_at']) || isset($data['canceled_at'])) { $subscription->ends_at = Carbon::createFromTimestamp($data['cancel_at'] ?? $data['canceled_at']); } else { $subscription->ends_at = null; }

Steps To Reproduce

Create subscription Cancel Set cancellation reason quickly Notice subscription ends_at is null

crynobone commented 2 months ago

Hey there,

Unfortunately we don't support this version of the library anymore. Please check out our support policy on which versions we are currently supporting. Can you please try to upgrade to the latest version and see if your problem persists? If so, please open up a new issue and we'll help you out.

Thanks!