# MPESA ANDROID SDK
This SDK allows android developers to easily make MPESA payments on their apps.
# Screenshots
# Features
The SDK includes the following:
1. Android native SDK to accept MPESA payments in less than 10 lines of code
2. A sample backend in Laravel you can easily deploy to your server to quickly get started.Get it here.
3. A sample DB schema for the backend
4. Integration with Firebase Cloud Messaging to easily send push notifications to the app after payments
5. A complete sample application you can easily run to see the SDK in action
6. A free hosted backend you can use for testing purposes.
7. This nice README :(
## Getting started
To get started you need the following from the Safaricom Developer dashboard
1. Your Consumer Key
2. Your Consumer Secret
3. The business shortcode
4. A Firebase project with a server key. Create one here
For testing purposes, you can get test credentials here.
Use the *Lipa Na Mpesa Online Shortcode* and *Lipa Na Mpesa Online Passkey* from the link.
## Integrating with your app
1. Add the SDK to your project
``` compile 'com.bdhobare:mpesa:0.0.6'```
2. Initialize the SDK
```Mpesa.with(context, CONSUMER_KEY, CONSUMER_SECRET);```
You can optionally pass the mode as the third parameter , either `SANDBOX` or `PRODUCTION`.
```Mpesa.with(context, CONSUMER_KEY, CONSUMER_SECRET, Mode.PRODUCTION);```
3. Implement the `AuthListener` interface in your activity.The interface provides two methods
* ```public void onAuthError(Pair result)```
This method is called when initializing the Mpesa instance fails.You can get the response code using `result.code` and the error message using `result.message`. Make sure your credentials are correct
* ``` public void onAuthSuccess()```
This method is called once the Mpesa instance initializes successfully.You can only make a successful transaction after this method is called.Therefore, you can use this method to update the user interface like enabling a disabled button.
## …