Introduction
The Phoenix Java Middleware provides a comprehensive set of payment operations that enable you to process transactions, validate customer accounts, check payment status, and manage wallet balances. All payment operations are exposed through thePaymentsController and implemented in the PaymentsService.
Available operations
The middleware exposes the following payment endpoints:Customer validation
Validate customer account details before processing payments
Process payments
Execute payment transactions with support for multiple payment methods
Transaction status
Check the status of payment transactions using request references
Wallet balance
Retrieve current wallet balance for your terminal
Architecture
Controller layer
ThePaymentsController handles HTTP requests and routes them to the appropriate service methods:
Service layer
ThePaymentsService contains the business logic for all payment operations. Each method:
- Performs key exchange to obtain authentication tokens
- Generates Interswitch authentication headers
- Encrypts sensitive data (OTP, auth tokens)
- Makes HTTP requests to the Phoenix API
Security features
Key exchange
Before each payment operation, the service performs a key exchange to obtain:- Auth token: Used for authentication
- Terminal key: Used for encrypting sensitive data
- Session keys: Temporary keys for secure communication
The key exchange is automatically performed before each transaction. You don’t need to call it manually when using the middleware endpoints.
Data encryption
Sensitive data is encrypted using AES-256-CBC with PKCS7 padding:Authentication headers
All requests include Interswitch authentication headers:- Authorization: Base64-encoded client ID
- Timestamp: Current timestamp in Africa/Kampala timezone
- Nonce: Unique identifier for request
- Signature: SHA-256 RSA signature of request parameters
- Auth-Token: Encrypted authentication token
Payment request structure
Most payment operations use thePaymentRequest DTO which extends PaymentsTerminalRequest:
Response codes
The Phoenix API uses standardized response codes defined inPhoenixResponseCodes:
| Code | Message | Description |
|---|---|---|
| 90000 | TRANSACTION APPROVED | Payment successful |
| 90051 | INSUFFICIENT FUNDS | Customer has insufficient balance |
| 90052 | UN RECOGNIZABLE CUSTOMER NUMBER | Invalid customer ID |
| 90055 | WRONG PIN OR OTP | Incorrect PIN or OTP entered |
| 90026 | DUPLICATE REQUEST REFERENCE | Request reference already used |
| 90091 | REMOTE SYSTEM TEMPORARILY UNAVAILABLE | System temporarily down |
Base URL configuration
Configure the Phoenix API base URL in yourapplication.properties:
Next steps
Validate customers
Learn how to validate customer accounts before processing paymentsCustomer validation →
Process payments
Execute payment transactions with the middlewareMaking payments →
Check status
Monitor transaction status and handle responsesTransaction status →
Manage balances
Retrieve and monitor wallet balancesWallet balance →