Retrieve available currencies

Use the getAvailableCurrencies method via SOAP 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
Type / Description

sessionId

Required (string) 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

Required (string) 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

Required (string) The payment method for which you are retrieving the list of available currencies.

Request sample

<?php

$apiVersion = '6.0';
$host = "http://api.avangate.local:8081/soap/".$apiVersion."/";

$client = new SoapClient($host."?wsdl", array('location' => $host, 'cache_wsdl' => WSDL_CACHE_NONE));
$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');

$merchantCode = "124231873235";
$key = "%&7+J[Q7T!B!1(z1e7&a";

$date = gmdate('Y-m-d H:i:s');
$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
$hash = hash_hmac('md5', $string, $key);

try {
    echo "login \r\n";
    $sessionID = $client->login($merchantCode, $date, $hash);
} catch (SoapFault $e) {
    echo  $e->getMessage();
}

print_r("session: ". $sessionID);

$countryCode = 'ro';
$paymentMethod = 'CC';

try {
//    $response = $client->getAvailableCurrencies($sessionID);
    $response = $client->getAvailableCurrencies($sessionID, $countryCode, $paymentMethod);
}

catch (SoapFault $e) {
    echo "VendorSettingsController.php: " . $e->getMessage();
    exit;
}
var_dump($response);

Response parameters

Parameter
Type / Description

currencies

Array An array of currency objects.

Response sample

Last updated

Was this helpful?