Documentation Index Fetch the complete documentation index at: https://mintlify.com/theresasogunle/Fintech-flutterwave-Java-Library/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Before you can use the Rave Java Library to process payments, you need to configure it with your Flutterwave API credentials and choose the appropriate environment. This guide covers all configuration options and best practices.
RaveConstant class
The RaveConstant class is the central configuration point for the library. It holds three critical static properties that must be set before making any API calls:
public class RaveConstant {
public static String SECRET_KEY ;
public static String PUBLIC_KEY ;
public static Environment ENVIRONMENT ;
}
Required configuration
You must configure these three properties at the start of your application:
Set your public key
Your public key identifies your application to Flutterwave: RaveConstant . PUBLIC_KEY = "FLWPUBK-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-X" ;
Set your secret key
Your secret key is used to encrypt sensitive payment data: RaveConstant . SECRET_KEY = "FLWSECK-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-X" ;
Never commit your secret key to version control or expose it in client-side code.
Set the environment
Choose between staging (testing) and live (production) environments: RaveConstant . ENVIRONMENT = Environment . STAGING ;
Environment enumeration
The Environment enum defines two possible values:
public enum Environment {
STAGING ,
LIVE
}
STAGING environment
Use the staging environment for development and testing:
RaveConstant . ENVIRONMENT = Environment . STAGING ;
In staging mode:
No real money is charged
Test cards and accounts can be used
API calls go to Flutterwave’s test servers
Use your test API keys from the test dashboard
LIVE environment
Use the live environment for production:
RaveConstant . ENVIRONMENT = Environment . LIVE ;
In live mode:
Real money is charged
Only real cards and accounts work
API calls go to Flutterwave’s production servers
Use your live API keys from the production dashboard
Complete configuration example
Here’s a complete configuration example:
import com.github.theresasogunle.RaveConstant;
import com.github.theresasogunle.Environment;
public class Configuration {
public static void configure () {
// Set public key
RaveConstant . PUBLIC_KEY = "FLWPUBK-8ba286388b24dbd6c20706def0b4ea23-X" ;
// Set secret key
RaveConstant . SECRET_KEY = "FLWSECK-c45e0f704619e673263844e584bba013-X" ;
// Set environment
RaveConstant . ENVIRONMENT = Environment . STAGING ;
}
public static void main ( String [] args ) {
configure ();
System . out . println ( "Rave configured successfully!" );
}
}
Getting your API keys
You need to obtain API keys from your Flutterwave dashboard:
Sign up for an account
Create a Flutterwave account:
Access your dashboard
Log in to your Flutterwave dashboard after account verification.
Navigate to API settings
Go to Settings > API in the dashboard menu.
Copy your keys
You’ll find two sets of keys:
Test keys : For use with Environment.STAGING
Live keys : For use with Environment.LIVE
Copy both the public key and secret key.
Keep your test and live keys separate. Consider using environment variables or configuration files to manage them.
Security best practices
Follow these best practices to keep your integration secure:
1. Never expose your secret key
// ❌ BAD: Hardcoding keys in source code
RaveConstant . SECRET_KEY = "FLWSECK-c45e0f704619e673263844e584bba013-X" ;
// ✅ GOOD: Loading from environment variables
RaveConstant . SECRET_KEY = System . getenv ( "FLUTTERWAVE_SECRET_KEY" );
2. Use environment variables
Store your API keys in environment variables instead of hardcoding them:
import com.github.theresasogunle.RaveConstant;
import com.github.theresasogunle.Environment;
public class SecureConfiguration {
public static void configure () {
// Load from environment variables
RaveConstant . PUBLIC_KEY = System . getenv ( "FLUTTERWAVE_PUBLIC_KEY" );
RaveConstant . SECRET_KEY = System . getenv ( "FLUTTERWAVE_SECRET_KEY" );
// Determine environment from config
String env = System . getenv ( "FLUTTERWAVE_ENV" );
RaveConstant . ENVIRONMENT = "LIVE" . equals (env)
? Environment . LIVE
: Environment . STAGING ;
}
}
3. Use configuration files
Alternatively, use a properties file (excluded from version control):
flutterwave.public.key =FLWPUBK-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-X
flutterwave.secret.key =FLWSECK-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-X
flutterwave.environment =STAGING
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import com.github.theresasogunle.RaveConstant;
import com.github.theresasogunle.Environment;
public class ConfigLoader {
public static void loadConfiguration ( String configPath ) throws IOException {
Properties props = new Properties ();
props . load ( new FileInputStream (configPath));
RaveConstant . PUBLIC_KEY = props . getProperty ( "flutterwave.public.key" );
RaveConstant . SECRET_KEY = props . getProperty ( "flutterwave.secret.key" );
String env = props . getProperty ( "flutterwave.environment" );
RaveConstant . ENVIRONMENT = "LIVE" . equalsIgnoreCase (env)
? Environment . LIVE
: Environment . STAGING ;
}
}
Add config.properties to your .gitignore file to prevent accidentally committing your API keys to version control.
4. Validate configuration
Always validate that configuration is complete before processing payments:
import com.github.theresasogunle.RaveConstant;
public class ConfigValidator {
public static void validateConfiguration () throws IllegalStateException {
if ( RaveConstant . PUBLIC_KEY == null || RaveConstant . PUBLIC_KEY . isEmpty ()) {
throw new IllegalStateException ( "PUBLIC_KEY is not configured" );
}
if ( RaveConstant . SECRET_KEY == null || RaveConstant . SECRET_KEY . isEmpty ()) {
throw new IllegalStateException ( "SECRET_KEY is not configured" );
}
if ( RaveConstant . ENVIRONMENT == null ) {
throw new IllegalStateException ( "ENVIRONMENT is not configured" );
}
System . out . println ( "Configuration validated successfully" );
System . out . println ( "Environment: " + RaveConstant . ENVIRONMENT );
}
}
5. Separate test and production configurations
import com.github.theresasogunle.RaveConstant;
import com.github.theresasogunle.Environment;
public class EnvironmentConfig {
public static void configureStaging () {
RaveConstant . PUBLIC_KEY = System . getenv ( "FLUTTERWAVE_TEST_PUBLIC_KEY" );
RaveConstant . SECRET_KEY = System . getenv ( "FLUTTERWAVE_TEST_SECRET_KEY" );
RaveConstant . ENVIRONMENT = Environment . STAGING ;
}
public static void configureProduction () {
RaveConstant . PUBLIC_KEY = System . getenv ( "FLUTTERWAVE_LIVE_PUBLIC_KEY" );
RaveConstant . SECRET_KEY = System . getenv ( "FLUTTERWAVE_LIVE_SECRET_KEY" );
RaveConstant . ENVIRONMENT = Environment . LIVE ;
}
}
Configuration checklist
Before going live, verify your configuration:
Test environment works
Verify that you can successfully process payments in staging mode with test keys.
Live keys obtained
Ensure you have valid live API keys from your production dashboard.
Keys are secured
Confirm that secret keys are stored in environment variables or secure configuration files, not in source code.
Environment switching
Verify that your application correctly switches between staging and live environments based on configuration.
Error handling
Test that your application handles missing or invalid configuration gracefully.
The library automatically handles encryption and API endpoints based on your environment setting. You don’t need to configure these manually.
Common configuration issues
Issue: NullPointerException when making API calls
Cause : Configuration was not set before making API calls.
Solution : Ensure you set all three RaveConstant properties before creating any charge objects.
Issue: “Invalid key” errors
Cause : Using test keys in live environment or vice versa.
Solution : Verify that your keys match your environment setting:
Test keys with Environment.STAGING
Live keys with Environment.LIVE
Issue: API calls failing in production
Cause : Environment is still set to STAGING in production.
Solution : Ensure RaveConstant.ENVIRONMENT = Environment.LIVE is set when deploying to production.
Next steps
Quickstart Process your first payment with your configured credentials
Card payments Learn about all card payment options and methods
Authentication Learn about authentication and API keys
Error handling Handle configuration and API errors gracefully