You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-34Lines changed: 28 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,24 +11,19 @@ MTN MoMo API Client for Node JS.
11
11
Add the library to your project
12
12
13
13
```sh
14
-
npm install mtn-momo
14
+
npm install mtn-momo --save-dev
15
15
```
16
16
17
17
## Sandbox Credentials
18
18
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.
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;
32
27
33
28
```sh
34
29
Momo Sandbox Credentials {
@@ -37,34 +32,35 @@ Momo Sandbox Credentials {
37
32
}
38
33
```
39
34
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.
41
36
42
37
## Configuration
43
38
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:
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.
58
54
59
55
## Collections
60
56
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;
62
58
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.
66
62
67
-
You can create a collections client with the following;
63
+
You can create a collections client with the following
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`
0 commit comments