Overview
VoicePact integrates with mobile money platforms to enable secure escrow payments for contracts. Funds are held in escrow until both parties confirm the transaction is complete, protecting buyers and sellers.Escrow Protection
Funds held securely until delivery is confirmed by both parties
M-Pesa Integration
Direct integration with Kenya’s leading mobile money platform
Automated Release
Payment released automatically when delivery is confirmed
Transaction Tracking
Real-time status updates for all payment transactions
How It Works
Payment Flow
Mobile Checkout
Initiate a payment from the buyer:Checkout Flow
- API call initiates payment request
- M-Pesa sends STK Push to buyer’s phone
- Buyer enters M-Pesa PIN
- Payment confirmed and locked in escrow
- Webhook notification sent to VoicePact
- Contract status updated to “payment_locked”
Checkout Response
Payment Status
Query the status of a payment transaction:Status Values
- pending: Payment requested, awaiting user confirmation
- locked: Payment received and held in escrow
- released: Payment transferred to seller
- refunded: Payment returned to buyer
- failed: Payment failed or was cancelled
Webhook Notifications
VoicePact receives real-time payment updates via webhooks:Webhook Processing
The webhook handler:- Validates webhook signature for security
- Extracts transaction details
- Updates payment record in database
- Updates contract status
- Notifies relevant parties via SMS
- Triggers next workflow step
Payment Release
Release escrowed funds to the seller:Release Conditions
Payment is released when:- Seller confirms delivery (via SMS/USSD)
- Buyer accepts delivery (via SMS/USSD)
- No disputes have been raised
- Contract is marked as “completed”
Payment Refund
Refund payment to buyer if contract is cancelled or disputed:Transaction History
Retrieve payment history for a contract:Wallet Balance
Check VoicePact’s mobile money wallet balance:Payment Reference Generation
Generate unique payment reference codes:SMS Notifications
Automatic SMS notifications for payment events:Payment Received
Payment Released
Payment Template
Database Model
Payment records are stored in the database:Circuit Breaker Pattern
Payment service uses circuit breaker for reliability:Retry Logic
Payments are retried automatically on failure:Error Handling
Best Practices
Validate Before Checkout
Validate Before Checkout
- Verify contract exists and is valid
- Check payment amount matches contract
- Confirm phone number format
- Validate currency code
Handle Webhooks Reliably
Handle Webhooks Reliably
- Verify webhook signatures
- Process asynchronously
- Implement idempotency
- Log all webhook data
- Send 200 OK immediately
Monitor Transaction Status
Monitor Transaction Status
- Poll status for pending transactions
- Set timeout limits (e.g., 5 minutes)
- Handle expired transactions
- Retry failed payments
Secure Escrow Management
Secure Escrow Management
- Never release without confirmation from both parties
- Implement dispute resolution process
- Set escrow timeout periods
- Log all state changes with audit trail
Security Considerations
Webhook Signature Verification
Audit Trail
All payment actions are logged:Testing
Use Africa’s Talking sandbox for testing:Cost Structure
Mobile money transaction fees:- M-Pesa to Business: ~1-3% transaction fee
- Business to M-Pesa: Flat rate + percentage
- Balance Inquiry: Free
- Failed Transactions: No charge
Next Steps
Voice Contracts
Create payment-enabled contracts
SMS Verification
Confirm payments via SMS
USSD Integration
Check payment status via USSD
Digital Signatures
Cryptographic payment verification