The Rave By Flutterwave Developer Documentation

We have put together comprehensive guidelines and documentation to help you get right into integrating any of our products quickly. You can also get support when you need help!

Get Started    Discussions

Rave's Android Drop In UI

Rave's Android Drop-In is a readymade UI that allows you to accept card and bank payments in your Android app.

Screenshot of Drop-In

Before you begin

Requirements

The minimum supported SDK version is 15

Adding it to your project

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

dependencies {
 		implementation 'com.github.Flutterwave:rave-android:1.0.31'
}

Step 3. Add the required permission

Add the READ_PHONE_PERMISSION and INTERNET permissions to your android manifest

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.INTERNET" />

REQUIRED PERMISSION

This library requires the READ_PHONE_PERMISSION to get the build number for fraud detection and flagging as recommended here https://developer.android.com/training/articles/user-data-ids.html#i_abuse_detection_detecting_high_value_stolen_credentials

Usage

1. Create a RavePayManager instance

Set the public key, encryption key and other required parameters. The RavePayManager accepts a mandatory instance of the calling Activity

 new RavePayManager(activity).setAmount(amount)
                    .setCountry(country)
                    .setCurrency(currency)
                    .setEmail(email)
                    .setfName(fName)
                    .setlName(lName)
                    .setNarration(narration)
                    .setPublicKey(publicKey)
                    .setEncryptionKey(encryptionKey)
                    .setTxRef(txRef)
                    .acceptAccountPayments(boolean)
                    .acceptCardPayments(boolean)
                    .acceptMpesaPayments(boolean)
                    .acceptGHMobileMoneyPayments(boolean)
                    .onStagingEnv(boolean)
                    .allowSaveCardFeature(boolean)
                    .setMeta(List<Meta>)
                    .withTheme(styleId)
                    .isPreAuth(boolean)
                    .setSubAccounts(List<SubAccount>)
                    .initialize();
function parameter type required
setAmount(amount) This is the amount to be charged from card/account double Required
setCountry(country) This is the route country for the transaction with respect to the currency. You can find a list of supported countries and currencies here String Required
setCurrency(currency) This is the specified currency to charge the card in String Required
setfName(fName) This is the first name of the card holder or the customer String Required
setlName(lName) This is the last name of the card holder or the customer String Required
setEmail(email) This is the email address of the customer String Required
setNarration(narration) This is a custom description added by the merchant String Not Required
setPublicKey(publicKey) Merchant's public key. String Required
setEncryptionKey(encryptionKey) Merchant's encryption key String Required
setTxRef(txRef) This is the unique reference, unique to the particular transaction being carried out. It is generated by the merchant for every transaction String Required
acceptAccountPayments(boolean) Set to true if you want to accept payments via cards, else set to false. boolean Not Required
acceptCardPayments(boolean) Set to true if you want to accept payments via bank accounts, else set to false boolean Not Required
acceptMpesaPayments(boolean) Set to true if you want to accept Mpesa payments, else set to false . For this option to work, you should set your country to KE and your currency to KES boolean Not Required
acceptGHMobileMoneyPayments(boolean) Set to true if you want to accept Ghana mobile money payments, else set to false . For this option to work, you should set your country to GH and your currency to GHS boolean Not Required
onStagingEnv(boolean) Set to true if you want your transactions to run in the staging environment otherwise set to false. Defaults to false boolean Not Required
setMeta(List<Meta>) Pass in any other custom data you wish to pass. It takes in a List of Meta objects List<Meta> Not Required
setSubAccounts(List<SubAccount>) Pass in a List of SubAccount,if you want to split transaction fee with other people. Subaccounts are your vendors' accounts that you want to settle per transaction. To initialize a SubAccout class, do SubAccount(String subAccountId,String transactionSplitRatio) or SubAccount(String subAccountId,String transactionSplitRatio,String transactionChargeType, String transactionCharge) to also charge the subaccount a fee. Learn more about split payments and subaccounts. List<SubAccount> Not Required
setIsPreAuth(boolean) Set to true to preauthorise the transaction amount. Learn more about preauthourization. int Not Required
withTheme(styleId) Sets the theme of the UI. int Not Required
setPaymentPlan(payment_plan) If you want to do recurrent payment, this is the payment plan ID to use for the recurring payment, you can see how to create payment plans here and here. This is only available for card payments String Not Required
initialize() Launch the Rave Payment UI N/A Required

SECURITY ALERT

You should never store your SECRET KEY on the user's device

2. Handle the response

In the calling activity, override the onActivityResult method to receive the payment response as shown below

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == RaveConstants.RAVE_REQUEST_CODE && data != null) {
            String message = data.getStringExtra("response");
            if (resultCode == RavePayActivity.RESULT_SUCCESS) {
                Toast.makeText(this, "SUCCESS " + message, Toast.LENGTH_SHORT).show();
            }
            else if (resultCode == RavePayActivity.RESULT_ERROR) {
                Toast.makeText(this, "ERROR " + message, Toast.LENGTH_SHORT).show();
            }
            else if (resultCode == RavePayActivity.RESULT_CANCELLED) {
                Toast.makeText(this, "CANCELLED " + message, Toast.LENGTH_SHORT).show();
            }
        }
        else {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }

The intent's message object contains the raw JSON response from the Rave API. This can be parsed to retrieve any additional payment information needed.

3. Customize the look

You can apply a new look by changing the color of certain parts of the UI to highlight your brand colors

<style name="DefaultTheme" parent="AppTheme.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="OTPButtonStyle">@style/otpBtnStyle</item>
        <item name="PayButtonStyle">@style/payBtnStyle</item>
        <item name="PinButtonStyle">@style/pinButtonStyle</item>
        <item name="OTPHeaderStyle">@style/otpHeaderStyle</item>
        <item name="TabLayoutStyle">@style/tabLayoutStyle</item>
        <item name="PinHeaderStyle">@style/pinHeaderStyle</item>
        <item name="SavedCardButtonStyle">@style/svdCardsBtnStyle</item>
 </style>

Help