How to solve the check djstripe.W005 is not populated in the db

You may have installed dj-stripe, and set up all the configuration in your Django setting module. But there is a warning check that irritates you.

?: (djstripe.W005) The secret of Webhook Endpoint: DJSTRIPE_WEBHOOK_SECRET is not populated in the db. Events sent to it will not work properly.
    HINT: This can happen if it was deleted and resynced as Stripe sends the webhook secret ONLY on the creation call. Please use the django shell and update the secret ...

If you check out the source code of the check, check_webhook_endpoint_has_secret, you notice that the secret property of the model object WebhookEndpoint is being checked.

How to fix this

If you happen to have just one webhook instance, this will help you.

  1. First, make sure you have a WebhookEndpoint object in your admin site
  2. Go to the Django command shell python manage.py shell

  3. In the shell, run the following:

from django.conf import settings
from djstripe.models import WebhookEndpoint

# Get the WebhookEndpoint object
e = WebhookEndpoint.objects.last() # Or e = WebhookEndpoint.objects.all()[0]

# Set the current secret and save
e.secret = setting.DJSTRIPE_WEBHOOK_SECRET
e.save()

Note: If you wonder where to get the the Stripe Webhook secret, you need to visit the Stripe Dashboard, search for your webhook and click on Reveal the signing secret.

Stripe Webhook dashboard


πŸ“Š Create a modern CV
Create a modern CV

Create a modern CV to impress recruiters