I built a django library for subscriptions and metered billing. The best part is that you don’t need to configure webhooks or store any billing state in your application. It also comes with some nice-to-haves for tracking usage and checking subscription status.
@subscription_required(redirect_url='/pricing/')
def feature_view(request):
return render(request, 'feature.html')
@usage_within_limits(redirect_url='/upgrade/')
def limited_api(request):
return JsonResponse({"result": "ok"})
# Track usage automatically on successful responses
@track_usage("api_calls")
def my_api_view(request):
return JsonResponse({"result": "ok"})