Retrieve available currencies
Last updated: 04-Jun-2021
Rate this article:
Overview
Use the getAvailableCurrencies method via JSON-RPC API 6.0 to get the list of available currencies. If the countryCode parameter is added, the paymentMethod parameter also becomes mandatory (you need to use both parameters or none).
Request Parameters
Parameter Name | Type | Required/Optional | Description |
---|---|---|---|
sessionId | String | Required | Session identifier, the output of the Login method. Include sessionId into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionId expires in 10 minutes. |
countryCode | String | Required | The ISO country code (two-letter code). If the countryCode parameter is used, the paymentMethod parameter must be used as well and both parameters are mandatory. |
paymentMethod | String | Required | The payment method for which you are retrieving the list of available currencies. |
Request Example
<?php
include('Config.php');
// Grab Config Values
$config = new ConfigScripts();
$apiVersion = '6.0';
$i = 1;
$host = 'http://api.avangate.local:8081/rpc/' . $apiVersion . "/";
// Login to get the session id;
$sessionID = $config->rpcLogin($host);
$countryCode = 'ro';
$paymentMethod = 'CC';
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getAvailableCurrencies',
// 'params' => [$sessionID]
'params' => [$sessionID, $countryCode, $paymentMethod]
);
$response = $config->callRPC($jsonRpcRequest, $host, true);
print_r(json_encode($response));
?>
Response
Parameter Name | Type | Description |
---|---|---|
currencies | Array | An array of currency objects. |
Response Example
[
{
"Code":"USD",
"ISO3DigitCode":"840",
"Label":"United States Dollar",
"Symbol":"$",
"SymbolPosition":"left",
"DecimalSeparator":".",
"UnitSeparator":",",
"Decimals":"2"
}
]
Rate this article: