A Java SDK built around the Redde REST API that allows merchants to receive, send, check transaction status, and perform lots of payment transactions.
Before you can have access to APIs you need to register and create an Account. Header for all request should have {"apikey": "string"}: and this API key will be sent to merchant when their app configuration is setup for them by Wigal.
For more information on documentation go to developers.reddeonline.com
To use this library you'll need to have created a Redde account.
Maven and Gradle repository will be ready soon
Create variables and pass them as parameter in an instance of ReddeApiClient with your API key and App ID which will be provided to you by the Redde Team:
Stringapikey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; //Your Api KeyStringappid = "XX"; //Your App IdReddeApiClientapi = newReddeApiClient(apikey, appid);Create an object for the ReddePay class so that you can access the methods like receiveMoney and sendMoney
ReddePaypay = newReddePay();To use the API to recieve money from a customer, the receiveMoney() method will be used with a simple object made with chained methods and passing it as a parameter.
/** * An example object for passing parameters to receive money **/receive.amount(1.0) //The amount to receive
.appid(XX) //App ID given to you by Wigal
.clientreference("wwwe435345") //reference for transaction made
.clienttransid("435") //ID for transaction made
.description("payment subscription") //Description for payment to recieve
.nickname("wigal") //Example name for receiver
.paymentoption("MTN") // MTN | VODAFONE | AIRTELTIGO payment options available
.walletnumber("024XXXXXXX") //Walletnumber of reciever//.vouchercode("") // use this if you are receiving from vodafone
.toString(); To use the API to send money to a customer, the sendMoney() method will be used with a simple object made with chained methods and passing it as a parameter.
/** * An example object for passing parameters to receive money**/send.amount(1.0) //The amount to send
.appid(XX) //App ID given to you by Wigal
.clientreference("wwwe435345") //reference for transaction made
.clienttransid("435") //ID for transaction made
.description("payment subscription") //Description for payment to send
.nickname("wigal") //Example name for sender
.paymentoption("MTN") // MTN | VODAFONE | AIRTELTIGO payment options available
.walletnumber("024XXXXXXX") //Walletnumber of sender
.toString(); Most APIs implement callbacks for easy tracking of api transactions so we've spawn something simple for you to use. Check it out
//Pass your implemented callback url as a parameter for the callbackUrl methodStringcallback = notification.callbackUrl("http://example.com/reddestatus/paid.php"); //or something url callable. status = notification.statusObject(callback);
//shout(status.toString());/* *shout is a simple function created around System.out.println */shout("Status is " + status.getStatus());
shout("Reason is " + status.getReason());
shout("Client Transacion Id is " + status.getClientTransId());
shout("Transaction ID is " + status.getTransactionId());
shout("Status Date " + status.getStatusDate());packagecom.redde.client;
importcom.redde.client.model.ReddeApiRequest;
importcom.redde.client.model.ReddeTransaction;
importcom.redde.client.webhooks.ReddeWebhookNotification;
importcom.redde.client.webhooks.ReddeWebhookStatus;
importjava.io.IOException;
/** * An example of implenting Redde for processing money*/classApp {
/** * * @param args * @throws IOException */publicstaticvoidmain( String[] args ) throwsIOException {
Stringapikey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; //Your Api KeyStringappid = "XX"; //Your App IdReddeApiRequestapi = newReddeApiRequest(apikey, appid); //Instantiate api objectReddePaypay = newReddePay(); //Instantiate pay objectReddeTransactionreceive = newReddeTransaction(); //Instantiate receive objectReddeTransactionsend = newReddeTransaction();//Instantiate send objectReddeWebhookStatusstatus = newReddeWebhookStatus(); //Instantiate status objectReddeWebhookNotificationnotification = newReddeWebhookNotification(); //Instatiate notification object/** * An example object for passing parameters to receive money * */receive.amount(1.0) //The amount to receive
.appid(XX) //App ID given to you by Wigal
.clientreference("wwwe435345") //reference for transaction made
.clienttransid("435") //ID for transaction made
.description("payment subscription") //Description for payment to recieve
.nickname("wigal") //Example name for receiver
.paymentoption("MTN") // MTN | VODAFONE | AIRTELTIGO payment options available
.walletnumber("024XXXXXXX") //Walletnumber of reciever//.vouchercode("") // use this if you are receiving from vodafone
.toString(); /** * An example object for passing parameters to receive money * */send.amount(1.0) //The amount to send
.appid(XX) //App ID given to you by Wigal
.clientreference("wwwe435345") //reference for transaction made
.clienttransid("3243") //ID for transaction made
.description("payment subscription") //Description for payment to send
.nickname("wigal") //Example name for sender
.paymentoption("MTN") // MTN | VODAFONE | AIRTELTIGO payment options available
.walletnumber("024XXXXXXX") //Walletnumber of sender
.toString(); try {
/** * Example on receiving money from customer */StringreceiveResponse = pay.receiveMoney(api, receive);
System.out.println(receiveResponse);
System.out.println("Recieve Money done");
/** * Example on sending money to customer */StringsendResponse = pay.sendMoney(api, send);
System.out.println(sendResponse);
System.out.println("Send Money done");
//Pass your implemented callback url as a parameter for the callbackUrl methodStringcallback = notification.callbackUrl("http://example.com/reddestatus/paid.php"); //or something url callable. status = notification.statusObject(callback);
//shout(status.toString());/* *shout is a simple function created around System.out.println */shout("Status is " + status.getStatus());
shout("Reason is " + status.getReason());
shout("Client Transacion Id is " + status.getClientTransId());
shout("Transaction ID is " + status.getTransactionId());
shout("Status Date " + status.getStatusDate());
} catch (Exceptione) {
//System.out.println("Something went wrong");e.printStackTrace();
}
}
/** * This is used for development purposes to display things * @param s * */privatestaticvoidshout(Strings) {
System.out.println(s);
}
}
This library is released under the MIT License
