My Profile_


MCP Get Rate

NEW!   We now have our Interactive tool for this section.

Performs a foreign currency exchange rate look-up, and secures that exchange rate for use in a subsequent MCP financial transaction. .

The exchange rate retrieved by this transaction request is represented in the response as the RateToken, and the underlying exchange rate is locked in for a limited time period

MCP Get Rate transaction object definition

MCPGetRate getRate = new MCPGetRate();

HttpsPostRequest object for MCP Get Rate transaction

HttpsPostRequest mpgReq = new HttpsPostRequest();

mpgReq.setTransaction(getRate);

Canada Code Sample

package Canada;

import JavaAPI.*;

public class TestCanadaMCPGetRate
{
	public static void main(String[] args)
	{
	String store_id = "store5";
        String api_token = "yesguy";
        String processing_country_code = "CA";
        
        
        MCPGetRate getRate = new MCPGetRate();
        getRate.setMCPVersion("1.0");   //MCP Version number.  Should always be 1.0
        getRate.setRateTxnType("P");    //P or R are valid values (Purchase or Refund)
        
        MCPRate rate = new MCPRate();
        rate.addCardholderAmount("500", "840");   //penny value amount 1.25 = 125. Foreign amount and SO-4217 country currency number    
        //rate.addMerchantSettlementAmount("200", "826");   //penny value amount 1.25 = 125. Domestic(CAD) amount and SO-4217 country currency number
        //rate.addMerchantSettlementAmount("300", "036");   //penny value amount 1.25 = 125. Domestic(CAD) amount and SO-4217 country currency number
               
        getRate.setMCPRateInfo(rate);
        
        HttpsPostRequest mpgReq = new HttpsPostRequest();
        mpgReq.setProcCountryCode(processing_country_code);
        mpgReq.setTestMode(true);   //false or comment out this line for production transactions
        mpgReq.setStoreId(store_id);
        mpgReq.setApiToken(api_token);
        mpgReq.setTransaction(getRate);
        mpgReq.send();
        
        try
        {
            Receipt receipt = mpgReq.getReceipt();
            
            System.out.println("RateTxnType = " + receipt.getRateTxnType());
            System.out.println("MCPRateToken = " + receipt.getMCPRateToken());
            
            System.out.println("RateInqStartTime = " + receipt.getRateInqStartTime());  //The time (unix UTC) of when the rate is requested
            System.out.println("RateInqEndTime = " + receipt.getRateInqEndTime());  //The time (unix UTC) of when the rate is returned
            System.out.println("RateValidityStartTime = " + receipt.getRateValidityStartTime());    //The time (unix UTC) of when the rate is valid from
            System.out.println("RateValidityEndTime = " + receipt.getRateValidityEndTime());    //The time (unix UTC) of when the rate is valid until
            System.out.println("RateValidityPeriod = " + receipt.getRateValidityPeriod());  //The time in minutes this rate is valid for
            
            System.out.println("ResponseCode = " + receipt.getResponseCode());
            System.out.println("Message = " + receipt.getMessage());
            System.out.println("Complete = " + receipt.getComplete());
            System.out.println("TransDate = " + receipt.getTransDate());
            System.out.println("TransTime = " + receipt.getTransTime());
            System.out.println("TimedOut = " + receipt.getTimedOut());
            
            //RateData
			for (int index = 0; index < receipt.getRatesCount(); index++)
			{
                System.out.println("MCPRate = " + receipt.getMCPRate(index));
                System.out.println("MerchantSettlementCurrency = " + receipt.getMerchantSettlementCurrency(index));
                System.out.println("MerchantSettlementAmount = " + receipt.getMerchantSettlementAmount(index));    //Domestic(CAD) amount
                System.out.println("CardholderCurrencyCode = " + receipt.getCardholderCurrencyCode(index));
                System.out.println("CardholderAmount = " + receipt.getCardholderAmount(index));    //Foreign amount
                
                System.out.println("MCPErrorStatusCode = " + receipt.getMCPErrorStatusCode(index));
                System.out.println("MCPErrorMessage = " + receipt.getMCPErrorMessage(index));
            }
            
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
	}
}
                

MCP Get Rate Transaction Request Fields – Required

Variable Name Type and Limits Set Method Description
MCP version number

String

current version is 1.0

getRate.setMCPVersion("MCP_ VERSION_NUM"); Release version number for MCP
rate transaction type

String

1-character alphabetic

purchase (P) or refund (R)

getRate.setRateTxnType ("TRANSACTION_TYPE_VALUE");

Value representing the type of subsequent transaction request that the rate token will be used for.

Allowable values:

P – Purchase

R – Refund

MCP Rate Info

Object

N/A

getRate.setMCPRateInfo(rate); Nested object in the MCP Get Rate transaction containing the add cardholder amount and add merchant settlement fields

MCP Get Rate Info Object Fields

At least one of the following variables must be sent:

Variable Name Type and Limits Set Method Derscription
add cardholder amount

String array

12-character numeric, 3- character numeric

(smallest discrete unit of foreign currency, currency code)

rate.addCardholderAmount ("FOREIGN_AMT", "FOREIGN_ CURRENCY_CODE"); A string array representing:
  • the amount, in units of foreign currency, the cardholder will be charged, and
  • the ISO currency code corresponding to the foreign currency of the cardholder
add merchant settlement amount

String array

12-character numeric, 3- character numeric

(amount in CAD pennies, currency code)

rate.addMerchantSettlementAmount("CAD_AMOUNT", "FOREIGN_ CURRENCY_CODE"); A string array representing:
  • the amount the merchant will receive in the transaction, in Canadian dollars
  • the ISO currency code corresponding to the foreign currency of the cardholder