Urgent.News

What's breaking now, across thousands of outlets.

Tech

Two products, one Stripe event, and the branch that must come first

Notifio sells two things. A lifetime licence for the monitoring and email alerts, and a one-time upgrade that unlocks auto-reply, where the app fills in and submits the listing's own contact form for you. Both are 20 pounds. Neither is a subscription. That means our entire Stripe integration listens for exactly one event: /** * Both products are one-time payments, so `checkout.session.completed`…

Notifio sells two products - a lifetime licence for monitoring and email alerts, and a one-time upgrade that unlocks auto-reply. Both products cost 20 pounds and are one-time payments, so the Stripe integration listens for only one event: checkout.session.completed. The discriminator between the two products is metadata, set at session creation, with `kind` indicating whether it's an upgrade or new licence purchase.

The licence branch was written first, assuming any completed session is a purchase of a new licence. However, this is incorrect for an upgrade, as the customer already has a licence and a token. The upgrade branch is written to handle this specific case, ensuring the customer only receives one activation code for the product they own.

The upgrade branch is placed before the licence branch to prevent issuing a second licence and activation email to customers who have already purchased it. The code also handles idempotency, ensuring that a Stripe webhook retry does not double-apply the upgrade. The upgrade is only available to customers who have an existing, active licence, and the code checks for this before starting the Stripe Checkout session.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

A student house is one IP address, so our rate limit counts licences

Notifio is a desktop app that watches rental search pages and emails you when a new listing appears. The app never sends that email itself.

  • The app Notifio monitors rental listings and notifies users via email.
  • Rate limit is key by license, not IP address, to prevent unfair competition.
  • Each student in a shared house gets own budget, ensuring all receive alerts.

I built a tiny library that makes your audit logs tamper-evident

Most apps keep an audit log — who did what, and when. An admin deleted a user, a payment went through, a permission changed.

  • Chainlog library makes audit logs tamper-evident
  • Each entry contains SHA-256 hash and previous hash
  • Verify() function detects tampering in single pass

More from Friday 25 September →