Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: attach transaction to error if available #30

Merged
merged 2 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 17 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ As an example, you might configure the library like this:
```js
const momo = require("mtn-momo");

const { Collections, Disbursements } = momo.create({ callbackHost: process.env.CALLBACK_HOST });
const { Collections, Disbursements } = momo.create({
callbackHost: process.env.CALLBACK_HOST
});
```

## Collections
Expand All @@ -76,28 +78,22 @@ const collections = Collections({

#### Methods

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`

2. `getTransaction(transactionId: string): Promise<Payment>`

This method is used to get the payment including status and all information from the request. Use the `transactionId` returned from `requestToPay`
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`

3. `getBalance(): Promise<Balance>`
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

Get the balance of the account.
3. `getBalance(): Promise<Balance>`: Get the balance of the account.

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.
4. `isPayerActive(id: string, type: PartyIdType = "MSISDN"): Promise<string>`: check if an account holder is registered and active in the system.

#### Sample Code

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

const { Collections } = momo.create({ callbackHost: process.env.CALLBACK_HOST });
const { Collections } = momo.create({
callbackHost: process.env.CALLBACK_HOST
});

const collections = Collections({
userSecret: process.env.COLLECTIONS_USER_SECRET,
Expand Down Expand Up @@ -162,27 +158,23 @@ const disbursements = Disbursements({

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

Used to transfer an amount from the owner’s account to a payee account. Status of the transaction can be validated by using the

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

This method is used to get the transfer object including status and all information from the request. Use the reference id returned from `transfer`
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

3. `getBalance(): Promise<Balance>`
3. `getBalance(): Promise<Balance>`: Get your account balance.

Get the balance of the account.

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.
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.

#### Sample Code

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

// initialise momo library
const { Disbursements } = momo.create({ callbackHost: process.env.CALLBACK_HOST });
const { Disbursements } = momo.create({
callbackHost: process.env.CALLBACK_HOST
});

// initialise disbursements
const disbursements = Disbursements({
Expand Down Expand Up @@ -225,7 +217,4 @@ disbursements

console.log(error.message);
});

```


Loading