I am integrating Stripe API with Firebase using Fastapi and I am facing the issue - "stripe.error.SignatureVerificationError: No signatures found matching the expected signature for payload"
The code is working in local testing with Stripe CLI but doesn't work in deployment. The error is on the last line.
async def feathers_buy_update(request: Request):
"""Endpoint to handle the Stripe session status updates like checkout completed or checkout expired
Args:
"""
event = None
payload = await request.body()
sig_header = request.headers.get("stripe-signature")
endpoint_secret = "<endpoint_secret>"
event = stripe.Webhook.construct_event(payload, sig_header, endpoint_secret)
I printed the type of all three inputs. Payload - bytes, sig_header - string, endpoint_secret - string.
There's a lot of different reasons you could be hitting verification issues, but usually when you hit these issues after already confirming things work locally during testing it's one of the following:
whsec_123
) from the stripe listen
command, but a lot of people forget to replace it once they deploy their real webhook endpoint. Make sure the webhook secret you have in your code matches what is displayed in the dashboard (when you open the webhook endpoint in the Stripe dashboard you'll see a section where you can "Reveal" the Signing Secret).payload
as a string to confirm whether it looks correct first.