Logo Lanfrica

bandym05/MTN-Momo-API-using-PHP

Domain:

digital infrastructure

Record type:

software
Creator:
ban
Host:
A lightweight PHP implementation for integrating MTN Mobile Money (MoMo) API – supporting collection, disbursement, and account balance queries. Secure, flexible, and ready for e-commerce and fintech use cases. 🔐 OAuth2-secured | 💸 Seamless Transactions | 🌍 Built for Africa # MTN Mobile Money Payment Gateway This repository implements a payment gateway system using the **MTN Mobile Money API**. It enables seamless processing of mobile money payments with features such as token generation, API user creation, and handling payment requests through a sandbox environment for testing purposes. This system uses the **Collections | Enable remote collection of bills, fees or taxes.** subscription from MTN Momo. ## Prerequisites Before running the system, ensure that you have: 1. PHP installed on your server or local environment. 2. Access to the **MTN Mobile Money Developer** sandbox environment. You can register and obtain API keys here. 3. Basic knowledge of cURL in PHP for handling API requests. ## Project Structure The project consists of the following key files: - **momo_config.php**: Contains the API keys, UUID generation function, and other configuration data. - **access_token.php**: Handles the generation of access tokens from MTN's API. - **api_key.php**: Generates the API key for the provided API user. - **create_api_user.php**: Creates an API user in the MTN sandbox environment. - **index.php**: The main interface that captures payment information and triggers the payment process. - **push.php**: Displays a message to the user after the payment initiation, prompting them to complete the transaction via a mobile push notification. - **success.php**: Displays a success message once the payment is completed. - **fail.php**: Displays a failure message if the payment process fails. - **momo_style.css**: Contains the styles for the user interface. - **callback.php** (optional): Can be used to handle callbacks from MTN after payment completion. ## How It Works ### 1. Configuration (momo_config.php) This file contains the configuration values needed to interact with MTN’s API. It includes: - `$secondary_key`: The subscription key provided by MTN. - `$apiUser`: The unique user ID for the sandbox environment. - `$apiKey`: The API k …