Contents
On this page

Test Rate Provider - Plugixa Multi Currency for WooCommerce

POST /plugixa-multi-currency/v1/pro/rates/providers/{id}/test

Fetch rates from one provider for all your currencies and show them, without changing any rate. This is the Test button of a provider.

Needs a user with the plugixa_multi_currency_manage_settings capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators hold it; see Capabilities.

Note. Pro only: on the free plugin this route answers 404 rest_no_route.

Request

POST https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/rates/providers/ecb/test

Path parameters

Name Type Description
id string The provider id, for example ecb or fixer

Request body

Content type: application/json

No body. A provider that needs a key uses the saved one.

Responses

200 OK, the provider answered.

{
  "success": true,
  "data": {
    "ok": true,
    "rates": {
      "EUR": "0.9099181073",
      "GBP": "0.7619199272",
      "CAD": "1.4306642402",
      "AUD": "1.5001819836",
      "JPY": "158.64422202",
      "CHF": "0.8392174704",
      "INR": "92.6751592356"
    },
    "missing": []
  }
}
Field Type Meaning
ok boolean true
rates object Currency code to rate, for 1 unit of your store currency
missing string[] Your currencies the provider does not publish

200 OK, the provider failed.

{
  "success": true,
  "data": {
    "ok": false,
    "message": "Fixer needs an API key."
  }
}

message says why: no key, a refused key, a network error and so on.

Errors

Status Code When
401 / 403 rest_forbidden The caller lacks the capability: Sorry, you are not allowed to do that.
404 plugixa_multi_currency_unknown_provider Unknown rate provider.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/rates/providers/ecb/test" \
  -u "$WP_USER:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/rates/providers/ecb/test');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/rates/providers/ecb/test', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
  },
});
const { data } = await response.json();

Quick Links

Share