currencyConversion

Find currency conversion rate for a transaction amount.

Description

This method allows you to determine the rate of conversion for different currencies in multi-currency transactions. A merchant account must have support for specific types of currency before it will be able to run multi-currency transactions.

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 bulkCurrencyConversion, getSupportedCurrencies, getAccountDetails

Syntax

CurrencyConversion currencyConversion ( ueSecurityToken Token, integer FromCurrency, integer ToCurrency, double Amount )

Arguments

Type Name Description
ueSecurityToken Token Merchant security token: used to identify merchant and validate transaction.
string FromCurrency Currency code funds will be converted from.
string ToCurrency Currency code funds will be converted to.
double Amount Amount of currency to be converted.

Return Value

Type Description
CurrencyConversion Returns the rate of conversion and the amount of the converted currency.

Examples

PHP

    <?php

    // for directions on how to set up the
    // WSDL link and create "$mctoken" and "$client,"

    try {

       $ToCurrency='978';
       $FromCurrency='840';
       $Amount=50;    

       $res=$client->currencyConversion($mctoken, $FromCurrency, $ToCurrency, $Amount);
              print_r($res);

       $this->assertEquals($res->FromCurrency, $FromCurrency);

       $this->assertEquals($res->Currency, $ToCurrency);

       $this->assertTrue($res->Rate > 0);

       $this->assertTrue($res->Amount > 0);

    } catch (SoapFault $e) {
         echo $client->__getLastRequest();
         echo $client->__getLastResponse();
         die('Currency conversion failed : '.$e->getMessage());
    }

    ?>

.NET VB


    Dim from As String
            Dim convert As String
            Dim amount As Double
            from = "036"
            convert = "826"
            amount = 50

            Dim response As newtek.CurrencyConversion = New newtek.CurrencyConversion

            response = client.currencyConversion(token, from, convert, amount)
            MsgBox(response.Amount)

.NET C

                string from = "840";
                string to = "978";
                int amount = 50;

                newtek.CurrencyConversion response = new newtek.CurrencyConversion();

                try
                {
                    response = client.currencyConversion(token, from, to, amount);
                    MessageBox.Show(string.Concat(response.Amount));
                }

                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }