djangoproject.com
djangoproject.com copied to clipboard
fundraising: 'customer.subscription.deleted' webhook event always gets 404 response
The response to stripe 'customer.subscription.deleted' webhook event is always 404. The reason is:
In the cancel_donation view, stripe_subscription_id is set to an empty string https://github.com/django/djangoproject.com/blob/e5a4bf20fb58c463441c15d552c022b03f716858/fundraising/views.py#L178
In the subscription_cancelled webhook handler method, the donation object is fetched using stripe_subscription_id which was set to an empty string earlier.
https://github.com/django/djangoproject.com/blob/e5a4bf20fb58c463441c15d552c022b03f716858/fundraising/views.py#L232-L233
So, the response will always be 404 and no cancellation email will be sent to the donor.
@timgraham if this looks okay, Can I send a PR?
I haven't confirmed the issue. If you have, feel free to propose a fix.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The problem seems plausible. I suppose removing donation.stripe_subscription_id = '' from the cancel donation view would fix this. As long as the stripe webhook comes through, it will run the same statement. I'm not sure if there would be a noticeable delay for the user though (and if the webhook wasn't received for some reason, our database would be out of sync).
This issue still persists: https://github.com/django/djangoproject.com/blob/main/fundraising/views.py#L178
@Parbhat Would you like to send-in a PR?
@CuriousLearner I would like to send the PR