A TypeScript backend API service for managing multichain stablecoin payment lifecycle and dispatching all relevant microservice components.
Rozo Payment Manager is designed to accept crypto from any chain, coin, or wallet instantly. It maximizes conversion with a call-to-action that is:
- Intuitive: Let your customers use any token on any chain
- Fast: Payments complete in seconds
- Simple: Pay in a single step from any wallet
- Secure: No extra counterparties. Never holds user funds
- 🔗 Multichain Support: Ethereum, Base, Optimism, Arbitrum, Polygon, BSC
- 💰 Any Token: Accept payments in any supported token
- 🔄 Cross-chain Swaps: Automatic conversion between chains and tokens
- 🔐 Secure: Enterprise-grade security with API key authentication
- 📊 Real-time Tracking: Complete payment lifecycle monitoring
- 🔔 Webhooks: Real-time payment status notifications
- ⚡ Fast: Sub-second payment detection and processing
- 🛡️ Rate Limited: Built-in DDoS protection and rate limiting
- Payment Manager: Main API service for payment lifecycle management
- PayIn Service: Monitors blockchain for incoming payments
- PayOut Service: Executes outbound payments and cross-chain swaps
Based on Daimo's Payment API, providing:
- Payment creation and management
- Real-time status tracking
- Webhook notifications
- Comprehensive payment history
- Node.js 18+
- Supabase account
- API keys for blockchain RPC providers
- Clone the repository
git clone https://github.com/rozo/payment-manager.git
cd rozo-payment-manager
- Install dependencies
npm install
- Set up environment variables
cp .env.example .env
# Edit .env with your configuration
- Initialize Supabase
npm run supabase:start
npm run supabase:reset
- Start development server
npm run dev
Variable | Description | Required |
---|---|---|
SUPABASE_URL |
Supabase project URL | Yes |
SUPABASE_ANON_KEY |
Supabase anonymous key | Yes |
SUPABASE_SERVICE_ROLE_KEY |
Supabase service role key | Yes |
API_KEY_SECRET |
Secret for API key generation | Yes |
WEBHOOK_SECRET |
Secret for webhook signatures | Yes |
PAYIN_SERVICE_URL |
URL of PayIn microservice | Yes |
PAYOUT_SERVICE_URL |
URL of PayOut microservice | Yes |
BASE_URL |
Public URL of this service | Yes |
POST /api/payment
- Create a new paymentGET /api/payment/:id
- Get payment by IDGET /api/payment/external-id/:externalId
- Get payment by external IDGET /api/payment/stats
- Get payment statistics
GET /api/health
- Health checkPOST /api/callbacks/payin
- PayIn service callback (internal)POST /api/callbacks/payout
- PayOut service callback (internal)
All API endpoints require an API key in the header:
Api-Key: your-api-key-here
Or:
X-Api-Key: your-api-key-here
const response = await fetch('https://your-api.com/api/payment', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Api-Key': 'your-api-key'
},
body: JSON.stringify({
display: {
intent: "Pay for Premium Subscription",
paymentValue: "10.00",
currency: "USD"
},
destination: {
destinationAddress: "0x742d35cc6ab4925a59b2a6923e87e11d2a1e3b1f",
chainId: 8453, // Base
tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC
amountUnits: "10.00"
},
externalId: "sub_123456789",
metadata: {
userId: "user_123",
planType: "premium"
}
})
});
const payment = await response.json();
console.log('Payment URL:', payment.url);
const response = await fetch(`https://your-api.com/api/payment/${paymentId}`, {
headers: {
'Api-Key': 'your-api-key'
}
});
const payment = await response.json();
console.log('Payment status:', payment.status);
- Create Payment: API call creates payment record
- PayIn Monitoring: PayIn service monitors blockchain for payment
- Payment Detection: Incoming payment detected and verified
- PayOut Execution: PayOut service executes cross-chain swap if needed
- Completion: Payment marked as complete, webhook sent
payment_unpaid
: User has not paid yetpayment_started
: Payment detected, processingpayment_completed
: Payment successfully completedpayment_bounced
: Payment failed, funds refunded
Configure webhook URLs to receive real-time payment notifications:
{
"id": "webhook_123",
"type": "payment.completed",
"createdAt": "2024-01-15T10:30:00Z",
"payment": {
"id": "pay_123",
"status": "payment_completed",
"externalId": "order_456"
}
}
Webhook events:
payment.created
payment.started
payment.completed
payment.bounced
src/
├── config/ # Configuration files
├── controllers/ # API controllers
├── middleware/ # Express middleware
├── routes/ # API routes
├── services/ # Business logic services
├── types/ # TypeScript type definitions
└── utils/ # Utility functions
supabase/
├── migrations/ # Database migrations
└── functions/ # Edge functions
The application uses Supabase PostgreSQL with the following main tables:
payments
- Payment recordswebhooks
- Webhook delivery trackingpayin_logs
- PayIn service logspayout_logs
- PayOut service logsservice_health
- Microservice health monitoring
npm run dev
- Start development servernpm run build
- Build for productionnpm run start
- Start production servernpm run test
- Run testsnpm run lint
- Run linternpm run supabase:start
- Start local Supabasenpm run supabase:generate-types
- Generate TypeScript types
Deploy as a Supabase Edge Function:
supabase functions deploy rozo-payment-manager
- Set environment variables in Supabase dashboard
- Configure database with migrations
- Set up webhook endpoints
- Configure microservice URLs
- API key authentication for all endpoints
- Rate limiting with configurable limits
- Webhook signature verification
- Row Level Security (RLS) in database
- Input validation with Zod schemas
- Comprehensive logging and monitoring
- Health check endpoints for all services
- Real-time service health monitoring
- Payment statistics and analytics
- Comprehensive logging with Winston
- Error tracking and alerting
- Documentation: GitHub Wiki
- Issues: GitHub Issues
- Email: support@rozo.com
MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Built with ❤️ by the Rozo team.