developer:soap-1.6:methods:currencyconversion

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:soap-1.6:methods:currencyconversion [2012/08/04 11:26] (current)
tem created
Line 1: Line 1:
 +<embed ..:​contents/>​====== 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 =====
 +
 +[[..:​objects:​CurrencyConversion]] **currencyConversion** ( [[..:​objects:​ueSecurityToken]] Token, integer FromCurrency,​ integer ToCurrency, double Amount )
 +
 +===== Arguments =====
 +
 +^Type     ​^Name ​    ​^Description ​    ^
 +|[[..:​objects:​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 =====
 +
 +|[[..:​objects:​CurrencyConversion]] ​ |Returns the rate of conversion and the amount of the converted currency. |
 +
 +
 +===== Examples =====
 +==== PHP ====
 +
 +<code php>
 +<?php
 +
 +// for directions on how to set up the 
 +// WSDL link and create "​$mctoken"​ and "​$client,"​
 +// see: http://​wiki.usaepay.com/​developer/​soap/​howto ​
 +
 +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());​
 +}
 +
 +?> 
 +</​code>​
 +
 +==== .NET VB ====
 +<code vb>
 +
 +Dim from As String
 +        Dim convert As String
 +        Dim amount As Double
 +        from = "​036"​
 +        convert = "​826"​
 +        amount = 50
 +
 +        Dim response As usaepay.CurrencyConversion = New usaepay.CurrencyConversion
 +
 +        response = client.currencyConversion(token,​ from, convert, amount)
 +        MsgBox(response.Amount)
 +</​code>​
 +
 +==== .NET C# ====
 +<code c>
 +            string from = "​840";​
 +            string to = "​978";​
 +            int amount = 50;
 +
 +            usaepay.CurrencyConversion response = new usaepay.CurrencyConversion();​
 +
 +            try
 +            {
 +                response = client.currencyConversion(token,​ from, to, amount);
 +                MessageBox.Show(string.Concat(response.Amount));​
 +            }
 +
 +            catch (Exception err)
 +            {
 +                MessageBox.Show(err.Message);​
 +            }
 +</​code>​
 +
 +===== Change History =====
 +
 +^ Version ^ Change ^
 +| [[developer:​soap-1.4:​methods:​currencyconversion|1.4]] | FromCurrency and ToCurrency changed from integer to string |
 +| [[developer:​soap-1.1:​methods:​currencyconversion|1.1]] | Method added prior to soap-1.1 |
developer/soap-1.6/methods/currencyconversion.txt ยท Last modified: 2012/08/04 11:26 by tem

Page Tools