Overview
- Event
- PayPal AI Hackathon
- Format
- Online · Nov 2026
- Result
- Results announced end of Dec 2026
BillingRelay sits between PayPal and your app. You describe what you sell, approve the config, take payments through PayPal, and read correct billing state from your own Postgres. I built it for the PayPal AI Hackathon as a sandbox prototype, with no live money. It runs with Docker, and the demo video shows it end to end.
Challenge
Taking a PayPal payment is the easy part. The hard part is everything after it: knowing a payment really happened, granting what was bought exactly once, renewing and cancelling subscriptions, spending credits safely, and getting all of that into your app's database.
Solution
A billing API and server SDK with idempotent quotes and checkouts, verified webhooks, a transactional outbox and an append-only credit ledger, plus a worker that syncs billing state one way into your Postgres. AI drafts the setup and explains failures behind versioned human approvals.
Stack
TypeScript · Node.js · PostgreSQL · PayPal API · Docker · OpenAI · MCP
Demo
Architecture
Decisions
AI drafts the setup, a human approves it, payments never wait on it
WhyAI is useful for turning "what I sell" into a catalog and for explaining failures, but a model outage or a bad suggestion must never move money.
ApproachAI drafts catalog config that is schema-validated and saved as a new version. A person approves a version and chooses when it goes live. AI tools run through an MCP adapter with isolated, restricted permissions.
OutcomeTested against model outages, unauthorized operations and stale approvals. Payment operations keep working when the model is down.
Idempotency keys, verified webhooks and a transactional outbox
WhyPayment events arrive twice, workers crash, and sometimes the outcome of a payment is unknown.
ApproachIdempotency keys on quotes and checkouts, every payment verified with PayPal, a transactional outbox, and an append-only credit ledger.
OutcomeValidated atomic credit spending under 50 concurrent requests, and recovery from worker crashes, duplicate events and unknown payment outcomes, using PayPal Sandbox.
One-way sync into the merchant's own Postgres
WhyApps shouldn't need their own webhook handlers just to know who paid for what.
ApproachA worker copies purchases, access and credit balances into a billingrelay schema in the app's database, through a restricted role, with reconciliation and outage recovery.
OutcomeThe app reads billing state from its own database.
Impact
- Idempotent payment processing, verified webhooks, transactional outbox and an append-only credit ledger
- Atomic credit spending validated under 50 concurrent requests
- Recovers from worker crashes, duplicate events and unknown payment outcomes
- One-way sync to an independent Postgres, with reconciliation and outage recovery
- AI setup behind schema validation, versioned human approvals and restricted MCP tools
