Skip to content

theresasogunle/Rave-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coverage Status Maintainability Build Status Scrutinizer Code Quality

Flutterwave Rave (Rave-Java-Library)

Rave-Java-Library facilitates quick and easy development and integration of Java based applications with the Flutterwave API.

  • Contributors: Theresa Sogunle, Oluwole Adebiyi (KingFlamez)
  • Tags: rave, flutterwave, payment gateway, bank account, credit card, debit card, nigeria, kenya, ghana, international, mastercard, visa, KES, GHC, NGN, Java.

Getting Started

Prerequisite

Signup for a test account here

Signup for a live account here

Installation (Jar file)

Skip this installation if you want to use maven, gradle or ivy

  • Download latest Rave-Java-Library jar file from the releases tab
  • Install it and the other needed library dependencies which are contained in the lib.zip in the releases tab

How to Install Libraries

On Netbeans IDE: Project properties -> Libraries -> Compile -> ADD JAR/folder -> Add Jar

On Intelli J IDEA: File > Project Structure -> Project Settings > Modules > Dependencies > "+" sign > JARs or directories

  • Add a file to your root folder as env.json which will contain your public key, secret key and environment
{
    "API_KEYS": {
      "ENV": "LIVE",
      "PUBLIC_KEY": "FLWPUBK-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X",
      "SECRET_KEY": "FLWSECK-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X"
    }
}
  • ENV - Either LIVE or STAGING

  • PUBLIC_KEY - Gotten From Your Rave Dashboard

  • SECRET_KEY - Gotten From Your Rave Dashboard

  • Set to go 💪

Installation (Maven)

mvn install to build

To use as library,add this to your pom.xml file

<dependencies>
 <dependency>
  <groupId>com.github.theresasogunle</groupId>
  <artifactId>Rave</artifactId>
  <version>1.0</version>
  <type>pom</type>
</dependency>
</dependencies>

Gradle

repositories {
    maven {
        url  "https://dl.bintray.com/theresasogunle/Rave" 
    }
}

Ivy

<dependency org='com.github.theresasogunle' name='Rave' rev='1.0'>
  <artifact name='Rave' ext='pom' ></artifact>
</dependency>

Visit https://bintray.com/theresasogunle/Rave/Rave for more info

Sample Use

  • Getting the list of banks from Flutterwave
import com.rave.Bank;

public class Main {

    public static void main(String[] args) {
        // Create a bank Object
        Bank B = new Bank();
        // Print all banks with getAllBanks() method
        System.out.println(B.getAllBanks());
    }
}
  • Rave Card Charge
import com.rave.Encryption;
import org.json.JSONObject;

public class Main {

    public static void main(String[] args)throws JSONException {
	CardCharge ch=new CardCharge();
        ch.setCardno("4187427415564246")
          .setCvv("828")
          .setCurrency("NGN")
          .setCountry("NG")
          .setAmount("9000")
          .setExpiryyear("19")
          .setExpirymonth("09")
          .setEmail("sogunledolapo@gmail.com")
          .setIP("103.238.105.185")
          .setTxRef("MXX-ASC-4578")
          .setDevice_fingerprint("69e6b7f0sb72037aa8428b70fbe03986c");
     
         //for master card and verve
     
           ch.setPin("3310")
             .setSuggested_auth("PIN");
             JSONObject charge= ch.chargeMasterAndVerveCard();
            //if timeout
            JSONObject poll=ch.chargeMasterAndVerveCard(true);
   
       
       //for visa and intl cards
        ch.setRedirect_url("http://www.google.com");
        JSONObject chargevisa=ch.chargeVisaAndIntl();
	  //if timeout, poll
            JSONObject pollvisa=ch.chargeVisaAndIntl(true);
       
    }
}
  • Rave Account Charge
import com.rave.AccountCharge;
import com.rave.Encryption;
import org.json.JSONObject;

public class Main {

    public static void main(String[] args) throws JSONException{
      	   
	  
            AccountCharge ch= new AccountCharge();
            
          ch.setAccountnumber("0690000031")
            .setAccountbank("044")
            .setAmount("1000")
            .setCountry("NG")
            .setCurrency("NGN")
            .setLastname("Theresa")
            .setIP("1.3.4.4")
            .setPayment_type("account")
            .setTxRef("MX-678DH")
            .setEmail("sogunledolapo@gmail.com");
          
         JSONObject result=ch.chargeAccount();
          //polling
            JSONObject poll=ch.chargeAccount(true);
        System.out.println(result);
        //Validate The Charge
         //do not forget to set your fields
        ch.setTransaction_reference("ACHG-1520028650995")
          .setOtp("12345");
        //for polling
        JSONObject val=ch.validateAccountCharge(true);
        //without polling
        JSONObject validate=ch.validateAccountCharge());
    }
}

Classes and Methods

The documentation for each classes and methods

  1. AccountCharge
  2. AlternatePayment
  3. Bank
  4. CardCharge
  5. Encryption
  6. ExchangeRates
  7. Fees
  8. PreAuthorization
  9. Refund
  10. Transaction
  11. IntegrityChecksum

Alternative Payment Methods

Nigerian USSD- GTB and Zenith Bank

For Merchant

  • FOR GTB display *737*50*amount*159#and return flwRef for the customer so as to complete the transaction

For the developer

Ghana Mobile Money

For the developer

Kenya Mpesa

-Display the Mpesa Buisness account number 637747 and the Account number which is returned as orderRef in the charge response.

For the developer

Todo

  • Recurring Payments

License

The MIT License (MIT). Please see License File for more information.