mtn-open-api
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Mtn Open Api

Explore seamless integration with MTN Open API using this npm package. For in-depth information, refer to the official documentation at https://momodeveloper.mtn.com/.

Key Features

  • Full API Availability: Access a comprehensive set of API endpoints, providing developers with a versatile toolkit to address a wide range of scenarios. The package's commitment to inclusivity ensures that all necessary API endpoints are readily available for integration.

  • Robust Testing: Every endpoint is rigorously tested to ensure reliability and stability. By adhering to best practices in testing, the Mtn Open Api package delivers a dependable solution that developers can trust for their projects.

  • Comprehensive Documentation: All methods are thoroughly documented, ensuring that developers have access to clear and concise information on the functionality and usage of each feature. This commitment to documentation enhances the package's usability and simplifies the integration process.

Installation

Install the package and add to the application's package.json by executing:

$ npm install mtn-open-api

OR

yarn add mtn-open-api

Usage

SandboxProvisioning

Sandbox User Provisioning

This class provides a convenient interface for making requests to the MTN MoMo sandbox-provisioning-api API.

Initialization

You can initialize it with the following parameters:

Example

const { SandboxProvisioning } = require('mtn-open-api');

const commonHeaders = {
  "Authorization": "string",
  "X-Callback-Url": "string",
  "X-Target-Environment": "string",
  "Ocp-Apim-Subscription-Key": "string"
};

const sandboxprovisioning = new SandboxProvisioning({
  headers: commonHeaders,
});

const params = {
  "providerCallbackHost": "string"
};

const extraHeaders = {
  "X-Reference-Id": "string"
};

const response = sandboxprovisioning.postV10Apiuser(params, extraHeaders);

Methods

Collection

Enable remote collection of bills, fees or taxes

This class provides a convenient interface for making requests to the MTN MoMo collection API.

Initialization

You can initialize it with the following parameters:

Example

const { Collection } = require('mtn-open-api');

const commonHeaders = {
  "Authorization": "string",
  "X-Callback-Url": "string",
  "X-Target-Environment": "string",
  "Ocp-Apim-Subscription-Key": "string"
};

const collection = new Collection({
  headers: commonHeaders,
});

const params = {
  "amount": "string",
  "currency": "string",
  "externalId": "string",
  "payer": {
    "partyIdType": "MSISDN",
    "partyId": "string"
  },
  "payerMessage": "string",
  "payeeNote": "string"
};

const extraHeaders = {
  "X-Reference-Id": "string"
};

const response = collection.requesttoPay(params, extraHeaders);

Methods

  • getAccountBalance Get the balance of own account.
  • validateAccountHolderStatus Operation is used to check if an account holder is registered and active in the system.
  • requesttoPay This operation is used to request a payment from a consumer (Payer). The payer will be asked to authorize the payment. The transaction will be executed once the payer has authorized the payment. The requesttopay will be in status PENDING until the transaction is authorized or declined by the payer or it is timed out by the system. Status of the transaction can be validated by using the GET /requesttopay/<resourceId>
  • requesttoPayTransactionStatus This operation is used to get the status of a request to pay. X-Reference-Id that was passed in the post is used as reference to the request.
  • bcAuthorize This operation is used to claim a consent by the account holder for the requested scopes.
  • getBasicUserinfo This operation returns personal information of the account holder. The operation does not need any consent by the account holder.
  • requesttoPayDeliveryNotification This operation is used to send additional Notification to an End User.
  • getAccountBalanceInSpecificCurrency Get the balance of own account. Currency parameter passed in GET
  • requestToWithdrawV1 This operation is used to request a withdrawal (cash-out) from a consumer (Payer). The payer will be asked to authorize the withdrawal. The transaction will be executed once the payer has authorized the withdrawal
  • requestToWithdrawV2 This operation is used to request a withdrawal (cash-out) from a consumer (Payer). The payer will be asked to authorize the withdrawal. The transaction will be executed once the payer has authorized the withdrawal
  • requestToWithdrawTransactionStatus This operation is used to get the status of a request to withdraw. X-Reference-Id that was passed in the post is used as reference to the request.
  • createInvoice A merchant may use this in order to create an invoice that can be paid by an intended payer via any channel at a later stage.
  • getInvoiceStatus This operation is used to get the status of an invoice. X-Reference-Id that was passed in the post is used as reference to the request
  • cancelInvoice This operation is used to delete an invoice. The ReferenceId is associated with the invoice to be cancelled
  • preApproval Preapproval operation is used to create a pre-approval.
  • getPreApprovalStatus This operation is used to get the status of a pre-approval. X-Reference-Id that was passed in the post is used as reference to the request.
  • createOauth2token This operation is used to claim a consent by the account holder for the requested scopes.
  • getUserInfoWithConsent This operation is used to claim a consent by the account holder for the requested scopes.
  • createAccessToken This operation is used to create an access token which can then be used to authorize and authenticate towards the other end-points of the API.
  • createPayments Making it possible to perform payments via the partner gateway. This may be used to pay for external bills or to perform air-time top-ups.
  • getPaymentStatus This operation is used to get the status of a Payment. X-Reference-Id that was passed in the post is used as reference to the request

