Skip to main content

Overview

The ExchangeRates class enables you to query real-time foreign exchange rates between different currencies. This is useful for displaying conversion rates to users or calculating cross-currency transaction amounts.

Class: ExchangeRates

Properties

PropertyTypeDescription
origin_currencyStringThe currency to convert from (e.g., “NGN”)
destination_currencyStringThe currency to convert to (e.g., “USD”)
amountStringThe amount to convert

Method: forex()

Queries the exchange rate between two currencies for a specified amount. Returns: JSONObject containing the exchange rate information

Usage Example

Setter Methods

The ExchangeRates class supports method chaining for convenient configuration:

setAmount(String amount)

Sets the amount to convert. Parameters:
  • amount: The amount as a string
Returns: ExchangeRates instance (for chaining)

setOrigin_currency(String currency)

Sets the source currency code. Parameters:
  • currency: Three-letter currency code (e.g., “NGN”, “USD”, “GBP”)
Returns: ExchangeRates instance (for chaining)

setDestination_currency(String currency)

Sets the target currency code. Parameters:
  • currency: Three-letter currency code (e.g., “USD”, “EUR”, “GHS”)
Returns: ExchangeRates instance (for chaining)
All three properties (amount, origin_currency, and destination_currency) must be set before calling the forex() method.

Supported Currencies

Flutterwave supports a wide range of currencies. Common examples include:
  • NGN - Nigerian Naira
  • USD - US Dollar
  • EUR - Euro
  • GBP - British Pound
  • GHS - Ghanaian Cedi
  • KES - Kenyan Shilling
  • ZAR - South African Rand
Exchange rates are queried in real-time and may fluctuate based on market conditions.

Use Cases

  • Display current exchange rates to customers
  • Calculate transaction amounts in different currencies
  • Provide currency conversion estimates before payment
  • Build multi-currency pricing displays
  • Implement currency converters in your application

Next Steps

Card Payments

Accept card payments in multiple currencies

Configuration

Configure your API keys