Search.../

getConversionRate( )

Developer Preview

Returns the conversion rate between 2 currencies.

Description

This function is not a universal function and runs only on the backend.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getConversionRate(identifiers: GetConversionRateIdentifiers): Promise<ConversionRateResponse>

getConversionRate Parameters

NAME
TYPE
DESCRIPTION
identifiers
GetConversionRateIdentifiers

Identifying details needed to get the conversion rate. The combination of the from and to properties together comprise the unique ID.

Returns

Return Type:

Promise<
ConversionRateResponse
>
NAME
TYPE
DESCRIPTION
rate
DecimalValue

Conversion rate between 2 currencies.

rateTimestamp
Date

Date and time the conversion rate was last updated.

Was this helpful?

Return the conversion rate and timestamp

Copy Code
1import { currencies } from 'wix-ecom.v2';
2
3currencies.getConversionRate('USD', 'GBP')
4 .then((conversionRate) => {
5 const rate = conversionRate.rate;
6 const timestamp = conversionRate.rateTimestamp;
7 });
8
9/* Promise resolves to:
10 * {
11 * "rate": {
12 * value: "20",
13 * decimalPlaces: 2
14 * },
15 * "rateTimestamp": "2020-03-15T20:00:00.181Z"
16 * }
17 */