-
Notifications
You must be signed in to change notification settings - Fork 720
Description
Cashier Stripe Version
16.0.4
Laravel Version
latest
PHP Version
8.4
Database Driver & Version
No response
Description
When receiving a webhook for a soft deleted billable model you get the error:
Call to a member function stripe() on null
What going good is the fact that Cashier::findBillable() applies withTrashed() to find the soft deleted model inside of the WebhookController.
Where it's going wrong is in the asStripeSubscriptionItem() method of SubscriptionItem looking back to the owner like so:
public function asStripeSubscriptionItem(array $expand = [])
{
return $this->subscription->owner->stripe()->subscriptionItems->retrieve(
$this->stripe_id, ['expand' => $expand]
);
}This method is called from $subscription->currentPeriodEnd(); which does $item->currentPeriodEnd();, which calls $this->asStripeSubscriptionItem().
Here it loads the subscription, but it can't find the owner because it's soft deleted and there is no withTrashed() applied on the subscription->owner relation.
I think a solution would be to chaperone the subscription + owner to the SubscriptionItem, or add withTrashed() logic to the subscription->owner relation.
Steps To Reproduce
- Grab a starter kit
- Add soft deletes to a user
- Start a subscription
- Delete the user
- Cancel the subscription