#icurrytheteam
1 messages · Page 1 of 1 (latest)
I'd recommend reading this: https://stripe.com/docs/webhooks/signatures
May I have a second to take a look?
Sure, let me know if you have any specific Qs
So my backend is setup almost exactly like the example. I'm pretty sure I'm using the right endpoint and correctly identifying the request header.
But I'm still recieving the verification failure.
Are you getting a specific error in your webhook?
From which evt_xxx?
payment_invoice.succeeded
but it happens for all events
Do I just pass the endpoint secret when making the request in Postman?
A specific evt_xxx ID please
Which request in Postman?
I created the post request using django on my local setup. After running the local instance to test, I'd like to make the request using postman. Specifically, I want to try manually firing the webhook in postman.
i'll have an answer for this in a sec sorry
By evt_xxx, you're specifying the event id right?
also, i'm not using the cli
sorry if this seems obvious, but how do i fetch the id?
Check the Dashboard
i'm not recieving any events in the dashboard.
There's no events here? https://dashboard.stripe.com/test/events
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Can you share the ID of an object you're creating in Postman? Anything
I can't really help without an ID
And can you share the exact error you get in your webhook?
Looks like you are using the CLI to me :/
Otherwise not sure which webhook this event is being sent to
right, i realized that i was creating events with cli and not postman...
So you're using stripe listen --forward-to correct?
yes
stripe listen --forward-to localhost:4242/api/payments/webhook/
it seems to be listening
Ok, and which value are you using as the signing secret?
Is that what the CLI outputs when you use stripe listen?
yes
payload = request.body
sig_header = request.META['HTTP_STRIPE_SIGNATURE']
event = None
try:
event = stripe.Webhook.construct_event(
payload, sig_header, endpoint_secret
)
print('hello1')
except ValueError as e:
# Invalid payload
return Response({"message": "webhook contruct failed"},status=400)
except stripe.error.SignatureVerificationError as e:
# Invalid signature
return Response({"message": "signature verification failed"},status=400)
if event['type'] == 'payment_intent.succeeded':
print('hello2')
return Response({'message': "payment intent succeeded"}, status=200)
elif event['type'] == 'payment_intent.created':
print('hello4')
return Response({'message': "payment intent created"}, status=200)
elif event['type'] == 'invoice.payment_failed':
print('hello55')
failed_payment = event['data']['object']
print(failed_payment)
print('payment failed')
return Response({'message': "payment failed"}, status=200)
else:
print('hello3')
return Response({'message':"payment failed"}, status=400)```
@api_view(('POST',))
@authentication_classes([])
@permission_classes([])```
i had to split it into two since i dont have discord nitro
I'm recieving events now tho.
Ok, so it's working?
surprisingly, yes
i can do it using the cli
i didnt intent for that, but this works much better
Perfect