Adding Payments to a Small App Without Building a Billing System
Accepting money sounds like the kind of feature where I should build a large billing system.
For most small applications, I really do not want to.
A payment provider can already handle the difficult parts: card processing, checkout, receipts, taxes in some setups, subscription management and a lot of the security requirements I would rather not implement myself.
My application mainly needs to know three things:
- what the user is buying;
- whether the payment succeeded;
- what access or balance should change afterwards.
A typical flow can be quite small:
user chooses a product
↓
backend creates checkout
↓
payment provider handles payment
↓
webhook confirms the result
↓
application updates the user's access
The important detail is that I do not want to trust the browser simply because it returns from a “success” page.
The reliable confirmation should come from the payment provider, usually through a webhook. That gives the backend a trusted event it can use to update the user’s subscription, credits or purchased product.
This also means I can avoid storing card details entirely. The provider owns that problem.
There is still product logic I need to design myself. What happens after a refund? What if a webhook arrives twice? Does a subscription unlock features or add usage credits? What happens when payment fails?
But those are problems specific to my application, which is exactly where I want to spend my time.
The goal is not to build billing infrastructure. The goal is to add payments to the product with as little custom billing infrastructure as possible.
Topics
