TUTORIAL
Add HTTP 402 to Your API in 15 Minutes
You have an Express API. You want to charge for certain endpoints. Here’s how to add HTTP 402 Payment Required responses in 15 minutes, no SDK required.
By Jithin Raj & Originary Team••8 min read
What you’ll build
- A 
GET /pricedendpoint that returns 402 if no receipt is present - Receipt verification middleware that checks signatures and timestamps
 - A helper to generate 402 challenges with references
 
Production checklist
Before shipping to production:
- ✅ Replace in-memory Map with Redis or database
 - ✅ Use your payment provider’s receipt verification SDK
 - ✅ Add Cache-Control: no-store to 402 responses
 - ✅ Log challenges and verifications for audit trails
 - ✅ Set appropriate expiry times (5 minutes is typical)
 - ✅ Handle edge cases (malformed receipts, missing keys)
 - ✅ Add rate limiting to prevent abuse
 
Related Reading
Ready to implement?
Learn how Originary helps build production HTTP 402 flows with receipts and verification.