#Adaxer
1 messages · Page 1 of 1 (latest)
Where are you getting that error?
Can you link the Event ID?
Certainly, evt_1N0pzZEKarudGTfPSckvvFDI.
Should look like --> evt_abc123
That's an internal server error with your webhook handler. So wherever you're listening for webhooks, your server is sending back a bunch of raw HTML instead of a HTTP 200 code
Is there any guide on how to properly handle webhooks?
This is a pretty decent guide with some code-snippets for handling incoming webhooks: https://stripe.com/docs/webhooks
I tried that and the interactive guide, both of them returns the same.
It seems like it returns the django error html page, but it shouldn't...
endpoint_secret = 'whsec_kX...'
@csrf_exempt
def stripe_webhook(request):
event = None
payload = request.data
try:
event = json.loads(payload)
except:
return jsonify(success=False)
if endpoint_secret:
# Only verify the event if there is an endpoint secret defined
# Otherwise use the basic event deserialized with json
sig_header = request.headers.get('stripe-signature')
try:
event = stripe.Webhook.construct_event(
payload, sig_header, endpoint_secret
)
except stripe.error.SignatureVerificationError as e:
return jsonify(success=False)
if event.type == 'checkout.session.completed':
# do something
return jsonify(success=True)
There's nowhere it returns the html of the page, right?
I'm not sure. I don't have access to your server, so you'd need to put console.log(); lines throughout to see which line is doing this. For what it's worth, I think you may want to switch to Python on the docs and use this line to return the status code 200 return HttpResponse(status=200)