Skip to content

Commit 91b86d7

Browse files
committed
fix: attach transaction to error if available
1 parent 491149a commit 91b86d7

File tree

7 files changed

+343
-225
lines changed

7 files changed

+343
-225
lines changed

README.md

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ As an example, you might configure the library like this:
5353
```js
5454
const momo = require("mtn-momo");
5555

56-
const { Collections, Disbursements } = momo.create({ callbackHost: process.env.CALLBACK_HOST });
56+
const { Collections, Disbursements } = momo.create({
57+
callbackHost: process.env.CALLBACK_HOST
58+
});
5759
```
5860

5961
## Collections
@@ -76,28 +78,22 @@ const collections = Collections({
7678

7779
#### Methods
7880

79-
1. `requestToPay(request: PaymentRequest): Promise<string>`
80-
81-
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`
82-
83-
2. `getTransaction(transactionId: string): Promise<Payment>`
84-
85-
This method is used to get the payment including status and all information from the request. Use the `transactionId` returned from `requestToPay`
81+
1. `requestToPay(request: PaymentRequest): Promise<string>`: 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`
8682

87-
3. `getBalance(): Promise<Balance>`
83+
2. `getTransaction(transactionId: string): Promise<Payment>`: Retrieve transaction information using the `transactionId` returned by `requestToPay`. You can invoke it at intervals until the transaction fails or succeeds. If the transaction has failed, it will throw an appropriate error. The error will be a subclass of `MtnMoMoError`. Check [`src/error.ts`](https://github.com/sparkplug/momoapi-node/blob/master/src/errors.ts) for the various errors that can be thrown
8884

89-
Get the balance of the account.
85+
3. `getBalance(): Promise<Balance>`: Get the balance of the account.
9086

91-
4. `isPayerActive(id: string, type: PartyIdType = "MSISDN"): Promise<string>`
92-
93-
This method is used to check if an account holder is registered and active in the system.
87+
4. `isPayerActive(id: string, type: PartyIdType = "MSISDN"): Promise<string>`: check if an account holder is registered and active in the system.
9488

9589
#### Sample Code
9690

9791
```js
9892
const momo = require("mtn-momo");
9993

100-
const { Collections } = momo.create({ callbackHost: process.env.CALLBACK_HOST });
94+
const { Collections } = momo.create({
95+
callbackHost: process.env.CALLBACK_HOST
96+
});
10197

10298
const collections = Collections({
10399
userSecret: process.env.COLLECTIONS_USER_SECRET,
@@ -162,27 +158,23 @@ const disbursements = Disbursements({
162158

163159
1. `transfer(request: TransferRequest): Promise<string>`
164160

165-
Used to transfer an amount from the owner’s account to a payee account. Status of the transaction can be validated by using the
166-
167-
2. `getTransaction(transactionId: string): Promise<Transfer>`
161+
Used to transfer an amount from the owner’s account to a payee account. Status of the transaction can be validated by using the
168162

169-
This method is used to get the transfer object including status and all information from the request. Use the reference id returned from `transfer`
163+
2. `getTransaction(transactionId: string): Promise<Transfer>`: Retrieve transaction information using the `transactionId` returned by `transfer`. You can invoke it at intervals until the transaction fails or succeeds. If the transaction has failed, it will throw an appropriate error. The error will be a subclass of `MtnMoMoError`. Check [`src/error.ts`](https://github.com/sparkplug/momoapi-node/blob/master/src/errors.ts) for the various errors that can be thrown
170164

171-
3. `getBalance(): Promise<Balance>`
165+
3. `getBalance(): Promise<Balance>`: Get your account balance.
172166

173-
Get the balance of the account.
174-
175-
4. `isPayerActive(id: string, type: PartyIdType = "MSISDN"): Promise<string>`
176-
177-
This method is used to check if an account holder is registered and active in the system.
167+
4. `isPayerActive(id: string, type: PartyIdType = "MSISDN"): Promise<string>`: This method is used to check if an account holder is registered and active in the system.
178168

179169
#### Sample Code
180170

181171
```js
182172
const momo = require("mtn-momo");
183173

184174
// initialise momo library
185-
const { Disbursements } = momo.create({ callbackHost: process.env.CALLBACK_HOST });
175+
const { Disbursements } = momo.create({
176+
callbackHost: process.env.CALLBACK_HOST
177+
});
186178

187179
// initialise disbursements
188180
const disbursements = Disbursements({
@@ -225,7 +217,4 @@ disbursements
225217

226218
console.log(error.message);
227219
});
228-
229220
```
230-
231-

0 commit comments

Comments
 (0)