Set exchange rates (CurrencyCloud)

Updated on 31 May 2024

There are two options of getting exchange rates for the operations:

In our case, we use Currency Cloud (https://www.currencycloud.com/) as a third-party solution for getting currency exchange rates.

To switch between manual and automated mode (Currency Cloud) the system should be redeployed with corresponding changes in the YAML file.

1   rate:
2   exchange-rates:
3   ttl: PT6H
4   currency-cloud:
5   enabled: true
6   url: 'https://devapi.currencycloud.com/v2'
7   login-id: '...'
8   api-key: '...'

where:

  • TTL – a frequency of getting the updated rates from third-party
  • currency-cloud.enabled – true/false means turn on/turn off using Currency Cloud. If it’s turned off then the system uses manually set up exchange rates. If it’s turned on – the system gets exchange rates from Currency Cloud.

You need to create your own account in Currency Cloud in order to use it.

PaaS clients  need to provide us with their credentials in Currency Cloud, which include: login, password and API-key.

How it works

If rate.exchange-rates.currency-cloud.enabled = true

Call API to get exchange rates

permission: EXCHANGE_MANAGER, EXCHANGE_VIEWER
POST {{baseUrl}}/exchange-rates/view
request body
{
    "ratePairs": [
        {
            "inCurrencyId": "e0b47f2d-32d2-48bb-b5d6-ae4f7416da23",
            "outCurrencyId": "5a273b77-4a0a-4ffc-b979-6f0710c13f92"
        }
    ]
}
response body
{
    "records": [
        {
            "id": "5b9f9fa4-7c5e-4fcb-8de4-3fcb4b21c2e4",
            "inCurrency": {
                "id": "e0b47f2d-32d2-48bb-b5d6-ae4f7416da23",
                "sn": "USD",
                "code": "USD",
                "symbol": "$"
            },
            "outCurrency": {
                "id": "5a273b77-4a0a-4ffc-b979-6f0710c13f92",
                "sn": "EUR",
                "code": "EUR",
                "symbol": "€"
            },
            "rate": 0.843241,
            "exchanger": {
                "id": "234c927a-366d-4195-baba-b6f48c09f6bd",
                "type": "system",
                "name": "SDK.Finance",
                "organizationStatus": "approved",
                "contract_info": {
                    "id": "5e05abcd-9123-4827-a30b-3ac5027174d9",
                    "personType": "base",
                    "name": "base contract for org system"
                }
            },
            "active": true
        }
    ]
}
  • those rates that have already been created will update their values according to the configuration no later than 10 hours from the last update (ttl: PT10H can be changed in configuration)

  • those rates that have not been initialised will be initialised with new values received from CurrencyCloud