Add message for unhandled events
@@ -222,7 +222,13 @@ class StripeEventView(APIView):
def post(self, request, format=None):
try:
event = stripe.Event.construct_from(request.data, settings.STRIPE_SECRET)
- if event.type in self.EVENTS:
+ if event.type not in self.EVENTS:
+ log.warning('Unhandled Stripe event. event=%s', event.type)
+ return Response({
+ 'OK': False,
+ 'msg': f'Unhandled event. event={event.type}'
+ })
+
stripe_customer = event.data.object.customer
if event.type == self.EVENT_CHECKOUT_COMPLETED:
