Overview
This node processes M-Pesa payments by validating input data and interacting with an external M-Pesa API to initiate payment transactions. It is useful for automating mobile money payments in workflows, especially in contexts where M-Pesa is a common payment method (e.g., Mozambique). Typical use cases include sending payment requests to customers or recording payments received via M-Pesa.
The node validates the phone number format and amount before requesting an authentication token and then making the payment request. If no transaction reference is provided, it generates one automatically based on the current date and time.
Properties
| Name | Meaning |
|---|---|
| Phone Number | M-Pesa phone number (9 digits, must start with 84 or 85) |
| Amount | Payment amount in Mozambican Metical (MZN), between 1 and 1,250,000 |
| Reference | Transaction reference; if left empty, the node generates one automatically |
Output
The node outputs JSON objects for each processed item with the following structure:
success: Boolean indicating if the payment was successful.provider: Always"mpesa".reference: The transaction reference used.phone: The validated phone number.amount: The payment amount.timestamp: ISO string of when the payment was processed.response: The raw response from the M-Pesa payment API (present only on success).error: Error message (present only if the payment failed).
If the node is configured to continue on failure, errors are returned as part of the output JSON instead of stopping execution.
Dependencies
- Requires an API key credential with client ID, client secret, base URL, and wallet ID for the M-Pesa Emola API.
- The node makes HTTP POST requests to:
- Obtain an OAuth token (
/oauth/tokenendpoint). - Submit the payment (
/v1/c2b/mpesa-payment/{walletIdMpesa}endpoint).
- Obtain an OAuth token (
- Proper configuration of these credentials and network access to the API endpoints is necessary.
Troubleshooting
- Invalid phone number: The phone number must be exactly 9 digits and start with 84 or 85. Errors will indicate this validation failure.
- Invalid amount: Amount must be a number between 1 and 1,250,000 MZN. Out-of-range values cause errors.
- Authentication errors: Failure to obtain an access token from the API will result in an error. Check that client ID, client secret, and base URL are correct.
- API request failures: Any issues during the payment request will throw errors. Inspect the raw API response for details.
- Empty reference: If no reference is provided, the node auto-generates one. If you want to track payments precisely, provide your own unique references.
- To avoid workflow interruption on errors, enable "Continue On Fail" in the node settings.
Links and References
- M-Pesa Official Website
- M-Pesa API Documentation (Emola) (example placeholder, replace with actual if available)