Polling vs Webhooks for a Personal Stripe Revenue Widget: Why I Chose Polling
When you build a small tool that shows your own Stripe revenue, the first design question is how it learns about new payments. Webhooks feel like the "proper" answer. For a personal desktop widget, I think polling is usu
When you build a small tool that shows your own Stripe revenue, the first design question is how it learns about new payments. Webhooks feel like the "proper" answer. For a personal desktop widget, I think polling is usually the better fit.
What webhooks need
Stripe webhooks call a public HTTPS endpoint. A desktop app on a laptop has no stable public address, so you need a server or relay in the middle. That server now receives your payment events, needs its own secrets, uptime and logging, and becomes one more place your revenue data passes through.
What polling needs
Polling only needs the app to call the Stripe API on a schedule with a key it already has. With a restricted, read-only key (read access to charges, payment intents and balance transactions is usually enough), the app can list recent payments, compute today's and this month's totals, and never write anything. On macOS the key belongs in the Keychain.
Choosing an interval
The interval is a product decision, not just a technical one:
- Every minute burns API calls and battery to answer a question that rarely changes.
- Every couple of hours keeps the number fresh enough for a daily glance.
- A manual refresh button covers the moment you really want the latest figure.
- Pausing while the Mac sleeps avoids pointless work.
Being honest in the UI
If you poll, say so. Users should not think a widget is a payment alert system. If someone needs to react to each order, Stripe's own notifications or a webhook-backed service are the right tools.
First sync gotcha
On the first connection the app sees historical payments. Treat those as a baseline, not as "new" payments, or the user gets a burst of celebrations for old sales.
Where I used this
These choices shaped Notch Revenue, a native macOS app that shows today's and this month's Stripe revenue in the MacBook notch. It uses restricted read-only keys stored in the Keychain, syncs at launch and about every two hours with manual refresh, and keeps revenue data on the Mac. It is a one-time US$19.99 app for Apple Silicon Macs on macOS 14+.
Notch Revenue: https://notchrevenue.com
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.