A JavaScript library aiming to help developers integrating their products with M-Pesa Platform
# JavaScript M-Pesa SDK
This is a library willing to help you to integrate the Vodacom M-Pesa operations to your application.
### Features
Using this library, you can implement the following operations:
- Receive money from a mobile account to a business account (C2B)
- Send money from a business account to a mobile account (B2C)
- Send money from a business account to another business account (B2B)
- Revert any of the transactions above mentioned
- Query the status of a transaction
## Requirements
- NodeJS v12.0+
- NPM or Yarn
- Valid credentials obtained from the Mpesa Developer portal
## Installation
### Using NPM
```bash
npm install --save @paymentsds/mpesa
```
### Using Yarn
```bash
yarn add @paymentsds/mpesa
```
## Usage
Using this SDK is very simple and fast, let us see some examples:
#### Client configuration
```javascript
import { Client } from '@paymentsds/mpesa'
const client = new Client({
apiKey: ' ', // API Key
publicKey: ' ', // Public Key
serviceProviderCode: ' ', // Service Provider Code,
initiatorIdentifier: ' ', // Initiator Identifier,
securityIdentifier: ' ', // Security Credential
timeout: ' ', // time in seconds
debugging: true,
verifySSL: false,
userAgent: ' '
});
```
#### C2B Transaction (Receive money from mobile account)
##### On ES6 Modules
```javascript
import { Client } from '@paymentsds/mpesa'
const client = new Client({
apiKey: ' ', // API Key
publicKey: ' ', // Public Key
serviceProviderCode: ' ' // Service Provider Code
});
const paymentData = {
from: '841234567', // Customer MSISDN
reference: '11114', // Third Party Reference
transaction: 'T12344CC', // Transaction Reference
amount: '10' // Amount
};
client.receive(paymentData).then(r => {
// Handle success scenario
}).catch(e =>{
// Handle success scenario
});
```
##### CommonJS
```javascript
var Client = require("@payments …