Article
A technical deep-dive into how we built our self-serve sponsorship system with Stripe Checkout and dynamic pricing.
Manual sponsor deals don't scale. We wanted a system where anyone could book a banner slot, pay, and go live without human intervention.
The system has three core components:
We implemented a progressive discount system. The longer the campaign, the better the daily rate:
function calculatePrice(days: number): number {
const BASE_PRICE = 300 // $3.00 per day in cents
const MAX_DISCOUNT = 0.30
const MAX_DAYS = 30
const ratio = Math.min(days, MAX_DAYS) / MAX_DAYS
const discount = ratio * MAX_DISCOUNT
const dailyPrice = BASE_PRICE * (1 - discount)
return Math.round(dailyPrice * days)
}A 7-day campaign costs $2.79/day while a 30-day campaign drops to $2.10/day.
The webhook endpoint verifies the signature and activates the campaign:
export async function POST(req: Request) {
const body = await req.text()
const sig = req.headers.get("stripe-signature")!
const event = stripe.webhooks.constructEvent(
body,
sig,
process.env.STRIPE_WEBHOOK_SECRET!
)
if (event.type === "checkout.session.completed") {
const session = event.data.object
await activateSponsorCampaign(session.metadata)
}
return new Response("ok")
}Always verify the webhook signature. Never trust the payload without it.
The full source code is available in the template repository.
Our image pipeline compresses, resizes, and serves optimized thumbnails through Cloudflare R2.
Maximize your chances of being featured in the next weekly batch with these practical tips.
Discover how our weekly curated batches help the best new products get noticed.