How oj-washingtone/tranxs works
Project type and purpose
• Tranxs is an open-source SDK (npm package) that wraps the Safaricom Daraja M-Pesa APIs.
• Its goal is to simplify all major M-Pesa transactions (STK Push, B2C, B2B, C2B, Reversal, Account Balance, Transaction Status) for JavaScript/TypeScript applications.
File structure
Top level
• src/index.ts – public entrypoint, exports hooks & classes
• src/mpesa/ – core M-Pesa logic
– Mpesa.ts • main class for initializing credentials & environment
– segGen.ts • security signature generator (timestamp, nonce)
– cert.cer • TLS certificate for client authentication
• src/types/ – TypeScript definitions for various M-Pesa payloads
• src/utils/ – helper functions (cleanPhone.ts, generateTimeStamp.ts)
Config files
• package.json, tsconfig.json, .github/workflows/npm-publish.yml
Elements
• Callback endpoints as external nodes receiving POSTs from the API
– Blue for SDK internal modules
– Green for client application elements
– Orange for external services (Daraja API, callback endpoints)