Disbursement

Automatically deposit funds to multiple users

This class provides a convenient interface for making requests to the MTN MoMo disbursement API.

Initialization

You can initialize it with the following parameters:

Example

const { Disbursement } = require('mtn-open-api');

const commonHeaders = {
  "Authorization": "string",
  "X-Callback-Url": "string",
  "X-Target-Environment": "string",
  "Ocp-Apim-Subscription-Key": "string"
};

const disbursement = new Disbursement({
  headers: commonHeaders,
});

const params = "login_hint=ID:{msisdn}/MSISDN&scope={scope}&access_type={online/offline}";

const extraHeaders = {};

const response = disbursement.bcAuthorize(params, extraHeaders);

Methods

  • getAccountBalance Get the balance of own account.
  • validateAccountHolderStatus Operation is used to check if an account holder is registered and active in the system.
  • getTransferStatus This operation is used to get the status of a transfer. X-Reference-Id that was passed in the post is used as reference to the request.
  • getBasicUserinfo This operation returns personal information of the account holder. The operation does not need any consent by the account holder.
  • bcAuthorize This operation is used to claim a consent by the account holder for the requested scopes.
  • getAccountBalanceInSpecificCurrency Get the balance of own account. Currency parameter passed in GET
  • depositV1 deposit operation is used to deposit an amount from the owner’s account to a payee account.
    Status of the transaction can be validated by using the GET /deposit/{referenceId}
  • depositV2 deposit operation is used to deposit an amount from the owner’s account to a payee account.
    Status of the transaction can be validated by using the GET /deposit/{referenceId}
  • getDepositStatus This operation is used to get the status of a deposit. X-Reference-Id that was passed in the post is used as reference to the request.
  • refundV1 refund operation is used to refund an amount from the owner’s account to a payee account.
    Status of the transaction can be validated by using the GET /refund/{referenceId}
  • refundV2 refund operation is used to refund an amount from the owner’s account to a payee account.
    Status of the transaction can be validated by using the GET /refund/{referenceId}
  • getRefundStatus This operation is used to get the status of a refund. X-Reference-Id that was passed in the post is used as reference to the request.
  • createOauth2token This operation is used to claim a consent by the account holder for the requested scopes.
  • getUserInfoWithConsent This operation is used to claim a consent by the account holder for the requested scopes.
  • createAccessToken This operation is used to create an access token which can then be used to authorize and authenticate towards the other end-points of the API.
  • transfer Transfer operation is used to transfer an amount from the own account to a payee account.
    Status of the transaction can validated by using the GET /transfer/{referenceId}

Remittance

Remit funds to local recipients from the diaspora with ease

This class provides a convenient interface for making requests to the MTN MoMo remittance API.

Initialization

You can initialize it with the following parameters:

Example

const { Remittance } = require('mtn-open-api');

const commonHeaders = {
  "Authorization": "string",
  "X-Callback-Url": "string",
  "X-Target-Environment": "string",
  "Ocp-Apim-Subscription-Key": "string"
};

const remittance = new Remittance({
  headers: commonHeaders,
});

const params = {
  "amount": "string",
  "currency": "string",
  "externalId": "string",
  "payee": {
    "partyIdType": "MSISDN",
    "partyId": "string"
  },
  "payerMessage": "string",
  "payeeNote": "string"
};

const extraHeaders = {
  "X-Reference-Id": "string"
};

const response = remittance.transfer(params, extraHeaders);

Methods

  • getAccountBalance Get the balance of own account.
  • validateAccountHolderStatus Operation is used to check if an account holder is registered and active in the system.
  • transfer Transfer operation is used to transfer an amount from the own account to a payee account.
    Status of the transaction can validated by using the GET /transfer/{referenceId}
  • getTransferStatus This operation is used to get the status of a transfer. X-Reference-Id that was passed in the post is used as reference to the request.
  • getBasicUserinfo This operation returns personal information of the account holder. The operation does not need any consent by the account holder.
  • bcAuthorize This operation is used to claim a consent by the account holder for the requested scopes.
  • getAccountBalanceInSpecificCurrency Get the balance of own account. Currency parameter passed in GET
  • createOauth2token This operation is used to claim a consent by the account holder for the requested scopes.
  • getUserInfoWithConsent This operation is used to claim a consent by the account holder for the requested scopes.
  • createAccessToken This operation is used to create an access token which can then be used to authorize and authenticate towards the other end-points of the API.
  • cashTransfer Cash transfer operation is used to transfer an amount from the owner’s account to a payee account. Status of the transaction can be validated by using GET /cashtransfer/{referenceId}
  • getCashTransferStatus This operation is used to get the status of a transfer. X-Reference-Id that was passed in the post is used as reference to the request.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/koodeyo/mtn-open-api.

Readme

Keywords

Package Sidebar

Install

npm i mtn-open-api

Weekly Downloads

3

Version

1.0.0

License

ISC

Unpacked Size

1.62 MB

Total Files

8

Last publish

Collaborators

  • paulgrammer