Package paypal.payflow
Class PayflowUtility
java.lang.Object
paypal.payflow.PayflowUtility
This class contains all the utility function's which may be required during a transaction.
-
Method Summary
Modifier and TypeMethodDescriptionprotected static ArrayListalignContext(Context context, boolean isXmlPayRequest) protected static StringappendToRequest(String name, Object value) Appends a name value pair to requestprotected static StringThis function will be used to form the string with the context details.static StringGenerates Request Id.static StringProvides the status of the transaction based on the transaction response.static StringProvides the status (as a String) of the transaction based on the transaction response.protected static StringgetStringValue(byte[] byteArray, int length) get the string value.protected static booleanGets, sets mTraceInitializedstatic booleangetTransactionStatus(Response resp) Returns a boolean value indicating the status of the transactionprotected static StringgetXmlAttribute(String request, String attribute) Retrieves value of given Xml attribute from Xml Pay Request.protected static StringgetXmlNameSpace(String request) Gets the Xml Namespace from the XmlPay Request.protected static StringgetXmlNodeValue(Document xmlPayRequest, String nodeName) Gets the inner text from an xml node.protected static StringgetXmlPayNodeValue(String xmlPayRequest, String nodeName) Gets the inner text of a node from an XMLPay requestprotected static StringgetXmlVersion(String request) Retrieves XmlPay version from Xml Pay Request.protected static booleanisTimedOut(long timeoutMsec, long startTimeMsec) Check if timeout has occurredstatic StringlocateValueForName(String paramList, String name, boolean maskFoundValue) Locates value from name value pair and masks or returns it.protected static StringmaskNVPRequest(String parmList) Masks NVP Requestprotected static StringmaskSensitiveFields(String parmList) Masks the sensitive fields in the param list which will be used for logging purpose.protected static voidmaskXmlNodeValue(Document xmlPayRequest, String nodeName) masks an xmlNodeValueprotected static StringmaskXMLPayRequest(String parmList) Masks XMLPay Requestprotected static ErrorObjectpopulateCommError(String commMessageCode, Exception ex, int severityLevel, boolean isXmlPayReq, String addMessage) Populates Errors from Exceptions.protected static StringrequestIdFromParamList(boolean isXmlPayReq, String transRequest) Retrieves request id from param list.protected static voidsetTraceInitialized(boolean value) static StringStringValueLength(String StringValue)
-
Method Details
-
getRequestId
Generates Request Id. This can be used to generate a random request id.- Returns:
- strRet
-
getStringValue
get the string value.- Parameters:
byteArray- bytelength- 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
Appends a name value pair to request- Parameters:
name- Stringvalue- Object- Returns:
- RetVal String
-
StringValueLength
-
locateValueForName
Locates value from name value pair and masks or returns it.- Parameters:
paramList- Stringname- StringmaskFoundValue- boolean- Returns:
- value String
-
isTimedOut
protected static boolean isTimedOut(long timeoutMsec, long startTimeMsec) Check if timeout has occurred- Parameters:
timeoutMsec- longstartTimeMsec- long- Returns:
- true if timed out false if not.
-
getXmlVersion
Retrieves XmlPay version from Xml Pay Request.- Parameters:
request- String- Returns:
- version String
- Throws:
Exception- Exception
-
getXmlAttribute
Retrieves value of given Xml attribute from Xml Pay Request.- Parameters:
request- Stringattribute- String- Returns:
- attributeValue String
- Throws:
Exception- Exception
-
getXmlNameSpace
Gets the Xml Namespace from the XmlPay Request.- Parameters:
request- String- Returns:
- xmlNameSapce String
- Throws:
Exception- Exception
-
getXmlNodeValue
Gets the inner text from an xml node.- Parameters:
xmlPayRequest- DocumentnodeName- String- Returns:
- retVal String
-
requestIdFromParamList
protected static String requestIdFromParamList(boolean isXmlPayReq, String transRequest) throws Exception Retrieves request id from param list.- Parameters:
isXmlPayReq- booleantransRequest- 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- Stringex- ExceptionseverityLevel- intisXmlPayReq- booleanaddMessage- String- Returns:
- initError ErrorObject
-
maskSensitiveFields
Masks the sensitive fields in the param list which will be used for logging purpose.- Parameters:
parmList- String- Returns:
- retVal String
-
maskXMLPayRequest
Masks XMLPay Request- Parameters:
parmList- String- Returns:
- maskedRequest String
- Throws:
Exception- Exception
-
maskNVPRequest
Masks NVP Request- Parameters:
parmList- String- Returns:
- maskedRequest String
-
maskXmlNodeValue
masks an xmlNodeValue- Parameters:
xmlPayRequest- DocumentnodeName- String
-
getXmlPayNodeValue
Gets the inner text of a node from an XMLPay request- Parameters:
xmlPayRequest- StringnodeName- String- Returns:
- retVal String
-
getStatus
Provides the status of the transaction based on the transaction response.- Parameters:
transactionResponse- String- Returns:
- status String
-
alignContext
- Parameters:
context- ContextisXmlPayRequest- boolean- Returns:
- errors Arraylist
-
format
This function will be used to form the string with the context details.- Parameters:
msgBody- StringmsgParams- String[]- Returns:
- msgBody String
-
getStatus
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
Returns a boolean value indicating the status of the transaction- Parameters:
resp- - Response obtained from PayPal Payment Gateway.- Returns:
- - true if transaction was success
-