M-Pesa B2C Payment
AI-generatedOverview
This node facilitates Business-to-Customer (B2C) payments via the M-Pesa mobile money platform. It enables users to programmatically send payments from a business account to individual customers' mobile phone numbers. Typical use cases include disbursing salaries, refunds, commissions, or any other type of payment directly to customers or agents using their mobile wallets.
Practical examples:
- A company paying out commissions to sales agents.
- An e-commerce platform refunding customers for returned items.
- A service provider sending bonuses or incentives to customers.
Properties
| Name | Meaning |
|---|---|
| Transaction Reference | Reference identifier for the transaction (e.g., card number, invoice reference). |
| Customer MSISDN | Customer's phone number in the format 258XXXXXXXXX (country code + number). |
| Amount | The monetary value of the transaction (must be a positive number). |
| Third Party Reference | Unique reference from the third-party system identifying this payment. |
| Service Provider Code | The shortcode or code identifying the service provider initiating the payment. |
| Auto Generate Reference | Boolean flag indicating whether to auto-generate the third party reference if not provided. |
Output
The node outputs JSON data containing the response from the M-Pesa API along with metadata about the request and processing status. Each output item includes:
- The full API response fields.
- The original request parameters sent.
- A
successboolean indicating if the payment was accepted (trueif response code is"INS-0"). - A timestamp marking when the response was processed.
If an error occurs during processing and "Continue On Fail" is enabled, the output will contain an error field with the error message instead.
No binary data is produced by this node.
Dependencies
- Requires an API key credential for authenticating with the M-Pesa API.
- Uses an internal helper utility to handle API requests and validation.
- The node expects the service provider code to be either provided as input or sourced from credentials.
- Network access to the M-Pesa API endpoint
/ipg/v1x/b2cPayment/is required.
Troubleshooting
- Invalid MSISDN Format: The customer phone number must strictly follow the format
258XXXXXXXXX. Errors mentioning invalid MSISDN indicate incorrect formatting. - Invalid Amount: The amount must be a positive number. Non-numeric or negative values will cause errors.
- Reference Too Long: The third party reference cannot exceed 20 characters. If auto-generation is disabled and a longer reference is provided, the node will throw an error.
- API Request Failures: Network issues or invalid credentials can cause the API call to fail. Ensure the API key is valid and network connectivity is stable.
- Auto Generate Reference: If enabled, the node will generate a unique reference automatically, avoiding manual input errors related to the third party reference.
To resolve errors, verify input formats, ensure all required fields are populated correctly, and check API credentials.