Class Currency

java.lang.Object
paypal.payflow.Currency

public final class Currency extends Object
This class is used as the currency data type by all data and transaction objects.

This class should be used to denote any currency parameter. By default, the currency code is USD (US Dollars).

Following example shows how to use this class. ............. //inv is the Invoice object ............. *

//Set the currency object. Currency mt = new Currency(new Double(25.12)); // A valid amount is a two decimal value. // For values which have more than two decimal places Currency amt = new Currency(new Double(25.1214)); amt.setNoOfDecimalDigits( 2); //If the NoOfDecimalDigits property is used then it is mandatory to set one of the following properties to true. amt.setRound (true); amt.setTruncate (true); *

//Set the amount in the invoice object inv.setAmt( Amt); .............

  • Constructor Details

    • Currency

      public Currency(Double currValue)
      Constructor
      Parameters:
      currValue - Double

      Currency code is set as default USD.

      ............. //inv is the Invoice object ............. *

      //Set the invoice amount. inv.setAmt(new Currency(new Double(25.12))); *

      .............

    • Currency

      public Currency(Double currencyValue, String currCode)
      Constructor.
      Parameters:
      currencyValue - Double Currency value
      currCode - String 3 letter Currency code

      Currency code if not given is set as default USD.

      ............. //inv is the Invoice object ............. *

      //Set the invoice amount. inv.setAmt(new Currency(new Double(25.12),"USD")); *

      .............

  • Method Details

    • roundCurrencyValue

      protected String roundCurrencyValue(String currStringValue, int noOfdecimalDigits)
    • truncateCurrencyValue

      protected String truncateCurrencyValue(String currStringValue, int noOfdecimalDigits)
    • toString

      public String toString()
      Overrides ToString
      Overrides:
      toString in class Object
      Returns:
      String

      Formats string value of currency in format "$.CC"

      ............. //inv is the Invoice object ............. *

      //Set the invoice amount. inv.setAmt (new Currency(new Double(25.12),"USD")); String currValue = inv.ToString(); .............

    • getCurrencyCode

      public String getCurrencyCode()
      Gets the currency code.
      Returns:
      currencyCode
    • setNoOfDecimalDigits

      public void setNoOfDecimalDigits(int noOfDecimalDigits)
      Sets the number of decimal digits required after rounding or truncation.
      Parameters:
      noOfDecimalDigits - int
    • setRound

      public void setRound(boolean round)
      Sets Currency value rounding flag to true.
      Parameters:
      round - boolean . Note that only one of round OR truncate can be set to true.
    • setTruncate

      public void setTruncate(boolean truncate)
      Sets Currency value truncate flag to true.
      Parameters:
      truncate - boolean . Note that only one of round OR truncate can be set to true.
    • getError

      public String getError()
      Gets the error generated by the class.This should be used in case the toString() return blank.
      Returns:
      error String
    • getContext

      protected Context getContext()
    • setContext

      protected void setContext(Context context)
    • getRequestBuffer

      protected StringBuffer getRequestBuffer()
      Gets the Requestbuffer used for creating the actual request string.
      Returns:
      mRequestBuffer StringBuffer
    • setRequestBuffer

      protected void setRequestBuffer(StringBuffer value)
      sets the StringBuffer to hold the request string.
      Parameters:
      value - StringBuffer
    • generateRequest

      protected void generateRequest()