Introduction

Use the currency converter to get currency conversion rate for any pair of supported currencies. You can also convert an array of amounts from one currency to another. The exchange rates are provided by XE on a daily basis and include the timestamp when they were set.

Did this help?

convertAmounts( )


Converts an array of one or more amounts from one currency to another.

Use the convertAmounts() function to convert an array of one or more amounts between two currencies. The convertAmounts() function returns a Promise that resolves to a ConvertedAmounts object which contains an array of converted amounts and the timestamp for the conversion rate used.

Note: The currency codes used must exist in the array returned by the getAllCurrencies() function.

Method Declaration
Copy
function convertAmounts(
  options: ConvertAmountsOptions,
): Promise<ConvertedAmounts>;
Method Parameters
optionsConvertAmountsOptionsRequired

Currencies and amounts to convert.

Returns
Return Type:Promise<ConvertedAmounts>
Convert an array of amounts from one currency to another.
JavaScript
import { currencies } from "wix-pay-backend"; let conversionOptions = { amounts: [1.0, 2.5, 5.3], from: "USD", to: "GBP", }; currencies.currencyConverter .convertAmounts(conversionOptions) .then((convertedAmounts) => { const firstConvertedAmount = convertedAmounts.amounts[0]; const timestamp = convertedAmounts.timestamp; }); /* convertedAmounts: * { * "amounts":[0.8149261982, 2.0373154955, 4.31910885046], * "timestamp": "2020-03-15T21:00:00.277Z" * } */
Did this help?