Mozambique Payments icon

Mozambique Payments

Gateway unificado para pagamentos M-Pesa e E-Mola em Moçambique

Overview

The "Mozambique Payments" node provides a unified gateway to process mobile payments in Mozambique using two popular providers: M-Pesa and E-Mola. It supports three main operations:

  • Process Payment: Initiates a payment transaction to a specified phone number via the selected provider.
  • Validate Phone: Checks if a given phone number is valid for either M-Pesa or E-Mola based on number prefixes.
  • Generate Reference: Creates a unique transaction reference string, useful for tracking payments.

This node is beneficial for automating mobile money transactions within workflows, such as paying vendors, collecting customer payments, or validating user phone numbers before processing payments.

Practical Examples

  • Automatically charge customers via M-Pesa or E-Mola when they place an order.
  • Validate phone numbers entered by users to ensure they belong to supported providers.
  • Generate unique payment references for reconciliation and auditing purposes.

Properties

Name Meaning
Operation The action to perform: Process Payment, Validate Phone, or Generate Reference.
Provider The payment provider to use: M-Pesa, E-Mola, or Auto-Detect (detects based on phone prefix).
Phone Number The 9-digit phone number to process or validate (format: 8xxxxxxxx).
Amount The payment amount in Mozambican Metical (MZN), between 1 and 1,250,000. Required for payments.
Reference Optional transaction reference string; if empty, it will be generated automatically.

Output

The node outputs JSON objects with fields depending on the operation:

  • Process Payment:

    • success: Boolean indicating if the payment was successful.
    • provider: The payment provider used (mpesa or emola).
    • reference: The transaction reference string.
    • phone: The processed phone number.
    • amount: The payment amount.
    • timestamp: ISO timestamp of the transaction.
    • response: Raw response from the payment API.
  • Validate Phone:

    • valid: Boolean indicating if the phone number is valid.
    • phone: The processed phone number.
    • provider: The detected or selected provider.
    • message: Validation message.
    • timestamp: ISO timestamp of validation.
  • Generate Reference:

    • reference: Generated unique reference string.
    • provider: Provider inferred from phone prefix or default.
    • timestamp: ISO timestamp of generation.

The node does not output binary data.

Dependencies

  • Requires credentials containing:
    • Base URL of the payment API.
    • Client ID and client secret for OAuth2 authentication.
    • Wallet IDs for both M-Pesa and E-Mola.
  • Uses HTTP requests to authenticate and interact with the payment API endpoints.
  • Requires proper configuration of these credentials in n8n prior to use.

Troubleshooting

  • Invalid Phone Number Length: The phone number must have exactly 9 digits. Remove any non-digit characters before input.
  • Unrecognized Phone Prefix: If using auto-detect, the phone number must start with 84 or 85 for M-Pesa, or 86 or 87 for E-Mola.
  • Provider Mismatch: When selecting a specific provider, ensure the phone number prefix matches that provider's expected prefixes.
  • Amount Out of Range: Payment amounts must be between 1 and 1,250,000 MZN.
  • Authentication Errors: Failure to obtain an access token usually indicates incorrect or missing API credentials.
  • API Request Failures: Network issues or invalid wallet IDs can cause payment requests to fail.

To resolve errors, verify all inputs, ensure credentials are correctly set up, and confirm network connectivity to the payment API.

Links and References

Discussion