Intro

Have you ever wanted to create a website or an app where you can receive mobile money payments from anyone with a Registered mobile money simcard?

The VugaPay API allows you to receive mobile money payments from any mobile money users, in Addition VugaPay developers receive mobile money for free.

Note: This article explains how our API works, If you want to start integrating our API please sign up for a VugaPay Account and start accessing our Developers console

The VugaPay API uses HTTP verbs and a RESTful endpoint structure. OAuth 2.0 is used as the API Authorization framework. Request and response payloads are formatted as JSON.

API operations

The VugaPay REST APIs are supported in two environments. Use the Sandbox environment for testing purposes, then move to the live environment for production processing. When testing, generate an access token with your test credentials to make calls to the Sandbox URIs. When you’re set to go live, use the live credentials assigned to your app to generate a new access token to be used with the live URIs.

The following endpoints address our two environments:

Sandbox (for testing) : http://devs.vugapay.com/api/sandbox/

Live (production) : http://devs.vugapay.com/api/v1/

A complete REST operation is formed by combining an HTTP method (or “verb”) with the full URI to the resource you’re addressing. For example, here is the operation to create a new payment:

POST http://devs.vugapay.com/api/v1/payments/payment

To create a complete request, combine the operation with the appropriate HTTP headers and any required JSON payload.

Authentication & Headers

With each API call, you’ll need to set request headers, including an OAuth 2.0 access token. Get an access token by using the OAuth 2.0 client_credentials token grant type with your clientId:secret as your Basic Auth credentials. You can use your Sandbox access token to try any of the code in this reference.

Payment Request Sample in Java

This is a snapshot of our mobile money api

OAuthTokenCredential tokenCredential = new OAuthTokenCredential("<CLIENT_ID>", "<CLIENT_SECRET>");

//Get token
String accessToken = tokenCredential.getAccessToken();

//Optional details about transaction
AmountDetails amountDetails = new AmountDetails();
amountDetails.setReason("My money");
amountDetails.setMessage("I want my money");

//Set price, currency defaults to RWF
Amount amount = new Amount();
amount.setTotal("740");
amount.setCurrency("RWF");
amount.setDetails(amountDetails);

//Boom!
Payment payment = new Payment();
payment.setAmount(amount);

Payment createdPayment = payment.create(accessToken);

Notice how we made few lines of code to suit a typical African programmer

Response

Returns a payment object along with the state of the payment. The response includes a payment ID that uniquely identifies the transaction.

{
"id": "VP-17S8410768582940NKEE66EQ",
 "create_time": "2016-01-31T04:12:02Z",
 "update_time": "2016-01-31T04:12:04Z",
 "state": "approved",
 "from": "ceddy"
 "client": "me"

"transactions": {
  "amount": {
    "total": "740",
    "currency": "RFW",
    "details": {
      "reason": "My money",
      "message": "I want my money"
       }
    }
  }
}