M-Pesa Query Customer

Consultar nome do cliente M-Pesa

M-Pesa Query Customer

AI-generated

Overview

The M-Pesa Query Customer node allows users to query the name of an M-Pesa customer based on their phone number (MSISDN). It is designed to interact with the M-Pesa API to retrieve customer information, primarily the customer's registered name. This node is useful in scenarios where you need to verify or display the identity of a customer associated with a given phone number, such as in payment processing workflows, customer support systems, or CRM integrations.

Practical examples:

  • Verifying the name of a customer before processing a payment or refund.
  • Displaying customer names in dashboards or reports based on their phone numbers.
  • Automating customer verification steps in service workflows.

Properties

Name Meaning
Customer MSISDN The customer's phone number in the format 258XXXXXXXXX (e.g., 258843330333). Required.
Third Party Reference A unique reference string from the third-party system to identify the request. Required.
Service Provider Code The shortcode or code of the M-Pesa service provider. Defaults to a configured credential value. Required.
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 success status. The main fields include:

  • output_ResultCode and output_ResponseCode: Codes indicating the result of the query.
  • output_CustomerName: The name of the customer retrieved from M-Pesa. If unavailable, defaults to "N/A".
  • request: An object echoing the input parameters used for the query (customerMSISDN, thirdPartyReference, serviceProviderCode).
  • success: A boolean indicating whether the query was successful (true if result codes indicate success).
  • timestamp: ISO timestamp of when the query was executed.

If the node encounters errors and "Continue On Fail" is enabled, it outputs an error message per item instead of stopping execution.

Dependencies

  • Requires an API key credential for authenticating with the M-Pesa API.
  • Uses an internal helper class to handle API requests and validation.
  • The Service Provider Code can be supplied directly or pulled from credentials.
  • No additional external dependencies beyond the M-Pesa API and n8n's credential system.

Troubleshooting

  • Invalid MSISDN Format:
    Error message: MSISDN inválido: <value>. Deve estar no formato 258XXXXXXXXX
    Resolution: Ensure the phone number is exactly in the format starting with country code 258 followed by 9 digits.

  • Third Party Reference Too Long:
    Error message: Referência muito longa: <value>. Máximo 20 caracteres
    Resolution: Limit the third party reference string to 20 characters or enable auto-generation.

  • API Request Failures:
    If the API returns an error or unexpected response, check that the API credentials are valid and that the service provider code is correct.

  • Auto Generation of Reference:
    If you do not provide a third party reference and auto-generation is disabled, the node will throw an error. Enable auto-generation or provide a valid reference.

Links and References

Discussion