Easiest Way To Integrate Flutterwave’s Rave Payment Gateway On Android

Mendhie Emmanuel
3 min readMar 4, 2019

--

Updated on: October 25, 2019

Flutterwave has made it very easy for businesses in Nigeria and other African countries to accept payments, make payouts and manage their business funds from one integrated platform. Since the official release of their android SDK, they have further simplified the work of integrating their payment gateway on android devices. I have been using their platform for over 3years so I will guide you through on the easiest way to integrate it on android.

1.Create a Rave account

You need to create a Rave account and a Rave sandbox account. The sandbox account is where you obtain your staging keys (used only during development stage). You can get your live keys from the main rave account when you are about to publish on Play Store.

2. Download Flutterwave sdk to your application

Add these code to your project build.gradle

Then add the Flutterwave dependency to the app build.gradle

3. Add INTERNET and READ_PHONE permissions to the project manifest

According to Flutterwave, the library requires the READ_PHONE_PERMISSION to get the build number for fraud detection and flagging.

4. Design the user interface of your application the way you want

For this article, I have created a simple app that allows you to order two Nigerian foods. Yes, we all love well prepared local delicacies.

activity_main

Here’s the code for activity_main.xml

5. Create an instance of RavePayManager

The most important work will be in the Java file where you create an instance of RavePayManager, like in the code below. See Rave documentation for a list of parameters to pass.

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)
.acceptAchPayments(boolean)
.acceptGHMobileMoneyPayments(boolean)
.acceptUgMobileMoneyPayments(boolean)
.onStagingEnv(boolean)
.allowSaveCardFeature(boolean)
.setMeta(List<Meta>)
.withTheme(styleId)
.isPreAuth(boolean)
.setSubAccounts(List<SubAccount>)
.shouldDisplayFee(boolean)
.initialize();

Here is the full code for the main activity

Finally, you can customize the outlook by changing the color of certain parts of the UI to highlight your brand colors. Simply add this code to your styles.xml file

<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>

Alright, that’s all.

permission screeen
Card payment screen
Account payment screen

I created a GitHub repo with the full implementation in case you want to check out.

--

--