Class PayflowUtility

java.lang.Object
paypal.payflow.PayflowUtility

public final class PayflowUtility extends Object
This class contains all the utility function's which may be required during a transaction.
  • Method Details

    • getRequestId

      public static String getRequestId()
      Generates Request Id. This can be used to generate a random request id.
      Returns:
      strRet
    • getStringValue

      protected static String getStringValue(byte[] byteArray, int length)
      get the string value.
      Parameters:
      byteArray - byte
      length - int
      Returns:
      strRet String
    • getTraceInitialized

      protected static boolean getTraceInitialized()
      Gets, sets mTraceInitialized
      Returns:
      mTraceInitialized
    • setTraceInitialized

      protected static void setTraceInitialized(boolean value)
      Parameters:
      value - boolean
    • appendToRequest

      protected static String appendToRequest(String name, Object value)
      Appends a name value pair to request
      Parameters:
      name - String
      value - Object
      Returns:
      RetVal String
    • StringValueLength

      public static String StringValueLength(String StringValue)
    • locateValueForName

      public static String locateValueForName(String paramList, String name, boolean maskFoundValue)
      Locates value from name value pair and masks or returns it.
      Parameters:
      paramList - String
      name - String
      maskFoundValue - boolean
      Returns:
      value String
    • isTimedOut

      protected static boolean isTimedOut(long timeoutMsec, long startTimeMsec)
      Check if timeout has occurred
      Parameters:
      timeoutMsec - long
      startTimeMsec - long
      Returns:
      true if timed out false if not.
    • getXmlVersion

      protected static String getXmlVersion(String request) throws Exception
      Retrieves XmlPay version from Xml Pay Request.
      Parameters:
      request - String
      Returns:
      version String
      Throws:
      Exception - Exception
    • getXmlAttribute

      protected static String getXmlAttribute(String request, String attribute) throws Exception
      Retrieves value of given Xml attribute from Xml Pay Request.
      Parameters:
      request - String
      attribute - String
      Returns:
      attributeValue String
      Throws:
      Exception - Exception
    • getXmlNameSpace

      protected static String getXmlNameSpace(String request) throws Exception
      Gets the Xml Namespace from the XmlPay Request.
      Parameters:
      request - String
      Returns:
      xmlNameSapce String
      Throws:
      Exception - Exception
    • getXmlNodeValue

      protected static String getXmlNodeValue(Document xmlPayRequest, String nodeName)
      Gets the inner text from an xml node.
      Parameters:
      xmlPayRequest - Document
      nodeName - String
      Returns:
      retVal String
    • requestIdFromParamList

      protected static String requestIdFromParamList(boolean isXmlPayReq, String transRequest) throws Exception
      Retrieves request id from param list.
      Parameters:
      isXmlPayReq - boolean
      transRequest - String
      Returns:
      requestId String
      Throws:
      Exception - Exception
    • populateCommError

      protected static ErrorObject populateCommError(String commMessageCode, Exception ex, int severityLevel, boolean isXmlPayReq, String addMessage)
      Populates Errors from Exceptions.
      Parameters:
      commMessageCode - String
      ex - Exception
      severityLevel - int
      isXmlPayReq - boolean
      addMessage - String
      Returns:
      initError ErrorObject
    • maskSensitiveFields

      protected static String maskSensitiveFields(String parmList)
      Masks the sensitive fields in the param list which will be used for logging purpose.
      Parameters:
      parmList - String
      Returns:
      retVal String
    • maskXMLPayRequest

      protected static String maskXMLPayRequest(String parmList) throws Exception
      Masks XMLPay Request
      Parameters:
      parmList - String
      Returns:
      maskedRequest String
      Throws:
      Exception - Exception
    • maskNVPRequest

      protected static String maskNVPRequest(String parmList)
      Masks NVP Request
      Parameters:
      parmList - String
      Returns:
      maskedRequest String
    • maskXmlNodeValue

      protected static void maskXmlNodeValue(Document xmlPayRequest, String nodeName)
      masks an xmlNodeValue
      Parameters:
      xmlPayRequest - Document
      nodeName - String
    • getXmlPayNodeValue

      protected static String getXmlPayNodeValue(String xmlPayRequest, String nodeName)
      Gets the inner text of a node from an XMLPay request
      Parameters:
      xmlPayRequest - String
      nodeName - String
      Returns:
      retVal String
    • getStatus

      public static String getStatus(String transactionResponse)
      Provides the status of the transaction based on the transaction response.
      Parameters:
      transactionResponse - String
      Returns:
      status String
    • alignContext

      protected static ArrayList alignContext(Context context, boolean isXmlPayRequest)
      Parameters:
      context - Context
      isXmlPayRequest - boolean
      Returns:
      errors Arraylist
    • format

      protected static String format(String msgBody, String[] msgParams)
      This function will be used to form the string with the context details.
      Parameters:
      msgBody - String
      msgParams - String[]
      Returns:
      msgBody String
    • getStatus

      public static String getStatus(Response resp)
      Provides the status (as a String) of the transaction based on the transaction response.
      Parameters:
      resp - - Response obtained from PayPal Payment Gateway.
      Returns:
      - String result for the transaction: If Transaction Result = 0 then 'Transaction Successful.' else 'Transaction Failed.'
    • getTransactionStatus

      public static boolean getTransactionStatus(Response resp)
      Returns a boolean value indicating the status of the transaction
      Parameters:
      resp - - Response obtained from PayPal Payment Gateway.
      Returns:
      - true if transaction was success