#je_webhooks

1 messages ¡ Page 1 of 1 (latest)

timber sundialBOT
#

👋 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.

shell mountain
#

Yea i keep getting No signatures found matching the expected signature for payload

onyx shardBOT
gusty plover
#

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?

shell mountain
#

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

gusty plover
#

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?

shell mountain
#

okay I will try it

#

im still getting ⚠️ Webhook signature verification failed.No signatures found matching the expected signature for payload

gusty plover
#

You're using the raw payload data and still seeing this error?

shell mountain
#

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)```
onyx shardBOT
shell mountain
#

wait

#

i might of fixed it

#

wait nevermind its still like it

#

giving me the Webhook signature verification failed

hollow oracle
#

👋 Taking over this thread, catching up now

shell mountain
#

ok

hollow oracle
#

Where did you run this? Is it local endpoint or hosted Webhook endpoint? Webhook secrets are different from these two type of endpoints

shell mountain
#

i ran this on a hosted webhook endpoint

#

wait i might of copied the local endpoint

#

where do i find the right endpoint_secret

hollow oracle
#

You will have the webhook secret for this specific hosted webhook endpoint

shell mountain
#

oh i see

#

oh it works now

#

thank you

hollow oracle
#

Great to hear that it works!

shell mountain
#

but I have to ask

#

is there any way to create a payment link and check if that payment link is paid?

hollow oracle
#

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?

shell mountain
#

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?

hollow oracle
shell mountain
#

Wait what if the payment will be used by a lot of people

hollow oracle
#

One Checkout Session can only be paid once, and it can't be used once the payment is made

#

Your integration should create one Checkout Session for one customer, then listen to checkout.session.completed event for the sucessful payment

shell mountain
#

Ok

#

Thank you