bulkCurrencyConversion
Converts multiple amounts in a single method call.
Description
This method allows you to complete a large batch of currency conversions all at once without having to use the currencyConversion method for each conversion.
Currently this method supports bulk conversions from a single currency to another single currency and not several currencies simultaneously. (ie: if you want to convert fifty amounts from USD [US dollars] to CAD [Canadian dollars] and twenty amounts from USD to EUR [Euros] you would need to run two separate bulkCurrencyConversion method calls.)
To determine if a currency is supported by a merchant account, use either the getSupportedCurrencies or the getAccountDetails method.
Each currency type is assigned a three digit numeric code (ie: USD=840, Japanese yen=392). You must enter the three digit code for both the original currency and the converted currency in a conversion. The Currency Code list provides all of the three digit codes and their corresponding currencies for international currency conversion.
If you would like to add support for multi-currency transactions to a merchant account please contact the merchant's service provider or customer service.
See also currencyConversion, getSupportedCurrencies
Syntax
CurrencyConversion bulkCurrencyConversion ( ueSecurityToken Token, integer FromCurrency, integer ToCurrency, double Amounts )
Arguments
Type | Name | Description |
---|---|---|
ueSecurityToken | Token | Merchant security token: used to identify merchant and validate transaction. |
integer | FromCurrency | Currency code funds will be converted from. |
integer | ToCurrency | Currency code funds will be converted to. |
double | Amounts | Array of Amounts being converted. |
Return Value
Type | Description |
---|---|
CurrencyConversion | Returns conversion rates and amounts of currency converted. |
Examples
PHP
For directions on how to set up the WSDL link, create "$token" and "$client", go to PHP Soap How-to.
<?php
try {
$ToCurrency='978';
$FromCurrency='840';
$Amounts=array(
50.10,
11.23,
34.21,
12.23
);
$res=$client->bulkCurrencyConversion($mctoken, $FromCurrency, $ToCurrency, $Amounts);
print_r($res);
$this->assertEquals(count($res), count($Amounts));
$this->assertEquals($res[0]->FromCurrency, $FromCurrency);
$this->assertEquals($res[0]->Currency, $ToCurrency);
$this->assertEquals($res[0]->FromAmount, $Amounts[0]);
$this->assertTrue($res[0]->Rate > 0);
$this->assertTrue($res[0]->Amount > 0);
}
catch (SoapFault $e) {
die('Currency conversion failed : '.$e->getMessage());
}
?>
.NET VB
Dim from As String
Dim convert As String
Dim amount(0 To 2) As Double
from = "036"
convert = "826"
amount(0) = 10
amount(1) = 20
amount(2) = 30
Dim response() As newtek.CurrencyConversion
response = client.bulkCurrencyConversion(token, from, convert, amount)
MsgBox(response.Length)
.NET C
string from = "124";
string to = "826";
double[] amount = new double[3];
amount[0] = 10;
amount[1] = 5;
amount[2] = 19.99;
//newtek.CurrencyConversion response = new newtek.CurrencyConversion();
try
{
newtek.CurrencyConversion[] response = client.bulkCurrencyConversion(token, from, to, amount);
MessageBox.Show(string.Concat(response.Length));
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}