All Projects → urandu → mpesa-rest-api

urandu / mpesa-rest-api

Licence: GPL-2.0 License
mpesa rest api converts the mpesa api to a RESTful API that is easy for developers to use instead of the current SOAP web service provided by mpesa.

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects
shell
77523 projects

Projects that are alternatives of or similar to mpesa-rest-api

safaricom-daraja-nodejs
Standalone M-Pesa payments service using the new Daraja Payment API by Safaricom.
Stars: ✭ 31 (+29.17%)
Mutual labels:  mpesa, c2b, mpesa-api, safaricom
sapamapay
New Safaricom MPESA (Daraja) API
Stars: ✭ 31 (+29.17%)
Mutual labels:  mpesa, mpesa-api, safaricom
python-daraja
Python Wrapper for interacting with the MPESA Daraja API. More Features to be implemented
Stars: ✭ 20 (-16.67%)
Mutual labels:  payments, mpesa, mpesa-api
Gopay
💰 Integrace Gopay pro Nette Framework
Stars: ✭ 68 (+183.33%)
Mutual labels:  soap, payments
mobile-money
Mobile Money Payments API in Kenya (MPESA, EQUITY/EQUITEL,T-CASH). Supports B2B, B2C and C2B
Stars: ✭ 17 (-29.17%)
Mutual labels:  mpesa-api, mobile-money
mpesa-dart
A dart wrapper around mpesa daraja api
Stars: ✭ 19 (-20.83%)
Mutual labels:  mpesa, mpesa-api
mpesa-rust
An abstraction/wrapper on top of Safaricom's M-PESA daraja api in Rust
Stars: ✭ 17 (-29.17%)
Mutual labels:  mpesa, safaricom
Chowder
Chowder for Android M-Pesa payments.
Stars: ✭ 31 (+29.17%)
Mutual labels:  mpesa-api, safaricom
Project Mulla
Talk to MPESA API via a REST API. Bringing the MPESA G2 API to the 21st century. --
Stars: ✭ 282 (+1075%)
Mutual labels:  soap, payments
php-pesa
Open payment integration toolkit for PHP
Stars: ✭ 26 (+8.33%)
Mutual labels:  mpesa, mpesa-api
adyen-salesforce-commerce-cloud
Salesforce Commerce Cloud (formerly Demandware)
Stars: ✭ 63 (+162.5%)
Mutual labels:  payments
killbill-client-java
Java client library for Kill Bill
Stars: ✭ 30 (+25%)
Mutual labels:  payments
mangopay2-python-sdk
SDK Python for MANGOPAY
Stars: ✭ 31 (+29.17%)
Mutual labels:  payments
xsd-parser-rs
A xsd/wsdl => rust code generator written in rust
Stars: ✭ 45 (+87.5%)
Mutual labels:  soap
coindrop
The easiest way to accept donations & tips anywhere
Stars: ✭ 59 (+145.83%)
Mutual labels:  payments
xsdata
Naive XML & JSON Bindings for python
Stars: ✭ 144 (+500%)
Mutual labels:  soap
fake-toss-payments-server
Fake Toss Payments Server with Real SDK Library
Stars: ✭ 242 (+908.33%)
Mutual labels:  payments
creditcardnumber
Java library that can provide details of a bank issued credit card number
Stars: ✭ 43 (+79.17%)
Mutual labels:  payments
extensiveautomation-server
Extensive Automation server
Stars: ✭ 19 (-20.83%)
Mutual labels:  soap
mangopay2-java-sdk
Java SDK for MANGOPAY
Stars: ✭ 23 (-4.17%)
Mutual labels:  payments

Codacy Badge

Mpesa Rest API (MRA)

mpesa rest api converts the mpesa api to a RESTful API that is easy for developers to use instead of the current SOAP web service provided by mpesa.

Installation

Requirements

-Python 2.7 or 3.x

Configuration

In the settings file mpesa/settings.py scroll to the bottom and replace the following urls VALIDATION_URL = "http://127.0.0.1:8000/c2b/" and CONFIRMATION_URL = "http://127.0.0.1:8000/c2b/" with the validation and confirmation endpoint to your application respectively

example:

replace

VALIDATION_URL = "http://127.0.0.1:8000/c2b/"
CONFIRMATION_URL = "http://127.0.0.1:8000/c2b/"

with

VALIDATION_URL = "http://myapplication/validate_mpesa_payment/"
CONFIRMATION_URL = "http://myapplication/confirm_mpesa_payment/"

