Git Product home page Git Product logo

wigalgh / redde-java-sdk Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 993 KB

A Java SDK built around the Redde REST API that allows merchants to receive, send, check transaction status, and perform lots of payment transactions.

Home Page: https://github.com/wigalsolutionsltd/redde-java-sdk

License: MIT License

Java 100.00%
redde wigal wigalpayments payment-gateway payment-integration payment-api payment-platform java-sdk receivemoney sendmoney

redde-java-sdk's Introduction

redde-java-sdk

GitHub version Maintenance MIT license ForTheBadge built-by-developers

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

Installation

To use this library you'll need to have created a Redde account.

Usage

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:

String apikey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; //Your Api Key
String appid = "XX"; //Your App Id
ReddeApiClient api = new ReddeApiClient(apikey, appid);

Create an object for the ReddePay class so that you can access the methods like receiveMoney and sendMoney

ReddePay pay = new ReddePay();

Examples

Receiving money from Customer or Client

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(); 

Sending money to Customer or Client

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(); 

Callbacks

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 method
String callback = 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());

An Example Class that shows a full implemetation

package com.redde.client;

import com.redde.client.model.ReddeApiRequest;
import com.redde.client.model.ReddeTransaction;
import com.redde.client.webhooks.ReddeWebhookNotification;
import com.redde.client.webhooks.ReddeWebhookStatus;
import java.io.IOException;

/** 
 * An example of implenting Redde  for processing money
*/
class App {
    
    /**
     * 
     * @param args
     * @throws IOException
     */
    public static void main( String[] args )  throws IOException {

        String apikey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; //Your Api Key
        String appid = "XX"; //Your App Id
        
        ReddeApiRequest api = new ReddeApiRequest(apikey, appid); //Instantiate api object

        ReddePay pay = new ReddePay(); //Instantiate pay object
        
        ReddeTransaction receive = new ReddeTransaction(); //Instantiate receive object
        ReddeTransaction send = new ReddeTransaction();//Instantiate send object
        ReddeWebhookStatus status = new ReddeWebhookStatus(); //Instantiate status object
        ReddeWebhookNotification notification = new ReddeWebhookNotification(); //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
            */
            String receiveResponse = pay.receiveMoney(api, receive);
            System.out.println(receiveResponse);
            System.out.println("Recieve Money done");

            /** 
             * Example on sending money to customer
            */
            String sendResponse = 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 method
			String callback = 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 (Exception e) {
            //System.out.println("Something went wrong");
            e.printStackTrace();
        }

    }

    /**
     * This is used for development purposes to display things 
     * @param s 
     * 
     */
    private static void shout(String s) {
        System.out.println(s);
    }

}

License

This library is released under the MIT License

redde-java-sdk's People

Contributors

dependabot[bot] avatar otengkwame avatar stevkky avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.