Skip to content

Commit ae1e280

Browse files
committed
Update README
1 parent 8f35118 commit ae1e280

File tree

2 files changed

+32
-38
lines changed

2 files changed

+32
-38
lines changed

README.md

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,19 @@ MTN MoMo API Client for Node JS.
1111
Add the library to your project
1212

1313
```sh
14-
npm install mtn-momo
14+
npm install mtn-momo --save-dev
1515
```
1616

1717
## Sandbox Credentials
1818

19-
To get sandbox credentials; install the package globally and run the `momo-sandbox` command or install the package locally to your project and run `momo-sandbox` with the `npx` command.
19+
Next, we need to get the `User ID` and `User Secret` and to do this we shall need to use the `Primary Key` for the `Product` to which we are subscribed, as well as specify a `host`. We run the `momo-sandbox` as below.
2020

2121
```sh
2222
## Within a project
23-
npm install --save momoapi-node
2423
npx momo-sandbox --host example.com --primary-key 23e2r2er2342blahblah
25-
26-
## Globally
27-
npm install --global momoapi-node
28-
momo-sandbox --host example.com --primary-key 23e2r2er2342blahblah
2924
```
3025

31-
If all goes well, it will print something like this in your terminal;
26+
If all goes well, it will print the credentials on the terminal;
3227

3328
```sh
3429
Momo Sandbox Credentials {
@@ -37,34 +32,35 @@ Momo Sandbox Credentials {
3732
}
3833
```
3934

40-
You can use those values when developing against the sandbox. When ready to go live,
35+
These are the credentials we shall use for the `sandbox` environment. In production, these credentials are provided for you on the MTN OVA management dashboard after KYC requirements are met.
4136

4237
## Configuration
4338

44-
Before you can use collections, and later disbursements, you need to create an instance of the client. This library exports a function that returns the client given global configuration;
39+
Before we can fully utilize the library, we need to specify global configurations. The global configuration must contain the following:
40+
41+
- `baseUrl`: An optional base url to the MTN Momo API. By default the staging base url will be used
42+
- `environment`: Optional enviroment, either "sandbox" or "production". Default is 'sandbox'
43+
- `callbackHost`: The domain where you webhooks urls are hosted. This is mandatory.
44+
45+
As an example, you might configure the library like this:
4546

4647
```js
4748
const momo = require("mtn-momo");
4849

4950
const { Collections } = momo({ callbackHost: process.env.CALLBACK_HOST });
5051
```
5152

52-
The global configuration must contain the following;
53-
54-
- `baseUrl`: An optional base url to the MTN Momo API. By default the staging base url will be used
55-
- `environment`: Optional enviroment, either "sandbox" or "production". Sandbox by default
56-
- `callbackHost`: The domain where you webhooks urls are hosted;
57-
53+
Currently, the library only supports `Collections`. Let us create a client with the previously generated credentials for the `Collections` product.
5854

5955
## Collections
6056

61-
The collections client can be created with the following paramaters;
57+
The collections client can be created with the following paramaters. Note that the `userID` and `userSecret` for production are provided on the MTN OVA dashboard;
6258

63-
- `subscriptionKey`: Find this on the MTN Momo API dashboard
64-
- `userId`: For production, find your Collections User ID on MTN Momo API dashboard. For sandbox, use the one generated with the `momo-sandbox` command for sandbox
65-
- `userSecret`: For production, find your Collections User Secret on MTN Momo API dashboard. For sandbox, use the one generated with the `momo-sandbox` command for sandbox
59+
- `primaryKey`: Primary Key for the `Collections` product.
60+
- `userId`: For sandbox, use the one generated with the `momo-sandbox` command.
61+
- `userSecret`: For sandbox, use the one generated with the `momo-sandbox` command.
6662

67-
You can create a collections client with the following;
63+
You can create a collections client with the following
6864

6965
```js
7066
const collections = Collections({
@@ -78,11 +74,19 @@ const collections = Collections({
7874

7975
1. `requestToPay(request: PaymentRequest): Promise<string>`
8076

81-
This method inititates a payment. The user can then authorise to it with their PIN. It returns a promise that resolves the transaction id. You can use the transaction id to check the transaction status, check the nmethod below.
77+
This operation is used to request a payment from a consumer (Payer). The payer will be asked to authorize the payment. The transaction is executed once the payer has authorized the payment. The transaction will be in status PENDING until it is authorized or declined by the payer or it is timed out by the system. Status of the transaction can be validated by using `getTransaction`
8278

83-
2. `getTransactionStatus(transactionId: string): Promise<Transaction>`
79+
2. `getTransaction(transactionId: string): Promise<Transaction>`
8480

85-
3. `getAccountBalance(): Promise<AccountBalance>`
81+
This method is used to get the Transaction object.
82+
83+
3. `getBalance(): Promise<AccountBalance>`
84+
85+
Get the balance of the account.
86+
87+
4. `isPayerActive(id: string, type: PartyIdType = "MSISDN"): Promise<any>`
88+
89+
This method is used to check if an account holder is registered and active in the system.
8690

8791
#### Sample Code
8892

@@ -132,14 +136,4 @@ collections
132136
});
133137
```
134138

135-
## Development
136139

137-
Clone this repository and compile
138-
139-
```sh
140-
git clone [email protected]:sparkplug/momoapi-node.git
141-
cd momoapi-node
142-
npm install
143-
npm run compile
144-
npm link # to test and develop the cli tool locally
145-
```

src/collections.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class Collections {
1616
}
1717

1818
/**
19-
* This operation is used to request a payment from a consumer (Payer).
19+
* This method is used to request a payment from a consumer (Payer).
2020
* The payer will be asked to authorize the payment. The transaction will
2121
* be executed once the payer has authorized the payment.
2222
* The requesttopay will be in status PENDING until the transaction
@@ -41,9 +41,9 @@ export default class Collections {
4141
}
4242

4343
/**
44-
* This operation is used to get the status of a request to pay.
44+
* This method is used to get the Transaction object.
4545
*
46-
* @param referenceId the value returned from `getTransactionStatus`
46+
* @param referenceId the value returned from `requestToPay`
4747
*/
4848
public getTransaction(referenceId: string): Promise<Transaction> {
4949
return this.client
@@ -61,7 +61,7 @@ export default class Collections {
6161
}
6262

6363
/**
64-
* Operation is used to check if an account holder is registered and active in the system.
64+
* This method is used to check if an account holder is registered and active in the system.
6565
*
6666
* @param id Specifies the type of the party ID. Allowed values [msisdn, email, party_code].
6767
* accountHolderId should explicitly be in small letters.

0 commit comments

Comments
 (0)