Skip to main content

Overview

The Endpoints class manages all API endpoint URLs for the Flutterwave Rave Java Library. It automatically configures endpoints based on the environment setting (staging or live) and provides getter methods to access properly formatted endpoint URLs.

Class Definition

public class Endpoints

Public Fields

Endpoint Constants

BANK_ENDPOINT
String
Endpoint for retrieving the list of supported banks.Access: public
CHARGE_ENDPOINT
String
Endpoint for initiating payment charges.Access: public static
CARD_VALIDATE_ENDPOINT
String
Endpoint for validating card charges (OTP, PIN, etc.).Access: public static
ACCOUNT_VALIDATE_ENDPOINT
String
Endpoint for validating account/bank charges.Access: public static
TIMEOUT_ENDPOINT
String
Endpoint for handling timeout scenarios with polling enabled.Access: public static
POLL_ENDPOINT
String
Endpoint for polling transaction status.Access: public static
FEES_ENDPOINT
String
Endpoint for calculating transaction fees.Access: public static
REFUND_ENDPOINT
String
Endpoint for processing refunds.Access: public static
FOREX_ENDPOINT
String
Endpoint for foreign exchange rate queries.Access: public static
VERIFY_TRANSACTION_ENDPOINT
String
Endpoint for verifying transaction status.Access: public static
VERIFY_XREQUERY_ENDPOINT
String
Endpoint for cross-verifying transaction queries.Access: public static
CAPTURE_ENDPOINT
String
Endpoint for capturing pre-authorized transactions.Access: public static
REFUNDVOID_ENDPOINT
String
Endpoint for refunding or voiding transactions.Access: public static
CHARGE_TIMEOUT_ENDPOINT
String
Endpoint for initiating charges with timeout polling.Access: public static
VALIDATE_CARD_CHARGE_TIMEOUT_ENDPOINT
String
Endpoint for validating card charges with timeout polling.Access: public static
VALIDATE_ACCOUNT_CHARGE_TIMEOUT_ENDPOINT
String
Endpoint for validating account charges with timeout polling.Access: public static

Public Methods

getBankEndPoint()

public String getBankEndPoint()
Retrieves the endpoint URL for fetching supported banks. Returns: String - The complete bank endpoint URL based on current environment

getChargeEndPoint()

public String getChargeEndPoint()
Retrieves the endpoint URL for initiating payment charges. Returns: String - The complete charge endpoint URL

getValidateCardChargeEndPoint()

public String getValidateCardChargeEndPoint()
Retrieves the endpoint URL for validating card charges. Returns: String - The complete card validation endpoint URL

getValidateAccountChargeEndPoint()

public String getValidateAccountChargeEndPoint()
Retrieves the endpoint URL for validating account/bank charges. Returns: String - The complete account validation endpoint URL

getFeesEndPoint()

public String getFeesEndPoint()
Retrieves the endpoint URL for calculating transaction fees. Returns: String - The complete fees endpoint URL

getRefundEndPoint()

public String getRefundEndPoint()
Retrieves the endpoint URL for processing refunds. Returns: String - The complete refund endpoint URL

getForexEndPoint()

public String getForexEndPoint()
Retrieves the endpoint URL for foreign exchange queries. Returns: String - The complete forex endpoint URL

getVerifyEndPoint()

public String getVerifyEndPoint()
Retrieves the endpoint URL for verifying transactions. Returns: String - The complete verification endpoint URL

getVerifyXrequeryEndPoint()

public String getVerifyXrequeryEndPoint()
Retrieves the endpoint URL for cross-verifying transaction queries. Returns: String - The complete xrequery endpoint URL

getCaptureEndPoint()

public String getCaptureEndPoint()
Retrieves the endpoint URL for capturing pre-authorized transactions. Returns: String - The complete capture endpoint URL

getRefundOrVoidEndPoint()

public String getRefundOrVoidEndPoint()
Retrieves the endpoint URL for refunding or voiding transactions. Returns: String - The complete refund/void endpoint URL

getChargeTimeoutEndpoint()

public String getChargeTimeoutEndpoint()
Retrieves the endpoint URL for initiating charges with timeout polling enabled. Returns: String - The complete charge timeout endpoint URL

getValidateCardChargeTimeoutEndpoint()

public String getValidateCardChargeTimeoutEndpoint()
Retrieves the endpoint URL for validating card charges with timeout polling. Returns: String - The complete card validation timeout endpoint URL

getValidateAccountChargeTimeoutEndpoint()

public String getValidateAccountChargeTimeoutEndpoint()
Retrieves the endpoint URL for validating account charges with timeout polling. Returns: String - The complete account validation timeout endpoint URL

Usage Example

Basic Usage

import com.github.theresasogunle.Endpoints;
import com.github.theresasogunle.RaveConstant;
import com.github.theresasogunle.Environment;

// Configure environment first
RaveConstant.PUBLIC_KEY = "FLWPUBK_TEST-xxxxxxxxxxxxx-X";
RaveConstant.SECRET_KEY = "FLWSECK_TEST-xxxxxxxxxxxxx-X";
RaveConstant.ENVIRONMENT = Environment.STAGING;

// Create Endpoints instance
Endpoints endpoints = new Endpoints();

// Get specific endpoint URLs
String chargeUrl = endpoints.getChargeEndPoint();
String verifyUrl = endpoints.getVerifyEndPoint();
String bankUrl = endpoints.getBankEndPoint();

System.out.println("Charge URL: " + chargeUrl);
// Output: Charge URL: https://ravesandboxapi.flutterwave.com/flwv3-pug/getpaidx/api/charge

Environment-Aware Endpoints

import com.github.theresasogunle.Endpoints;
import com.github.theresasogunle.RaveConstant;
import com.github.theresasogunle.Environment;

// Configure for live environment
RaveConstant.ENVIRONMENT = Environment.LIVE;

Endpoints endpoints = new Endpoints();
String chargeUrl = endpoints.getChargeEndPoint();
// Returns: https://api.ravepay.co/flwv3-pug/getpaidx/api/charge

// Switch to staging
RaveConstant.ENVIRONMENT = Environment.STAGING;
Endpoints newEndpoints = new Endpoints();
String stagingChargeUrl = newEndpoints.getChargeEndPoint();
// Returns: https://ravesandboxapi.flutterwave.com/flwv3-pug/getpaidx/api/charge
Each getter method automatically calls init() internally, which configures all endpoints based on the current RaveConstant.ENVIRONMENT setting. The endpoints dynamically switch between staging and live URLs.

How It Works

  1. Initialization: When any getter method is called, it triggers the init() method
  2. Environment Check: The init() method checks RaveConstant.ENVIRONMENT
  3. URL Selection: Based on the environment, either staging or live base URL is selected:
    • Staging: https://ravesandboxapi.flutterwave.com/
    • Live: https://api.ravepay.co/
  4. Endpoint Construction: All endpoint constants are constructed by appending specific paths to the base URL
  5. Return Value: The getter method returns the fully qualified endpoint URL

Best Practices

  • Always configure RaveConstant.ENVIRONMENT before creating Endpoints instances
  • Create new instances if you switch environments to ensure fresh endpoint configuration
  • Use getter methods instead of accessing fields directly for guaranteed initialization
  • Cache endpoint instances within the same environment context to avoid repeated initialization
  • RaveConstant - Configuration class that stores environment settings
  • Environment - Environment enum used for endpoint selection