Gets a currency conversion rate.
The getConversionRate()
function returns a Promise that resolves to a ConversionRate
object, which contains the currency conversion rate between two currencies. The exchange rates are provided by XE on a daily basis and include the timestamp when they were set.
Note: By using this function you agree to XE's Terms of Use.
function getConversionRate(
sourceCurrency: string,
targetCurrency: string,
): Promise<ConversionRate>;
Currency to convert from.
Currency to convert to.
import { currencies } from "wix-pay-backend";
currencies.currencyConverter
.getConversionRate("USD", "GBP")
.then((conversionRate) => {
const rate = conversionRate.rate;
const timestamp = conversionRate.timestamp;
});
/* conversionRate:
* {
* "rate": 0.8152242392,
* "timestamp": "2020-03-15T20:00:00.181Z"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.