Development

git clone https://github.com/urandu/mpesa-rest-api.git
cd mpesa-rest-api
pip install -r requirements.txt
python manage.py runserver

Production (not ready for production)

git clone https://github.com/urandu/mpesa-rest-api.git
cd mpesa-rest-api
pip install -r requirements.txt
./start.sh

Docker

To run the application via using docker (docker should be installed on your machine) :

git clone https://github.com/urandu/mpesa-rest-api.git
cd mpesa-rest-api

docker-compose up

C2B Validation And Confirmation

For validation and confirmation you need to have validation end point that will receive validation requests in json form. You also need to have a confirmation endpoint in your application that will receive confirmation requests from MRA(mpesa rest api).

When requesting for validation and confirmation G2 API access from safaricom, they will ask you for two endpoints, the validation and the confirmation endpoints.

Below are the endpoints you should give them once you you deploy MRA

Confirmation endpoint = http://your_application_ip_address/confirmation/

Validation endpoint = http://your_application_ip_address/validation/

validation workflow and payloads

-when a users makes a paybill payment via mpesa from his/her phone, mpesa will send a validation request to MRA.

-MRA will parse the SOAP request and convert it to json.

-MRA will then post the json to the validation endpoint provided in the settings.py file. below is a sample (format) of the json payload:

{
  "trans_time": "20140227082020",
  "kycinfo": "[{\"KYCName\": \"[Personal Details][First Name]\", \"KYCValue\": \"Hoiyor\"}, {\"KYCName\": \"[Personal Details][Middle Name]\", \"KYCValue\": \"G\"}, {\"KYCName\": \"[Personal Details][Last Name]\", \"KYCValue\": \"Chen\"}]",
  "trans_amount": "123.00",
  "trans_type": "PayBill",
  "msisdn": "254722703614",
  "invoive_number": null,
  "paybill_number": "12345",
  "trans_id": "1234560000007031",
  "account_number": "hjhdjhd"
}

-The response that MRA expects from the validation endpoint is :

The result_code returned by the validation endpoint should be 0 for success otherwise, use one of the codes below to describe the error:

result_code       result_description
C2B00011          Invalid MSISDN
C2B00012          Invalid Account number
C2B00013          Invalid Amount
C2B00014          Invalid KYC details
C2B00015          Invalid Shortcode
C2B00016          Other Error

Example response:

{
     "result_code": "0"
     "result_description": "sucessful validation" 
     "custom_trans_id": "id from your application" 
}

confirmation workflow and payloads

Once the confirmed transaction has been proccessed by mpesa, MRA will send a post request to the confirmation endpoint in the settings.py transaction

the payload in the post request shall be as below:

{
  "trans_time": "20140227082020",
  "kycinfo": "[{\"KYCName\": \"[Personal Details][First Name]\", \"KYCValue\": \"Hoiyor\"}, {\"KYCName\": \"[Personal Details][Middle Name]\", \"KYCValue\": \"G\"}, {\"KYCName\": \"[Personal Details][Last Name]\", \"KYCValue\": \"Chen\"}]",
  "trans_amount": "123.00",
  "trans_type": "PayBill",
  "msisdn": "254722703614",
  "paybill_number": "12345",
  "trans_id": "1234560000007031",
  "account_number": "hjhdjhd"
}

Online checkout (C2B)

For online checkout, you initiate a payment request from your application to MRA as outlined below

send a post request to http://your_mra_instance/request/payment

with the below params

-merchant_transaction_id: "gf5rsewalu8j" [optional]ID of the transaction generated by your application
-account_number: "xxxxxx" [optional] paybill account number
-amount: "50.00" the amount to be paid
-msisdn: "254726345xxx" the phone number that should make the payment (note the format)

response

{
   "trx_id": "gstsf25sfsftsfs52",
   "return_code": "00"  00=success 01=an error occured,
   "description": "success"
}

If the user authenticates the action from his/her phone MRA will send a post request to the MERCHANT_ONLINE_CHECKOUT_CALLBACK url that you specified in settings.py

the body of the request will contain the below payload

{
    "msisdn": "254726983xxx",
    "amount": "50",
    "date": "10-10-1997",
    "mpesa_transaction_id": "KMJH7700GDH",
    "transaction_status": "success",
    "return_code": "00",
    "description": "payment successful",
    "merchant_transaction_id": "dsdfsfsfsfs"
}

B2C

(coming soon)

B2B

(coming soon)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].