Our Stripe Delivery Pipeline — From Checkout to Download in 30 Seconds
When someone buys from Whoff Agents, they get their product in under 30 seconds. No manual fulfillment. No waiting for a human to check Stripe.
Here is exactly how the pipeline works.
The Flow
Stripe Checkout → Webhook → Atlas listener → File delivery → Email receipt
Total time: ~28 seconds on average.
Step 1: Stripe Webhook
We listen to checkout.session.completed. The moment Stripe fires it, our webhook handler wakes up.
We validate the signature (stripe.webhooks.constructEvent) before doing anything. Security first.
const event = stripe.webhooks.constructEvent(
req.body,
sig,
process.env.STRIPE_WEBHOOK_SECRET
);
if (event.type === "checkout.session.completed") {
await handlePurchase(event.data.object);
}
Step 2: Customer Record Creation
handlePurchase does four things:
- Extracts customer email and product ID from the session
- Creates a customer record in our flat-file database
- Generates a time-limited download token (24hr expiry)
- Queues the delivery email
We use flat files, not Postgres. For our current volume, it is faster to set up and easier for Atlas to read/write autonomously.
Step 3: Download Token
The token is a signed JWT:
const token = jwt.sign(
{ customerId, productId, email },
process.env.JWT_SECRET,
{ expiresIn: "24h" }
);
const downloadUrl = `https://whoffagents.com/download?token=${token}`;
The download endpoint validates the token, logs the access, and serves the file.
Step 4: Delivery Email
Resend handles the email. Template is simple: product name, download link, expiry notice, support email.
await resend.emails.send({
from: "deliver@whoffagents.com",
to: email,
subject: `Your ${productName} is ready`,
html: deliveryTemplate({ name, downloadUrl, expiresAt })
});
Total email delivery time: 2-4 seconds.
What We Learned Building This
Webhook validation is non-negotiable. Skip it and anyone can POST fake events to your endpoint and trigger free downloads. We got this right on day one.
Idempotency matters. Stripe can fire the same webhook twice. Our handler checks if a customer record already exists before creating one. No duplicate deliveries.
Flat files beat a database at launch scale. We can serve 100 customers without spinning up Postgres. When we hit 1,000, we will migrate. Until then, files are faster to ship and Atlas can read them directly.
Test with Stripe CLI before going live. stripe listen --forward-to localhost:3000/webhook lets you fire real test events locally. We caught 3 bugs this way.
The Numbers
- Average time from payment to email delivered: 28 seconds
- Failed deliveries in first 48 hours: 0
- Manual fulfillment interventions: 0
What Is Coming Next
- License key generation per download
- Download count limits (configurable per product)
- Customer portal for re-downloading without re-purchasing
Full Stack
- Payments: Stripe Checkout
- Webhooks: Express + stripe-node
- Tokens: jsonwebtoken
- Email: Resend
- Storage: Local filesystem (upgrading to S3 at scale)
- Orchestration: Atlas monitors delivery logs daily
Building Whoff Agents in public. If you have questions about the Stripe delivery pipeline or want to see the code, ask in the comments.
Top comments (0)