Search…
Merchants and Currencies
The Virtual Cards Simulator comes pre-configured with a number of merchants and currency conversion rates.
The Virtual Cards Simulator comes pre-configured with a number of merchants that have a variety of characteristics that allow you to simulate different transactions. It also contains a small number of currency conversion rates.
Some merchants have specific behaviors that will cause particular decline codes to be generated when an authorization is requested. The returned SimulatorMerchant objects have a description field that provides a brief description of any special behavior of that merchant.

List the Simulator Merchants

The merchants that are defined in the simulator can be fetched by calling the getSimulatorMerchants API.
There are only a small number of merchants defined in the simulator, so this API does not require the results to be paged.
An example implementation of listing the merchants is:
TypeScript
Swift
Kotlin
1
try {
2
const result = await simulatorClient.listSimulatorMerchants()
3
} catch (error) {
4
// Handle error
5
}
Copied!
1
simulatorClient.getSimulatorMerchants() { result in
2
switch result {
3
case .success:
4
// Find a hotel or motel
5
let hotel = try result.get().first { $0.mcc == "7011" }
6
case .failure:
7
// Handle/notify the user of exception
8
}
9
}
Copied!
1
launch {
2
try {
3
val merchants = withContext(Dispatchers.IO) {
4
simulatorClient.getSimulatorMerchants()
5
}
6
// Find a hotel or motel
7
val hotel = merchants.find { it.mcc == "7011" }
8
} catch (e: GetSimulatorMerchantsException) {
9
// Handle/notify the user of exception
10
}
11
}
Copied!
If an exception occurs, the error or exception will contain a description of the fault that caused the exception.

List the Simulator Conversion Rates

The currency conversion rates that are defined in the simulator can be fetched by calling the getSimulatorConversionRates API.
There are only a small number of conversion rates defined in the simulator, so this API does not require the results to be paged.
An example implementation of listing the conversion rates is:
TypeScript
Swift
Kotlin
1
try {
2
const rates = await simulatorClient.listSimulatorMerchants()
3
const usd = rates.find((r) => { r.currency == "USD" })
4
const aud = rates.find((r) => { r.currency == "AUD" })
5
if (usd && aud) {
6
const usdToAud = Number(usd.amount) / Number(aud.amount)
7
console.log(`USD to AUD ${usdToAud}`)
8
}
9
} catch (error) {
10
// Handle error
11
}
Copied!
1
simulatorClient.getSimulatorConversionRates() { result in
2
switch result {
3
case .success:
4
let rates = try result.get()
5
let usd = rates.first { $0.currency == "USD" }
6
let aud = rates.first { $0.currency == "AUD" }
7
if usd != nil && aud != nil {
8
let usdToAud = Double(usd!.amount) / Double(aud!.amount)
9
print("USD to AUD \(usdToAud)")
10
}
11
case .failure:
12
// Handle/notify the user of exception
13
}
14
}
Copied!
1
launch {
2
try {
3
val rates = withContext(Dispatchers.IO) {
4
simulatorClient.getSimulatorConversionRates()
5
}
6
// Find the rate of USD to AUD
7
val usd = rates.find { it.currency == "USD" }
8
val aud = rates.find { it.currency == "AUD" }
9
val usdToAud = usd.amount.toDouble() /
10
aud.amount.toDouble()
11
println("USD to AUD $usdToAud")
12
} catch (e: GetSimulatorConversionRatesException) {
13
// Handle/notify the user of exception
14
}
15
}
Copied!
The list of CurrencyAmount classes returned contain the currency code and the conversion rate amount expressed as an Int. To convert between two currencies find the CurrencyAmount class for each currency, convert the amount to a Double then divide the two rates. If an exception occurs, the error or exception will contain a description of the fault that caused the exception.
Last modified 14d ago