#Beikeni-webhook
1 messages · Page 1 of 1 (latest)
👋 happy to help
could you please provide the Webhook Endpoint id we_xxx so I could take a look at it?
whsec_QenZdd0fwpojNOmoGoLmywxuT4AUFp5u
it's a test endpoint
Thank you for answering so quickly btw
just for the sake of clarity this id whsec_QenZdd0fwpojNOmoGoLmywxuT4AUFp5u is not the Webhook Endpoint id, this is the webhook secret and unfortunately I can't use it to take a look on your webhook
ah sorry, ok
just a sec
we_1KX6pUFTv35B9Lv0lxUcngLc
here
sorry for the misunderstanding
on it thanks
💯
your webhook endpoint is returning a 404 not found for the url configured for your endpoint
try to make sure that the endpoint exists and takes a POST request
the webhook is there, and i can see the request coming in. The problem is that the line "event = stripe.Webhook.construct_event(
payload, sig_header, endpoint_secret
)" doesnt work
i mean, the endpoint is there, the request comes in normally, i can print it and see the data from the payment
but it fails to generate a valid signature
but im using the stripe built in signature verification tool so i dont know what im doing wrong
It throws this error: stripe.error.SignatureVerificationError
could you paste the endpoint code please?
`@csrf_exempt
def webhook_received(request):
"""
Stripe Notes
The order with which the webhook events will come in
1. customer.subscription.created
2. invoice.created
3. invoice.paid
4. charge.created (if there’s a charge)
"""
user = None
endpoint_secret = settings.STRIPE_ENDPOINT_SECRET
payload = request.body
# print(f"PAYLOAD ::: {payload}")
sig_header = request.META['HTTP_STRIPE_SIGNATURE']
event = None
try:
print("try kona2 webhook_received")
event = stripe.Webhook.construct_event(
payload, sig_header, endpoint_secret
)
print("try kona2 webhook_received OK")
except ValueError as e:
print("Invalid payload:", e)
# Invalid payload
connection.close()
print("CHECKPOINT kona2 create_checkout_session end 1")
return HttpResponse(status=400)
except stripe.error.SignatureVerificationError as e:
print("Invalid signature:", e)
# Invalid signature
connection.close()
print("CHECKPOINT kona2 create_checkout_session end 2")
return HttpResponse(status=400)`
As you can see, the signature header comes along with the request being received. I don't see how that can be wrong 🤷♂️
are you returning HTTPResponse(status=200) at the ends?
yeah
return JsonResponse({'status': 200})
i didnt paste the whole function cause its a bit long
no worries
and anyway it never gets past the row where it tries to run construct_event
Hey i figure id out
The developer who built this messed up in linking the correct .env file 🤦♂️
I thought i checked it already but i guess i wasnt thorough enough
could you please check that the key you're using is the right one? whsec_QenZdd0fwpojNOmoGoLmywxuT4AUFp5u
yeah exactly, the key was wrong
Sorry my bad I wrote the message a while ago and thought I sent it 🤦
Ahah, no problem, im just happy it works now
Thanks for your help, have a good day!
let me know if you need any more help