Skip to content
pCon.configurator onlineDocumentation
Esc
↑↓navigate↵open⌘Jpreview
On this page

Currencies

Synopsis

app.basket.currencies

Default Value: currencies

The default value is the base name of the currency configuration file, without suffix .cfg, located in directory etc/.

The value of this property must be an URI-reference. If this reference is relative (i.e. does not contain a scheme) and consists of a single path segment that does not contain a period then .cfg is appended to the reference. Relative references are then resolved against the URI representing the etc/ directory.

The URI is then matched against the pattern returned by method getSourceURIPattern() of currency provider factories to select the factory used to produce a currency provider.

To use a Fixer-compatible currency provider (see fixer.io), the session start-up file property app.basket.currencies must be set to the request URL used to access the Fixer-compatible web service. The following restrictions apply:

  • The path of the request URL must end with either /latest or with a slash followed by an ISO date.
  • The query component may contain only the following parameters:
Parameter Description
access_key the access key; required with data.fixer.io, but not necessarily required by alternative implementations of the service
base the base/reference currency; The default value is EUR. Note that this is also the only base currency supported by the free pricing plan of the fixer.io service.
symbols a comma-separated list of currency codes used to restrict the set of conversion rates provided by the web service; Without this parameter the fixer.io service returns about 170 conversion rates, and the exchangeratesapi.io service (see below) returns about 30 conversion rates.

Example:

http://data.fixer.io/api/latest?access_key=<access-key>

If the request path ends with /latest then the provider’s conversion rates are regularly updated a quarter past every full hour. This results in about 700 to 750 updates per month which is within the limit of the maximum number of monthly requests allowed by the free pricing plan of the fixer.io service as long as the access key is used by only one instance of EAIWS.

Responses from successful requests are cached in var/ebasket/currency/fixer/cache using a digest computed from the request URL as key (file name). The cache is used when the provider is first accessed after an EAIWS (re)start. If a matching entry is found then the behavior is as follows:

  • If the request path ends with an ISO date then the cached data is used.
  • If the request path ends with /latest then the connect and read timeouts for the request are both reduced to 5 seconds (instead of the default 30 seconds) and the cached data is used if the request does not produce a valid result (due to timeout or some other error).

To use this provider with other Fixer-compatible web service implementations they must be registered using application start-up property egr.eai.basket.currency.fixer.api_base. For instance, to use the open source Foreign exchange rates API that provides exchange rates published by the European Central Bank, the server start-up file should contain one or both of the following entries:

egr.eai.basket.currency.fixer.api_base=http://api.exchangeratesapi.io/
egr.eai.basket.currency.fixer.api_base=https://api.exchangeratesapi.io/

Then, the application or session start-up file property app.basket.currencies can be set to something like

https://api.exchangeratesapi.io/2019-03-18?base=USD&symbols=EUR,USD,RUB

The example references a currency provider that uses USD as base currency and provides the conversion rates for EUR, USD and RUB as published by the EZB for March 18, 2019.