Forex

In order to display prices in currencies other than your channel's base currency, you can perform a GET request for your channel as shown in our API Documentation

As shown in the documentation, and below, the response object includes a field named forex_feed. This contains a rates object that contains all currencies available against your channel's base currency and the rate to apply to your base amount to obtain an amount in that currency.

Example of Channel response

Example

Your channel has a base currency of EUR, you are selling a product for EUR 99.99 and you wish to display a price in GBP.

Perform a GET Request for the channel GET {{url}}/wp-json/tmt/v2/channels/{{channel_id}}

var settings = {
    "url": "{{url}}/wp-json/tmt/v2/channels/{{channel_id}}",
    "method": "GET",
    "timeout": 0,
};

Obtain response.forex_feed.rates.GBP.rate using the documentation as an example, this would be 0.93881

$.ajax(settings).done(function (response) {
    var rate = response.forex_feed.rates.GBP.rate;
});

Multiply your base cost of EUR 99.99 by the rate: 99.99 * 0.93881 = 93.8716119

var paymentAmount = rate * baseAmount;

Round to the nearest cent value (rounding down from .5 where applicable) to get GBP 93.87.

var displayAmount = paymentAmount.toFixed(2);

results matching ""

    No results matching ""