Back to Prompts
Coding Assistant

Handle Payment Webhooks

Common use case - payment processing From the Webhooks AI Coding Building Block.

Prompt
Create a complete payment webhook handler for Stripe. I want to handle successful payments and failed payments properly.

Framework: [Express, Flask, Django, FastAPI, etc.]

Handle these events:
1. payment_intent.succeeded - Payment was successful
2. payment_intent.payment_failed - Payment failed
3. customer.subscription.created - New subscription started
4. customer.subscription.deleted - Subscription cancelled

For each event:
- Log what happened
- Update my database (show placeholder code)
- Send appropriate emails (show where I would call my email service)

Also show me:
- How to handle events I don't care about (ignore gracefully)
- How to avoid processing the same event twice (idempotency)
- How to respond quickly so Stripe doesn't timeout

I'm learning, so explain each part simply.
1 views 0 copies