Skip to main content

Currency Exchange

Introduction

The Currency Exchange Service provides a solution for managing currency conversions in your application, enabling the creation and retrieval of exchange rate quotes, ensuring rate stability, and simplifying currency exchange integration.

Key Features:

  • Creating Currency Exchange Rate Quote.
  • Getting Currency Exchange Rate Quote.
note

The exchange rate includes the respective Paysafe fees. It should be noted, that because of the way Paysafe applies the fee some rounding might internally cause minor difference in the actual conversion output. Usually this would be in customer benefit.

Prerequisites

Before integrating the Currency Exchange Service, ensure you have:

  • A valid Paysafe account with appropriate permissions.
  • Set up instructions for Paysafe SDK Android or iOS.

To get started, initialize the CurrencyExchangeService instance in your app as shown below:

val currencyExchangeService = Wallet.getInstance().getCurrencyExchangeService()

Create a FxRate

To create a specific exchange rate quote, use the createQuote method, providing a FxRateRequest with the source and target currencies in ISO 4217 Format (e.g., "USD", "EUR"). This method returns a FxRate object that can be used to ensure stability and predictability for transactions. The created quote remains valid for a specified period, allowing you to avoid fluctuations in exchange rates during the transaction process.

  val fxRateRequest = FxRateRequest(sourceCurrency = "USD", targetCurrency = "EUR")
val fxRate = currencyExchangeService.createQuote(fxRateRequest)

Retrieve a FxRate

To retrieve a specific exchange rate, use the getQuote method by pass the unique ID of the quote to get a FxRate object with the details of the quote. Each quote has a limited validity period, during which it can be used to avoid fluctuations in exchange rates.

  val id = "404679be-ccbf-4528-b880-e14cc5041753"

val fxRate = currencyExchangeService.getQuote(id)

Exchange Currency

The exchange rate quote can be used to transfer money between two accounts for same customer. This is done by creating a CustomerTransferRequest without specifying a recipient but including the ID of the FX rate quote you created and then proceeding with the transfer normally as described here. If the quote has expired, the currency conversion/transfer will fail.

val fxRateRequest = FxRateRequest(sourceCurrency = "USD", targetCurrency = "EUR")
val fxRate = currencyExchangeService.createQuote(fxRateRequest)

val transferRequest = CustomerTransferRequest(
amount = 200,
currencyCode = "USD",
merchantRefNum = "2b01127a-4929-4d0e-b9cb-a29a8d1c499c",
fxQuote = fxRate.id,
transferDetails = TransferDetails(
reason = TransferReason.CURRENCY_EXCHANGE,
description = "Exchange USD to EUR"
)
)

val transferPreview = transferService.preview(transferRequest)
// Proceed with the transfer