The payment system handles Stellar blockchain transaction verification and updates split/participant status in real-time. It ensures secure, transparent payment processing using the Stellar network.
- Interacts with Stellar Horizon API
- Verifies transactions on the Stellar network
- Extracts transaction details (sender, amount, asset)
- Supports both mainnet and testnet
- Handles payment submission workflow
- Validates payment against participant's owed amount
- Updates participant and split status
- Prevents duplicate submissions
- Manages partial payments
- Main service layer for payment operations
- Provides API endpoints for payment functionality
- Handles business logic and data access
- Real-time notifications for payment events
- Updates clients on payment status changes
- Broadcasts split completion events
- Tracks the overall bill split
- Contains total amount and payment status
- Represents individual users in a split
- Tracks owed vs paid amounts
- Maintains payment status
- Records individual payment transactions
- Links to Stellar transaction hashes
- Stores amount, asset, and status
Submit a Stellar transaction for payment verification.
Request Body:
{
"splitId": "uuid",
"participantId": "uuid",
"stellarTxHash": "string"
}Response:
{
"success": true,
"message": "Payment confirmed. Amount: 10.50 XLM-USDC",
"paymentId": "uuid"
}Verify a Stellar transaction without creating a payment record.
Response:
{
"valid": true,
"amount": 10.50,
"asset": "XLM-USDC",
"sender": "G...",
"receiver": "G...",
"timestamp": "2023-01-01T00:00:00Z"
}Get payment details by transaction hash.
Get all payments for a specific split.
Get all payments for a specific participant.
Get payment statistics for a split.
- Validates Stellar transaction exists on the network
- Checks transaction status (successful/failed)
- Extracts payment operation details
- Supports various payment types (direct payments, path payments)
- Matches payment amount to participant's owed amount
- Handles exact payments, partial payments, and overpayments
- Updates participant status (pending/paid/partial)
- Updates split status (active/completed/partial)
- Idempotency checks using Stellar transaction hash
- Prevents double-processing of transactions
- Accepts payments less than the full amount owed
- Updates participant status to 'partial'
- Continues to track remaining balance
- WebSocket connections for live updates
- Payment status change notifications
- Split completion notifications
Uses Stellar SDK to interact with Horizon API:
- Transaction verification via transaction hash
- Operation parsing to extract payment details
- Account validation to ensure active accounts
- Atomic database updates for consistency
- TypeORM for database interactions
- Proper transaction isolation
- Comprehensive error handling for network issues
- Invalid transaction responses
- Missing participant/split errors
- Validation errors
- Input validation on all API endpoints
- Transaction hash verification against Stellar network
- Duplicate submission prevention
- Proper authentication (to be implemented with user system)
- Unit tests for individual services
- Integration tests for end-to-end payment flow
- Testnet integration for real Stellar transactions
- Edge case testing (partial payments, invalid transactions)