#mxd
1 messages ยท Page 1 of 1 (latest)
Hello ๐
Are you seeing any errors in your server log aside from the 500 error?
no
@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:
# Invalid payload
raise e
except stripe.error.SignatureVerificationError as e:
# Invalid signature
raise e
# Handle the event
if event['type'] == 'customer.subscription.created':
subscription = event['data']['object']
elif event['type'] == 'customer.subscription.deleted':
subscription = event['data']['object']
elif event['type'] == 'customer.subscription.updated':
subscription = event['data']['object']
# ... handle other event types
else:
print('Unhandled event type {}'.format(event['type']))
return jsonify(success=True)
``` do I need to change 'STRIPE_SIGNATURE' ?
you don't need to change it, no. It is delivered as part of the event payload.
Can you try adding some print statements in the exceptions?
Something must be triggering this 500 response code
Oh from the error it looks like your server isn't even routing the request to your "/webhook" route
The code seems to be running into some error way before that.
so I did it where, once a customer subscribes it redirects to mysite.com/webhook
Oh that's not how webhooks are supposed to work. Webhooks are supposed to be used server-side. If you're redirecting your users to this route client-side then that won't really work.
We have a video that goes into details
https://www.youtube.com/watch?v=oYSLhriIZaA
Just a heads up, the video is from 2019 so you may see some different code/logic, but I'd recommend watching it to learn basics about webhooks.
I watched that already
I followed this one https://www.youtube.com/watch?v=QK31ioLTqGU and the documentation
Ah I was just about to link that video here
Hi ๐
@ashen coral had to step out. Are you still experiencing this error when testing your webhook endpoint?
yeah I probably need to do something to get more info on the 500 error
- How are you testing events?
- Are you using the Stripe CLI to forward events to your local machine?
im using the https://dashboard.stripe.com/test/webhooks/
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
so the problem starts when I SUBSCRIBE, it doesnt redirect me to the mysite.com/member
which I set up in the product page
the payment goes through, but Redirect and Webhook failure