Back to work
Case Study · Ongoing · 6+ monthsFinTech · Social Commerce

Moment0

Serverless backend powering card payments, instalment loans, digital wallets, and automated seller payouts for an Australian social commerce platform.

Firebase Cloud FunctionsFirestoreTypeScriptGCPZepto
50+API endpoints
12Domain modules
6+ monthsIn production

Moment0 connects consumers with local businesses and causes. Buying in the app can mean paying by card, in person, or in instalments — and behind each is real money moving between real bank accounts. I built the backend behind all of it.

The Challenge

Three very different payment methods needed to feel like one experience. Wallet balances, rewards, refunds, and weekly payouts all had to reconcile perfectly. And a single user could hold multiple account types, each with staff who need different levels of access.

Approach

I designed a unified transaction lifecycle that abstracts away the payment method — card, in-person, or instalment all follow the same state machine. Every money-moving operation is idempotent by design, and financial history is append-only so it's fully reconstructable. The goal was a system where adding a fourth payment method later would mean plugging into an existing lifecycle, not rebuilding payment logic.

Solution

A fully serverless backend on Firebase Cloud Functions with Firestore as the primary data store, Stripe for card and instalment processing, and TypeScript end-to-end. The architecture is split across twelve domain-specific modules — each with its own middleware, validation, and permission checks — but all sharing one consistent transaction model and error handling pattern. This modular approach meant individual domains (payments, wallets, campaigns, payouts) could be developed, tested, and deployed independently without risk of side effects.

Unified payment engine

All three payment methods — card, in-person, and instalment — run through one transaction lifecycle with well-defined states and transitions. The mobile app can never mark a payment complete; confirmation comes only from a verified Stripe webhook or an explicit seller action. Unpaid requests expire automatically at their exact deadline, cleaning up stale transactions without manual intervention.

Append-only wallet ledger

Every balance change — reward earned, refund issued, purchase deducted — is recorded as a permanent ledger entry, not an overwritten number. The current balance is always derivable from the full history. This makes auditing trivial and eliminates the class of bugs where a balance silently drifts out of sync.

Automated payouts & campaigns

Seller payouts are batched weekly and processed automatically with retry logic and daily reconciliation — no manual transfers. Geo-targeted promotional campaigns are billed per active day with an anti-gaming minimum spend, preventing abuse of the campaign system.

Permission system

A single user can own multiple account types (consumer, business, cause) and assign staff with granular per-feature permissions. The permission model is checked at the middleware level, so no endpoint can accidentally bypass access control.

Results

50+ endpoints across 12 domains, all on one consistent middleware and permission model. No double-charges or duplicate payouts — every money-moving operation is idempotent. Financial history is fully reconstructable, and seller payouts run unattended.

Architecture

Moment0 high-level architecture
High-level architecture — serverless backend across 12 domain modules
Moment0 request and payment flow
Request & payment flow — how transactions move through the unified lifecycle

Have a similar project in mind?

Let's talk about how to bring it to life, end to end.

Start a conversation