#Ricardo Caterino Polini

1 messages ยท Page 1 of 1 (latest)

fickle nymphBOT
undone jetty
#

hello! can you share your code for processing webhooks?

#

make sure you remove any api keys before sharing

wet barn
#

@api.route('/webhook', methods=['POST'])
def webhook():
event = None
payload = request.data
sig_header = request.headers['STRIPE_SIGNATURE']
# This is your Stripe CLI webhook secret for testing your endpoint locally.
endpoint_secret = ' '

print("evento de webhoooks")

try:
    event = stripe.Webhook.construct_event(
        payload, sig_header, endpoint_secret
    )
except ValueError as e:
    # Invalid payload
    raise e
except stripe.error.SignatureVerificationError as e:
    # Invalid signature
    raise e

# Handle the event
if event['type'] == 'charge.captured':
  charge = event['data']['object']
elif event['type'] == 'charge.succeeded':
  charge = event['data']['object']
  ejemplo = charge.billing_details.email
  user = User.query.filter_by(email = ejemplo).first()
  pay = Pay(cliente_id = cliente.id, amount = charge.amount / 100 )
  #cliente.corrienteDePago = True
  db.session.add(pay)
  db.session.commit()

# ... handle other event types
else:
  print('Unhandled event type {}'.format(event['type']))

return jsonify(success=True)
surreal moat
#

๐Ÿ‘‹ Taking over this thread from alex, catching up now

#

Does your webhook secret start with whsec_?

wet barn
#

yes

#

where i found my endpoint secret in dashboard?

#

sorry for my english

surreal moat
#

Are you listening to the webhook in local or using endpoint?

wet barn
#

using endpoint

#

i believe de endpoint secret that i use isn't correct

surreal moat
wet barn
#

thanks...

#

now it's working

#

another error but i can handle it jajaja have a good day and nice weekend

surreal moat
#

No problem! Happy to help ๐Ÿ˜„

wet barn
#

other ask....

#

How can I send the customer data in the
login attempt for checkout? this in order for the webhook to return the customer data to correctly save the payment information

surreal moat
#

Which integration are you using? Payment Element or Checkout Session?

wet barn
#

payment element

#

with chechkout form

wet barn
#

I think it's checkout session

surreal moat
#

metadata will be returned in event