A comprehensive payment disbursement system built with Rust, Axum, and PostgreSQL, integrating with Paystack's Transfer API for NGN bank transfers.
- User Authentication: JWT-based authentication system
- Payment Disbursement: Initiate NGN transfers to any Nigerian bank account
- Idempotency: Handle duplicate requests safely using transaction references
- Webhook Integration: Real-time status updates from Paystack
- Transaction Tracking: Complete transaction history and status monitoring
- Bank Account Validation: Support for all Nigerian banks
- Pending: Transaction created, awaiting processing
- Processing: Transaction sent to Paystack, awaiting completion
- Completed: Transfer successful
- Failed: Transfer failed with reason
POST /auth/register- Register a new userPOST /auth/login- Login userGET /auth/profile- Get current user profile (protected)
POST /payouts- Initiate payout to bank account (protected)GET /transactions- Get all user transactions (protected)GET /transactions/:id- Get specific transaction details (protected)
POST /webhooks/paystack- Paystack webhook endpoint
-
Start the database:
cd Rust_Fin_Tech_Backend docker-compose up -d -
Set up environment variables:
cp env.example .env # Edit .env with your Paystack credentials -
Run the application:
cargo run
DATABASE_URL- PostgreSQL connection stringJWT_SECRET- Secret key for JWT token signingPORT- Server port (default: 3000)PAYSTACK_SECRET_KEY- Your Paystack secret keyPAYSTACK_BASE_URL- Paystack API base URLPAYSTACK_WEBHOOK_SECRET- Webhook signature verification secret
curl -X POST http://localhost:3000/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "john_doe",
"email": "john@example.com",
"password": "password123"
}'curl -X POST http://localhost:3000/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "john_doe",
"password": "password123"
}'curl -X POST http://localhost:3000/payouts \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"amount": 1000.00,
"bank_account_number": "1234567890",
"bank_code": "058",
"recipient_name": "John Doe",
"description": "Payment for services",
"tx_reference": "TXN_20240101_001"
}'curl -X GET http://localhost:3000/transactions \
-H "Authorization: Bearer YOUR_JWT_TOKEN"curl -X GET http://localhost:3000/transactions/TRANSACTION_ID \
-H "Authorization: Bearer YOUR_JWT_TOKEN"id- UUID primary keyusername- Unique usernameemail- Unique email addresspassword_hash- Bcrypt hashed passwordcreated_at- Account creation timestampupdated_at- Last update timestamp
id- UUID primary keyuser_id- Foreign key to users tablereference- Unique transaction reference (for idempotency)amount- Transfer amount in NGNbank_account_number- Recipient bank account numberbank_code- Nigerian bank codebank_name- Bank name (optional)recipient_name- Recipient name (optional)description- Transaction description (optional)status- Transaction status (pending, processing, completed, failed)paystack_transfer_code- Paystack transfer codepaystack_reference- Paystack referencefailure_reason- Failure reason if transaction failedcreated_at- Transaction creation timestampupdated_at- Last update timestamp
The application handles idempotency by using the tx_reference field. If a transaction with the same reference already exists for the user, it returns the existing transaction instead of creating a new one.
Webhook signatures are verified using HMAC-SHA512 to ensure requests are genuinely from Paystack.
Comprehensive error handling with appropriate HTTP status codes and error messages.
Real-time status updates via Paystack webhooks ensure accurate transaction tracking.