Skip to main content

Overview

The Fees class allows you to calculate transaction fees before processing a payment. This helps you display accurate fee information to your users and understand the costs associated with different transaction types.

Class: Fees

package com.github.theresasogunle;

public class Fees

Methods

getFees()

Calculates the transaction fee for a given amount and currency.
public JSONObject getFees()
Returns: JSONObject - Fee calculation details including the fee amount and total Description: This method calculates the standard transaction fee based on the amount and currency set in the class properties. The fee is calculated using Flutterwave’s standard fee structure.

Example

Fees fees = new Fees();
fees.setAmount("5000")
    .setCurrency("NGN");

JSONObject feeDetails = fees.getFees();
System.out.println("Fee: " + feeDetails.toString());

getFeesForCard6()

Calculates the transaction fee including international card fees based on the first 6 digits of the card number.
public JSONObject getFeesForCard6()
Returns: JSONObject - Fee calculation details including international fees if applicable Description: This method is used when the user has entered the first 6 digits of their card number. It helps determine international fees on the transaction if the card being used is an international card. The BIN (Bank Identification Number) is used to identify the card type and origin.

Parameters Required

Before calling this method, set the following properties:
amount
String
required
The transaction amount
currency
String
required
The currency code (e.g., “NGN”, “USD”, “GHS”)
card6
String
required
The first 6 digits of the card number (BIN)

Example

Fees fees = new Fees();
fees.setAmount("5000")
    .setCurrency("NGN")
    .setCard6("539983");

JSONObject feeDetails = fees.getFeesForCard6();
System.out.println("Fee with card check: " + feeDetails.toString());

Setter Methods

The Fees class uses a fluent interface pattern, allowing you to chain setter methods.

setAmount()

Sets the transaction amount.
public Fees setAmount(String amount)
amount
String
required
The transaction amount as a string
Returns: Fees - Returns the instance for method chaining

setCurrency()

Sets the currency for the transaction.
public Fees setCurrency(String currency)
currency
String
required
The currency code (e.g., “NGN”, “USD”, “GHS”, “KES”)
Returns: Fees - Returns the instance for method chaining

setCard6()

Sets the first 6 digits of the card number (BIN).
public Fees setCard6(String card6)
card6
String
required
The first 6 digits of the card number
Returns: Fees - Returns the instance for method chaining

Getter Methods

getAmount()

Retrieves the currently set amount.
public String getAmount()
Returns: String - The transaction amount

getCurrency()

Retrieves the currently set currency.
public String getCurrency()
Returns: String - The currency code

getCard6()

Retrieves the currently set card BIN.
public String getCard6()
Returns: String - The first 6 digits of the card number
All fee calculations require your public key to be configured in RaveConstant.PUBLIC_KEY.