#je_webhooks
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1229576957302411325
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Yea i keep getting No signatures found matching the expected signature for payload
Hi, can you add a bit more details here? What have you tried? Can you share an example event id that failed? What does your code look like? What language are you using to implement this code?
Yea so im making it when theres a new checkout and someone pays it goes to the webhook and i get the no signatures found
im using py
@app.route('/webhook', methods=['POST'])
def webhook():
event = None
payload = request.data
sig_header = request.headers['STRIPE_SIGNATURE']
try:
event = stripe.Webhook.construct_event(payload, sig_header, endpoint_secret)
except ValueError as e:
print("â ď¸ Invalid payload")
raise e
except stripe.error.SignatureVerificationError as e:
print("â ď¸ Webhook signature verification failed.")
raise e
# Handle the event
if event['type'] == 'checkout.session.async_payment_failed':
session = event['data']['object']
print("PAYMENT FAILED")
elif event['type'] == 'checkout.session.completed':
session = event['data']['object']
print("PAID")
elif event['type'] == 'checkout.session.expired':
session = event['data']['object']
print("EXPIRED")
elif event['type'] == 'payment_link.created':
payment_link = event['data']['object']
print("PAYMENT LINK CREATED")
elif event['type'] == 'payment_link.updated':
payment_link = event['data']['object']
print("PAYMENT LINK UPDATED")
else:
print('Unhandled event type {}'.format(event['type']))
return jsonify(success=True)```
this is how I have it
Have you confirmed that you're using the webhook signature from the correct account?
Once you've confirmed this, it's likely that you're not using passing a raw body. Stripe requires the raw, unmodified request body to form the webhook signature. Can you pass the raw body there, https://docs.stripe.com/webhooks/quickstart#signature-check?
okay I will try it
im still getting â ď¸ Webhook signature verification failed.No signatures found matching the expected signature for payload
You're using the raw payload data and still seeing this error?
i switched my code to this
@app.route('/webhook', methods=['POST'])
def webhook():
event = None
payload = request.data
try:
event = json.loads(payload)
except json.decoder.JSONDecodeError as e:
print('â ď¸ Webhook error while parsing basic request.' + str(e))
return jsonify(success=False)
if endpoint_secret:
sig_header = request.headers.get('stripe-signature')
try:
event = stripe.Webhook.construct_event(
payload, sig_header, endpoint_secret
)
except stripe.error.SignatureVerificationError as e:
print('â ď¸ Webhook signature verification failed.' + str(e))
return jsonify(success=False)
if event['type'] == 'checkout.session.async_payment_failed':
session = event['data']['object']
print("PAYMENT FAILED")
elif event['type'] == 'checkout.session.completed':
session = event['data']['object']
print("PAID")
elif event['type'] == 'checkout.session.expired':
session = event['data']['object']
print("EXPIRED")
elif event['type'] == 'payment_link.created':
payment_link = event['data']['object']
print("PAYMENT LINK CREATED")
elif event['type'] == 'payment_link.updated':
payment_link = event['data']['object']
print("PAYMENT LINK UPDATED")
else:
print('Unhandled event type {}'.format(event['type']))
return jsonify(success=True)```
wait
i might of fixed it
wait nevermind its still like it
giving me the Webhook signature verification failed
đ Taking over this thread, catching up now
ok
Where did you run this? Is it local endpoint or hosted Webhook endpoint? Webhook secrets are different from these two type of endpoints
i ran this on a hosted webhook endpoint
wait i might of copied the local endpoint
where do i find the right endpoint_secret
Webhook secrets can be different. I'd recommend going to https://dashboard.stripe.com/test/webhooks > Choose your Webhook endpoint > Click Reveal button under Signing secret
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
You will have the webhook secret for this specific hosted webhook endpoint
Great to hear that it works!
but I have to ask
is there any way to create a payment link and check if that payment link is paid?
Will this payment link be one-time or multiple usages, i.e. do you expect this payment link to be paid by once by a customer only?
yea just a one time
im planning on making a discord bot that people can do /buy it genreates a payment link and it keeps checking every 60 seconds when its paid and when it is they will be given a role
is it possible?
For one-time payment link, Stripe offers Checkout Session (a payment hosted page) for one-time payment: https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=stripe-hosted
After the payment is made, Stripe will send checkout.session.completed event which can be used to determine whether the role should be given: https://docs.stripe.com/payments/checkout/fulfill-orders
Wait what if the payment will be used by a lot of people