A production-ready payment API that solves the critical problem of payment fingerprint harvesting while maintaining publicly shareable booking links. Built with Deno, TypeScript, and enterprise-grade security controls.
- Token-Based Booking Access: 256-bit secure tokens replace direct booking ID access
- Dual Authentication: API key + nonce requirement for payment operations
- Single-Use Nonces: IP-bound, 15-minute expiry with automatic invalidation
- Environment Protection: Server requires critical secrets to start
- Comprehensive Rate Limiting: Per-endpoint throttling prevents abuse
# Required environment variables export PAYMENT_USERNAME=your_payment_gateway_username export PAYMENT_PASSWORD=your_payment_gateway_password export MERCHANT_CODE=your_merchant_code export API_KEY=your_secure_api_key
deno run --allow-net --allow-read --allow-env --allow-import --allow-write --allow-ffi main.ts
Server starts on http://localhost:5000 with:
- π 12 endpoints (5 public, 7 authenticated)
- π Interactive API documentation at
/api/docs - π‘οΈ Multi-layered security with comprehensive logging
π Complete Documentation - Detailed architecture, security flows, and API reference
- Problem & Solution: Why this architecture prevents fingerprint harvesting
- Security Model: Multi-layered protection mechanisms
- API Reference: Complete endpoint documentation with examples
- Frontend Integration: Required client-side functions and flow examples
- File Structure: Purpose of each component in the system
// Generate secure booking token (Admin)
POST /api/generate-booking-token
Authorization: Bearer {api_key}
// Access booking with token (Public)
GET /booking/{token}
// 1. Generate nonce
POST /api/create-payment-nonce
Body: { bookingId: "booking_123" }
// 2. Create payment fingerprint (Dual Auth Required)
POST /api/create-payment-hash
Authorization: Bearer {api_key}
X-Payment-Nonce: {nonce}
// 3. Refresh session after failures
POST /api/v1/payment/refresh
Body: { bookingId: "booking_123" }
β
Token-based booking access prevents ID enumeration
β
Dual authentication (API key + nonce) for payment operations
β
Environment secret validation prevents unauthorized deployment
β
Rate limiting (5-20 req/min per endpoint) blocks abuse
β
Single-use nonces with IP binding and 15-minute expiry
β
Dynamic schema validation from OpenAPI specifications
β
Comprehensive audit logging with structured security events
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Public User β β Admin/Client β β Payment Gateway β
βββββββββββ¬ββββββββ βββββββββββ¬βββββββββ βββββββββββ¬ββββββββ
β β β
β GET /booking/{token} β β
βββββββββββββββββββββββΊβ β
β β Dual Auth Required β
β ββββββββββββββββββββββββΊβ
β β Payment Fingerprint β
β βββββββββββββββββββββββββ€
β Secure Payment Form β β
ββββββββββββββββββββββββ€ β
β β β
- Prevents mass fingerprint harvesting through dual authentication
- Blocks booking enumeration attacks with secure tokens
- Eliminates replay attacks using single-use nonces
- Provides comprehensive audit trails for compliance
- Maintains shareable booking links without compromising security
- Reduces payment failures from fingerprint abuse
- Enables public access while protecting sensitive operations
- Supports compliance with industry security standards
src/
βββ gateway/apiGateway.ts # Centralized routing & security control
βββ handlers/ # Endpoint handlers (booking, payment, etc.)
βββ middleware/ # Security middleware (CORS, rate limiting)
βββ services/ # Core business logic (auth, nonce, payment)
βββ utils/ # Utilities (logging, validation, OpenAPI)
All endpoints tested and verified:
- Booking token generation and access
- Payment nonce and fingerprint creation
- Security controls and rate limiting
- Error handling and validation
- Environment variables configured
- CORS origins set for production domains
- SSL/TLS certificates installed
- Monitoring and alerting configured
- Database backup strategy implemented
- Security event logging enabled
Built with Enterprise Security β’ Production Ready β’ Fully Documented