diff --git a/dotNET/Payflow dotNET SDK.sln b/dotNET/Payflow dotNET SDK.sln index ace8c4b..53f5e79 100644 --- a/dotNET/Payflow dotNET SDK.sln +++ b/dotNET/Payflow dotNET SDK.sln @@ -3,12 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30428.66 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PFProSDK", "PFProSDK\PFProSDK.csproj", "{CE010258-E90B-4349-9BDA-C717768C9442}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamplesCS", "SamplesCS\SamplesCS.csproj", "{73AD89A0-693B-464F-99EC-020DE7DFF591}" EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SamplesVB", "SamplesVB\SamplesVB.vbproj", "{5DFB23B2-BC06-496A-AA34-41488BC86F82}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9BCC3AAF-6761-49BB-B187-11B5B3315AB1}" ProjectSection(SolutionItems) = preProject CHANGELOG.md = CHANGELOG.md @@ -17,7 +13,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}") = "Payflow SDK Docs", "..\..\..\Sandcastle Help\Payflow SDK Docs.shfbproj", "{0A65541E-8B2C-4401-9A0C-648F6B194E3B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PayflowProSDK", "PayflowProSDK\PayflowProSDK.csproj", "{8009B18A-EFBC-467D-9E86-AFBC1C7AB031}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples", "Samples\Samples.csproj", "{3F8705C4-FE34-4759-A739-2929A9B5179B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PFProSDK", "PFProSDK\PFProSDK.csproj", "{CE010258-E90B-4349-9BDA-C717768C9442}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SamplesVB", "SamplesVB\SamplesVB.vbproj", "{5DFB23B2-BC06-496A-AA34-41488BC86F82}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -25,22 +27,26 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CE010258-E90B-4349-9BDA-C717768C9442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE010258-E90B-4349-9BDA-C717768C9442}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE010258-E90B-4349-9BDA-C717768C9442}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE010258-E90B-4349-9BDA-C717768C9442}.Release|Any CPU.Build.0 = Release|Any CPU {73AD89A0-693B-464F-99EC-020DE7DFF591}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {73AD89A0-693B-464F-99EC-020DE7DFF591}.Debug|Any CPU.Build.0 = Debug|Any CPU {73AD89A0-693B-464F-99EC-020DE7DFF591}.Release|Any CPU.ActiveCfg = Release|Any CPU {73AD89A0-693B-464F-99EC-020DE7DFF591}.Release|Any CPU.Build.0 = Release|Any CPU + {8009B18A-EFBC-467D-9E86-AFBC1C7AB031}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8009B18A-EFBC-467D-9E86-AFBC1C7AB031}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8009B18A-EFBC-467D-9E86-AFBC1C7AB031}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8009B18A-EFBC-467D-9E86-AFBC1C7AB031}.Release|Any CPU.Build.0 = Release|Any CPU + {3F8705C4-FE34-4759-A739-2929A9B5179B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F8705C4-FE34-4759-A739-2929A9B5179B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F8705C4-FE34-4759-A739-2929A9B5179B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F8705C4-FE34-4759-A739-2929A9B5179B}.Release|Any CPU.Build.0 = Release|Any CPU + {CE010258-E90B-4349-9BDA-C717768C9442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE010258-E90B-4349-9BDA-C717768C9442}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE010258-E90B-4349-9BDA-C717768C9442}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE010258-E90B-4349-9BDA-C717768C9442}.Release|Any CPU.Build.0 = Release|Any CPU {5DFB23B2-BC06-496A-AA34-41488BC86F82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5DFB23B2-BC06-496A-AA34-41488BC86F82}.Debug|Any CPU.Build.0 = Debug|Any CPU {5DFB23B2-BC06-496A-AA34-41488BC86F82}.Release|Any CPU.ActiveCfg = Release|Any CPU {5DFB23B2-BC06-496A-AA34-41488BC86F82}.Release|Any CPU.Build.0 = Release|Any CPU - {0A65541E-8B2C-4401-9A0C-648F6B194E3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0A65541E-8B2C-4401-9A0C-648F6B194E3B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0A65541E-8B2C-4401-9A0C-648F6B194E3B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0A65541E-8B2C-4401-9A0C-648F6B194E3B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Context.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Context.cs new file mode 100644 index 0000000..0be4f27 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Context.cs @@ -0,0 +1,519 @@ +using System; +using System.Collections; +using PayPal.Payments.Common.Logging; +using PayPal.Payments.Common.Utility; +using System.Text; + +namespace PayPal.Payments.Common +{ + /// ----------------------------------------------------------------------------- + /// + /// This class contains the all error message generated for the class containing + /// the context.This also contains the highest severity level contained by the + /// context + /// + /// + /// + /// + /// ----------------------------------------------------------------------------- + public class Context + { + #region "Member variable" + + /// + /// Holds the collection of error objects for the context instance. + /// + private ArrayList mErrorObjects = new ArrayList(); + + /// + /// Indicates the highest severity level error in the array list. + /// + private int mHighestErrorLvl; + + /// + /// Indicates if the Error messages due to Logger class needs to be added to the context. + /// + private bool mLoadLoggerErrs ; + + #endregion + + #region "Constructor" + + /// + /// Constructor for Context + /// + internal Context() + { + } + + #endregion + + #region "Properties" + + //Gets the highestErrorLvl + /// + /// Indicates the highest severity level error in the array list. + /// + public int HighestErrorLvl + { + get + { + int ErrCnt = 0; + int ErrMaxCnt = 0; + int ErrSeverityLevel = 0; + PopulateErrors(); + ErrMaxCnt = mErrorObjects.Count; + for (ErrCnt = 0; ErrCnt < ErrMaxCnt; ErrCnt++) + { + ErrSeverityLevel = ((ErrorObject) mErrorObjects[ErrCnt]).SeverityLevel; + if (mHighestErrorLvl < ErrSeverityLevel) + { + mHighestErrorLvl = ErrSeverityLevel; + } + } + return mHighestErrorLvl; + } + } + + /// + /// Indicates if the Error messages due to Logger class needs to be added to the context. + /// + public bool LoadLoggerErrs + { + get + { + return mLoadLoggerErrs ; + } + set + { + mLoadLoggerErrs = value; + } + } + #endregion + + #region "Methods" + + /// ----------------------------------------------------------------------------- + /// + /// This method adds the passed error object in the array list contained by + /// the context object + /// + /// ErrorObject + /// Nothing + /// + /// + /// ----------------------------------------------------------------------------- + internal void AddError(ErrorObject ErrObject) + { + if (mErrorObjects == null) + { + mErrorObjects = new ArrayList(); + } + mErrorObjects.Insert(0,ErrObject); + return; + } + + /// ----------------------------------------------------------------------------- + /// + /// This method adds the passed arraylist of error objects + /// to the context object + /// + /// Array List + /// Nothing + /// + /// + /// ----------------------------------------------------------------------------- + internal void AddErrors(ArrayList ErrorObjects) + { + mErrorObjects.InsertRange(0,ErrorObjects); + return; + } + + /// ----------------------------------------------------------------------------- + /// + /// This method will log all the error and exceptions contained in the ErrorObjects + /// arraylist.This will then call the log method from the Logger class after + /// converting the array list into a ErrorObject array. + /// + /// Nothing + /// + /// + /// ----------------------------------------------------------------------------- + public bool LogErrors() + { + //This method will log all the errors using the Logger class + //convert the array list into a array of error objects + try + { + int ErrCnt = 0; + Logger Instance = null; + ArrayList PopulatedErr = new ArrayList(0); + + if (mErrorObjects != null) + { + Instance = Logger.Instance; + PopulatedErr = Instance.PopulateErrorDetails(mErrorObjects); + mErrorObjects.Clear(); + mErrorObjects.InsertRange(ErrCnt, PopulatedErr); + Instance.Log(mErrorObjects); + } + return true; + } + catch + { + return false; + } + } + + + /// ----------------------------------------------------------------------------- + /// + /// This method will check if the context contains any error message.This method + /// can be used for checking if the context is empty. + /// + /// boolean value 'true' - If errors are present + /// false in case of no errors. + /// + /// + /// ----------------------------------------------------------------------------- + public bool IsErrorContained() + { + if (mErrorObjects != null) + { + if (mErrorObjects.Count > 0) + return true; + + return false; + } + return false; + } + + /// ----------------------------------------------------------------------------- + /// + /// This method will check if the context contains a specific error message.This method + /// can be used for checking if the context is empty. + /// + ///Error Object + /// boolean value 'true' - If specific Error is present + /// false in case of no errors. + /// + /// + /// ----------------------------------------------------------------------------- + internal bool IsCommunicationErrorContained(ErrorObject Error) + { + if (IsErrorContained()) + { + foreach (ErrorObject Err in mErrorObjects) + { + if (Err != null && Err.MessageCode.Equals(Error.MessageCode)) + { + if (Err.MessageParams != null && Error.MessageParams != null) + { + if (Err.MessageParams[0].Equals(Error.MessageParams[0])) + { + return true; + } + } + //return false; + } + } + return false; + } + return false; + } + + /// ----------------------------------------------------------------------------- + /// + /// This method will return the error object from the Context as per the index + /// passed to the function.If the index value passed is more than the count of the + /// errors in the array list then it returns a null. + /// + /// int + /// ErrorObject + /// + /// + /// ----------------------------------------------------------------------------- + //Get the error object form the array list depending on the index passed + public ErrorObject GetError(int Index) + { + PopulateErrors(); + if (Index < mErrorObjects.Count) + { + return (ErrorObject) mErrorObjects[Index]; + } + return null; + } + + /// ----------------------------------------------------------------------------- + /// + /// This method returns the array list populated with all the error contained + /// in the context + /// + /// Array List + /// + /// + /// ----------------------------------------------------------------------------- + //Get all the error contained by the context + public ArrayList GetErrors() + { + PopulateErrors(); + return mErrorObjects; + } + + + /// ----------------------------------------------------------------------------- + /// + /// This method will return the array list populated with all the error contained + /// in the context which are equal to or above the severity level passed to the + /// function + /// + /// integer + /// Array List + /// + /// + /// ----------------------------------------------------------------------------- + //Get all the error contained by the context equal to or above a severity level + public ArrayList GetErrors(int SevLvl) + { + ArrayList HighSevErrors = new ArrayList(); + int ErrMaxCount = 0; + int ErrCnt = 0; + PopulateErrors(); + ErrMaxCount = mErrorObjects.Count; + for (ErrCnt = 0; ErrCnt < ErrMaxCount; ErrCnt++) + { + if (((ErrorObject) mErrorObjects[ErrCnt]).SeverityLevel >= + SevLvl) + { + HighSevErrors.Add(mErrorObjects[ErrCnt]); + } + } + return HighSevErrors; + } + + /// ----------------------------------------------------------------------------- + /// + /// This method will return the total number of errors contained in the + /// Context Object. + /// + /// Integer + /// + /// + /// ----------------------------------------------------------------------------- + //Get the count of ErrorObjects in the Context + public int getErrorCount() + { + if (mErrorObjects != null) + { + return mErrorObjects.Count; + } + return 0; + } + + /// ----------------------------------------------------------------------------- + /// + /// This method will populate all the error objects contained in the arraylist with + /// details such as the severity level and message body.It uses 'PopulateErrorDetails' + /// method of the Logger class. + /// + /// + /// + /// + /// ----------------------------------------------------------------------------- + //Populate the error objects with information from the sorted List + private void PopulateErrors() + { + int ErrCnt = 0; + Logger Instance = null; + ArrayList PopulatedErr = new ArrayList(0); + + if (mErrorObjects != null) + { + Instance = Logger.Instance; + PopulatedErr = Instance.PopulateErrorDetails(mErrorObjects); + if (LoadLoggerErrs) + { + //PopulatedErr.AddRange (Instance.GetLoggerErrs); + //Check for duplicate Logger errors + ArrayList TempList = Instance.GetLoggerErrs; + if (TempList != null) + { + for (int i=0;i + /// This method overrides the toString() method of the System.Object Class.This method + /// converts the information in the Context in the string format.The format is as follows: + /// + /// Message (Message Number in the context)----------------------------- + /// [(Message severity Level)](Message code)-(Formatted message body with context info) + /// Message stack Trace + /// + /// + /// Returns all the messages contained by the context in the string format. + /// + /// + /// + /// ----------------------------------------------------------------------------- + public override String ToString() + { + StringBuilder RetVal = new StringBuilder(""); + int ErrCount = 0; + int ErrMaxCount = 0; + ErrorObject Err; + + PopulateErrors(); + ErrMaxCount = mErrorObjects.Count; + for (ErrCount = 0; ErrCount < ErrMaxCount; ErrCount++) + { + Err = (ErrorObject) mErrorObjects[ErrCount]; + if (ErrMaxCount > 0) + { + RetVal.Append(PayflowConstants.FORMAT_MSG_SEPERATOR); + RetVal.Append(ErrCount + 1); + RetVal.Append(PayflowConstants.FORMAT_MSG_LINESEPERATOR); + RetVal.Append(Environment.NewLine); + } + RetVal.Append(PayflowConstants.FORMAT_MSG_OPENBRACKET); + RetVal.Append(GetStringSeverity(Err.SeverityLevel)); + RetVal.Append(PayflowConstants.FORMAT_MSG_CLOSEBRACKET); + //RetVal.Append(Err.MessageCode); + //RetVal.Append(PayflowConstants.FORMAT_MSG_CODEBODY_SEP); + RetVal.Append(Err.ToString()); + RetVal.Append(Environment.NewLine); + RetVal.Append(Err.ErrorStackTrace); + if (ErrCount < ErrMaxCount - 1) + RetVal.Append(Environment.NewLine); + } + return RetVal.ToString(); + } + + /// ----------------------------------------------------------------------------- + /// + /// This method is another overload for the method toString().This method + /// converts the information in the Context in the string format.This will return + /// the formatted error string for messages that have severity level equal to or above + /// the severitylevel parameter passed to this function.The messages for different errors + /// are separated by the separator format passed to the method.In case no separator is + /// passed a new line character is used. + /// + /// + /// All the errors messages which have severity levels equal + /// to or greater than this is returned + /// Message separator. + /// Returns the messages contained by the context in the string format. + /// + /// + /// + /// ----------------------------------------------------------------------------- + /// + public String ToString(int SeverityLevel, String Seperator) + { + StringBuilder RetVal = new StringBuilder(""); + int ErrCount = 0; + int ErrMaxCount = 0; + ErrorObject Err; + ArrayList ErrObjects = new ArrayList(0); + ErrObjects = GetErrors(SeverityLevel); + + ErrMaxCount = ErrObjects.Count; + for (ErrCount = 0; ErrCount < ErrMaxCount; ErrCount++) + { + Err = (ErrorObject) ErrObjects[ErrCount]; + RetVal.Append(Err.ToString()); + if (ErrCount < ErrMaxCount - 1) + { + if (Seperator != null && Seperator.Length != 0) + { + RetVal.Append(Seperator); + } + else + { + RetVal.Append(Environment.NewLine); + } + } + } + return RetVal.ToString(); + } + + /// + /// This resets the context object + /// + /// Void + public void ClearErrors() + { + if (mErrorObjects != null) + { + mErrorObjects.Clear(); + mHighestErrorLvl = 0; + } + } + /// + /// This gets the severity level for a + /// severity integer value. + /// + /// Severity level integer value + /// Severity level string value + private static String GetStringSeverity(int Severity) + { + String RetVal = PayflowConstants.ERROR_WARN ; + + switch(Severity) + { + case PayflowConstants.SEVERITY_DEBUG: + RetVal = PayflowConstants.ERROR_DEBUG; + break; + case PayflowConstants.SEVERITY_INFO: + RetVal = PayflowConstants.ERROR_INFO; + break; + case PayflowConstants.SEVERITY_WARN: + RetVal = PayflowConstants.ERROR_WARN; + break; + case PayflowConstants.SEVERITY_ERROR: + RetVal = PayflowConstants.ERROR_ERROR; + break; + case PayflowConstants.SEVERITY_FATAL: + RetVal = PayflowConstants.ERROR_FATAL; + break; + } + return RetVal; + } + + /// + /// Not implemented + /// + /// + /// Object.Equals + [System.Runtime.InteropServices.ComVisible(false)] + public override bool Equals(object obj) + { + return base.Equals (obj); + } + + /// + /// Not implemented + /// + /// Object.GetHashCode + [System.Runtime.InteropServices.ComVisible(false)] + public override int GetHashCode() + { + return base.GetHashCode (); + } + + #endregion + } // END CLASS DEFINITION Context + +} // Payments.Common \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/ErrorObject.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/ErrorObject.cs new file mode 100644 index 0000000..6dda9d7 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/ErrorObject.cs @@ -0,0 +1,243 @@ +using System; +using System.Collections; +using PayPal.Payments.Common.Utility; + +namespace PayPal.Payments.Common +{ + /// ----------------------------------------------------------------------------- + /// + /// This class contains the error message along with the message code ,Severity level + /// of the error and the stack Trace.This class represents the format of an error/message. + /// + /// + /// + /// + /// ----------------------------------------------------------------------------- + public class ErrorObject + { + #region "Member Variables" + + /// + /// Holds the message code for the Error. + /// + private String mMsgCode; + + /// + /// Holds the context parameters for the place holders.These parameters will be used + /// in conjunction with the message body to get the formatted message for the error. + /// + private ArrayList mMsgCodeParams; + + /// + /// Holds the Severity Level for the error.Sets this to debug by default. + /// + private int mSeverity; + + /// + /// Holds the stack trace, if applicable.This is helpful in case the error is an + /// Exception. + /// + private String mStackTrace; + + /// + /// Holds the message body for the Error. + /// + private String mMsgBody; + + #endregion + + #region "Property Declarations" + + //Gets the property for the Message Body of the Error Object + internal String MessageBody + { + get { return mMsgBody; } + } + + //Gets the property for the Message Code of the Error Object + /// + /// Gets Message Code + /// + public String MessageCode + { + get { return mMsgCode; } + } + + /*Gets the property for the Stack Trace of the Error Object. + * This is applicable only if the error is an exception*/ + + /// + /// Gets Stack Trace of the Error Object. + /// + public String ErrorStackTrace + { + get { return mStackTrace; } + } + + //Gets the property for the mSeverityLevel of the Error Object + /// + /// Gets the SeverityLevel + /// + public int SeverityLevel + { + get { return mSeverity; } + } + + + /// + /// Gets MessageParams + /// + public ArrayList MessageParams + { + get { return mMsgCodeParams; } + } + + #endregion + + #region "Methods" + + /// ----------------------------------------------------------------------------- + /// + /// This function overrides the object.toString method. + /// This function formats the error message by filling the place holders with the + /// context parameters + /// + /// Formatted error String + /// + /// + /// ----------------------------------------------------------------------------- + public override String ToString() + { + //This needs to get the message bode using the message code + String FormattedMessage = PayflowConstants.EMPTY_STRING; + if (mMsgCodeParams != null) + { + //Convert the arraylist mMsgCodeparams to an array of String + String[] MsgParams = new String[mMsgCodeParams.Count]; + + mMsgCodeParams.CopyTo(MsgParams); + try + { + FormattedMessage = String.Format(mMsgBody, MsgParams); + } + catch(Exception Ex) + { + String StackTrace = PayflowConstants.EMPTY_STRING; + PayflowUtility.InitStackTraceOn(); + + if(PayflowConstants.TRACE_ON.Equals(PayflowConstants.TRACE)) + { + StackTrace = " " + Ex.ToString(); + } + + FormattedMessage = PayflowConstants.MESSAGE_FORMATTING_ERROR + StackTrace; + } + //catch + //{ + // FormattedMessage = PayflowConstants.MESSAGE_FORMATTING_ERROR; + //} + } + else + { + FormattedMessage = mMsgBody; + } + + return FormattedMessage; + } + + #endregion + + #region "Constructors" + + // Used for Validation Errors which don’t have a stack trace. + /// + /// Used for Validation Errors which don’t have a stack trace. + /// + /// Severity level for the error. + /// Message Code. + /// Parameters which are used as context information. + internal ErrorObject(int Severity, String MsgCode, + String[] MsgCodeParams) + { + this.mSeverity = Severity; + this.mMsgCode = MsgCode; + this.mMsgCodeParams = new ArrayList(); + this.mMsgCodeParams.AddRange(MsgCodeParams); + } + + // Used for populating error message from the Message xml file. + /// + /// Used for populating error message from the Message xml file. + /// + /// Severity level for the error. + /// Message Code. + /// Message Description for the Error. + internal ErrorObject(int Severity, String MsgCode, String MsgBody) + { + this.mSeverity = Severity; + this.mMsgCode = MsgCode; + this.mMsgBody = MsgBody; + this.mStackTrace = PayflowConstants.EMPTY_STRING; + this.mMsgCodeParams = new ArrayList(); + } + + // Used for Exception objects, which have a stack trace. + /// + /// Used for Exception objects, which have a stack trace. + /// + /// Severity level for the error. + /// Message Code. + /// Parameters which are used as context information. + /// Stack Trace information for the Error. + internal ErrorObject(int Severity, String MsgCode, String[] MsgCodeParams, String StackTrace) : this(Severity, MsgCode, MsgCodeParams) + { + this.mStackTrace = StackTrace; + } + + // Used for copying the error object in the logger class + /// + /// Used for copying the error object in the logger class. + /// + /// Severity level for the error. + /// Message Code. + /// Message Description for the Error. + /// Parameters which are used as context information. + /// Stack Trace information for the Error. + internal ErrorObject(int Severity, String MsgCode, String MsgBody, String[] MsgCodeParams, String StackTrace) : this(Severity, MsgCode, MsgCodeParams) + { + this.mMsgBody = MsgBody; + this.mStackTrace = StackTrace; + } + + // Used for Exception objects without any message code. + /// + /// Used for Exception objects without any message code. + /// + /// Message Description for the Error. + /// Stack Trace information for the Error. + internal ErrorObject(String MsgBody, String StackTrace) + { + this.mSeverity = PayflowConstants.SEVERITY_FATAL; + this.mMsgBody = MsgBody; + this.mStackTrace = StackTrace; + this.mMsgCode = PayflowConstants.EMPTY_STRING; + this.mMsgCodeParams = new ArrayList(); + } + + // Used for Exception objects without any message code and stack trace. + /// + /// Used for Exception objects without any message code and stack trace. + /// + /// Message Description for the Error. + internal ErrorObject(String MsgBody) + { + this.mMsgBody = MsgBody; + this.mMsgCode = PayflowConstants.EMPTY_STRING; + this.mMsgCodeParams = new ArrayList(); + this.mStackTrace = PayflowConstants.EMPTY_STRING; + this.mSeverity = PayflowConstants.SEVERITY_FATAL; + } + + #endregion + } // END CLASS DEFINITION ErrorObject +} // Payments.Common \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/BaseException.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/BaseException.cs new file mode 100644 index 0000000..f196fd3 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/BaseException.cs @@ -0,0 +1,111 @@ +using System; + +namespace PayPal.Payments.Common.Exceptions +{ + /// ----------------------------------------------------------------------------- + /// + /// This is the base class for all the different exception classes. + /// + /// + /// + /// + /// ----------------------------------------------------------------------------- + [Serializable()] + internal abstract class BaseException : Exception + { + #region "Member variable" + + /// + /// Static context object which holds the information about the different exceptions + /// that are raised. + /// + private Context mErrorContext = new Context(); //This will hold the context for the error + + #endregion "Member variable" + + #region "Properties" + + /* //returns the context for the exception + /// + /// Static context object which holds the information about the different exceptions + /// that are raised. + /// + internal Context ErrContext + { + get { return mErrorContext; } + } + */ + + #endregion "Properties" + + #region "Constructor" + + //The constructor initializes the context and adds the error object + //passed to it + /// + /// Constructor with Error object as a parameter. + /// + /// ErrorObject which needs to be added to the exception. + protected BaseException(ErrorObject Err) + { + mErrorContext.AddError(Err); + } + + /// + /// Constructor with another exception as a parameter. + /// + /// Exception which needs to be converted into a Base + /// exception type. + protected BaseException(Exception Ex) + { + ErrorObject ErrObj = new ErrorObject(Ex.Message, Ex.StackTrace); + mErrorContext.AddError(ErrObj); + } + + #endregion "Constructor" + + #region "Methods" + + /// ----------------------------------------------------------------------------- + /// + /// This method will return the information contained in the exception in + /// the String format.This internally calls the context.ToString() method to get + /// the string format + /// + /// String representation of the Exception + /// + /// + /// ----------------------------------------------------------------------------- + public override String ToString() + { + String RetVal = ""; + RetVal = mErrorContext.ToString(); + return RetVal; + } + + /* /// ----------------------------------------------------------------------------- + /// + /// This method will log the information contained in the exception. + /// This internally calls the context.Log method to log the message. + /// + /// boolean values indicating success or failure + /// + /// + /// ----------------------------------------------------------------------------- + public bool Log() + { + return mErrorContext.LogErrors(); + }*/ + + internal virtual ErrorObject GetFirstErrorInExceptionContext() + { + if (mErrorContext.getErrorCount() > 0) + { + return mErrorContext.GetError(0); + } + return null; + } + + #endregion "Methods" + } // END CLASS DEFINITION BaseException +} // Payments.Common.Exceptions \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/CommunicationException.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/CommunicationException.cs new file mode 100644 index 0000000..11b7836 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/CommunicationException.cs @@ -0,0 +1,33 @@ +using System; + +namespace PayPal.Payments.Common.Exceptions +{ + /// + /// This Exception class will be used for handling the Communication Exceptions. + /// + [Serializable()] + internal class CommunicationException : BaseException + { + #region "constructor" + + /// + /// Constructor with Error object as a parameter. + /// + /// ErrorObject which needs to be added to the exception. + internal CommunicationException(ErrorObject ErrObject) : base(ErrObject) + { + } + + /// + /// Constructor with another exception as a parameter. + /// + /// Exception which needs to be converted into a Communication + /// exception type. + internal CommunicationException(Exception Ex) : base(Ex) + { + } + + #endregion + } // END CLASS DEFINITION CommunicationException + +} // Payments.Common.Exceptions \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/DataObjectException.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/DataObjectException.cs new file mode 100644 index 0000000..6d687ec --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/DataObjectException.cs @@ -0,0 +1,32 @@ +using System; + +namespace PayPal.Payments.Common.Exceptions +{ + /// + /// This Exception class will be used for handling the DataObject Exceptions. + /// + [Serializable()] + internal class DataObjectException : BaseException + { + #region "constructor" + + /// + /// Constructor with Error object as a parameter. + /// + /// ErrorObject which needs to be added to the exception. + internal DataObjectException(ErrorObject ErrObject) : base(ErrObject) + { + } + + /// + /// Constructor with another exception as a parameter. + /// + /// Exception which needs to be converted into a DataObjectException type. + internal DataObjectException(Exception Ex) : base(Ex) + { + } + + #endregion + } // END CLASS DEFINITION DataObjectException + +} // Payments.Common.Exceptions \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/GeneralException.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/GeneralException.cs new file mode 100644 index 0000000..167bbd5 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/GeneralException.cs @@ -0,0 +1,33 @@ +using System; + +namespace PayPal.Payments.Common.Exceptions +{ + /// + /// This Exception class will be used for handling the General Exceptions. + /// + [Serializable()] + internal class GeneralException : BaseException + { + #region "constructor" + + /// + /// Constructor with Error object as a parameter. + /// + /// ErrorObject which needs to be added to the exception. + internal GeneralException(ErrorObject ErrObject) : base(ErrObject) + { + } + + /// + /// Constructor with another exception as a parameter. + /// + /// Exception which needs to be converted into + /// a GeneralException type. + internal GeneralException(Exception Ex) : base(Ex) + { + } + + #endregion + } // END CLASS DEFINITION GeneralException + +} // Payments.Common.Exceptions \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/NamespaceDoc.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/NamespaceDoc.cs new file mode 100644 index 0000000..3096d51 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/NamespaceDoc.cs @@ -0,0 +1,11 @@ + + +namespace PayPal.Payments.Common.Exceptions +{ + /// + ///NameSpace doc for Exceptions namespace + /// + internal class NamespaceDoc + { + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/ProtocolException.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/ProtocolException.cs new file mode 100644 index 0000000..2ec763b --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/ProtocolException.cs @@ -0,0 +1,33 @@ +using System; + +namespace PayPal.Payments.Common.Exceptions +{ + /// + /// This Exception class will be used for handling the Protocol Exceptions. + /// + [Serializable()] + internal class ProtocolException : BaseException + { + #region "constructor" + + /// + /// Constructor with Error object as a parameter. + /// + /// ErrorObject which needs to be added to the exception. + internal ProtocolException(ErrorObject ErrObject) : base(ErrObject) + { + } + + /// + /// Constructor with another exception as a parameter. + /// + /// Exception which needs to be converted into + /// a ProtocolException type. + internal ProtocolException(Exception Ex) : base(Ex) + { + } + + #endregion + } // END CLASS DEFINITION ProtocolException + +} // Payments.Common.Exceptions \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/TransactionException.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/TransactionException.cs new file mode 100644 index 0000000..84daef9 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Exceptions/TransactionException.cs @@ -0,0 +1,33 @@ +using System; + +namespace PayPal.Payments.Common.Exceptions +{ + /// + /// This Exception class will be used for handling the Transaction Exceptions. + /// + [Serializable()] + internal class TransactionException : BaseException + { + #region "constructor" + + /// + /// Constructor with Error object as a parameter. + /// + /// ErrorObject which needs to be added to the exception. + internal TransactionException(ErrorObject ErrObject) : base(ErrObject) + { + } + + /// + /// Constructor with another exception as a parameter. + /// + /// Exception which needs to be converted into + /// a GeneralException type. + internal TransactionException(Exception Ex) : base(Ex) + { + } + + #endregion + } // END CLASS DEFINITION TransactionException + +} // Payments.Common.Exceptions \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Logging/Logger.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Logging/Logger.cs new file mode 100644 index 0000000..52172d5 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Logging/Logger.cs @@ -0,0 +1,669 @@ + + +#region "Using" + +using System; +using System.Collections; +//using System.Configuration; +//using System.Xml; +using System.IO; +//using System.Reflection; +using System.Security.Permissions; +using System.Security; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Communication; +#endregion + +namespace PayPal.Payments.Common.Logging +{ + /// ----------------------------------------------------------------------------- + /// + /// This is the main class which is used for Logging.It has a static constructor + /// which initializes the sortedlist containing all the error messages. + /// This class will primarily be used by the Context class. + /// The only method from this class which can be used outside the assembly is the log + /// method which takes in a string and severity level as parameters. + /// + /// + /// + /// + /// ----------------------------------------------------------------------------- + public sealed class Logger + { + #region "Member variable" + /// + /// This SortedList holds the Message code,Body and severity level of the messages + /// mentioned in the XML file. + /// + private SortedList mMessages; + /// + /// Holds the instance of this singleton class. + /// + private static Logger mInstance; + /// + /// Holds the errors generated by Logger class. + /// + private ArrayList mLoggerErrs = new ArrayList(); + /// + /// Holds log file name + /// + private String mLogFileName; + /// + /// Holds Log file size + /// + private long mFileLength = 0; + /// + /// Holds log file + /// + private FileInfo mFileInfo = null; + /// + /// This StermWriter writes in to Log file + /// + private StreamWriter mWriteToFile = null; + /// + /// Holds Log file size Limit from Config file + /// + private long mFileSize; // = PayflowConstants.LOGFILE_SIZE; + /// + /// This flag indicates, if an error occurred because of the Logger class. + /// + private static bool mErrInLogger = false; + /// + /// Holds Log level info + /// + private int mLogLevel = 0; + /// + /// Holds Log file size limit + /// + private string mFileSizeLimit; + /// + /// Hold COM information + /// + private bool mIsCom= false; + + private String mStrLogLevel; + + /// + /// Hold RequestID information + /// + public String mRequestId; + + #endregion + + #region "properties" + + #endregion + + #region "Private constructor" + /// ----------------------------------------------------------------------------- + /// + /// This private constructor reads the config file for the name of file which contains the + /// error messages.After getting the name it loads the static member "mMessages" with + /// the messages mentioned in the file. + /// Gets Log file name from Config file. If not available then assign default file name. + /// Gets Log file size from Config file. If not available then assign default file size. + /// + /// Nothing + /// + /// + /// ----------------------------------------------------------------------------- + private Logger() + { + InitializeInstance(); + } + + private Logger(String LoggingLevel, String LogFileName, String MaxLogLimit, bool IsComWrapper) + { + mStrLogLevel = LoggingLevel; + mLogFileName = LogFileName; + mFileSizeLimit = MaxLogLimit; + mIsCom = IsComWrapper; + InitializeInstance(); + } + + private void InitializeInstance() + { + //FileSizeLimit=""; + string KeyName=""; + bool IsLogLevelKeyPresent = false; + bool IsLogFilenameKeyPresent = false; + bool IsLogFileSizeKeyPresent = false; + + /* Reads the config file to get the path of the file containing all the messages. + * It will then load all the message from this file into the hashtable. + */ + //Reads the XML message file and loads the messages into a error object. + + PopulateMessages(); + if(!mIsCom) + { + try + { + mStrLogLevel=PayflowUtility.AppSettings(PayflowConstants.CONFIG_LOG_LEVEL); + } + catch + { + KeyName=PayflowConstants.CONFIG_LOG_LEVEL; + mLogLevel = PayflowConstants.LOGGING_OFF; + IsLogLevelKeyPresent = false; + } + } + + if(mStrLogLevel == null || mStrLogLevel.Length == 0) + { + KeyName = PayflowConstants.CONFIG_LOG_LEVEL; + mLogLevel = PayflowConstants.LOGGING_OFF; + IsLogLevelKeyPresent = false; + } + else + { + switch(((mStrLogLevel.Trim()).ToUpper())) + { + case "OFF": + mLogLevel = PayflowConstants.LOGGING_OFF; + break; + case "DEBUG": + mLogLevel = PayflowConstants.SEVERITY_DEBUG; + break; + case "INFO": + mLogLevel= PayflowConstants.SEVERITY_INFO; + break; + case "WARN": + mLogLevel= PayflowConstants.SEVERITY_WARN; + break; + case "ERROR": + mLogLevel= PayflowConstants.SEVERITY_ERROR; + break; + case "FATAL": + mLogLevel= PayflowConstants.SEVERITY_FATAL; + break; + default: + mLogLevel = PayflowConstants.LOGGING_OFF; + break; + } + } + IsLogLevelKeyPresent = (mLogLevel > PayflowConstants.LOGGING_OFF && mLogLevel <= PayflowConstants.SEVERITY_FATAL); + + + + // Do not need to do any further processing if Logging is set to OFF. + if(mLogLevel != PayflowConstants.LOGGING_OFF) + { + if(!mIsCom) + { + try + { + mLogFileName = PayflowUtility.AppSettings(PayflowConstants.CONFIG_LOGFILE_NAME); + } + catch + { + if(String.Empty.Equals(KeyName)) + { + KeyName=PayflowConstants.CONFIG_LOGFILE_NAME; + } + else + { + KeyName=KeyName + ", " + PayflowConstants.CONFIG_LOGFILE_NAME; + } + + } + } + + // if (mLogFileName == null || mLogFileName.Length == 0) + // { + // mLogFileName = PayflowConstants.LOGFILE_NAME; + // + // } + + // If no log file information found in .config file, create file name using relative path. + if (mLogFileName == null || mLogFileName.Length == 0) + { + mLogFileName = PayflowConstants.LOGFILE_NAME; + // if(String.Empty.Equals(KeyName)) + // { + // KeyName=PayflowConstants.CONFIG_LOGFILE_NAME; + // } + // else + // { + // KeyName=KeyName + ", " + PayflowConstants.CONFIG_LOGFILE_NAME; + // } + } + else + { + // mLogFileName = AppDomain.CurrentDomain.BaseDirectory + @"\" + mLogFileName; Changed to Absolute (03/17/2007) + IsLogFilenameKeyPresent =true; + } + + + + + if(!mIsCom) + { + try + { + mFileSizeLimit = PayflowUtility.AppSettings(PayflowConstants.CONFIG_LOGFILE_SIZE); + } + catch + { + //mFileSize = PayflowConstants.LOGFILE_SIZE; + if(String.Empty.Equals(KeyName)) + { + KeyName=PayflowConstants.CONFIG_LOGFILE_SIZE; + } + else + { + KeyName = KeyName + ", " + PayflowConstants.CONFIG_LOGFILE_SIZE; + } + } + + } + if (mFileSizeLimit == null || mFileSizeLimit.Length == 0) + { + mFileSize = PayflowConstants.LOGFILE_SIZE; + } + else + { + try + { + mFileSize = Int32.Parse(mFileSizeLimit); + } + catch + { + mFileSize = PayflowConstants.LOGFILE_SIZE; + if(String.Empty.Equals(KeyName)) + { + KeyName=PayflowConstants.CONFIG_LOGFILE_SIZE; + } + else + { + KeyName = KeyName + ", " + PayflowConstants.CONFIG_LOGFILE_SIZE; + } + } + if (mFileSize < 1) + mFileSize = PayflowConstants.LOGFILE_SIZE; + IsLogFileSizeKeyPresent =true; + } + } + + if(!(IsLogLevelKeyPresent== true && IsLogFilenameKeyPresent== true && IsLogFileSizeKeyPresent== true)) + { + if(!(IsLogLevelKeyPresent== false && IsLogFilenameKeyPresent== false && IsLogFileSizeKeyPresent== false)) + { + ErrorObject Error; + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_CONFIG_ERROR] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_CONFIG_ERROR] + + "Tags " + + KeyName + + " are not present in the config file or config file is missing."; + if (IsLogLevelKeyPresent== false) + { + Error = new ErrorObject(PayflowConstants.SEVERITY_ERROR, "",RespMessage); + } + else + { + Error = new ErrorObject(PayflowConstants.SEVERITY_WARN, "",RespMessage); + } + mLoggerErrs.Add(Error); + //if(IsLogLevelKeyPresent ) + //{ + // InitializeStream(); + //} + } + } + + } + + #endregion + + #region "Get Instance" + + + /// + ///Holds the instance of this singleton class. + /// + public static Logger Instance + { + get + { + lock (typeof (Logger)) + { + if (mInstance == null) + mInstance = new Logger(); + return mInstance; + } + } + } + /// + /// Get the Errors generated from the Logger. + /// + public ArrayList GetLoggerErrs + { + get + { + return mLoggerErrs ; + } + } + + #endregion + + #region "Methods" + /// ----------------------------------------------------------------------------- + /// + /// This is a internal method and takes in a errorobject as a parameter.This method + /// then calls another overloaded version for the method Log which takes in a + /// string to be logged and the severity level of the Error Object. + /// + /// ErrorObject + /// + /// + /// + /// ----------------------------------------------------------------------------- + internal void Log(ErrorObject Message) + { + if (Message != null) + { + Log(Message.ToString(), Message.SeverityLevel); + } + } + + + /// ----------------------------------------------------------------------------- + /// + /// This is a internal method and takes in a arraylist of the errorobjects + /// as a parameter.The method goes through the array list for each errorobject + /// found makes a call to another overloaded version of the Log method which takes + /// in ErrorObject as a parameter.If there are some errors which have been generated by + /// the Logger class then those are logged instead of the passed messages. + /// + /// ArrayList containing the error objects + /// + /// + /// + /// ----------------------------------------------------------------------------- + internal void Log(ArrayList Messages) //ArrayList containing the error objects + { + int ErrCnt = 0; + int ErrMaxCnt = 0; + if (mLoggerErrs.Count != 0) // This means no error was previously generated in this class + { + Messages = mLoggerErrs; + } + ErrMaxCnt = Messages.Count; + for (ErrCnt = 0; ErrCnt < ErrMaxCnt; ErrCnt++) + { + Log((ErrorObject) Messages[ErrCnt]); + } + } + + /// ----------------------------------------------------------------------------- + /// + /// This method used to log the data in a file.Different type of severity level are logged here. + /// The levels that can be logged are decided by the configuration settings in the + /// Application config file. + /// + /// String value that needs to be logged + /// Severity level of the message.This could be one of the following: + /// 1 (Debug) + /// 2 (Info) + /// 3 (Warn) + /// 4 (Error) + /// 5 (Fatal) + /// + /// + /// + /// + /// ----------------------------------------------------------------------------- + public void Log(String Message, int SeverityLvl) + { + String StrDebugLevel = String.Empty; + String MessageToLog = String.Empty; + if ( mLogLevel != 0 && ! mErrInLogger ) + { + if (SeverityLvl >= mLogLevel) + { + try + { + switch (SeverityLvl) + { + case PayflowConstants.SEVERITY_DEBUG: + StrDebugLevel = "DEBUG"; + break; + case PayflowConstants.SEVERITY_INFO: + StrDebugLevel = "INFO"; + break; + case PayflowConstants.SEVERITY_WARN: + StrDebugLevel = "WARN"; + break; + case PayflowConstants.SEVERITY_ERROR: + StrDebugLevel = "ERROR"; + break; + case PayflowConstants.SEVERITY_FATAL: + StrDebugLevel = "FATAL"; + break; + default: + return; + } + + InitializeStream(); + //int nProcessID = System.Diagnostics.Process.GetCurrentProcess().Id; + + MessageToLog = "[" + DateTime.Now +":" + GlobalClass.GlobalVar.ToString() + ":[" + StrDebugLevel + "]-" + Message; + mFileInfo.Refresh(); + mFileLength = mFileInfo.Length + MessageToLog.Length +1; + mWriteToFile.WriteLine(MessageToLog); + + if(mFileLength >= mFileSize ) + { + if (ArchivedLogFile()) + mFileLength= 0; + } + } + catch(Exception Ex) + { + String StackTrace = PayflowConstants.EMPTY_STRING; + PayflowUtility.InitStackTraceOn(); + if(PayflowConstants.TRACE_ON.Equals(PayflowConstants.TRACE)) + { + StackTrace = ": " + Ex.StackTrace; + } + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_LOG_ERROR] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_LOG_ERROR] + + PayflowConstants.MESSAGE_LOG_ERROR + + Ex.Message + + StackTrace; + ErrorObject Err = new ErrorObject( + PayflowConstants.SEVERITY_WARN, "", + RespMessage); + mLoggerErrs.Add(Err); + mErrInLogger = true; + } + } + } + } + /// ----------------------------------------------------------------------------- + /// + /// This is a internal method.This method contains implementation for rolling file functionality. + /// + /// + /// + /// + /// ----------------------------------------------------------------------------- + private bool ArchivedLogFile() + { + bool ArchivedFile = false; + FileInfo ArchivedLog = null; + string TempFileName; + mWriteToFile.Close(); + try + { + String LogfileName = mFileInfo.FullName; + int TargetPosition =LogfileName.LastIndexOf(mFileInfo.Extension); + for(int i = 1; !ArchivedFile; i++) + { + TempFileName=LogfileName.Insert(TargetPosition,PayflowConstants.UNDERSCORE) + .Insert(TargetPosition+1,i.ToString()) + .ToString(); + ArchivedLog = new FileInfo(TempFileName); + if(!ArchivedLog.Exists) + { + mFileInfo.CopyTo(TempFileName); + mFileInfo.Delete(); + ArchivedFile = true; + } + } + } + catch + { + ArchivedFile = false; + } + mWriteToFile = null; + mFileInfo = null; + return ArchivedFile; + } + + /// ----------------------------------------------------------------------------- + /// + /// This method populates each ErrorObject int the arraylist passed, with the + /// details from the SortedList held by the logger class.It populates the mLoggerErrs + /// in case the relevant message code is not found. + /// + /// ErrorObject + /// ErrorObject + /// + /// + /// ----------------------------------------------------------------------------- + //Populate the error object with the details + internal ArrayList PopulateErrorDetails(ArrayList ErrObj) + { + ErrorObject ErrMesg; + ErrorObject RetErrorObj = null; + ArrayList RetErrObjs = new ArrayList(0); + int ErrCnt; + int ErrMaxCnt; + int SevLvlAssigned; + String[] MesgParams; + + //Iterate through all the error objects in the array list + ErrMaxCnt = ErrObj.Count; + for (ErrCnt = 0; ErrCnt < ErrMaxCnt; ErrCnt++) + { + if (((ErrorObject) ErrObj[ErrCnt]).MessageCode.Length != 0) + { + ErrMesg = (ErrorObject) mMessages[((ErrorObject) ErrObj[ErrCnt]).MessageCode]; + if (((ErrorObject) ErrObj[ErrCnt]).SeverityLevel != 0) + { + SevLvlAssigned = ((ErrorObject) ErrObj[ErrCnt]).SeverityLevel; + } + else + { + SevLvlAssigned = ErrMesg.SeverityLevel; + } + MesgParams = new String[((ErrorObject) ErrObj[ErrCnt]).MessageParams.Count]; + ((ErrorObject) ErrObj[ErrCnt]).MessageParams.CopyTo(MesgParams); + RetErrorObj = new ErrorObject(SevLvlAssigned, + ErrMesg.MessageCode, ErrMesg.MessageBody, + MesgParams, + ((ErrorObject) ErrObj[ErrCnt]).ErrorStackTrace); + + } + else //It is an exception. + { + RetErrorObj = (ErrorObject) ErrObj[ErrCnt]; + } + RetErrObjs.Add(RetErrorObj); + } + return RetErrObjs; + } + + private void PopulateMessages() + { + mMessages = new SortedList(); + ErrorObject Err = null; + Err = new ErrorObject(PayflowConstants.SEVERITY_INFO,PayflowConstants.MSG_COMMUNICATION_ERROR,"RESULT={0}&RESPMSG={1}"); + mMessages.Add(PayflowConstants.MSG_COMMUNICATION_ERROR, Err); + Err = null; + Err = new ErrorObject(PayflowConstants.SEVERITY_INFO,PayflowConstants.MSG_COMMUNICATION_ERROR_XMLPAY, "{0}{1}"); + mMessages.Add(PayflowConstants.MSG_COMMUNICATION_ERROR_XMLPAY, Err); + Err = null; + Err = new ErrorObject(PayflowConstants.SEVERITY_INFO,PayflowConstants.MSG_COMMUNICATION_ERROR_NO_RESPONSE_ID,"RESULT={0}&RESPMSG={1}"); + mMessages.Add(PayflowConstants.MSG_COMMUNICATION_ERROR_NO_RESPONSE_ID, Err); + Err = null; + Err = new ErrorObject(PayflowConstants.SEVERITY_INFO,PayflowConstants.MSG_COMMUNICATION_ERROR_XMLPAY_NO_RESPONSE_ID, "{0}{1}"); + mMessages.Add(PayflowConstants.MSG_COMMUNICATION_ERROR_XMLPAY_NO_RESPONSE_ID, Err); + Err = null; + + } + + + private void InitializeStream() + { + try + { + if ( (mFileInfo == null) || (mWriteToFile == null)) + { + + mFileInfo = new FileInfo(mLogFileName); + + if (mFileInfo.Extension.Length == 0) + { + mLogFileName = mLogFileName+".Log"; + mFileInfo = new FileInfo(mLogFileName); + } + + if (!Directory.Exists(mFileInfo.DirectoryName)) + { + Directory.CreateDirectory(mFileInfo.DirectoryName); + } + mWriteToFile = new StreamWriter(mLogFileName,true); + mWriteToFile.AutoFlush = true; + } + } + catch(Exception Ex) + { + String StackTrace = PayflowConstants.EMPTY_STRING; + PayflowUtility.InitStackTraceOn(); + if(PayflowConstants.TRACE_ON.Equals(PayflowConstants.TRACE)) + { + StackTrace = ": " + Ex.StackTrace; + } + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_LOG_ERROR] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_LOG_ERROR] + + PayflowConstants.MESSAGE_LOG_ERROR + + " " +Ex.Message + + " " +StackTrace; + ErrorObject Err = new ErrorObject( + PayflowConstants.SEVERITY_ERROR, "", + RespMessage); + mLoggerErrs.Add(Err); + mErrInLogger = true; + } + + } + + internal static void SetInstance(String LoggingLevel, String LogFileName, String MaxLogSize,bool IsCOMWrapper) + { + if(mInstance != null) + { + mInstance = null; + } + mInstance = new Logger(LoggingLevel,LogFileName,MaxLogSize,IsCOMWrapper); + } + #endregion + } // END CLASS DEFINITION Logger + +} // Payments.Common.Logging \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Logging/NamespaceDoc.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Logging/NamespaceDoc.cs new file mode 100644 index 0000000..1ad2a5c --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Logging/NamespaceDoc.cs @@ -0,0 +1,11 @@ + + +namespace PayPal.Payments.Common.Logging +{ + /// + ///NameSpace doc for Logging namespace + /// + internal class NamespaceDoc + { + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/NamespaceDoc.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/NamespaceDoc.cs new file mode 100644 index 0000000..8fb97eb --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/NamespaceDoc.cs @@ -0,0 +1,11 @@ + + +namespace PayPal.Payments.Common +{ + /// + ///NameSpace doc for Common namespace + /// + internal class NamespaceDoc + { + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/GlobalClass.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/GlobalClass.cs new file mode 100644 index 0000000..47d3077 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/GlobalClass.cs @@ -0,0 +1,18 @@ +using System; + +namespace PayPal.Payments.Common.Utility +{ + /// + /// Summary description for GlobalClass. + /// + public class GlobalClass + { + private static string m_globalVar = ""; + + public static string GlobalVar + { + get { return m_globalVar; } + set { m_globalVar = value; } + } + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/LocalPolicy.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/LocalPolicy.cs new file mode 100644 index 0000000..a3f4c62 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/LocalPolicy.cs @@ -0,0 +1,97 @@ +#region "Imports" + +using System; +using System.Net; +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; + +#endregion + +namespace PayPal.Payments.Common.Utility +{ + /// + /// Custom class to define custom security + /// policy for SSL server certificates. + /// + + // This class is deprecated in VS2005 and is only here to allow testing of .NET SDK in the + // QA environment where the certificate does not match the host URL. If you do not uncomment the line listed + // below you will receive an exception of "The underlying connection was closed: Could not establish trust + // relationship with remote server." + // + // The line to uncomment can be found in PaymentConnection.cs within the SendToServer function and is: + // + // System.Net.ServicePointManager.CertificatePolicy = new LocalPolicy(ref mContext,IsXmlPayRequest); + // + // IMPORTANT: Make sure to comment the line prior to creating a build for release. + + //internal class LocalPolicy : System.Net.ICertificatePolicy + //{ + + // #region "Member Variables" + // /// + // /// Context object + // /// + // private Context mContext; + // /// + // /// Flag to indicate whether NVP or + // /// XML Pay request + // /// + // private bool mIsXmlPayRequest; + // #endregion + + // #region "Constructors" + // /// + // /// Constructor + // /// + // public LocalPolicy(ref Context CurrentContext, bool IsXmlPayRequest) : this() + // { + // mContext = CurrentContext; + // mIsXmlPayRequest = IsXmlPayRequest; + // } + + // /// + // /// Constructor + // /// + // private LocalPolicy() + // { + // } + + // #endregion + + // #region "Functions" + // /// + // /// This overridden method is called by the + // /// runtime after the server cert is validated + // /// + // /// Current Service point of the request + // /// Certificate + // /// Web request + // /// Problem Code + // /// True if certificate is valid, false otherwise + // public bool CheckValidationResult(ServicePoint ServicePoint, X509Certificate Cert, + // WebRequest WebRequest, int ProblemCode) + // { + // return true; + + // } + + // #endregion + //} + + public static class SSLValidator + { + private static bool OnValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, + SslPolicyErrors sslPolicyErrors) + { + return true; + } + public static void OverrideValidation() + { + ServicePointManager.ServerCertificateValidationCallback = + OnValidateCertificate; + ServicePointManager.Expect100Continue = true; + } + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/NamespaceDoc.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/NamespaceDoc.cs new file mode 100644 index 0000000..51afa50 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/NamespaceDoc.cs @@ -0,0 +1,11 @@ + + +namespace PayPal.Payments.Common.Utility +{ + /// + ///NameSpace doc for Utility namespace + /// + internal class NamespaceDoc + { + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/ParameterListValidator.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/ParameterListValidator.cs new file mode 100644 index 0000000..b671e35 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/ParameterListValidator.cs @@ -0,0 +1,443 @@ +#region "Imports" + +using System; +using System.Xml; +using System.Collections; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Logging; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.Common.Utility +{ + /// + /// Parameter List Validator Class. + /// + internal sealed class ParameterListValidator + { + #region "Private Constructor" + + /// + /// private Constructor. + /// + private ParameterListValidator() + { + } + + #endregion + + #region "Validator functions" + + /// + /// Validates the parameter list. + /// + /// Parameter List + /// true if Request is XmlPay, false otherwise. + /// Context object by reference. + public static void Validate(String ParamList, bool IsXmlPayReq, ref Context CurrentContext) + { + Logger.Instance.Log("PayPal.Payments.Common.Utility.ParameterListValidator.Validate(String,bool,String,String,ref Context): Entered", PayflowConstants.SEVERITY_DEBUG); + try + { + if (IsXmlPayReq) + { + XmlDocument XmlPayReq = new XmlDocument(); + XmlPayReq.LoadXml(ParamList); + } + else + { + if (ParamList != null && ParamList.Length > 0) + { + ParseNVPList(ParamList, ref CurrentContext, false); + } + } + + } + catch (Exception Ex) + { + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_INVALID_NVP, Ex, PayflowConstants.SEVERITY_FATAL, IsXmlPayReq, null); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + + } + //catch + //{ + // ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_INVALID_NVP, null, PayflowConstants.SEVERITY_FATAL, IsXmlPayReq, null); + // if (!CurrentContext.IsCommunicationErrorContained(Err)) + // { + // CurrentContext.AddError(Err); + // } + + //} + finally + { + Logger.Instance.Log("PayPal.Payments.Common.Utility.ParameterListValidator.Validate(String,bool,String,String,ref Context): Exiting", PayflowConstants.SEVERITY_DEBUG); + } + } + + /// + /// Validates Name Value Pair Request. + /// + /// Name Value Param List. + /// Context object by reference. + /// True will populate the return hashtable, false will just parse the request and check for validity + /// Name value hash table + public static Hashtable ParseNVPList(String ParamList, ref Context CurrentContext, bool PopulateResponseHashTable) + { + Logger.Instance.Log("PayPal.Payments.Common.Utility.ParameterListValidator.ParseNVPList(String,String,String,ref context,bool): Entered", PayflowConstants.SEVERITY_DEBUG); + long ParamListLen = ParamList.Length; + int index = 0; + bool OpenBracket = false; + bool CloseBracket = false; + String AddlMessage; + ErrorObject Err; + Hashtable ParamListHashTable = new Hashtable(); + if (ParamList == null || ParamList.Length <= 0) + { + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_EMPTY_PARAM_LIST, null, PayflowConstants.SEVERITY_FATAL, false, null); + CurrentContext.AddError(Err); + } + + while (index < ParamListLen && CurrentContext.HighestErrorLvl < PayflowConstants.SEVERITY_FATAL) + { + long NameBuffSize = 1000; + long ValBuffSize = 1000; + long LenBuffSize = 1000; + char[] NameBuffer = new char[NameBuffSize]; + char[] LenValueBuffer = new char[LenBuffSize]; + char[] ValueBuffer = new char[ValBuffSize]; + char[] TempArray = null; + int LenIndex = 0; + int NameIndex = 0; + + while (index < ParamListLen && ParamList[index] != '\0' && ParamList[index] != '=') + { + if (ParamList[index] == '[') + { + if (OpenBracket) + { + AddlMessage = "Found unmatched '[' followed by another '[' at index " + (index + 1).ToString(); + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN, null, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + break; + } + OpenBracket = true; + index++; + continue; + } + if (ParamList[index] == ']') + { + if (!OpenBracket) + { + AddlMessage = "Unmatched ']' at index " + (index + 1).ToString(); + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN, null, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + break; + } + else if ((index + 1) < ParamListLen && ParamList[index + 1] != '=') + { + AddlMessage = "']' is not followed by '=' in param list at index " + (index + 1).ToString(); + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN, null, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + break; + } + else if ((index + 1) < ParamListLen && ParamList[index - 1] == '[') + { + AddlMessage = "Length of value not found in '[]' at index " + (index + 1).ToString(); + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN, null, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + break; + } + else + { + if (CloseBracket) + { + AddlMessage = "Found unmatched ']' followed by another ']' at index " + (index + 1).ToString(); + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN, null, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + break; + } + index++; + CloseBracket = true; + continue; + } + } + + if (OpenBracket && !CloseBracket) + { + //increase the size of LenValueBuffer if required + if (LenIndex >= LenBuffSize) + { + LenBuffSize += 2000; + TempArray = new char[LenBuffSize]; + System.Array.Copy(LenValueBuffer, TempArray, LenValueBuffer.LongLength); + LenValueBuffer = TempArray; + } + LenValueBuffer[LenIndex] = ParamList[index]; + LenIndex++; + index++; + continue; + } + else + { + //increase the size of NameBuffer if required + if (NameIndex >= NameBuffSize) + { + NameBuffSize += 2000; + TempArray = new char[NameBuffSize]; + System.Array.Copy(NameBuffer, TempArray, NameBuffer.LongLength); + NameBuffer = TempArray; + } + NameBuffer[NameIndex] = ParamList[index]; + if (NameBuffer[NameIndex] == '&') + { + AddlMessage = new string(NameBuffer); + AddlMessage = AddlMessage.Trim('\0'); + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME, null, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + } + index++; + NameIndex++; + continue; + } + } + //skip '=' + if (index < ParamListLen && ParamList[index] != '\0') + { + index++; + } + + if (OpenBracket && !CloseBracket) + { + AddlMessage = "Unmatched '[' at index " + (index + 1).ToString(); + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN, null, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + break; + } + + /*if(OpenBracket && CloseBracket && LenValueBuffer != null && LenValueBuffer.Length > 0 && LenValueBuffer[0] == '0') + { + String Len = new string(LenValueBuffer).Trim('\0'); + AddlMessage = "Invalid param length = " + Len; + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN,null,PayflowConstants.SEVERITY_FATAL,false,AddlMessage); + if(!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + break; + + }*/ + + if (OpenBracket && CloseBracket && LenValueBuffer != null && LenValueBuffer.Length > 0 && LenValueBuffer[0] == '-') + { + String Len = new string(LenValueBuffer).Trim('\0'); + AddlMessage = "Invalid param length = " + Len; + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN, null, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + break; + + } + + int ValIndex = 0; + while (index < ParamListLen && ParamList[index] != '\0' && CurrentContext.HighestErrorLvl < PayflowConstants.SEVERITY_FATAL) + { + if (LenValueBuffer != null && LenValueBuffer.Length > 0 && LenValueBuffer[0] != '\0') + { + String LenString = new String(LenValueBuffer); + LenString = LenString.Trim(); + int Len; + try + { + Len = Int32.Parse(LenString); + } + catch (Exception Ex) + { + String Name = new string(NameBuffer).Trim('\0'); + AddlMessage = "Value in [] is not numeric data, data in '[]' = " + LenString.Trim('\0') + "for Name = " + Name; + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN, Ex, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + break; + } + //catch + //{ + // String Name = new string(NameBuffer).Trim('\0'); + // AddlMessage = "Value in [] is not numeric data, data in '[]' = " + LenString.Trim('\0') + "for Name = " + Name; + // Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN, null, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + // if (!CurrentContext.IsCommunicationErrorContained(Err)) + // { + // CurrentContext.AddError(Err); + // } + // break; + //} + + int AmpIndex = index + Len; + if (AmpIndex < ParamListLen && ParamList[AmpIndex] != '&') + { + String Name = new string(NameBuffer).Trim('\0'); + AddlMessage = "Param length in '[]' does not match actual value length.Param Name = " + Name; + Err = PayflowUtility.PopulateCommError(PayflowConstants.E_PARM_NAME_LEN, null, PayflowConstants.SEVERITY_FATAL, false, AddlMessage); + if (!CurrentContext.IsCommunicationErrorContained(Err)) + { + CurrentContext.AddError(Err); + } + index += Len + 1; + break; + } + else + { + //increase the size of ValueBuffer if required + if (Len >= ValBuffSize) + { + ValBuffSize += Len + 2000; + ValueBuffer = new char[ValBuffSize]; + } + int ValueIndex; + for (ValueIndex = 0; ValueIndex < Len && index + ValueIndex < ParamListLen; ValueIndex++) + { + ValueBuffer[ValueIndex] = ParamList[index + ValueIndex]; + } + index += Len + 1; + break; + } + } + else + { + //increase the size of NameBuffer if required + if (ValIndex >= ValBuffSize) + { + ValBuffSize += 2000; + TempArray = new char[ValBuffSize]; + System.Array.Copy(ValueBuffer, TempArray, ValueBuffer.LongLength); + ValueBuffer = TempArray; + } + if (ParamList[index] == '&') + { + if ((index + 1) < ParamListLen && ParamList[index + 1] == '&') + { + ValueBuffer[ValIndex] = ParamList[index]; + } + else if (ParamList[index - 1] == '&') + { + ValueBuffer[ValIndex] = ParamList[index]; + } + else + { + index++; + ValIndex++; + break; + } + } + else + { + ValueBuffer[ValIndex] = ParamList[index]; + } + + } + index++; + ValIndex++; + } + + //put data in hash table as name - value + if (PopulateResponseHashTable) + { + String Name = new String(NameBuffer).Trim('\0'); + String Value = new String(ValueBuffer).Trim('\0'); + if (ParamListHashTable.Contains(Name)) + { + Name = Name + PayflowConstants.TAG_DUPLICATE + PayflowUtility.RequestId; + } + + ParamListHashTable.Add(Name, Value); + + } + + OpenBracket = false; + CloseBracket = false; + NameBuffer = null; + LenValueBuffer = null; + ValueBuffer = null; + TempArray = null; + } + Logger.Instance.Log("PayPal.Payments.Common.Utility.ParameterListValidator.ParseNVPList(String,String,String,ref context,bool): Exiting", PayflowConstants.SEVERITY_DEBUG); + return ParamListHashTable; + } + +// internal static bool ValidateNVPHighLevel(String ParamList, out String AddlMessage) +// { +// bool Invalid = false; +// AddlMessage = PayflowConstants.EMPTY_STRING; +// Logger.Instance.Log("PayPal.Payments.Common.Utility.ParameterListValidator.ValidateNVPHighLevel(String,out String): Entered", PayflowConstants.SEVERITY_DEBUG); +// if (ParamList.StartsWith(PayflowConstants.DELIMITER_NVP)) +// { +// Invalid = true; +// AddlMessage = "Param list begins with '&'"; +// } +// else if (ParamList.IndexOf(PayflowConstants.SEPARATOR_NVP) < 0) +// { +// Invalid = true; +// AddlMessage = "No separator '=' found in param list"; +// } +// else if (ParamList.StartsWith(PayflowConstants.SEPARATOR_NVP) || ParamList.EndsWith(PayflowConstants.SEPARATOR_NVP)) +// { +// Invalid = true; +// AddlMessage = "Param list begins or ends with '='"; +// } +// else if (ParamList.StartsWith(PayflowConstants.OPENING_BRACE_NVP) || ParamList.EndsWith(PayflowConstants.OPENING_BRACE_NVP)) +// { +// Invalid = true; +// AddlMessage = "Param list begins or ends with '['"; +// } +// else if (ParamList.StartsWith(PayflowConstants.CLOSING_BRACE_NVP) || ParamList.EndsWith(PayflowConstants.CLOSING_BRACE_NVP)) +// { +// Invalid = true; +// AddlMessage = "Param list begins or ends with ']'"; +// } +// else +// { +// int Index = ParamList.LastIndexOf(PayflowConstants.DELIMITER_NVP); +// if (Index >= 0 && Index < ParamList.Length) +// { +// if(ParamList[Index-1] != '&' && ParamList.IndexOf(PayflowConstants.SEPARATOR_NVP, Index) < 0) +// { +// Invalid = true; +// AddlMessage = "Parameter list format error: unmatched name"; +// } +// } +// } +// Logger.Instance.Log("PayPal.Payments.Common.Utility.ParameterListValidator.ValidateNVPHighLevel(String,out String): Exiting", PayflowConstants.SEVERITY_DEBUG); +// return Invalid; +// } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/PayflowConstants.cs b/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/PayflowConstants.cs new file mode 100644 index 0000000..8d18260 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Common/Utility/PayflowConstants.cs @@ -0,0 +1,2381 @@ +#region "Imports" + +using System; +using System.Collections; + +#endregion + +namespace PayPal.Payments.Common.Utility +{ + /// + /// Summary description for PayflowConstants. + /// + public sealed class PayflowConstants + { + #region "Private Constructor" + + /// + /// Private constructor + /// for PayflowConstants + /// + private PayflowConstants() + { + } + + #endregion + + // Stores the Client Version - Update as needed. + #region "Communication Objects Related Constants" + + //Default timeout in seconds + /// + /// Default Timeout in seconds (45 sec) + /// + internal const int DEFAULT_TIMEOUT = 45; + /// + /// Default Connection reconnect Time span in seconds (3 sec) + /// + internal const int DEFAULT_RETRYCONNECTIONTIME = 3000; + /// + /// Default Payflow Host port (443) + /// + internal const int DEFAULT_HOSTPORT = 443; + /// + /// SDK Client Prefix + /// + internal const String CLIENT_PREFIX = "PNCLIENT"; + /// + /// SDK Client Type (N --> .NET) + /// + internal const String CLIENT_TYPE = "N"; + // if you change the SDK Client Version (CLIENT_VERSION) below, remember to + // change the assembly version in the AssemblyInfo.cs to match. + /// + /// SDK Client Version (400 --> V4 protocol) + /// + internal const String CLIENT_VERSION = "500"; + /// + /// SDK User Agent (Payflow SDK for .NET) + /// + internal const String USER_AGENT = "Payflow SDK for .NET"; + /// + /// SDK Request Type + /// + internal const String STRONG_ASSEMBLY = "Strong"; + /// + /// SDK Request Type + /// + internal const String WEAK_ASSEMBLY = "Weak"; + /// + /// Maximum retry attempts (3) + /// + internal const int MAX_RETRY = 3; + /// + /// XmlPay ID + /// + internal const String XML_ID = " + /// XmlPay Response ID + /// + internal const String XML_RESP_ID = " + /// XML Content Type (text/xml) + /// + internal const String XML_CONTENT_TYPE = "text/xml"; + /// + /// Name value Content Type (text/namevalue) + /// + internal const String NV_CONTENT_TYPE = "text/namevalue"; + /// + /// XML Pay namespace (http://www.paypal.com/XMLPay) + /// + internal const String XMLPAY_NAMESPACE = "http://www.paypal.com/XMLPay"; + /// + /// XML Pay request tag (XMLPayRequest) + /// + internal const String XMLPAY_REQUEST_TAG = "XMLPayRequest"; + + #endregion + + #region "General Constants" + + /// + /// Empty String + /// + public const String EMPTY_STRING = ""; + /// + /// Default Country Code + /// + internal const String CURRENCYCODE_DEFAULT = CURRENCYCODE_USD; + /// + /// Currency code for USD + /// + internal const String CURRENCYCODE_USD = "USD"; + /// + /// NVP Delimiter (&) + /// + internal const String DELIMITER_NVP = "&"; + /// + /// NVP Opening Brace ([) + /// + internal const String OPENING_BRACE_NVP = "["; + /// + /// NVP Closing Brace (]) + /// + internal const String CLOSING_BRACE_NVP = "]"; + /// + /// Constant Underscore + /// + internal const String UNDERSCORE = "_"; + /// + /// Constant DOT + /// + internal const String DOT = "."; + /// + /// NVP Separator (=) + /// + internal const String SEPARATOR_NVP = "="; + /// + /// Numeric values initialize + /// + internal const long INVALID_NUMBER = -384783; + /// + /// Duplicate tag + /// + internal const String TAG_DUPLICATE = "DUPLIACTE_NAME_KEY"; + /// + /// Xml Pay Param Result + /// + internal const String XML_PARAM_RESULT = "Result"; + /// + /// Xml Pay param Message + /// + internal const String XML_PARAM_MESSAGE = "Message"; + #endregion + + #region "Tender Related Constants" + + /// + /// Card Tender (C) + /// + internal const String TENDERTYPE_CARD = "C"; + /// + /// ACH Tender (A) + /// + internal const String TENDERTYPE_ACH = "A"; + /// + /// Telecheck Tender (K) + /// + internal const String TENDERTYPE_TELECHECK = "K"; + /// + /// PayPal Tender (P) + /// + internal const String TENDERTYPE_PAYPAL = "P"; + + #region "ACH Tender Related Constants" + + /// + /// ACH Authtype CCD + /// + internal const String AchAuthTypeCCD = "CCD"; + /// + /// ACH Authtype PPD + /// + internal const String AchAuthTypePPD = "PPD"; + /// + /// ACH Authtype POP + /// + internal const String AchAuthTypePOP = "POP"; + /// + /// ACH Authtype WEB + /// + internal const String AchAuthTypeWEB = "WEB"; + /// + /// ACH Authtype RCK + /// + internal const String AchAuthTypeRCK = "RCK"; + /// + /// ACH Authtype ARC + /// + internal const String AchAuthTypeARC = "ARC"; + /// + /// ACH Authtype TEL + /// + internal const String AchAuthTypeTEL = "TEL"; + + #endregion + + #endregion + + #region "Transaction Type Related Constants" + + /// + /// Authorization TrxType (A) + /// + internal const String TRXTYPE_AUTH = "A"; + /// + /// Sale TrxType (S) + /// + internal const String TRXTYPE_SALE = "S"; + /// + /// Credit Trxtype (C) + /// + internal const String TRXTYPE_CREDIT = "C"; + /// + /// Voice Authorization Trxtype (F) + /// + internal const String TRXTYPE_VOICEAUTH = "F"; + /// + /// Capture Trxtype (D) + /// + internal const String TRXTYPE_CAPTURE = "D"; + /// + /// Inquiry Trxtype (I) + /// + internal const String TRXTYPE_INQUIRY = "I"; + /// + /// Void Trxtype (V) + /// + internal const String TRXTYPE_VOID = "V"; + /// + /// Recurring Trxtype (R) + /// + internal const String TRXTYPE_RECURRING = "R"; + /// + /// Fraud Review Trxtype (U) + /// + internal const String TRXTYPE_FRAUDAPPROVE = "U"; + /// + /// Buyer auth Verify Enrollment Trxtype (E) + /// + internal const String TRXTYPE_BUYERAUTH_VE = "E"; + /// + /// Buyer auth Validate Authentication Trxtype (Z) + /// + internal const String TRXTYPE_BUYERAUTH_VA = "Z"; + + #endregion + + #region "RMS Related Constants" + + /// + /// RMS Update Action Approve + /// + internal const String RMS_UPDATEACTION_APPROVE = "RMS_APPROVE"; + /// + /// RMS Update Action Decline + /// + internal const String RMS_UPDATEACTION_DECLINE = "RMS_MERCHANT_DECLINE"; + + #endregion + + #region "Recurring Transaction Related Constants" + + #region "Action Related Constants" + + /// + /// Recurring Action Add (A) + /// + internal const String RECURRING_ACTION_ADD = "A"; + /// + /// Recurring Action Modify (M) + /// + internal const String RECURRING_ACTION_MODIFY = "M"; + /// + /// Recurring Action Reactivate (R) + /// + internal const String RECURRING_ACTION_REACTIVATE = "R"; + /// + /// Recurring Action Cancel (C) + /// + internal const String RECURRING_ACTION_CANCEL = "C"; + /// + /// Recurring Action Inquiry (I) + /// + internal const String RECURRING_ACTION_INQUIRY = "I"; + /// + /// Recurring Action Payment (P) + /// + internal const String RECURRING_ACTION_PAYMENT = "P"; + + #endregion + + #region "Payment Period Related Constants" + + /// + /// Recurring PayPeriod Every Week (WEEK) + /// + internal const String RECURRING_PAYPERIOD_WEEK = "WEEK"; + /// + /// Recurring PayPeriod Every Two Weeks (BIWK) + /// + internal const String RECURRING_PAYPERIOD_BIWK = "BIWK"; + /// + /// Recurring PayPeriod Twice Every Month (SMMO) + /// + internal const String RECURRING_PAYPERIOD_SMMO = "SMMO"; + /// + /// Recurring PayPeriod Every Four Weeks (FRWK) + /// + internal const String RECURRING_PAYPERIOD_FRWK = "FRWK"; + /// + /// Recurring PayPeriod Every Month (MONT) + /// + internal const String RECURRING_PAYPERIOD_MONT = "MONT"; + /// + /// Recurring PayPeriod Every Quarter (QTER) + /// + internal const String RECURRING_PAYPERIOD_QTER = "QTER"; + /// + /// Recurring PayPeriod Twice Every Year (SMYR) + /// + internal const String RECURRING_PAYPERIOD_SMYR = "SMYR"; + /// + /// Recurring PayPeriod Every Year (YEAR) + /// + internal const String RECURRING_PAYPERIOD_YEAR = "YEAR"; + + #endregion + + #endregion + + #region "Constants for Message Code" + /// + /// Error Message Constant for communication error (MSG_1012) + /// + internal const string MSG_COMMUNICATION_ERROR = "MSG_1012"; + /// + /// Error Message Constant for communication error xml pay (MSG_1005) + /// + internal const string MSG_COMMUNICATION_ERROR_XMLPAY = "MSG_1013"; + /// + /// Error Message Constant for communication error (MSG_1012) + /// + internal const string MSG_COMMUNICATION_ERROR_NO_RESPONSE_ID = "MSG_1015"; + /// + /// Error Message Constant for communication error xml pay (MSG_1005) + /// + internal const string MSG_COMMUNICATION_ERROR_XMLPAY_NO_RESPONSE_ID = "MSG_1016"; + #endregion + + #region "Check Type" + + /// + /// Check type Personal (P) + /// + internal const String CHECK_TYPE_PERSONEL = "P"; + /// + /// Check type Corporate (C) + /// + internal const String CHECK_TYPE_CORPORATE = "C"; + + #endregion + + #region "Communication Error HashTable" + + /// + /// Communication Error Codes + /// + internal static Hashtable CommErrorCodes = PopulateErrorCodes(); + + /// + /// Communication Error Messages + /// + internal static Hashtable CommErrorMessages = PopulateErrorMessages(); + + #endregion + + /// + /// Populates Error code hash table + /// + /// Error code hash table + private static Hashtable PopulateErrorCodes() + { + Hashtable ErrorCodeTable = new Hashtable(); + ErrorCodeTable.Add(E_SOK_CONN_FAILED, "-1"); + ErrorCodeTable.Add(E_PARM_NAME, "-6"); + ErrorCodeTable.Add(E_PARM_NAME_LEN, "-7"); + ErrorCodeTable.Add(E_TIMEOUT_WAIT_RESP, "-12"); + ErrorCodeTable.Add(E_NULL_HOST_STRING, "-23"); + ErrorCodeTable.Add(E_INVALID_TIMEOUT, "-30"); + ErrorCodeTable.Add(E_COMMON_NAME, "-32"); + ErrorCodeTable.Add(E_MISSING_REQUEST_ID, "-41"); + ErrorCodeTable.Add(E_EMPTY_PARAM_LIST, "-100"); + ErrorCodeTable.Add(E_CONTXT_INIT_FAILED, "-103"); + ErrorCodeTable.Add(E_UNKNOWN_STATE, "-104"); + ErrorCodeTable.Add(E_INVALID_NVP, "-105"); + ErrorCodeTable.Add(E_RESPONSE_FORMAT_ERROR, "-106"); + ErrorCodeTable.Add(E_VERSION_NOT_SUPPORTED, "-107"); + ErrorCodeTable.Add(E_CONFIG_ERROR, "-109"); + ErrorCodeTable.Add(E_LOG_ERROR, "-110"); + ErrorCodeTable.Add(E_MSGFILE_INIT_ERROR, "-111"); + ErrorCodeTable.Add(E_CURRENCY_PROCESS_ERROR, "-113"); + return ErrorCodeTable; + } + + /// + /// Populates Message code hash table + /// + /// Message code hash table + private static Hashtable PopulateErrorMessages() + { + Hashtable ErrorMessageTable = new Hashtable(); + ErrorMessageTable.Add(E_SOK_CONN_FAILED, "Failed to connect to host"); + ErrorMessageTable.Add(E_PARM_NAME, "Parameter list format error: & in name"); + ErrorMessageTable.Add(E_PARM_NAME_LEN, "Parameter list format error: invalid [] name length clause"); + ErrorMessageTable.Add(E_TIMEOUT_WAIT_RESP, "Timeout waiting for response"); + ErrorMessageTable.Add(E_NULL_HOST_STRING, "Host address not specified"); + ErrorMessageTable.Add(E_INVALID_TIMEOUT, "Invalid timeout value"); + ErrorMessageTable.Add(E_MISSING_REQUEST_ID, "Required Request ID not found in request."); + ErrorMessageTable.Add(E_EMPTY_PARAM_LIST, "Parameter List cannot be empty"); + ErrorMessageTable.Add(E_CONTXT_INIT_FAILED, "Context Initialization failed"); + ErrorMessageTable.Add(E_UNKNOWN_STATE, "Unexpected transaction state"); + ErrorMessageTable.Add(E_INVALID_NVP, "Invalid name value pair request"); + ErrorMessageTable.Add(E_RESPONSE_FORMAT_ERROR, "Invalid response format"); + ErrorMessageTable.Add(E_VERSION_NOT_SUPPORTED, "This XMLPay Version is not supported"); + ErrorMessageTable.Add(E_CONFIG_ERROR, CONFIG_ERROR); + ErrorMessageTable.Add(E_LOG_ERROR, LOGGING_ERROR); + ErrorMessageTable.Add(E_MSGFILE_INIT_ERROR, "Could not initialize from message file."); + ErrorMessageTable.Add(E_CURRENCY_PROCESS_ERROR, "Unable to round and truncate the currency value simultaneously. You can set only one of the two properties Round OR Truncate in the Data Object Currency."); + ErrorMessageTable.Add(E_COMMON_NAME, "The certificate chain did not validate, common name did not match URL."); + return ErrorMessageTable; + } + + #region "Communication Header Related constants" + + /// + /// HTTP Header PAYFLOW-Request-ID + /// + internal const String PAYFLOWHEADER_REQUEST_ID = "X-VPS-Request-ID"; + /// + /// HTTP Header PAYFLOW-CLIENT-TIMEOUT + /// + internal const String PAYFLOWHEADER_TIMEOUT = "X-VPS-CLIENT-TIMEOUT"; + + #endregion + + //Constants for Exception Framework + + #region "Config Constants" + + /// + /// Holds the name of the key used to get the message file name. + /// + internal const String MESSAGE_FILE_NAME = "MSG_FILE"; + /// + /// Holds the key name which holds the Log file name + /// + internal const String CONFIG_LOGFILE_NAME = "LOG_FILE"; + + /// + /// Holds the key name which holds the limit for Log file size + /// + internal const String CONFIG_LOGFILE_SIZE = "LOGFILE_SIZE"; + + /// + /// Holds the key name which holds the Logging level + /// + internal const String CONFIG_LOG_LEVEL = "LOG_LEVEL"; + /// + /// Holds the default Log file name + /// + //internal static String LOGFILE_NAME = AppDomain.CurrentDomain.BaseDirectory + "PayflowSDK.log"; + internal static String LOGFILE_NAME = "PayflowSDK.log"; + + /// + /// Holds the default limit for Log file size + /// + internal const int LOGFILE_SIZE = 10230000; + + /// + /// Logging Level OFF + /// + public const int LOGGING_OFF = 0; + + #endregion + + #region "Message file constants" + + /// + /// Holds the name of the key in the message file that holds the message code. + /// + internal const String MESSAGE_ID = "Id"; + /// + /// Holds the name of the key in the message file that holds the message body. + /// + internal const String MESSAGE_BODY = "Body"; + /// + /// Holds the name of the key in the message file that holds the message severity. + /// + internal const String MESSAGE_SEVERITY = "Severity"; + /// + /// Tag for TRACE in config file + /// + internal const String TRACE_TAG = "TRACE"; + /// + /// Default value of Trace + /// + internal const String TRACE_DEFAULT = TRACE_OFF; + /// + /// On value for Trace + /// + internal const String TRACE_ON = "ON"; + /// + /// Off value for Trace + /// + internal const String TRACE_OFF = "OFF"; + /// + /// Trace value + /// + internal static String TRACE = TRACE_DEFAULT; + + #endregion + + #region "Severity Level constants" + + //-------------------------------------------------------- + //Holds the constants defining the error severity levels + /// + /// Severity for a FATAL level message. + /// + internal const String ERROR_FATAL = "FATAL"; + /// + /// Severity for a ERROR level message. + /// + internal const String ERROR_ERROR = "ERROR"; + /// + /// Severity for a WARN level message. + /// + internal const String ERROR_WARN = "WARN"; + /// + /// Severity for a INFO level message. + /// + internal const String ERROR_INFO = "INFO"; + /// + /// Severity for a DEBUG level message. + /// + internal const String ERROR_DEBUG = "DEBUG"; + //-------------------------------------------------------- + + //-------------------------------------------------------- + //Holds the integer constants defining the error severity levels + /// + /// Severity for a FATAL level message. + /// + public const int SEVERITY_FATAL = 5; + /// + /// Severity for a ERROR level message. + /// + public const int SEVERITY_ERROR = 4; + /// + /// Severity for a WARN level message. + /// + public const int SEVERITY_WARN = 3; + /// + /// Severity for a INFO level message. + /// + public const int SEVERITY_INFO = 2; + /// + /// Severity for a DEBUG level message. + /// + public const int SEVERITY_DEBUG = 1; + //-------------------------------------------------------- + + #endregion + + #region "Messages description" + + //Constants for the Exception + /// + /// Represents the description for error in the configuration file. + /// + internal const String CONFIG_ERROR = "Unable to read from the configuration file. "; + /// + /// Represents the description for error occurred during the logging process. + /// + internal const String LOGGING_ERROR = "Log error: "; + /// + /// Error occurred while formatting message. + /// + internal const String MESSAGE_FORMATTING_ERROR = "Error occurred while formatting the message. "; + /// + /// Error occurred while Adding invalid client(Wrapper) header. + /// + internal const String MESSAGE_WRAPPERHEADER_ERROR = "Error occurred while Adding invalid client(Wrapper) header."; + /// + /// Error occurred while Writting in to Log file + /// + internal const String MESSAGE_LOG_ERROR = "Unable to log messages. "; + /// + /// Error occurred while KEYs are not present in config file for Log + /// + internal const String MESSAGE_CONFIG_LOG_ERROR = "Key does not exist in config file:"; + #endregion + + #region "String formation constants" + + //Constants used for Formatting the message string + /// + /// Format Message Separator (Message) + /// + internal const String FORMAT_MSG_SEPERATOR = "Message "; + /// + /// Format Message Line Separator (---------------------) + /// + internal static String FORMAT_MSG_LINESEPERATOR = Environment.NewLine; + /// + /// Format Message Open Bracket ([) + /// + internal const String FORMAT_MSG_OPENBRACKET = "["; + /// + /// Format Message Close Bracket (]) + /// + internal const String FORMAT_MSG_CLOSEBRACKET = "]"; + /// + /// Format Message Code body Separator (-) + /// + internal const String FORMAT_MSG_CODEBODY_SEP = "-"; + // + + #endregion + + #region "Communication Errors Constants" + + /// + /// Communication Error Connection Failed + /// + internal const String E_SOK_CONN_FAILED = "E_SOK_CONN_FAILED"; + /// + /// Communication Error Param Name Error + /// + internal const String E_PARM_NAME = "E_PARM_NAME"; + /// + /// Communication Error Param Name Length Error + /// + internal const String E_PARM_NAME_LEN = "E_PARM_NAME_LEN"; + /// + /// Communication Error Timeout Waiting for Response + /// + internal const String E_TIMEOUT_WAIT_RESP = "E_TIMEOUT_WAIT_RESP"; + /// + /// Communication Error Null Host String + /// + internal const String E_NULL_HOST_STRING = "E_NULL_HOST_STRING"; + /// + /// Communication Error Invalid Timeout + /// + internal const String E_INVALID_TIMEOUT = "E_INVALID_TIMEOUT"; + /// + /// Communication Error Missing Request Id + /// + internal const String E_MISSING_REQUEST_ID = "E_MISSING_REQUEST_ID"; + /// + /// Communication Error Empty Param List + /// + internal const String E_EMPTY_PARAM_LIST = "E_EMPTY_PARAM_LIST"; + /// + /// Communication Error Context Initialization Failed + /// + internal const String E_CONTXT_INIT_FAILED = "E_CONTXT_INIT_FAILED"; + /// + /// Communication Error Unknown State + /// + internal const String E_UNKNOWN_STATE = "E_UNKNOWN_STATE"; + /// + /// Communication Error Invalid Name Value Pair Request + /// + internal const String E_INVALID_NVP = "E_INVALID_NVP"; + /// + /// Communication Error Response Format Error + /// + internal const String E_RESPONSE_FORMAT_ERROR = "E_RESPONSE_FORMAT_ERROR"; + /// + /// Communication Error Version Not Supported + /// + internal const String E_VERSION_NOT_SUPPORTED = "E_VERSION_NOT_SUPPORTED"; + /// + /// Internal Error Configuration Error. + /// + internal const String E_CONFIG_ERROR = "E_CONFIG_ERROR"; + /// + /// Internal Error Log error. + /// + internal const String E_LOG_ERROR = "E_LOG_ERROR"; + /// + /// Internal Error Log4net initialization error. + /// + internal const String E_MSGFILE_INIT_ERROR = "E_MSGFILE_INIT_ERROR"; + /// + /// Internal Error currency Process error. + /// + internal const String E_CURRENCY_PROCESS_ERROR = "E_CURRENCY_PROCESS_ERROR"; + /// + /// Internal Error currency Process error. + /// + internal const String E_COMMON_NAME = "E_COMMON_NAME"; + + #endregion + + #region "Payflow params constants" + + /// + /// Internal Param REQUEST + /// + internal const String INTL_PARAM_REQUEST = "REQUEST"; + /// + /// Internal Param FULLRESPONSE + /// + internal const String INTL_PARAM_FULLRESPONSE = "FULLRESPONSE"; + /// + /// Internal Param PAYFLOW_HOST + /// + internal const String INTL_PARAM_PAYFLOW_HOST = "PAYFLOW_HOST"; + /// + /// Internal Param PAYFLOW_PORT + /// + internal const String INTL_PARAM_PAYFLOW_PORT = "PAYFLOW_PORT"; + /// + /// Internal Param PAYFLOW_TIMEOUT + /// + internal const String INTL_PARAM_PAYFLOW_TIMEOUT = "PAYFLOW_TIMEOUT"; + /// + /// Internal Param rule + /// + internal const String XML_PARAM_RULE = "rule"; + /// + /// Internal Param num + /// + internal const String XML_PARAM_NUM = "num"; + /// + /// Internal Param ruleId + /// + internal const String XML_PARAM_RULEID = "ruleId"; + /// + /// Internal Param ruleAlias + /// + internal const String XML_PARAM_RULEALIAS = "ruleAlias"; + /// + /// Internal Param ruleDescription + /// + internal const String XML_PARAM_RULEDESCRIPTION = "ruleDescription"; + /// + /// Internal Param action + /// + internal const String XML_PARAM_ACTION = "action"; + /// + /// Internal Param triggeredMessage + /// + internal const String XML_PARAM_TRIGGEREDMESSAGE = "triggeredMessage"; + /// + /// Internal Param rulevendorparms + /// + internal const String XML_PARAM_RULEVENDORPARMS = "rulevendorparms"; + /// + /// Internal Param ruleParameter + /// + internal const String XML_PARAM_RULEPARAMETER = "ruleParameter"; + /// + /// Internal Param name + /// + internal const String XML_PARAM_NAME = "name"; + /// + /// Internal Param value + /// + internal const String XML_PARAM_VALUE = "value"; + /// + /// Internal Param type + /// + internal const String XML_PARAM_TYPE = "type"; + /// + /// XML Pay Param version + /// + internal const String XML_PARAM_VERSION = "version"; + /// + /// XML Pay Param Vendor + /// + internal const String XML_PARAM_VENDOR = "Vendor"; + /// + /// XML Pay Param User + /// + internal const String XML_PARAM_USER = "User"; + /// + /// XML Pay Param Partner + /// + internal const String XML_PARAM_PARTNER = "Partner"; + /// + /// XML Pay Param Password + /// + internal const String XML_PARAM_PASSWORD = "Password"; + /// + /// XML Pay Param AcctNum + /// + internal const String XML_PARAM_ACCTNUM = "AcctNum"; + /// + /// XML Pay Param CardNum + /// + internal const String XML_PARAM_CARDNUM = "CardNum"; + /// + /// XML Pay Param ExpDate + /// + internal const String XML_PARAM_EXPDATE = "ExpDate"; + /// + /// XML Pay Param MagData + /// + internal const String XML_PARAM_MAGDATA = "MagData"; + /// + /// XML Pay Param MICR + /// + internal const String XML_PARAM_MICR = "MICR"; + /// + /// XML Pay Param CVNum + /// + internal const String XML_PARAM_CVNUM = "CVNum"; + /// + /// XML Pay Param DL + /// + internal const String XML_PARAM_DL = "DL"; + /// + /// XML Pay Param SS + /// + internal const String XML_PARAM_SS = "SS"; + /// + /// XML Pay Param DOB + /// + internal const String XML_PARAM_DOB = "DOB"; + /// + /// XML Pay Start tag + /// + internal const String XML_PARAM_START_TAG = " 0) + { + int NVDelimiterIndex = ParamList.IndexOf("&", NVSeparatorIndex); + if (NVDelimiterIndex + 1 < ParamList.Length && ParamList[NVDelimiterIndex + 1] == '&') + { + NVDelimiterIndex += 2; + NVDelimiterIndex = ParamList.IndexOf("&", NVDelimiterIndex); + } + + if (NVDelimiterIndex < 0) + { + NVDelimiterIndex = ParamList.Length; + } + + if (MaskFoundValue) + { + int MaskIndex; + char[] ValueArr = Value.ToCharArray(); + if (Name == PayflowConstants.PARAM_ACCT) + { + for (MaskIndex = NVSeparatorIndex + 7; MaskIndex < NVDelimiterIndex - 4; MaskIndex++) + { + ValueArr[MaskIndex] = 'X'; + } + } + else + { + for (MaskIndex = NVSeparatorIndex + 1; MaskIndex < NVDelimiterIndex; MaskIndex++) + { + ValueArr[MaskIndex] = 'X'; + } + } + Value = new String(ValueArr); + } + else + { + Value = ParamList.Substring(NVSeparatorIndex + 1, (NVDelimiterIndex) - (NVSeparatorIndex + 1)); + } + } + } + return Value; + } + + + /// + /// Check if timeout has occurred + /// + /// Time out in Msec + /// Start time in Msec + /// out Time remaining in Msec + /// True if Timed out, false otherwise + internal static bool IsTimedOut(long TimeOutMsec, long StartTimeMsec, out long TimeRemainingMsec) + { + long CurrentTimeMsec = DateTime.Now.Ticks / 10000; + long TimeElapsedMsec = CurrentTimeMsec - StartTimeMsec; + TimeRemainingMsec = TimeOutMsec - TimeElapsedMsec; + Logger.Instance.Log("Time Remaining = " + TimeRemainingMsec.ToString(), PayflowConstants.SEVERITY_INFO); + if (TimeRemainingMsec >= 0) + { + return false; + } + else + { + return true; + } + } + + /// + /// Retrieves XmlPay version from Xml Pay Request. + /// + /// Xml Pay Request. + /// String Value of version + internal static String GetXmlVersion(String Request) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.GetXmlVersion(String): Entered.", PayflowConstants.SEVERITY_DEBUG); + String Version; + Version = GetXmlAttribute(Request, PayflowConstants.XML_PARAM_VERSION); + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.GetXmlVersion(String): Exiting.", PayflowConstants.SEVERITY_DEBUG); + return Version; + } + + /// + /// Retrieves value of given Xml attribute from Xml Pay Request. + /// + /// Xml Pay Request + /// Attribute Tag Name + /// + internal static String GetXmlAttribute(String Request, String Attribute) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.GetXmlAttribute(String,String): Entered.", PayflowConstants.SEVERITY_DEBUG); + + String RetVal = PayflowConstants.EMPTY_STRING; + if (Request != null && Request.Length > 0) + { + String AttributeValue = null; + XmlDocument XmlPayRequest = new XmlDocument(); + XmlPayRequest.LoadXml(Request); + XmlNodeList XmlPayChildNodes = XmlPayRequest.ChildNodes; + foreach (XmlNode XmlPayNode in XmlPayChildNodes) + { + if (XmlPayNode.LocalName.Equals(PayflowConstants.XMLPAY_REQUEST_TAG)) + { + XmlAttributeCollection XmlPayReqAttributes = XmlPayNode.Attributes; + if (XmlPayReqAttributes != null) + { + XmlNode AttributeNode = XmlPayReqAttributes.GetNamedItem(Attribute); + if (AttributeNode != null) + { + AttributeValue = AttributeNode.InnerText; + } + break; + } + else + { + break; + } + } + } + + RetVal = AttributeValue; + } + return RetVal; + } + + /// + /// Gets the Xml Namespace from the XmlPay Request. + /// + /// Xml Pay Request. + /// String Value of Xml Namespace. + internal static String GetXmlNameSpace(String Request) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.GetXmlNameSpace(String): Entered.", PayflowConstants.SEVERITY_DEBUG); + + String XmlNameSpace = ""; + String XmlPayVersion = null; + XmlPayVersion = GetXmlVersion(Request); + if (!("1.0".Equals(XmlPayVersion))) + { + XmlNameSpace = PayflowConstants.XMLPAY_NAMESPACE; + } + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.GetXmlNameSpace(String): Exiting.", PayflowConstants.SEVERITY_DEBUG); + return XmlNameSpace; + + } + + /// + /// Gets the inner text from an xml node. + /// + /// XmlPay Request loaded in System.Xml.XmlDocument. + /// Node Name + /// Inner text in node. + internal static String GetXmlNodeValue(XmlDocument XmlPayRequest, String NodeName) + { + String RetVal = PayflowConstants.EMPTY_STRING; + if (XmlPayRequest != null && NodeName != null && NodeName.Length > 0) + { + XmlNodeList NodeList = XmlPayRequest.GetElementsByTagName(NodeName); + if (NodeList != null && NodeList.Count == 1) + { + XmlNode NodeElement = NodeList[0]; + if (NodeElement != null) + { + RetVal = NodeElement.InnerText; + } + } + } + return RetVal; + } + + + + /// + /// Populates Errors from Exceptions. + /// + /// Error Message Code + /// Occurred Exception, pass null if no Exception. + /// Additional Message + /// True if request is xml pay request, false otherwise + /// Severity Level + /// Populated ErrorObject. + internal static ErrorObject PopulateCommError(String CommMessageCode, + Exception Ex, int SeverityLevel, bool IsXmlPayReq, String AddMessage) + { + String Message; + String MessageCode; + String Trace = PayflowConstants.EMPTY_STRING; + + InitStackTraceOn(); + + string[] MsgParams = null; + + if (AddMessage == null) + { + AddMessage = PayflowConstants.EMPTY_STRING; + } + else if (AddMessage.Length > 0) + { + AddMessage = " " + AddMessage; + } + if (Ex != null && 0 == String.Compare(PayflowConstants.TRACE_ON, PayflowConstants.TRACE, true)) + { + Trace = " " + Ex.ToString(); + } + + Message = (String)PayflowConstants.CommErrorMessages[CommMessageCode] + + AddMessage + Trace; + + if (IsXmlPayReq) + { + MessageCode = PayflowConstants.MSG_COMMUNICATION_ERROR_XMLPAY; + MsgParams = new string[] { (String)PayflowConstants.CommErrorCodes[CommMessageCode], Message }; + + } + else + { + MessageCode = PayflowConstants.MSG_COMMUNICATION_ERROR; + MsgParams = new string[] { (String)PayflowConstants.CommErrorCodes[CommMessageCode], Message }; + + } + + + ErrorObject InitError = new ErrorObject(SeverityLevel, MessageCode, MsgParams); + return InitError; + } + + /// + /// Masks the sensitive fields in the + /// param list which will be used for + /// logging purpose. + /// + /// Paramlist to be masked. + /// Masked param list. + internal static String MaskSensitiveFields(String ParmList) + { + String RetVal; + if (ParmList != null && ParmList.Length > 0) + { + if (ParmList.IndexOf(PayflowConstants.XML_ID) >= 0) + { + RetVal = MaskXMLPayRequest(ParmList); + } + else + { + RetVal = MaskNVPRequest(ParmList); + } + } + else + { + RetVal = ParmList; + } + return RetVal; + } + + /// + /// Masks XMLPay Request + /// + /// XMLPay request to be masked + /// Masked XMLPay Request + internal static String MaskXMLPayRequest(String ParmList) + { + String RetVal; + try + { + XmlDocument XmlPayRequest = new XmlDocument(); + XmlPayRequest.LoadXml(ParmList); + //Mask ACCT if present : Corresponding XmlPay element --> AcctNum or CardNum + PayflowUtility.MaskXmlNodeValue(ref XmlPayRequest, PayflowConstants.XML_PARAM_ACCTNUM); + PayflowUtility.MaskXmlNodeValue(ref XmlPayRequest, PayflowConstants.XML_PARAM_CARDNUM); + //Mask EXPDATE if present : Corresponding XmlPay element --> ExpDate + //PayflowUtility.MaskXmlNodeValue(ref XmlPayRequest, PayflowConstants.XML_PARAM_EXPDATE); + //Mask SWIPE if present : Corresponding XmlPay element --> MagData + PayflowUtility.MaskXmlNodeValue(ref XmlPayRequest, PayflowConstants.XML_PARAM_MAGDATA); + //Mask MICR if present : Corresponding XmlPay element --> MICR or MagData + PayflowUtility.MaskXmlNodeValue(ref XmlPayRequest, PayflowConstants.XML_PARAM_MICR); + //Mask CVV2 if present : Corresponding XmlPay element --> CVNum + PayflowUtility.MaskXmlNodeValue(ref XmlPayRequest, PayflowConstants.XML_PARAM_CVNUM); + //Mask PWD if present : Corresponding XmlPay element --> Password + PayflowUtility.MaskXmlNodeValue(ref XmlPayRequest, PayflowConstants.XML_PARAM_PASSWORD); + //Mask DL if present : Corresponding XmlPay element --> DL + PayflowUtility.MaskXmlNodeValue(ref XmlPayRequest, PayflowConstants.XML_PARAM_DL); + //Mask SS if present : Corresponding XmlPay element --> CVNum + PayflowUtility.MaskXmlNodeValue(ref XmlPayRequest, PayflowConstants.XML_PARAM_SS); + //Mask DOB if present : Corresponding XmlPay element --> DOB + PayflowUtility.MaskXmlNodeValue(ref XmlPayRequest, PayflowConstants.XML_PARAM_DOB); + + RetVal = XmlPayRequest.InnerXml; + } + catch + { + RetVal = ParmList; + } + return RetVal; + } + + /// + /// Masks the NVP request + /// + /// Param List to be masked + /// Masked Param List + internal static String MaskNVPRequest(String ParmList) + { + String LogParmList = ParmList; + //Mask ACCT if present + LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_ACCT, true); + //Mask EXPDATE if present + //LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_EXPDATE, true); + //Mask SWIPE if present + LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_SWIPE, true); + //Mask MICR if present + LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_MICR, true); + //Mask CVV2 if present + LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_CVV2, true); + //Mask PWD + LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_PWD, true); + //Mask DL if present + LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_DL, true); + //Mask SS if present + LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_SS, true); + //Mask DOB if present + LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_DOB, true); + //Mask MAGTEKPWD if present + LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.MAGTEK_PARAM_MAGTEKPWD, true); + //Mask VIT_OSNAME if present + //LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_VIT_OSNAME, true); + //Mask VIT_OSARCH if present + //LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_VIT_OSARCH, true); + //Mask VIT_OSVERSION if present + //LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_VIT_OSVERSION, true); + //Mask VIT_SDKRUNTIMEVERSION if present + //LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_VIT_SDKRUNTIMEVERSION, true); + //Mask VIT_PROXY if present + //LogParmList = PayflowUtility.LocateValueForName(LogParmList, PayflowConstants.PARAM_VIT_PROXY, true); + return LogParmList; + } + + /// + /// This method replaces the inner text of the node NodeName in the XMLPayRequest xml document with XXXXX + /// + /// This is the XML Document + /// This is the node name whose inner text is to be masked + internal static void MaskXmlNodeValue(ref XmlDocument XmlPayRequest, String NodeName) + { + String RetVal = ""; + String MaskValue = ""; + if (XmlPayRequest != null && NodeName != null && NodeName.Length > 0) + { + XmlNodeList NodeList = XmlPayRequest.GetElementsByTagName(NodeName); + if (NodeList != null && NodeList.Count > 0) + { + int n = 0; + do + { + XmlNode NodeElement = NodeList[n]; + if (NodeElement != null) + { + RetVal = NodeElement.InnerText; + for (int i = 0; i < RetVal.Length; i++) + { + MaskValue = MaskValue + "X"; + } + NodeElement.InnerText = MaskValue; + n++; MaskValue = ""; + } + } while (n < NodeList.Count); + } + } + } + + internal static void InitStackTraceOn() + { + + if (!mTraceInitialized) + { + try + { + String StackTraceOn; + StackTraceOn = PayflowUtility.AppSettings(PayflowConstants.TRACE_TAG); + if (0 == String.Compare(PayflowConstants.TRACE_ON, StackTraceOn, true)) + { + PayflowConstants.TRACE = PayflowConstants.TRACE_ON; + } + } + catch + { + PayflowConstants.TRACE = PayflowConstants.TRACE_DEFAULT; + } + } + mTraceInitialized = true; + } + + /// + /// Provides the status of the transaction based on the transaction response. + /// + /// Response obtained from PayPal Payment Gateway. + /// String result for the transaction: + /// + /// If Transaction Result = 0 then Transaction Successful. + /// If Transaction Result != 0 then Transaction Failed. + /// + /// + public static String GetStatus(Response Resp) + { + String Status = null; + + if (Resp.TransactionResponse != null && 0 == Resp.TransactionResponse.Result) + { + Status = "Transaction Successful."; + } + else + { + Status = "Transaction Failed."; + } + return Status; + } + + /// + /// Provides the status of the transaction based on the transaction responses. + /// + /// Transaction response string obtained from PayPal Payment Gateway. + /// String result for the transaction: + /// + /// If Transaction Result = 0 Transaction Successful. + /// If Transaction Result != 0 then Transaction Failed. + /// + /// + public static String GetStatus(String TransactionResponse) + { + String Status = PayflowConstants.EMPTY_STRING; + bool IsTrxRespXmlPay = false; + bool NullTrxResp = false; + int Index; + if (TransactionResponse != null) + { + Index = TransactionResponse.IndexOf(PayflowConstants.XML_RESP_ID); + if (Index >= 0) + { + IsTrxRespXmlPay = true; + } + else + { + IsTrxRespXmlPay = false; + } + } + else + { + NullTrxResp = true; + } + + + String TrxResult = PayflowConstants.EMPTY_STRING; + + if (!NullTrxResp) + { + if (IsTrxRespXmlPay) + { + TrxResult = GetXmlPayNodeValue(TransactionResponse, PayflowConstants.XML_PARAM_RESULT); + } + else + { + TrxResult = LocateValueForName(TransactionResponse, PayflowConstants.PARAM_RESULT, false); + } + } + + if ((!NullTrxResp)) + { + if ("0".Equals(TrxResult)) + { + Status = "Transaction Successful."; + } + else + { + Status = "Transaction Failed."; + } + } + return Status; + } + /// + /// Returns a boolean value indicating the status of the transaction + /// + /// Response obtained from PayPal Payment Gateway. + /// true if transaction was success + public static bool GetTransactionStatus(Response Resp) + { + return (Resp.TransactionResponse != null && 0 == Resp.TransactionResponse.Result); + } + + /// + /// Gets the inner text of a node from an XMLPay request + /// + /// XMLPay request string + /// Node name + /// Inner text string + public static String GetXmlPayNodeValue(String XmlPayRequest, String NodeName) + { + String RetVal = null; + try + { + XmlDocument XmlPayDoc = new XmlDocument(); + XmlPayDoc.LoadXml(XmlPayRequest); + RetVal = GetXmlNodeValue(XmlPayDoc, NodeName); + } + catch + { + RetVal = null; + } + return RetVal; + } + + + internal static ArrayList AlignContext(Context Context, bool IsXmlPayRequest) + { + ArrayList Errors = Context.GetErrors(); + ArrayList RetVal = new ArrayList(); + int ErrorCount = Errors.Count; + int Index; + for (Index = 0; Index < ErrorCount; Index++) + { + ErrorObject Error = (ErrorObject)Errors[Index]; + String MessageCode = Error.MessageCode; + if (Error != null) + { + if (MessageCode != null && MessageCode.Length > 0) + { + bool Msg1012 = false; + bool Msg1013 = false; + bool Msg1015 = false; + bool Msg1016 = false; + + if ("MSG_1012".Equals(MessageCode)) + { Msg1012 = true; } + else if ("MSG_1013".Equals(MessageCode)) + { Msg1013 = true; } + else if ("MSG_1015".Equals(MessageCode)) + { Msg1015 = true; } + else if ("MSG_1016".Equals(MessageCode)) + { Msg1016 = true; } + + if (IsXmlPayRequest) + { + if (Msg1013 || Msg1016) + { + RetVal.Add(Error); + } + else + { + ErrorObject NewError = null; + try + { + + if (Msg1012) + { + ArrayList MsgParams = Error.MessageParams; + String[] NewMsgParams = new String[] { (String)MsgParams[0], + (String)MsgParams[1]}; + NewError = new ErrorObject(Error.SeverityLevel, "MSG_1013", NewMsgParams, Error.ErrorStackTrace); + } + else if (Msg1015) + { + ArrayList MsgParams = Error.MessageParams; + String[] NewMsgParams = new String[] { (String)MsgParams[0], + (String)MsgParams[1]}; + NewError = new ErrorObject(Error.SeverityLevel, "MSG_1016", NewMsgParams, Error.ErrorStackTrace); + + } + else + { + String ErrMessage = Error.ToString(); + NewError = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE, null, Error.SeverityLevel, true, ErrMessage); + } + } + catch + { + NewError = null; + } + + if (NewError != null) + { + RetVal.Add(NewError); + } + } + } + else + { + if (Msg1012 || Msg1015) + { + RetVal.Add(Error); + } + else + { + ErrorObject NewError = null; + try + { + if (Msg1013) + { + ArrayList MsgParams = Error.MessageParams; + String[] NewMsgParams = new String[] {(String)MsgParams[2], + (String)MsgParams[3]}; + NewError = new ErrorObject(Error.SeverityLevel, "MSG_1012", NewMsgParams, Error.ErrorStackTrace); + } + else if (Msg1016) + { + ArrayList MsgParams = Error.MessageParams; + String[] NewMsgParams = new String[] {(String)MsgParams[1], + (String)MsgParams[2]}; + NewError = new ErrorObject(Error.SeverityLevel, "MSG_1015", NewMsgParams, Error.ErrorStackTrace); + } + else + { + String ErrMessage = Error.ToString(); + NewError = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE, null, Error.SeverityLevel, false, ErrMessage); + } + } + catch + { + NewError = null; + } + + if (NewError != null) + { + RetVal.Add(NewError); + } + } + } + } + else + { + ErrorObject NewError = null; + try + { + String ErrMessage = Error.ToString(); + if (ErrMessage != null && ErrMessage.Length > 0) + { + String Result = PayflowConstants.EMPTY_STRING; + String RespMsg = PayflowConstants.EMPTY_STRING; + bool ErrIsXmlPay = (ErrMessage.IndexOf(PayflowConstants.XML_RESP_ID) >= 0); + //Check whether the error string is in nvp format + // or xml pay format. + if (ErrIsXmlPay) + { + //Try to get values in nodes Result, RespMsg + Result = PayflowUtility.GetXmlPayNodeValue(ErrMessage, PayflowConstants.XML_PARAM_RESULT); + RespMsg = PayflowUtility.GetXmlPayNodeValue(ErrMessage, PayflowConstants.XML_PARAM_MESSAGE); + } + else + { + //Try to get RESULT , RESPMSG from the error if + // available. + Result = PayflowUtility.LocateValueForName(ErrMessage, PayflowConstants.PARAM_RESULT, false); + RespMsg = PayflowUtility.LocateValueForName(ErrMessage, PayflowConstants.PARAM_RESPMSG, false); + } + + if (Result != null && Result.Length > 0 && RespMsg != null && RespMsg.Length > 0) + { + StringBuilder NewErrMessage = new StringBuilder(""); + if (IsXmlPayRequest && !ErrIsXmlPay) + { + NewErrMessage = new StringBuilder(""); + NewErrMessage.Append(Result); + NewErrMessage.Append(""); + NewErrMessage.Append(RespMsg); + NewErrMessage.Append(""); + NewError = new ErrorObject(Error.SeverityLevel, "", NewErrMessage.ToString()); + + } + else if (!IsXmlPayRequest && ErrIsXmlPay) + { + NewErrMessage = new StringBuilder(PayflowConstants.PARAM_RESULT); + NewErrMessage.Append(PayflowConstants.SEPARATOR_NVP); + NewErrMessage.Append(Result); + NewErrMessage.Append(PayflowConstants.DELIMITER_NVP); + NewErrMessage.Append(PayflowConstants.PARAM_RESPMSG); + NewErrMessage.Append(PayflowConstants.SEPARATOR_NVP); + NewErrMessage.Append(RespMsg); + + NewError = new ErrorObject(Error.SeverityLevel, "", NewErrMessage.ToString()); + } + else + { + NewError = new ErrorObject(Error.SeverityLevel, "", ErrMessage); + } + } + else + { + StringBuilder NewErrMessage = new StringBuilder(""); + if (IsXmlPayRequest) + { + NewErrMessage = new StringBuilder(""); + NewErrMessage.Append((String)PayflowConstants.CommErrorCodes[PayflowConstants.E_UNKNOWN_STATE]); + NewErrMessage.Append(""); + NewErrMessage.Append((String)PayflowConstants.CommErrorMessages[PayflowConstants.E_UNKNOWN_STATE] + " " + ErrMessage); + NewErrMessage.Append(""); + + } + else + { + NewErrMessage = new StringBuilder(PayflowConstants.PARAM_RESULT); + NewErrMessage.Append(PayflowConstants.SEPARATOR_NVP); + NewErrMessage.Append((String)PayflowConstants.CommErrorCodes[PayflowConstants.E_UNKNOWN_STATE]); + NewErrMessage.Append(PayflowConstants.DELIMITER_NVP); + NewErrMessage.Append(PayflowConstants.PARAM_RESPMSG); + NewErrMessage.Append(PayflowConstants.SEPARATOR_NVP); + NewErrMessage.Append((String)PayflowConstants.CommErrorMessages[PayflowConstants.E_UNKNOWN_STATE] + " " + ErrMessage); + + } + + NewError = new ErrorObject(Error.SeverityLevel, "", NewErrMessage.ToString()); + + } + + } + } + catch + { + NewError = null; + } + + if (NewError != null) + { + RetVal.Add(NewError); + } + } + } + } + + return RetVal; + } + + /// + /// Returns AppSettings + /// + /// + /// + public static String AppSettings(String AppSettingsKey) + { + /// Uncomment the line below for .NET Core to be able to read the app.config file. + var mPFProAPPSettingsReader = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSettings; + AppSettingsReader mPFProAppSettingsReader; + mPFProAppSettingsReader = new AppSettingsReader(); + return (String)mPFProAppSettingsReader.GetValue(AppSettingsKey, typeof(String)); + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/InitState.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/InitState.cs new file mode 100644 index 0000000..92040c4 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/InitState.cs @@ -0,0 +1,101 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Logging; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// InitState - PayPal Payment State + abstract internal class InitState : PaymentState + { + #region "Properties" + + #endregion + + #region "Constructors" + + /// + /// Constructor for InitState. + /// + /// PaymentConnection Object. + /// Initial Parameter list. + /// Context Object by ref + public InitState(PaymentConnection connection, String InitialParameterList, ref Context PsmContext) : base(connection, InitialParameterList, ref PsmContext) + { + } + + /// + /// Copy Constructor for InitState. + /// + /// PaymentState Object. + public InitState(PaymentState CurrentPaymentState) : base(CurrentPaymentState) + { + } + + #endregion + + /// + /// Sets the appropriate server file path for the connection + /// and initializes the connection uri. + /// + public override void Execute() + { + bool IsConnected = false; + Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Entered.", PayflowConstants.SEVERITY_DEBUG); + if (!InProgress) + return; + try + { + Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Initializing Connection.", PayflowConstants.SEVERITY_INFO); + //Begin Payflow Timeout Check Point 2 + long TimeRemainingMsec; + bool TimedOut = PayflowUtility.IsTimedOut(mConnection.TimeOut, mConnection.StartTime, out TimeRemainingMsec); + if (TimedOut) + { + String AddlMessage = "Input timeout value in millisec : " + Connection.TimeOut.ToString(); + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_TIMEOUT_WAIT_RESP, null, PayflowConstants.SEVERITY_FATAL, IsXmlPayRequest, AddlMessage); + if (!CommContext.IsCommunicationErrorContained(Err)) + { + CommContext.AddError(Err); + } + } + else + { + mConnection.TimeOut = TimeRemainingMsec; + } + //End Payflow Timeout Check Point 2 + IsConnected = mConnection.ConnectToServer(); + } + catch (Exception Ex) + { + Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Error occurred While Initializing Connection.", PayflowConstants.SEVERITY_ERROR); + Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Exception " + Ex.ToString(), PayflowConstants.SEVERITY_ERROR); + IsConnected = false; + } + //catch + //{ + // IsConnected = false; + //} + finally + { + if (IsConnected) + { + Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Connection Initialization = Success", PayflowConstants.SEVERITY_INFO); + SetStateSuccess(); + } + else + { + Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Initialized Connection = Failure", PayflowConstants.SEVERITY_INFO); + SetStateFail(); + } + + } + + Logger.Instance.Log("PayPal.Payments.Communication.InitState.Execute(): Exiting.", PayflowConstants.SEVERITY_DEBUG); + } + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/NamespaceDoc.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/NamespaceDoc.cs new file mode 100644 index 0000000..1facf28 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/NamespaceDoc.cs @@ -0,0 +1,10 @@ + +namespace PayPal.Payments.Communication +{ + /// + ///NameSpace doc for Communications namespace + /// + internal class NamespaceDoc + { + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/PayflowNETAPI.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/PayflowNETAPI.cs new file mode 100644 index 0000000..99c4503 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/PayflowNETAPI.cs @@ -0,0 +1,1484 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Logging; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.DataObjects; +using System.Collections; +using System.Text; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// PayflowNETAPI is used to submit a Name-value pair or XMLPay request to + /// PayPal payment gateway for online payment processing. The response + /// returned is the string value of the response from the PayPal payment + /// gateway. + /// + /// Instance of PayflowNETAPI initialized with the information related + /// to connection to the PayPal payment gateway. + /// If the empty constructor of this class is used to create the object or + /// passed values are empty, then The following values (if empty) + /// are looked for as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// PAYFLOW_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + /// + /// + /// /// .......... + /// // Sample Request. + /// // Please replace user, vendor, password & partner with your merchant information. + /// String Request = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password"; + /// + /// // Create an instance of PayflowNETAPI. + /// PayflowNETAPI PayflowNetApi = new PayflowNETAPI(); + /// + /// // RequestId is a unique string that is required for each & every transaction. + /// // The merchant can use her/his own algorithm to generate this unique request id or + /// // use the SDK provided API to generate this as shown below (PayflowUtility.RequestId). + /// String Response = PayflowNetApi.SubmitTransaction(Request, PayflowUtility.RequestId); + /// + /// // To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PayflowNetApi.TransactionRequest); + /// Console.WriteLine(Environment.NewLine + "Response = " + Response); + /// + /// // Following lines of code are optional. + /// // Begin optional code for displaying SDK errors ... + /// // It is used to read any errors that might have occurred in the SDK. + /// + /// String TransErrors = PayflowNetApi.TransactionContext.ToString(); + /// if (TransErrors != null && TransErrors.Length > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + /// } + /// + /// + /// + /// ' Sample Request. + /// ' Please replace user, vendor, password & partner with your merchant information. + /// Dim Request As String = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password" + /// + /// ' Create an instance of PayflowNETAPI. + /// Dim PayflowNetApi As PayflowNETAPI = new PayflowNETAPI + /// + /// ' RequestId is a unique string that is required for each & every transaction. + /// ' The merchant can use her/his own algorithm to generate this unique request id or + /// ' use the SDK provided API to generate this as shown below (PayflowUtility.GetRequestId()). + /// Dim Response As String = PayflowNetApi.SubmitTransaction(Request, PayflowUtility.RequestId) + /// + /// ' To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PayflowNetApi.TransactionRequest) + /// Console.WriteLine(Environment.NewLine + "Response = " + Response) + /// + /// ' Following lines of code are optional. + /// ' Begin optional code for displaying SDK errors ... + /// ' It is used to read any errors that might have occurred in the SDK. + /// + /// Dim TransErrors As String = PayflowNetApi.TransactionContext.ToString() + /// If (Not TransErrors Is Nothing And TransErrors.Length > 0) Then + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors) + /// End If + /// + /// + + [System.Runtime.InteropServices.ComVisible(true)] + [System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual)] + public sealed class PayflowNETAPI + { + #region "Member Variables" + + /// + /// PaymentStateMachine object. + /// + private PaymentStateMachine mPaymentStateMachine; + + /// + /// Request Id + /// + private String mRequestId; + + /// + /// Host Address + /// + private String mHostAddress; + + /// + /// Host Port + /// + private int mHostPort; + + /// + /// TimeOut + /// + private int mTimeOut; + + /// + /// Proxy Address + /// + private String mProxyAddress; + + /// + /// Proxy Port + /// + private int mProxyPort; + + /// + /// Proxy Logon + /// + private String mProxyLogon; + + /// + /// Proxy Password + /// + private String mProxyPassword; + + /// + /// Transaction Context + /// p + private Context mTransactionContext; + + /// + /// Transaction Request + /// + private String mTransactionRequest; + + /// + /// Transaction Response + /// + private String mTransactionResponse; + + /// + /// Flag for Strong Assembly Transaction; + /// + private bool mIsStrongAssemblyTransaction; + /// + /// Flag for xml pay request + /// + private bool mIsXmlPayRequest = false; + /// + /// Transaction request withought masking + /// + private String mTransRqst; + /// + /// Client information. + /// + private ClientInfo mClientInfo; + #endregion + + #region "Constructors" + + /// + /// PayflowNETAPI Constructor + /// + /// + /// PayflowNETAPI is used to submit a Name-value pair or XMLPay request to + /// PayPal payment gateway for online payment processing. The response + /// returned is the string value of the response from the PayPal payment + /// gateway. + /// + /// Instance of PayflowNETAPI initialized with the information related + /// to connection to the PayPal payment gateway. + /// If the empty constructor of this class is used to create the object or + /// passed values are empty, then The following values (if empty) + /// are looked for as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// PAYFLOW_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + /// + /// + /// /// .......... + /// // Sample Request. + /// // Please replace user, vendor, password & partner with your merchant information. + /// String Request = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password"; + /// + /// // Create an instance of PayflowNETAPI. + /// PayflowNETAPI PfProNetApi = new PayflowNETAPI(); + /// + /// // RequestId is a unique string that is required for each & every transaction. + /// // The merchant can use her/his own algorithm to generate this unique request id or + /// // use the SDK provided API to generate this as shown below (PayflowUtility.RequestId). + /// String Response = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId); + /// + /// // To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest); + /// Console.WriteLine(Environment.NewLine + "Response = " + Response); + /// + /// // Following lines of code are optional. + /// // Begin optional code for displaying SDK errors ... + /// // It is used to read any errors that might have occurred in the SDK. + /// + /// String TransErrors = PfProNetApi.TransactionContext.ToString(); + /// if (TransErrors != null && TransErrors.Length > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + /// } + /// + /// // End optional code for displaying SDK errors. + /// + /// + /// + /// ' Sample Request. + /// ' Please replace user, vendor, password & partner with your merchant information. + /// Dim Request As String = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password" + /// + /// ' Create an instance of PayflowNETAPI. + /// Dim PfProNetApi As PayflowNETAPI = new PayflowNETAPI + /// + /// ' RequestId is a unique string that is required for each & every transaction. + /// ' The merchant can use her/his own algorithm to generate this unique request id or + /// ' use the SDK provided API to generate this as shown below (PayflowUtility.GetRequestId()). + /// Dim Response As String = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId) + /// + /// ' To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest) + /// Console.WriteLine(Environment.NewLine + "Response = " + Response) + /// + /// ' Following lines of code are optional. + /// ' Begin optional code for displaying SDK errors ... + /// ' It is used to read any errors that might have occurred in the SDK. + /// + /// Dim TransErrors As String = PfProNetApi.TransactionContext.ToString() + /// If (Not TransErrors Is Nothing And TransErrors.Length > 0) Then + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors) + /// End If + /// + /// 'End optional code for displaying SDK errors. + /// + /// + public PayflowNETAPI() + : this(null, 0, 0, null, 0, null, null) + { + } + + /// + /// PayflowNETAPI Constructor + /// + /// Payflow Host Address. + /// Payflow Host Port. + /// Transaction Timeout. + /// Proxy Address. + /// Proxy Port. + /// Proxy Logon Id. + /// Proxy Password. + /// + /// PayflowNETAPI is used to submit a Name-value pair or XMLPay request to + /// PayPal payment gateway for online payment processing. The response + /// returned is the string value of the response from the PayPal payment + /// gateway. + /// + /// Instance of PayflowNETAPI initialized with the information related + /// to connection to the PayPal payment gateway. + /// If the empty constructor of this class is used to create the object or + /// passed values are empty, then The following values (if empty) + /// are looked for as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// PAYFLOW_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + /// + /// + /// /// .......... + /// // Sample Request. + /// // Please replace user, vendor, password & partner with your merchant information. + /// String Request = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password"; + /// + /// // Create an instance of PayflowNETAPI. + /// PayflowNETAPI PfProNetApi = new PayflowNETAPI(); + /// + /// // RequestId is a unique string that is required for each & every transaction. + /// // The merchant can use her/his own algorithm to generate this unique request id or + /// // use the SDK provided API to generate this as shown below (PayflowUtility.RequestId). + /// String Response = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId); + /// + /// // To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest); + /// Console.WriteLine(Environment.NewLine + "Response = " + Response); + /// + /// // Following lines of code are optional. + /// // Begin optional code for displaying SDK errors ... + /// // It is used to read any errors that might have occurred in the SDK. + /// + /// String TransErrors = PfProNetApi.TransactionContext.ToString(); + /// if (TransErrors != null && TransErrors.Length > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + /// } + /// + /// // End optional code for displaying SDK errors. + /// + /// + /// + /// ' Sample Request. + /// ' Please replace user, vendor, password & partner with your merchant information. + /// Dim Request As String = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password" + /// + /// ' Create an instance of PayflowNETAPI. + /// Dim PfProNetApi As PayflowNETAPI = new PayflowNETAPI + /// + /// ' RequestId is a unique string that is required for each & every transaction. + /// ' The merchant can use her/his own algorithm to generate this unique request id or + /// ' use the SDK provided API to generate this as shown below (PayflowUtility.GetRequestId()). + /// Dim Response As String = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId) + /// + /// ' To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest) + /// Console.WriteLine(Environment.NewLine + "Response = " + Response) + /// + /// ' Following lines of code are optional. + /// ' Begin optional code for displaying SDK errors ... + /// ' It is used to read any errors that might have occurred in the SDK. + /// + /// Dim TransErrors As String = PfProNetApi.TransactionContext.ToString() + /// If (Not TransErrors Is Nothing And TransErrors.Length > 0) Then + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors) + /// End If + /// + /// 'End optional code for displaying SDK errors. + /// + /// + public PayflowNETAPI(String HostAddress, int HostPort, int TimeOut, String ProxyAddress, int ProxyPort, String ProxyLogon, String ProxyPassword) + { + mTransactionContext = new Context(); + SetParameters(HostAddress, HostPort, TimeOut, ProxyAddress, ProxyPort, ProxyLogon, ProxyPassword, null, null, null, null, false); + } + + /// + /// PayflowNETAPI Constructor + /// + /// Payflow Host Address. + /// Payflow Host Port. + /// + /// PayflowNETAPI is used to submit a Name-value pair or XMLPay request to + /// PayPal payment gateway for online payment processing. The response + /// returned is the string value of the response from the PayPal payment + /// gateway. + /// + /// Instance of PayflowNETAPI initialized with the information related + /// to connection to the PayPal payment gateway. + /// If the empty constructor of this class is used to create the object or + /// passed values are empty, then The following values (if empty) + /// are looked for as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// PAYFLOW_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + /// + /// + /// /// .......... + /// // Sample Request. + /// // Please replace user, vendor, password & partner with your merchant information. + /// String Request = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password"; + /// + /// // Create an instance of PayflowNETAPI. + /// PayflowNETAPI PfProNetApi = new PayflowNETAPI(); + /// + /// // RequestId is a unique string that is required for each & every transaction. + /// // The merchant can use her/his own algorithm to generate this unique request id or + /// // use the SDK provided API to generate this as shown below (PayflowUtility.RequestId). + /// String Response = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId); + /// + /// // To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest); + /// Console.WriteLine(Environment.NewLine + "Response = " + Response); + /// + /// // Following lines of code are optional. + /// // Begin optional code for displaying SDK errors ... + /// // It is used to read any errors that might have occurred in the SDK. + /// + /// String TransErrors = PfProNetApi.TransactionContext.ToString(); + /// if (TransErrors != null && TransErrors.Length > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + /// } + /// + /// // End optional code for displaying SDK errors. + /// + /// + /// + /// ' Sample Request. + /// ' Please replace user, vendor, password & partner with your merchant information. + /// Dim Request As String = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password" + /// + /// ' Create an instance of PayflowNETAPI. + /// Dim PfProNetApi As PayflowNETAPI = new PayflowNETAPI + /// + /// ' RequestId is a unique string that is required for each & every transaction. + /// ' The merchant can use her/his own algorithm to generate this unique request id or + /// ' use the SDK provided API to generate this as shown below (PayflowUtility.GetRequestId()). + /// Dim Response As String = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId) + /// + /// ' To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest) + /// Console.WriteLine(Environment.NewLine + "Response = " + Response) + /// + /// ' Following lines of code are optional. + /// ' Begin optional code for displaying SDK errors ... + /// ' It is used to read any errors that might have occurred in the SDK. + /// + /// Dim TransErrors As String = PfProNetApi.TransactionContext.ToString() + /// If (Not TransErrors Is Nothing And TransErrors.Length > 0) Then + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors) + /// End If + /// + /// 'End optional code for displaying SDK errors. + /// + /// + public PayflowNETAPI(String HostAddress, int HostPort) + : this(HostAddress, HostPort, 0, null, 0, null, null) + { + } + + /// + /// PayflowNETAPI Constructor + /// Payflow Host Address. + /// Payflow Host Port. + /// Proxy Address. + /// Proxy Port. + /// Proxy Logon Id. + /// Proxy Password. + /// + /// + /// PayflowNETAPI is used to submit a Name-value pair or XMLPay request to + /// PayPal payment gateway for online payment processing. The response + /// returned is the string value of the response from the PayPal payment + /// gateway. + /// + /// Instance of PayflowNETAPI initialized with the information related + /// to connection to the PayPal payment gateway. + /// If the empty constructor of this class is used to create the object or + /// passed values are empty, then The following values (if empty) + /// are looked for as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// PAYFLOW_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + /// + /// + /// /// .......... + /// // Sample Request. + /// // Please replace user, vendor, password & partner with your merchant information. + /// String Request = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password"; + /// + /// // Create an instance of PayflowNETAPI. + /// PayflowNETAPI PfProNetApi = new PayflowNETAPI(); + /// + /// // RequestId is a unique string that is required for each & every transaction. + /// // The merchant can use her/his own algorithm to generate this unique request id or + /// // use the SDK provided API to generate this as shown below (PayflowUtility.RequestId). + /// String Response = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId); + /// + /// // To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest); + /// Console.WriteLine(Environment.NewLine + "Response = " + Response); + /// + /// // Following lines of code are optional. + /// // Begin optional code for displaying SDK errors ... + /// // It is used to read any errors that might have occurred in the SDK. + /// + /// String TransErrors = PfProNetApi.TransactionContext.ToString(); + /// if (TransErrors != null && TransErrors.Length > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + /// } + /// + /// // End optional code for displaying SDK errors. + /// + /// + /// + /// ' Sample Request. + /// ' Please replace user, vendor, password & partner with your merchant information. + /// Dim Request As String = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password" + /// + /// ' Create an instance of PayflowNETAPI. + /// Dim PfProNetApi As PayflowNETAPI = new PayflowNETAPI + /// + /// ' RequestId is a unique string that is required for each & every transaction. + /// ' The merchant can use her/his own algorithm to generate this unique request id or + /// ' use the SDK provided API to generate this as shown below (PayflowUtility.GetRequestId()). + /// Dim Response As String = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId) + /// + /// ' To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest) + /// Console.WriteLine(Environment.NewLine + "Response = " + Response) + /// + /// ' Following lines of code are optional. + /// ' Begin optional code for displaying SDK errors ... + /// ' It is used to read any errors that might have occurred in the SDK. + /// + /// Dim TransErrors As String = PfProNetApi.TransactionContext.ToString() + /// If (Not TransErrors Is Nothing And TransErrors.Length > 0) Then + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors) + /// End If + /// + /// 'End optional code for displaying SDK errors. + /// + /// + public PayflowNETAPI(String HostAddress, int HostPort, String ProxyAddress, int ProxyPort, String ProxyLogon, String ProxyPassword) + : this(HostAddress, HostPort, 0, ProxyAddress, ProxyPort, ProxyLogon, ProxyPassword) + { + } + + /// + /// PayflowNETAPI Constructor + /// + /// Payflow Host Address. + /// Payflow Host Port. + /// Transaction Timeout. + /// + /// PayflowNETAPI is used to submit a Name-value pair or XMLPay request to + /// PayPal payment gateway for online payment processing. The response + /// returned is the string value of the response from the PayPal payment + /// gateway. + /// + /// Instance of PayflowNETAPI initialized with the information related + /// to connection to the PayPal payment gateway. + /// If the empty constructor of this class is used to create the object or + /// passed values are empty, then The following values (if empty) + /// are looked for as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// PAYFLOW_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + /// + /// + /// /// .......... + /// // Sample Request. + /// // Please replace user, vendor, password & partner with your merchant information. + /// String Request = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password"; + /// + /// // Create an instance of PayflowNETAPI. + /// PayflowNETAPI PfProNetApi = new PayflowNETAPI(); + /// + /// // RequestId is a unique string that is required for each & every transaction. + /// // The merchant can use her/his own algorithm to generate this unique request id or + /// // use the SDK provided API to generate this as shown below (PayflowUtility.RequestId). + /// String Response = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId); + /// + /// // To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest); + /// Console.WriteLine(Environment.NewLine + "Response = " + Response); + /// + /// // Following lines of code are optional. + /// // Begin optional code for displaying SDK errors ... + /// // It is used to read any errors that might have occurred in the SDK. + /// + /// String TransErrors = PfProNetApi.TransactionContext.ToString(); + /// if (TransErrors != null && TransErrors.Length > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + /// } + /// + /// // End optional code for displaying SDK errors. + /// + /// + /// + /// ' Sample Request. + /// ' Please replace user, vendor, password & partner with your merchant information. + /// Dim Request As String = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password" + /// + /// ' Create an instance of PayflowNETAPI. + /// Dim PfProNetApi As PayflowNETAPI = new PayflowNETAPI + /// + /// ' RequestId is a unique string that is required for each & every transaction. + /// ' The merchant can use her/his own algorithm to generate this unique request id or + /// ' use the SDK provided API to generate this as shown below (PayflowUtility.GetRequestId()). + /// Dim Response As String = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId) + /// + /// ' To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest) + /// Console.WriteLine(Environment.NewLine + "Response = " + Response) + /// + /// ' Following lines of code are optional. + /// ' Begin optional code for displaying SDK errors ... + /// ' It is used to read any errors that might have occurred in the SDK. + /// + /// Dim TransErrors As String = PfProNetApi.TransactionContext.ToString() + /// If (Not TransErrors Is Nothing And TransErrors.Length > 0) Then + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors) + /// End If + /// + /// 'End optional code for displaying SDK errors. + /// + /// + public PayflowNETAPI(String HostAddress, int HostPort, int TimeOut) + : this(HostAddress, HostPort, TimeOut, null, 0, null, null) + { + } + + /// + /// PayflowNETAPI Constructor + /// + /// Payflow Host Address. + /// + /// PayflowNETAPI is used to submit a Name-value pair or XMLPay request to + /// PayPal payment gateway for online payment processing. The response + /// returned is the string value of the response from the PayPal payment + /// gateway. + /// + /// Instance of PayflowNETAPI initialized with the information related + /// to connection to the PayPal payment gateway. + /// If the empty constructor of this class is used to create the object or + /// passed values are empty, then The following values (if empty) + /// are looked for as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// PAYFLOW_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + /// + /// + /// /// .......... + /// // Sample Request. + /// // Please replace user, vendor, password & partner with your merchant information. + /// String Request = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password"; + /// + /// // Create an instance of PayflowNETAPI. + /// PayflowNETAPI PfProNetApi = new PayflowNETAPI(); + /// + /// // RequestId is a unique string that is required for each & every transaction. + /// // The merchant can use her/his own algorithm to generate this unique request id or + /// // use the SDK provided API to generate this as shown below (PayflowUtility.RequestId). + /// String Response = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId); + /// + /// // To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest); + /// Console.WriteLine(Environment.NewLine + "Response = " + Response); + /// + /// // Following lines of code are optional. + /// // Begin optional code for displaying SDK errors ... + /// // It is used to read any errors that might have occurred in the SDK. + /// + /// String TransErrors = PfProNetApi.TransactionContext.ToString(); + /// if (TransErrors != null && TransErrors.Length > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + /// } + /// + /// // End optional code for displaying SDK errors. + /// + /// + /// + /// ' Sample Request. + /// ' Please replace user, vendor, password & partner with your merchant information. + /// Dim Request As String = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password" + /// + /// ' Create an instance of PayflowNETAPI. + /// Dim PfProNetApi As PayflowNETAPI = new PayflowNETAPI + /// + /// ' RequestId is a unique string that is required for each & every transaction. + /// ' The merchant can use her/his own algorithm to generate this unique request id or + /// ' use the SDK provided API to generate this as shown below (PayflowUtility.GetRequestId()). + /// Dim Response As String = PfProNetApi.SubmitTransaction(Request, PayflowUtility.RequestId) + /// + /// ' To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PfProNetApi.TransactionRequest) + /// Console.WriteLine(Environment.NewLine + "Response = " + Response) + /// + /// ' Following lines of code are optional. + /// ' Begin optional code for displaying SDK errors ... + /// ' It is used to read any errors that might have occurred in the SDK. + /// + /// Dim TransErrors As String = PfProNetApi.TransactionContext.ToString() + /// If (Not TransErrors Is Nothing And TransErrors.Length > 0) Then + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors) + /// End If + /// + /// 'End optional code for displaying SDK errors. + /// + /// + public PayflowNETAPI(String HostAddress) + : this(HostAddress, 0, 0, null, 0, null, null) + { + } + + #endregion + + #region "Properties" + + /// + /// Gets the Request Id. + /// + + public String RequestId + { + get { return mRequestId; } + } + + + /// + /// Gets the Transaction Context object. + /// + + public Context TransactionContext + { + get { return mTransactionContext; } + } + + /// + /// Gets the Transaction response. + /// + + public String TransactionResponse + { + get { return mTransactionResponse; } + } + + /// + /// Gets the Transaction request. + /// + + + public String TransactionRequest + { + get { return mTransactionRequest; } + } + + /// + /// Gets, Sets flag for Strong Assembly + /// Transaction. + /// + + internal bool IsStrongAssemblyTransaction + { + get { return mIsStrongAssemblyTransaction; } + set { mIsStrongAssemblyTransaction = value; } + } + + /// + /// Gets the PayflowNETAPI Client Version. + /// + + public String Version + { + get { return PayflowConstants.CLIENT_TYPE + PayflowConstants.CLIENT_VERSION; } + } + + internal bool IsXmlPayRequest + { + get { return mIsXmlPayRequest; } + set { mIsXmlPayRequest = value; } + } + + /// + /// Client information. + /// + [System.Runtime.InteropServices.ComVisible(false)] + public ClientInfo ClientInfo + { + get { return mClientInfo; } + set { mClientInfo = value; } + } + + #endregion + + #region "Functions" + /// + /// SetParameters will be used to initialize the different parameters passed by the user. This has been kept + /// as a public function since this needs to be called by the COM implementation. This is an undocumented + /// functionionality which the pure dotNET client are not suppose to use. + /// + public void SetParameters(String HostAddress, + int HostPort, + int TimeOut, + String ProxyAddress, + int ProxyPort, + String ProxyLogon, + String ProxyPassword, + String Trace, + String LogLevel, + String LogFileName, + String LogFileSize, + bool WrapperIsCOM) + { + mTransactionContext.ClearErrors(); + if (WrapperIsCOM) + { + PayflowConstants.TRACE = Trace; + PayflowUtility.TraceInitialized = true; + Logger.SetInstance(LogLevel, LogFileName, LogFileSize, WrapperIsCOM); + } + + if (HostAddress != null) + { + mHostAddress = HostAddress.Trim(); + } + + mHostPort = HostPort; + mTimeOut = TimeOut; + + if (ProxyAddress != null) + { + mProxyAddress = ProxyAddress.Trim(); + } + + mProxyPort = ProxyPort; + + if (ProxyLogon != null) + { + mProxyLogon = ProxyLogon.Trim(); + } + + if (ProxyPassword != null) + { + mProxyPassword = ProxyPassword.Trim(); + } + + InitDefaultValues(); + } + + /// + /// Submits a transaction to Payflow Server. + /// PayflowNETAPI is used to submit a Name-value pair or XMLPay request to + /// PayPal payment gateway for online payment processing. The response + /// returned is the string value of the response from the PayPal payment + /// gateway. + /// + /// Parameter list. + /// Request Id + /// String value of transaction response. + /// Instance of PayflowNETAPI initialized with the information related + /// to connection to the PayPal payment gateway. + /// If the empty constructor of this class is used to create the object or + /// passed values are empty, then The following values (if empty) + /// are looked for as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// Payflow_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction TimeOut + /// 45 seconds + /// NA + /// + /// + /// + /// + /// + /// /// .......... + /// // Sample Request. + /// // Please replace user, vendor, password & partner with your merchant information. + /// String Request = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password"; + /// + /// // Create an instance of PayflowNETAPI. + /// PayflowNETAPI PayflowNetApi = new PayflowNETAPI(); + /// + /// // RequestId is a unique string that is required for each & every transaction. + /// // The merchant can use her/his own algorithm to generate this unique request id or + /// // use the SDK provided API to generate this as shown below (PayflowUtility.RequestId). + /// String Response = PayflowNetApi.SubmitTransaction(Request, PayflowUtility.RequestId); + /// + /// // To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PayflowNetApi.TransactionRequest); + /// Console.WriteLine(Environment.NewLine + "Response = " + Response); + /// + /// // Following lines of code are optional. + /// // Begin optional code for displaying SDK errors ... + /// // It is used to read any errors that might have occurred in the SDK. + /// + /// String TransErrors = PayflowNetApi.TransactionContext.ToString(); + /// if (TransErrors != null && TransErrors.Length > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + /// } + /// + /// // End optional code for displaying SDK errors. + /// + /// + /// + /// ' Sample Request. + /// ' Please replace user, vendor, password & partner with your merchant information. + /// Dim Request As String = "TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0115&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&USER=user&VENDOR=vendor&PARTNER=partner&PWD=password" + /// + /// ' Create an instance of PayflowNETAPI. + /// Dim PayflowNetApi As PayflowNETAPI = new PayflowNETAPI + /// + /// ' RequestId is a unique string that is required for each & every transaction. + /// ' The merchant can use her/his own algorithm to generate this unique request id or + /// ' use the SDK provided API to generate this as shown below (PayflowUtility.GetRequestId()). + /// Dim Response As String = PayflowNetApi.SubmitTransaction(Request, PayflowUtility.RequestId) + /// + /// ' To write the Response on to the console. + /// Console.WriteLine(Environment.NewLine + "Request = " + PayflowNetApi.TransactionRequest) + /// Console.WriteLine(Environment.NewLine + "Response = " + Response) + /// + /// ' Following lines of code are optional. + /// ' Begin optional code for displaying SDK errors ... + /// ' It is used to read any errors that might have occurred in the SDK. + /// + /// Dim TransErrors As String = PayflowNetApi.TransactionContext.ToString() + /// If (Not TransErrors Is Nothing And TransErrors.Length > 0) Then + /// Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors) + /// End If + /// + /// 'End optional code for displaying SDK errors. + /// + /// + + + public String SubmitTransaction(String ParamList, String RequestId) + { + Logger.Instance.Log("PayPal.Payments.Communication.PayflowNETAPI.SubmitTransaction(String): Entered.", PayflowConstants.SEVERITY_DEBUG); + + String RetVal; + mRequestId = RequestId; + GlobalClass.GlobalVar = mRequestId; + mTransRqst = ParamList; + mTransactionRequest = PayflowUtility.MaskSensitiveFields(ParamList); + + if (mClientInfo == null) + { + mClientInfo = new ClientInfo(); + } + + mClientInfo.SetClientVersion(PayflowConstants.CLIENT_VERSION); + mClientInfo.SetClientType(PayflowConstants.CLIENT_TYPE); + + if (IsStrongAssemblyTransaction) + { + mClientInfo.RequestType = PayflowConstants.STRONG_ASSEMBLY; + } + else + { + mClientInfo.RequestType = PayflowConstants.WEAK_ASSEMBLY; + } + try + { + CheckTransactionArgs(ParamList, RequestId); + + if (!IsStrongAssemblyTransaction) + { + mTransactionContext.LoadLoggerErrs = true; + ArrayList Errors = PayflowUtility.AlignContext(mTransactionContext, IsXmlPayRequest); + mTransactionContext.LoadLoggerErrs = false; + mTransactionContext.ClearErrors(); + mTransactionContext.AddErrors(Errors); + } + + if (mTransactionContext.HighestErrorLvl == PayflowConstants.SEVERITY_FATAL) + { + ArrayList ErrorList = mTransactionContext.GetErrors(PayflowConstants.SEVERITY_FATAL); + ErrorObject FirstFatalError = (ErrorObject)ErrorList[0]; + RetVal = FirstFatalError.ToString(); + mTransactionRequest = PayflowUtility.MaskSensitiveFields(ParamList); + mTransactionResponse = RetVal; + Logger.Instance.Log("PayPal.Payments.Communication.PayflowNETAPI.SubmitTransaction(String): Exiting.", PayflowConstants.SEVERITY_DEBUG); + return RetVal; + } + + mPaymentStateMachine = PaymentStateMachine.Instance; + + + mPaymentStateMachine.InitializeContext(mHostAddress, mHostPort, mTimeOut, mProxyAddress, mProxyPort, mProxyLogon, mProxyPassword, mClientInfo); + + //Initialize transaction + mPaymentStateMachine.InitTrans(ParamList, RequestId); + + //Begin Payflow Timeout Check Point 1 + long TimeRemainingMsec; + + if (PayflowUtility.IsTimedOut(mPaymentStateMachine.TimeOut, mPaymentStateMachine.StartTime, out TimeRemainingMsec)) + { + String AddlMessage = "Input timeout in millsec = " + mPaymentStateMachine.TimeOut.ToString(); + + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_TIMEOUT_WAIT_RESP, null, PayflowConstants.SEVERITY_FATAL, mPaymentStateMachine.IsXmlPayRequest, AddlMessage); + + if (!mPaymentStateMachine.PsmContext.IsCommunicationErrorContained(Err)) + { + mPaymentStateMachine.PsmContext.AddError(Err); + } + } + else + { + mPaymentStateMachine.TimeOut = TimeRemainingMsec; + } + //End Payflow Timeout Check Point 1 + + + //Begin Toggle through states + while (mPaymentStateMachine.InProgress) + { + mPaymentStateMachine.Execute(); + } + //End Toggle through states + + + mTransactionResponse = mPaymentStateMachine.Response; + RetVal = mTransactionResponse; + mClientInfo = mPaymentStateMachine.ClientInfo; + //Assign the context data + mRequestId = mPaymentStateMachine.RequestId; + mTransactionRequest = PayflowUtility.MaskSensitiveFields(ParamList); + mTransactionContext.AddErrors(mPaymentStateMachine.PsmContext.GetErrors()); + mPaymentStateMachine = null; + ArrayList ErrList = PayflowUtility.AlignContext(mTransactionContext, IsXmlPayRequest); + mTransactionContext.LoadLoggerErrs = false; + mTransactionContext.ClearErrors(); + mTransactionContext.AddErrors(ErrList); + + } + catch (Exception Ex) + { + RetVal = Ex.ToString(); + } + finally + { + + } + Logger.Instance.Log("PayPal.Payments.Communication.PayflowNETAPI.SubmitTransaction(String): RetVal = " + RetVal, PayflowConstants.SEVERITY_DEBUG); + Logger.Instance.Log("PayPal.Payments.Communication.PayflowNETAPI.SubmitTransaction(String): Exiting.", PayflowConstants.SEVERITY_DEBUG); + return RetVal; + + } + + + /// + /// Initializes the default connection values + /// + private void InitDefaultValues() + { + Logger.Instance.Log("PayPal.Payments.Communication.PayflowNETAPI.InitDefaultValues(): Entered", PayflowConstants.SEVERITY_DEBUG); + //Check if the values held in the PayPal server connection related params if they are passed null or 0 (for int values) then initialize + // them to appropriate default values. + + // if timeout value not passed, set the TimeOut to default value. + if (mTimeOut == 0) + { + mTimeOut = PayflowConstants.DEFAULT_TIMEOUT*1000; + } + else + { + mTimeOut = mTimeOut*1000; + } + + + // Set the timeout value. + /*if (mTimeOut == 0) + { + try + { + // Obtain timeout value from .config file, if present. + mTimeOut = Convert.ToInt32(PayflowUtility.AppSettings(PayflowConstants.INTL_PARAM_PAYFLOW_TIMEOUT)) * 1000; + } + catch (Exception) + { + // Set default if TIMEOUT is not in .config file. + mTimeOut = PayflowConstants.DEFAULT_TIMEOUT * 1000; + Logger.Instance.Log("PayPal.Payments.Communication.PayflowNETAPI.InitDefaultValues(): Timeout set to Default Value: " + mTimeOut.ToString(), PayflowConstants.SEVERITY_DEBUG); + } + } + */ + if (mHostPort == 0) + { + mHostPort = PayflowConstants.DEFAULT_HOSTPORT; + } + + try + { + if (mHostAddress == null || mHostAddress.Length == 0) + { + String HostAddress = PayflowUtility.AppSettings(PayflowConstants.INTL_PARAM_PAYFLOW_HOST); + if (HostAddress != null && HostAddress.Length > 0) + { + HostAddress = HostAddress.TrimStart().TrimEnd(); + if (HostAddress.Length == 0) + { + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_CONFIG_ERROR] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_CONFIG_ERROR] + + "Tag " + + PayflowConstants.INTL_PARAM_PAYFLOW_HOST + + " is not present in the config file or config file is missing."; + ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, "", RespMessage); + mTransactionContext.AddError(Error); + } + else + { + mHostAddress = HostAddress; + } + } + else + { + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_CONFIG_ERROR] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_CONFIG_ERROR] + + "Tag " + + PayflowConstants.INTL_PARAM_PAYFLOW_HOST + + " is not present in the config file or config file is missing."; + ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, "", RespMessage); + mTransactionContext.AddError(Error); + } + } + } + catch (Exception Ex) + { + String StackTrace = PayflowConstants.EMPTY_STRING; + PayflowUtility.InitStackTraceOn(); + if (PayflowConstants.TRACE_ON.Equals(PayflowConstants.TRACE)) + { + StackTrace = ": " + Ex.Message + Ex.StackTrace; + } + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_CONFIG_ERROR] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_CONFIG_ERROR] + + "Tag " + + PayflowConstants.INTL_PARAM_PAYFLOW_HOST + + " is not present in the config file or config file is missing." + + StackTrace; + ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, "", RespMessage); + mTransactionContext.AddError(Error); + } + Logger.Instance.Log("PayPal.Payments.Communication.PayflowNETAPI.InitDefaultValues(): Exiting", PayflowConstants.SEVERITY_DEBUG); + } + + /// + /// Checks the vital transaction arguments + /// for null or empty and populates context + /// accordingly. + /// + /// Param list + /// Request Id + private void CheckTransactionArgs(String ParamList, String RequestId) + { + Logger.Instance.Log("PayPal.Payments.Communication.PayflowNETAPI.CheckTransactionArgs(String,String,String,bool): Entered", PayflowConstants.SEVERITY_DEBUG); + try + { + if (ParamList == null || ParamList.Trim().Length == 0) + { + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_EMPTY_PARAM_LIST] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_EMPTY_PARAM_LIST]; + + ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, "", RespMessage); + mTransactionContext.AddError(Error); + } + else + { + //Check for XmlPay 1.0 + //We are not supporting Xml Pay 1.0 + ParamList = ParamList.TrimStart(new char[1] { ' ' }); + int Index = ParamList.TrimStart().IndexOf(PayflowConstants.XML_ID); + if (Index >= 0 && ParamList.IndexOf("<") == 0) + { + String Version = PayflowUtility.GetXmlAttribute(ParamList, PayflowConstants.XML_PARAM_VERSION); + if (Version != null && Version.Trim().Length > 0) + { + mIsXmlPayRequest = true; + if ("1.0".Equals(Version)) + { + String AddlMessage = " ,Input XMLPay Request Version = " + Version; + String[] ErrParams = new String[] { (String)PayflowConstants.CommErrorCodes["E_VERSION_NOT_SUPPORTED"], (String)PayflowConstants.CommErrorMessages["E_VERSION_NOT_SUPPORTED"] + AddlMessage }; + ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, PayflowConstants.MSG_COMMUNICATION_ERROR_XMLPAY_NO_RESPONSE_ID, ErrParams); + mTransactionContext.AddError(Error); + } + } + } + else + { + if (!mIsStrongAssemblyTransaction) + { + ParameterListValidator.Validate(ParamList, false, ref mTransactionContext); + } + } + } + + if (RequestId == null || RequestId.Trim().Length == 0) + { + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_MISSING_REQUEST_ID] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_MISSING_REQUEST_ID]; + + ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, "", RespMessage); + mTransactionContext.AddError(Error); + } + + } + catch (Exception Ex) + { + String AddlMessage = PayflowConstants.EMPTY_STRING; + if (Ex is System.Xml.XmlException) + { + IsXmlPayRequest = true; + AddlMessage = "Error while parsing the xml request."; + } + else + { + IsXmlPayRequest = false; + } + + ErrorObject Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE, Ex, PayflowConstants.SEVERITY_FATAL, IsXmlPayRequest, AddlMessage); + mTransactionContext.AddError(Error); + } + Logger.Instance.Log("PayPal.Payments.Communication.PayflowNETAPI.CheckTransactionArgs(String,String,String,bool): Exiting", PayflowConstants.SEVERITY_DEBUG); + } + + + /* + This function has been out in place to support generation of requestID from the COM Wrapper.This is + because a static function cannot be called from COM Wrapper and PayflowUtility is a static class and has + a private constructor. + */ + public String GenerateRequestId() + { + return PayflowUtility.RequestId; + } + + #region "PAYFLOW-HEADERs related methods" + /// + /// Adds a Transaction header + /// + /// Header Name + /// Header Value + public void AddTransHeader(String HeaderName, String HeaderValue) + { + AddHeader(HeaderName, HeaderValue); + } + + /// + /// Removes a Transaction header + /// + /// Header Name + public void RemoveTransHeader(String HeaderName) + { + RemoveHeader(HeaderName); + } + + /// + /// Removes a header + /// + /// Header Name + private void RemoveHeader(String HeaderName) + { + if (mClientInfo != null) + { + if (mClientInfo.ClientInfoHash.ContainsKey(HeaderName)) + { + mClientInfo.ClientInfoHash.Remove(HeaderName); + } + + } + } + /// + /// Adds a header + /// + /// Header name + /// Header value + private void AddHeader(String HeaderName, String HeaderValue) + { + if (mClientInfo == null) + { + mClientInfo = new ClientInfo(); + } + + mClientInfo.AddHeaderToHash(HeaderName, HeaderValue); + + } + #endregion + #endregion + + #region "System.Object overides" + /// + /// This function overides the System.Object.Equals function. + /// + /// Object which needs to be compared. + /// Returns the boolean value indicating if the Object passed is equal to the current object. + /// + [System.Runtime.InteropServices.ComVisible(false)] + public override bool Equals(object obj) + { + return base.Equals(obj); + } + + /// + /// This function overides the System.Object.GetHashCode function. + /// + /// Returns the HashCode for the current instance. + /// + [System.Runtime.InteropServices.ComVisible(false)] + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// This function overides the System.Object.ToString function. + /// + /// Returns the String representation of the current instance. + /// + [System.Runtime.InteropServices.ComVisible(false)] + public override string ToString() + { + return base.ToString(); + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/PaymentConnection.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/PaymentConnection.cs new file mode 100644 index 0000000..52a0c10 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/PaymentConnection.cs @@ -0,0 +1,743 @@ +#region "Imports" + +using System; +using System.Net; +using PayPal.Payments.Common.Utility; +using System.IO; +using System.Text; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Logging; +using System.Security.Permissions; +using PayPal.Payments.DataObjects; +using System.Collections; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// This is the Connection Class. + /// + internal class PaymentConnection + { + #region "Member Variables" + + /// + /// Holds whether transaction is + /// with or without proxy. + /// + private bool mIsProxy; + + /// + /// Payflow Host Address + /// + private String mHostAddress; + + /// + /// Payflow Host Port + /// + private int mHostPort; + + /// + /// Payflow Server Uri object. + /// + private Uri mServerUri; + + /// + /// Connection object. + /// + private HttpWebRequest mServerConnection; + + /// + /// Proxy Address. + /// + private String mProxyAddress; + + /// + /// Proxy Port + /// + private int mProxyPort; + + /// + /// Proxy Logon Id + /// + private String mProxyLogon; + + /// + /// Proxy Password + /// + private String mProxyPassword; + + /// + /// Connection TimeOut Value. + /// + private long mConnectionTimeOut; + + /// + /// Transaction start time. + /// + private long mStartTime; + + /// + /// Request Id + /// + private String mRequestId; + + /// + /// Param List Content Type + /// + private String mContentType; + + /// + /// Proxy Object. + /// + private WebProxy mProxyInfo; + + /// + /// Flag for XmlPay Request Type. + /// + private bool mIsXmlPayRequest; + + /// + /// Context object. + /// + private Context mContext; + /// + /// Client information. + /// + private ClientInfo mClientInfo; + /// + /// Status of proxy connection. + /// False if proxy host address is not parsed successfully. + /// + private bool mProxyStatus = true; + + #endregion + + #region "Properties" + + /// + /// Gets whether transaction + /// is with or without proxy. + /// + public bool IsProxy + { + get { return mIsProxy; } + } + + /// + /// Gets, Sets the param list + /// content type. + /// + public String ContentType + { + get { return mContentType; } + set { mContentType = value; } + } + + /// + /// Gets, Sets Request Id. + /// + public String RequestId + { + get { return mRequestId; } + set { mRequestId = value; } + } + + /// + /// Gets the StartTime of the + /// transaction. + /// + public long StartTime + { + get + { + if (mStartTime == 0) + { + InitTransactionStartTime(); + } + return mStartTime; + } + } + + /// + /// Gets, Sets the timeout + /// value of transaction. + /// + public long TimeOut + { + get { return mConnectionTimeOut; } + set { mConnectionTimeOut = value; } + } + + /// + /// Gets the Connection + /// context object. + /// + internal Context ConnContext + { + get { return mContext; } + } + + /// + /// Gets, Sets XmlPay Request type flag. + /// + public bool IsXmlPayRequest + { + get { return mIsXmlPayRequest; } + set { mIsXmlPayRequest = value; } + } + + /// + /// Client information. + /// + public ClientInfo ClientInfo + { + get { return mClientInfo; } + set { mClientInfo = value; } + } + #endregion + + #region "Constructor" + + /// + /// Constructor for PaymentConnection. + /// + /// Context object by reference. + public PaymentConnection(ref Context PsmContext) + { + mContext = PsmContext; + } + + #endregion + + #region "Init functions" + + private void InitTransactionStartTime() + { + //Start time in mill seconds. + mStartTime = DateTime.Now.Ticks/10000; + } + + /// + /// Initializes Connection Host Attributes. + /// + /// String Value of Host Address. + /// Host port as positive integer. + /// Connection Timeout in Seconds. + private void InitializeHost(String HostAddress, int HostPort, int TimeOut) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeHost(String,int,int): Entered.", + PayflowConstants.SEVERITY_DEBUG); + + if (HostAddress != null && HostAddress.Length > 0) + { + mHostAddress = HostAddress; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeHost(String,int,int): HostAddress = " + mHostAddress, + PayflowConstants.SEVERITY_INFO); + } + else + { + ErrorObject NullHostError = PayflowUtility.PopulateCommError(PayflowConstants.E_NULL_HOST_STRING, null, + PayflowConstants.SEVERITY_FATAL, IsXmlPayRequest, + null); + if (!ConnContext.IsCommunicationErrorContained(NullHostError)) + { + ConnContext.AddError(NullHostError); + } + } + + mHostPort = HostPort; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeHost(String,int,int): HostPort = " + mHostPort.ToString(), + PayflowConstants.SEVERITY_INFO); + mConnectionTimeOut = TimeOut; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeHost(String,int,int): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + + /// + /// Initializes proxy Attributes + /// + /// String Value of Proxy Address. + /// Proxy port as positive integer. + /// String Value of Proxy User Id. + /// String Value of Proxy Password. + private void InitializeProxy(String ProxyAddress, int ProxyPort, String ProxyLogon, String ProxyPassword) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeProxy(String,int,String, String): Entered.", PayflowConstants.SEVERITY_DEBUG); + + mProxyAddress = ProxyAddress; + mProxyPort = ProxyPort; + mProxyLogon = ProxyLogon; + mProxyPassword = ProxyPassword; + + if (mProxyAddress != null && mProxyAddress.Length > 0 && mProxyPort > 0) + { + mIsProxy = true; + } + + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeProxy(String,int,String, String): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + + /// + /// Initializes Connection from Connection Attributes. + /// + /// String Value of Host Address. + /// Host port as positive integer. + /// Connection Timeout in Seconds. + /// String Value of Proxy Address. Pass null if not applicable. + /// Proxy port as positive integer.Pass 0 if not applicable. + /// String Value of Proxy User Id.Pass null if not applicable. + /// String Value of Proxy Password.Pass null if not applicable. + public void InitializeConnection(String HostAddress, int HostPort, + int TimeOut, String ProxyAddress, int ProxyPort, + String ProxyLogon, String ProxyPassword) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeConnection(String,int,int,String,int,String,String): Entered.", + PayflowConstants.SEVERITY_DEBUG); + InitializeHost(HostAddress, HostPort, TimeOut); + InitializeProxy(ProxyAddress, ProxyPort, ProxyLogon, ProxyPassword); + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeConnection(String,int,int,String,int,String,String): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + + + /// + /// Initialized the Server Uri object from + /// available connection attributes. + /// + private void InitServerUri() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitServerUri(String): Entered.", + PayflowConstants.SEVERITY_DEBUG); + + UriBuilder ServerUriBuilder = new UriBuilder(); + + try + { + ServerUriBuilder.Host = mHostAddress; + ServerUriBuilder.Scheme = "https"; + ServerUriBuilder.Port = mHostPort; + mServerUri = ServerUriBuilder.Uri; + } + catch (Exception Ex) + { + String AddlMessage = "Input Server Uri = " + ServerUriBuilder.Scheme+"://"+ServerUriBuilder.Host+":"+ServerUriBuilder.Port; + if(Ex is System.UriFormatException && IsProxy) + { + AddlMessage += " Input Proxy info = http://" + mProxyAddress; + mProxyStatus = false; + } + else if (IsProxy) + { + AddlMessage += " Input Proxy info = " + mProxyInfo.Address.ToString(); + } + ErrorObject InitError = PayflowUtility.PopulateCommError(PayflowConstants.E_SOK_CONN_FAILED, Ex, + PayflowConstants.SEVERITY_ERROR, IsXmlPayRequest, + AddlMessage); + if (!ConnContext.IsCommunicationErrorContained(InitError)) + { + ConnContext.AddError(InitError); + } + } + finally + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitServerUri(String): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + } + + /// + /// Initializes Proxy Object from + /// available proxy information. + /// + private void InitProxyInfo() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitProxyInfo(): Entered.", + PayflowConstants.SEVERITY_DEBUG); + if (mIsProxy) + { + mProxyInfo = new WebProxy(); + UriBuilder ProxyUriBuilder = new UriBuilder(); + ProxyUriBuilder.Host = mProxyAddress; + ProxyUriBuilder.Port = mProxyPort; + ProxyUriBuilder.Scheme = "http"; + Uri ProxyUri = ProxyUriBuilder.Uri; + //NetworkCredential ProxyCredential = new NetworkCredential(mProxyLogon, mProxyPassword); + //CredentialCache ProxyCredentialCache = new CredentialCache(); + //ProxyCredentialCache.Add(ProxyUri, "Basic", ProxyCredential); + //mProxyInfo = new WebProxy(); + mProxyInfo.Address = ProxyUri; + //mProxyInfo.Credentials = ProxyCredentialCache; + mProxyInfo.Credentials = new NetworkCredential(mProxyLogon, mProxyPassword); + //mProxyInfo.BypassProxyOnLocal = true; + //mProxyInfo.UseDefaultCredentials = false; + mServerConnection.Proxy = mProxyInfo; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitProxyInfo(): Using Proxy Info: ", PayflowConstants.SEVERITY_DEBUG); + } + + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitProxyInfo(): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + + /// + /// Initializes all the connection attributes and creates the connection. + /// + private void CreateConnection() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.CreateConnection(): Entered.", + PayflowConstants.SEVERITY_DEBUG); + + try + { + //Create Connection Object. + + // 03/06/2017 Added TLS 1.2 support for .NET 4.5 support. Only TLS 1.2 is supported going forward. + System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // | SecurityProtocolType.Tls11; + mServerConnection = (HttpWebRequest) WebRequest.Create(mServerUri); + // Create a new request to the above mentioned URL. + // WebRequest mServerConnection = WebRequest.Create(mServerUri); + + //Set Connection Properties + mServerConnection.Method = "POST"; + mServerConnection.KeepAlive = false; + mServerConnection.UserAgent = PayflowConstants.USER_AGENT; + mServerConnection.ContentType = mContentType; + mServerConnection.Timeout = (int) mConnectionTimeOut; + // Add request id in the header. + mServerConnection.Headers.Add(PayflowConstants.PAYFLOWHEADER_REQUEST_ID, mRequestId); + long TimeOut = mConnectionTimeOut/1000; + mServerConnection.Headers.Add(PayflowConstants.PAYFLOWHEADER_TIMEOUT, TimeOut.ToString()); + + if (IsProxy) + { + if (mProxyInfo == null) + { + InitProxyInfo(); + } + + //mServerConnection.Proxy = mProxyInfo; + } + else + { + // added 09/02/2009, v4.33 + // reference: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.proxy.aspx + // sets the the global proxy to an empty proxy. + // mServerConnection.Proxy = GlobalProxySelection.GetEmptyWebProxy(); + // GlobalProxySelection is deprecated, replaced with WebRequest.DefaultWebProxy v4.50 0-3/15/2016 + WebRequest.DefaultWebProxy = null; + mServerConnection.Proxy = WebRequest.DefaultWebProxy; + } + + //Add VIT Headers + if(mClientInfo != null) + { + //Get the Hash map. + Hashtable ClientInfoHash = mClientInfo.ClientInfoHash; + if(ClientInfoHash != null && ClientInfoHash.Count > 0) + { + //Iterate through the hash map to add the + //appropriate headers. + foreach(DictionaryEntry HeaderKeyValue in ClientInfoHash) + { + Object ValueObj = HeaderKeyValue.Value; + if(ValueObj != null) + { + ClientInfoHeader CurrHeader = (ClientInfoHeader)ValueObj; + String HdrName = CurrHeader.HeaderName; + Object HdrValueObj = CurrHeader.HeaderValue; + String HdrValueStr = null; + //Check if Header name is non-null, non-empty string. + bool ValidHeaderName = (HdrName!= null && HdrName.Length > 0); + bool ValidHeaderValue = (HdrValueObj != null); + //Check if Header value object is non-null, object. + if(ValidHeaderValue) + { + HdrValueStr = CurrHeader.HeaderValue.ToString(); + //Check if the header value is non-null, non-empty. + ValidHeaderValue = (HdrValueStr != null && HdrValueStr.Length > 0); + } + + //If all conditions are satisfied, then add header to request. + if(ValidHeaderName && ValidHeaderValue) + { + try + { + mServerConnection.Headers.Add(HdrName,HdrValueStr); + } + catch(Exception Ex) + { + string AddlMessage = "Invalid Client(Wrapper) Header: "+ HdrName; + ErrorObject HeaderError = PayflowUtility.PopulateCommError(PayflowConstants.MESSAGE_WRAPPERHEADER_ERROR, Ex, + PayflowConstants.SEVERITY_WARN , IsXmlPayRequest, + AddlMessage); + if (!ConnContext.IsCommunicationErrorContained(HeaderError)) + { + ConnContext.AddError(HeaderError); + } + } + } + } + } + } + } + //Added VIT Headers to the http request. + } + catch (Exception Ex) + { + String AddlMessage = "Input Server Uri = " + mServerUri.AbsoluteUri; + + if(Ex is System.UriFormatException && IsProxy) + { + AddlMessage += " Input Proxy info = http://" + mProxyAddress; + mProxyStatus = false; + } + else if (IsProxy) + { + AddlMessage += " Input Proxy info = " + mProxyInfo.Address.ToString(); + } + ErrorObject InitError = PayflowUtility.PopulateCommError(PayflowConstants.E_SOK_CONN_FAILED, Ex, + PayflowConstants.SEVERITY_ERROR, IsXmlPayRequest, + AddlMessage); + if (!ConnContext.IsCommunicationErrorContained(InitError)) + { + ConnContext.AddError(InitError); + } + } + finally + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.CreateConnection(): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + } + + #endregion + + #region "Connection Functions" + + /// + /// Initializes the Server Connection. + /// + /// True if success, False otherwise. + public bool ConnectToServer() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ConnectToServer(String): Entered.", + PayflowConstants.SEVERITY_DEBUG); + bool RetVal = false; + + try + { + //Initialize Server Uri. + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ConnectToServer(String): Initializing Server Uri.", + PayflowConstants.SEVERITY_INFO); + InitServerUri(); + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ConnectToServer(String): Initialized Server Uri = " + mServerUri.AbsoluteUri, + PayflowConstants.SEVERITY_INFO); + + //Create Connection object & Set Connection Attributes + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ConnectToServer(String): Initializing Connection Attributes.", + PayflowConstants.SEVERITY_INFO); + CreateConnection(); + if (mServerConnection != null) + { + if (mProxyStatus) + { + RetVal = true; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ConnectToServer(String): Connection Created.", + PayflowConstants.SEVERITY_INFO); + } + else + { + RetVal= false; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ConnectToServer(String): Connection Creation Failure: Incorrect Proxy Details.", + PayflowConstants.SEVERITY_INFO); + } + } + else + { + RetVal = false; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ConnectToServer(String): Connection Creation Failure.", + PayflowConstants.SEVERITY_INFO); + } + } + catch (Exception Ex) + { + String AddlMessage = "Input Server Uri = " + mServerUri.AbsoluteUri; + if (IsProxy) + { + AddlMessage += " Input Proxy info = " + mProxyInfo.Address.ToString(); + } + ErrorObject InitError = PayflowUtility.PopulateCommError(PayflowConstants.E_SOK_CONN_FAILED, Ex, + PayflowConstants.SEVERITY_ERROR, IsXmlPayRequest, + AddlMessage); + if (!ConnContext.IsCommunicationErrorContained(InitError)) + { + ConnContext.AddError(InitError); + } + } + finally + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ConnectToServer(String): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + return RetVal; + } + + /// + /// Sends the request to the server. + /// + /// String Value of request. + /// True if success, False otherwise. + public bool SendToServer(String Request) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.SendToServer(String): Entered.", + PayflowConstants.SEVERITY_DEBUG); + bool RetVal = false; + + // Uncomment this line to test this SDK in QA. This will override the certificate check where the + // host URL does not match the server certificate causing the exception: + // + // "The underlying connection was closed: Could not establish trust relationship with remote server." + // + // See notes in LocalPolicy.cs in the Utility directory. + // + //System.Net.ServicePointManager.CertificatePolicy = new LocalPolicy(ref mContext,IsXmlPayRequest); + + try + { + ASCIIEncoding Encoding = new ASCIIEncoding(); + if (Request != null) + { + Byte[] ParamListBytes = Encoding.GetBytes(Request); + mServerConnection.ContentLength = ParamListBytes.Length; + Stream ReqStram = mServerConnection.GetRequestStream(); + ReqStram.Write(ParamListBytes, 0, ParamListBytes.Length); + ReqStram.Close(); + RetVal = true; + + String[] HeaderKeys = mServerConnection.Headers.AllKeys; + if(HeaderKeys != null) + { + + int KeysLen = HeaderKeys.GetLength(0); + int index; + Logger.Instance.Log("++++++++++++++++++++++", PayflowConstants.SEVERITY_DEBUG); + for(index=0;index + /// Receives the transaction response from + /// the server. + /// + /// String Value of Response. + public String ReceiveResponse() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ReceiveResponse(): Entered.", + PayflowConstants.SEVERITY_DEBUG); + String Response = PayflowConstants.EMPTY_STRING; + + try + { + HttpWebResponse ServerResponse = (HttpWebResponse) mServerConnection.GetResponse(); + Stream ResponseStream = ServerResponse.GetResponseStream(); + mRequestId = ServerResponse.Headers.Get(PayflowConstants.PAYFLOWHEADER_REQUEST_ID); + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ReceiveResponse(): Obtained RequestId = " + mRequestId, + PayflowConstants.SEVERITY_INFO); + + // v4.3.1 - changed stream handling due to issue with code below not returning a complete + // stream.//read the stream in bytes + //long RespLen = ServerResponse.ContentLength ; + //Byte[] RespByteBuffer = new byte[RespLen]; + //ResponseStream.Read (RespByteBuffer,0,Convert.ToInt32 (RespLen)); + //UTF8Encoding UtfEncoding = new UTF8Encoding (); + //Response = UtfEncoding.GetString(RespByteBuffer); + + Response = new StreamReader(ServerResponse.GetResponseStream()).ReadToEnd(); + + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ReceiveResponse(): Obtained Response.", + PayflowConstants.SEVERITY_INFO); + ResponseStream.Close(); + mServerConnection = null; + } + catch (Exception Ex) + { + String AddlMessage = "Input Server Uri = " + mServerUri.AbsoluteUri; + if (IsProxy) + { + AddlMessage += " Input Proxy info = " + mProxyInfo.Address.ToString(); + } + ErrorObject InitError = PayflowUtility.PopulateCommError(PayflowConstants.E_TIMEOUT_WAIT_RESP, Ex, + PayflowConstants.SEVERITY_ERROR, IsXmlPayRequest, + AddlMessage); + if (!ConnContext.IsCommunicationErrorContained(InitError)) + { + ConnContext.AddError(InitError); + } + } + finally + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ReceiveResponse(): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + return Response; + } + + /// + /// Disconnects from the server. + /// + public void Disconnect() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.Disconnect(): Entered.", + PayflowConstants.SEVERITY_DEBUG); + mServerConnection = null; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.Disconnect(): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/PaymentState.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/PaymentState.cs new file mode 100644 index 0000000..0403f2b --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/PaymentState.cs @@ -0,0 +1,928 @@ +#region "Imports" + +using System; +using System.Xml; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Logging; +using System.Text; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// This is the abstract Base class for all payment states. + /// + abstract internal class PaymentState + { + #region "Member Variables" + + /// + /// This is the default XMLPay namespace. + /// + /// + /// Maps to default value: + /// http://www.paypal.com/XMLPay + /// + private String mDefaultXmlNameSpace; + + /// + /// Payflow XMLPay namespace. + /// + private String PFProXmlNameSpace; + + /// + /// Param list content type. + /// + /// + /// Allowed content types are: + /// + /// + /// Content Type + /// Expected Value + /// + /// + /// Name Value Pair + /// text/namevalue + /// + /// + /// XML Pay + /// text/xml + /// + /// + /// Maps to HTTP Header CONTENT-TYPE + /// + private String mContentType; + + /// + /// Connection object. + /// + /// This connection object takes care of + /// initializing, connecting, sending and receiving data + /// from the Payflow server. + /// + /// + protected internal PaymentConnection mConnection; + + /// + /// Parameter List. + /// + /// This is the parameter list in Name-Value Pair or XMLPay format. + protected internal String mParameterList; + + /// + /// Transaction Request. + /// + /// Transaction Request in Name-Value Pair or XMLPay format. + private String mTransactionRequest; + + /// + /// Transaction Response. + /// + /// Transaction Response in Name-Value Pair or XMLPay format. + private String mTransactionResponse; + + + /// + /// Retry Attempt number. + /// + /// This retry number is the current retry attempt. The maximum number of + /// retries allowed are given by constant MAX_RETRY in PayflowConstants. + /// + protected int mAttemptNo; + + /// + /// In Progress flag. + /// + /// This indicates whether the current transaction is in progress or not. + /// True indicates in progress, false otherwise. + private bool mInProgress = true; + + /// + /// State executed flag. + /// + /// This indicates whether the current state has finished its execution. + /// True indicates executed, false otherwise. + private bool mStateExecuted; + + /// + /// State Success flag. + /// + /// This indicates whether the current state has succeeded. + /// True indicates succeeded, false otherwise. + private bool mStateSucceeded; + + /// + /// Context object. + /// + /// This is the context object which is passed by reference in the constructor. This is to + /// maintain a single context across the whole transaction. + private Context mContext; + + #endregion + + #region "Properties" + + /// + /// Gets the connection object. + /// + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// PaymentConnection Connection = + /// CurrentPaymentState.Connection; + /// + /// + /// ............ + /// ' CurrentPaymentState is the + /// ' PaymentState object. + /// + /// Dim Connection As PaymentConnection = + /// CurrentPaymentState.Connection + /// + /// + virtual public PaymentConnection Connection + { + get { return this.mConnection; } + + } + + /// + /// Gets the param list. + /// + /// This is the parameter list in Name-Value Pair or XMLPay format. + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// Console.WriteLine("Parameter List = " + CurrentPaymentState.ParameterList); + /// + /// + /// + /// ............ + /// ' CurrentPaymentState is the + /// ' PaymentState object. + /// + /// Console.WriteLine("Parameter List = " + CurrentPaymentState.ParameterList) + /// + /// + /// + virtual public String ParameterList + { + get { return this.mParameterList; } + + } + + /// + /// Gets, Sets the transaction Request. + /// + /// Transaction Request in Name-Value Pair or XMLPay format. + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// CurrentPaymentState.TransactionRequest = + /// "TRXTYPE[1]=S&ACCT[16]=5105105105105100&EXPDATE[4]=0115&TENDER[1]=C&INVNUM[8]=INV12345&AMT[5]=25.12 + /// &PONUM[7]=PO12345&STREET[23]=123 Main St.&ZIP[5]=12345& + /// USER=user&VENDOR=vendor&PARTNER=partner&PWD=password"; + /// + /// Console.WriteLine("Transaction Request = " + CurrentPaymentState.TransactionRequest); + /// + /// + /// + /// ............ + /// ' CurrentPaymentState is the + /// ' PaymentState object. + /// + /// CurrentPaymentState.TransactionRequest = + /// "TRXTYPE[1]=S&ACCT[16]=5105105105105100&EXPDATE[4]=0115&TENDER[1]=C&INVNUM[8]=INV12345&AMT[5]=25.12 + /// &PONUM[7]=PO12345&STREET[23]=123 Main St.&ZIP[5]=12345& + /// USER=user&VENDOR=vendor&PARTNER=partner&PWD=password" + /// + /// Console.WriteLine("Transaction Request = " + CurrentPaymentState.TransactionRequest) + /// + /// + /// + virtual public String TransactionRequest + { + get { return this.mTransactionRequest; } + set { mTransactionRequest = value; } + + } + + /// + /// Gets, Sets the transaction response. + /// + /// Transaction Response in Name-Value Pair or XMLPay format. + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// CurrentPaymentState.TransactionResponse = + /// "RESULT=0&PNREF=XXXXXXXXXXXX&RESPMSG=Approved"; + /// + /// Console.WriteLine("Transaction Response = " + CurrentPaymentState.TransactionResponse); + /// + /// + /// ............ + /// ' CurrentPaymentState is the + /// ' PaymentState object. + /// + /// CurrentPaymentState.TransactionResponse = + /// "RESULT=0&PNREF=XXXXXXXXXXXX&RESPMSG=Approved" + /// + /// Console.WriteLine("Transaction Response = " + CurrentPaymentState.TransactionResponse) + /// + /// + virtual public String TransactionResponse + { + get { return this.mTransactionResponse; } + set { this.mTransactionResponse = value; } + } + + + /// + /// Gets the retry attempt no. + /// + /// This retry number is the current retry attempt. The maximum number of + /// retries allowed are given by constant MAX_RETRY in PayflowConstants. + /// + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// int CurrentAttempt = CurrentPaymentState.AttemptNo; + /// + /// Console.WriteLine("Current Attempt Number = {0}",CurrentAttempt); + /// + /// + /// ............ + /// ' CurrentPaymentState is the + /// ' PaymentState object. + /// + /// Dim CurrentAttempt As Integer = CurrentPaymentState.AttemptNo + /// + /// Console.WriteLine("Current Attempt Number = " + CurrentAttempt) + /// + /// + virtual public int AttemptNo + { + get { return this.mAttemptNo; } + + } + + /// + /// Gets the param list content type. + /// + /// + /// Allowed content types are: + /// + /// + /// Content Type + /// Expected Value + /// + /// + /// Name Value Pair + /// text/namevalue + /// + /// + /// XML Pay + /// text/xml + /// + /// + /// Maps to HTTP Header CONTENT-TYPE + /// + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// Console.WriteLine("Request Content Type = " + CurrentPaymentState.ContentType); + /// + /// + /// ............ + /// ' CurrentPaymentState is the + /// ' PaymentState object. + /// + /// Console.WriteLine("Request Content Type = " + CurrentPaymentState.ContentType) + /// + /// + virtual public String ContentType + { + get { return this.mContentType; } + + } + + /// + /// Gets the XmlPay Request type flag. + /// + /// This indicates whether the transaction request is of type Name-Value pair or + /// XMLPay request. True if XMLPay request, false if Name-Value pair. + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// if(CurrentPaymentState.IsXmlPayRequest) + /// { + /// Console.WriteLine("Request Type = XML Pay request"); + /// } + /// else + /// { + /// Console.WriteLine("Request Type = Name-value pair request"); + /// } + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// If(CurrentPaymentState.IsXmlPayRequest) + /// { + /// Console.WriteLine("Request Type = XML Pay request") + /// } + /// Else + /// { + /// Console.WriteLine("Request Type = Name-value pair request") + /// } + /// EndIf + /// + /// + virtual public bool IsXmlPayRequest + { + get { return mConnection.IsXmlPayRequest; } + + } + + /// + /// Gets the Default Xml Namespace. + /// + /// + /// Maps to default value: + /// http://www.paypal.com/XMLPay + /// + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// + /// Console.WriteLine("Default Xml Namespace = " + CurrentPaymentState.DefaultXmlNameSpace); + /// + /// + /// ............ + /// ' CurrentPaymentState is the + /// ' PaymentState object. + /// + /// Console.WriteLine("Default Xml Namespace = " + CurrentPaymentState.DefaultXmlNameSpace) + /// + /// + virtual public String DefaultXmlNameSpace + { + get { return this.mDefaultXmlNameSpace; } + + } + + /// + /// Gets the Context Object. + /// + /// This is the context object which is passed by reference in the constructor. This is to + /// maintain a single context across the whole transaction. + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// + /// Context CommContext = CurrentPaymentState.CommContext; + /// + /// + /// ............ + /// ' CurrentPaymentState is the + /// ' PaymentState object. + /// + /// Dim CommContext As Context = CurrentPaymentState.CommContext + /// + /// + internal virtual Context CommContext + { + get { return mContext; } + } + + /// + /// Checks if the Request has Request Id value. + /// + /// True if Request id is Found, False otherwise. + /// This indicates whether request id is obtained, true if obtained, false otherwise. + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// if(CurrentPaymentState.HaveRequestId) + /// { + /// Console.WriteLine("RequestId obtained."); + /// } + /// else + /// { + /// Console.WriteLine("RequestId not obtained."); + /// } + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// If(CurrentPaymentState.HaveRequestId) + /// { + /// Console.WriteLine("RequestId obtained.") + /// } + /// Else + /// { + /// Console.WriteLine("RequestId not obtained.") + /// } + /// EndIf + /// + /// + private bool HaveRequestId + { + get + { + if (this.mConnection.RequestId == null || + this.mConnection.RequestId.Length == 0) + { + return false; + } + else + { + return true; + } + } + } + + /// + /// Gets Xml Name Space + /// + /// Xml Name Space Value. + /// This gives the Xml namespace value for the current transaction. + /// Generally, this is set to default namespace value i.e. + /// http://www.paypal.com/XMLPay + /// + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// + /// Console.WriteLine("Xml Namespace = " + CurrentPaymentState.XmlNameSpace); + /// + /// + /// ............ + /// ' CurrentPaymentState is the + /// ' PaymentState object. + /// + /// Console.WriteLine("Xml Namespace = " + CurrentPaymentState.XmlNameSpace) + /// + /// + public virtual String XmlNameSpace + { + get { return this.PFProXmlNameSpace; } + } + + /// + /// Checks if Response is obtained. + /// + /// True if Response if obtained, False otherwise. + /// This indicates whether response is obtained. True if obtained, false otherwise. + public virtual bool HasResponse + { + get { return (this.mTransactionResponse != null); } + } + + /// + /// Indicates if transaction is in progress. + /// + /// True if in progress, False otherwise. + /// This indicates whether the current transaction is in progress or not. + /// True indicates in progress, false otherwise. + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// if(CurrentPaymentState.InProgress) + /// { + /// Console.WriteLine("Transaction in progress."); + /// } + /// else + /// { + /// Console.WriteLine("Transaction not in progress."); + /// } + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// If(CurrentPaymentState.InProgress) + /// { + /// Console.WriteLine("Transaction in progress.") + /// } + /// Else + /// { + /// Console.WriteLine("Transaction not in progress.") + /// } + /// EndIf + /// + /// + public virtual bool InProgress + { + get { return this.mInProgress; } + } + + /// + /// Indicates current state success.. + /// This indicates whether the current state has succeeded. + /// True indicates succeeded, false otherwise. + /// + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// if(CurrentPaymentState.Success) + /// { + /// Console.WriteLine("Current state succeeds."); + /// } + /// else + /// { + /// Console.WriteLine("Current state does not succeed."); + /// } + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// If(CurrentPaymentState.Success) + /// { + /// Console.WriteLine("Current state succeeds.") + /// } + /// Else + /// { + /// Console.WriteLine("Current state does not succeed.") + /// } + /// EndIf + /// + /// + public virtual bool Success + { + get { return (this.mStateExecuted && this.mStateSucceeded); } + } + + /// + /// Current state failure. + /// This indicates whether the current state has failed. + /// True indicates failed, false otherwise. + /// + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// if(CurrentPaymentState.Failed) + /// { + /// Console.WriteLine("Current state fails."); + /// } + /// else + /// { + /// Console.WriteLine("Current state does not fail."); + /// } + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// If(CurrentPaymentState.Failed) + /// { + /// Console.WriteLine("Current state fails.") + /// } + /// Else + /// { + /// Console.WriteLine("Current state does not fail.") + /// } + /// EndIf + /// + /// + public virtual bool Failed + { + get { return (this.mStateExecuted && !this.mStateSucceeded); } + } + + /// + /// Returns state executed. + /// + /// + /// This indicates whether the current state has finished its execution. + /// True indicates executed, false otherwise. + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// if(CurrentPaymentState.HasExecuted) + /// { + /// Console.WriteLine("Current State has finished execution."); + /// } + /// else + /// { + /// Console.WriteLine("Current State has not finished execution."); + /// } + /// + /// + /// ............ + /// // CurrentPaymentState is the + /// // PaymentState object. + /// + /// If(CurrentPaymentState.HasExecuted) + /// { + /// Console.WriteLine("Current State has finished execution.") + /// } + /// Else + /// { + /// Console.WriteLine("Current State has not finished execution.") + /// } + /// EndIf + /// + /// + public virtual bool HasExecuted + { + get { return this.mStateExecuted; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor + /// + /// This is an abstract class, creating an object of PaymentState directly is not possible. + protected PaymentState() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.PaymentState(): Entered.", PayflowConstants.SEVERITY_DEBUG); + mDefaultXmlNameSpace = PayflowConstants.XMLPAY_NAMESPACE; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.PaymentState(): Exiting.", PayflowConstants.SEVERITY_DEBUG); + } + + /// + /// Constructor + /// + /// PaymentConnection Object + /// Parameter List + /// Context Object by ref + /// This is an abstract class, creating an object of PaymentState directly is not possible. + public PaymentState(PaymentConnection Connection, String ParamList, ref Context PsmContext) : this() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.PaymentState(PaymentConnection,String,Context): Entered.", PayflowConstants.SEVERITY_DEBUG); + + mContext = PsmContext; + mConnection = Connection; + InitializeContentType(ParamList); + + + + if (mContext.HighestErrorLvl < PayflowConstants.SEVERITY_FATAL) + { + mConnection.ContentType = mContentType; + + if (ParamList == null || ParamList.Length == 0) + { + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_EMPTY_PARAM_LIST, null, PayflowConstants.SEVERITY_FATAL, + IsXmlPayRequest, null); + mContext.AddError(Err); + } + + this.mTransactionRequest = ParamList; + + ValidateRequestId(); + } + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.PaymentState(PaymentConnection,String,Context): Exiting.", PayflowConstants.SEVERITY_DEBUG); + } + + /// + /// Copy Constructor + /// + /// Current PaymentState Object. + /// This is an abstract class, creating an object of PaymentState directly is not possible. + public PaymentState(PaymentState CurrentPmtState) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.PaymentState(PaymentState CurrentPmtState): Entered.", PayflowConstants.SEVERITY_DEBUG); + + mDefaultXmlNameSpace = PayflowConstants.XMLPAY_NAMESPACE; + this.mConnection = CurrentPmtState.Connection; + this.mParameterList = CurrentPmtState.ParameterList; + this.mTransactionRequest = CurrentPmtState.TransactionRequest; + this.mTransactionResponse = CurrentPmtState.TransactionResponse; + this.mConnection.RequestId = CurrentPmtState.mConnection.RequestId; + this.mConnection.IsXmlPayRequest = CurrentPmtState.mConnection.IsXmlPayRequest; + this.mAttemptNo = CurrentPmtState.AttemptNo; + this.mDefaultXmlNameSpace = CurrentPmtState.mDefaultXmlNameSpace; + this.PFProXmlNameSpace = CurrentPmtState.XmlNameSpace; + this.mContentType = CurrentPmtState.ContentType; + this.mContext = CurrentPmtState.CommContext; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.PaymentState(PaymentState CurrentPmtState): Exiting.", PayflowConstants.SEVERITY_DEBUG); + } + + #endregion + + #region "Member Functions" + + + /// + /// Initializes the Content Type of the Request. + /// + /// Param List. + /// This method initializes the content type of the + /// parameter list in the member mContentType. + /// Allowed content types are: + /// + /// + /// Content Type + /// Expected Value + /// + /// + /// Name Value Pair + /// text/namevalue + /// + /// + /// XML Pay + /// text/xml + /// + /// + /// Maps to HTTP Header CONTENT-TYPE + /// + private void InitializeContentType(String InitialParamList) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.InitializeContentType(String): Entered.", + PayflowConstants.SEVERITY_DEBUG); + + if (InitialParamList != null) + { + InitialParamList = InitialParamList.TrimStart(new char[1] {' '}); + int Index = InitialParamList.IndexOf(PayflowConstants.XML_ID); + if (Index >= 0 && InitialParamList.IndexOf("<") == 0) + { + mConnection.IsXmlPayRequest = true; + mContentType = PayflowConstants.XML_CONTENT_TYPE; + PFProXmlNameSpace = PayflowUtility.GetXmlNameSpace(InitialParamList); + } + else + { + mConnection.IsXmlPayRequest = false; + mContentType = PayflowConstants.NV_CONTENT_TYPE; + } + } + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.InitializeContentType(String): ContentType = " + mContentType, + PayflowConstants.SEVERITY_INFO); + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.InitializeContentType(String): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + + + /// + /// Sets the transaction complete flag. + /// + /// this method sets the value of member mInProgress. + /// This indicates whether the current transaction is in progress or not. + /// True indicates in progress, false otherwise. + internal void SetProgressComplete() + { + this.mInProgress = false; + } + + + /// + /// Sets transaction successful. + /// + /// This sets the transaction status to success. + public virtual void SetTransactionSuccess() + { + this.SetProgressComplete(); + } + + + /// + /// Sets transaction failed. + /// + /// This sets the transaction status to failed. + public virtual String SetTransactionFail + { + set + { + mTransactionResponse = value; + this.SetProgressComplete(); + } + } + + /// + /// Sets the state success. + /// + /// This sets the current state to success. + public virtual void SetStateSuccess() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.SetStateSuccess(): Entered.", + PayflowConstants.SEVERITY_DEBUG); + SetStateOutCome(true); + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.SetStateSuccess(): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + + /// + /// Sets state outcome. + /// + /// True if success, false otherwise. + /// This sets the state outcome to a desired value either true or false. + private void SetStateOutCome(bool Value) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.SetStateOutCome(bool): Entered.", + PayflowConstants.SEVERITY_DEBUG); + mStateExecuted = true; + mStateSucceeded = Value; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.SetStateOutCome(bool): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + + /// + /// Sets the state failed. + /// + /// This sets the current state to failed. + public virtual void SetStateFail() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.SetStateFail(): Entered.", + PayflowConstants.SEVERITY_DEBUG); + SetStateOutCome(false); + Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.SetStateFail(): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + + /// + /// Abstract function declaration + /// of Execute. + /// + /// This is the abstract method definition of Execute. The Execute method + /// acts as the main important method in these payment state hierarchy. this method is overridden as + /// per the requirements in the derived classes. + public abstract void Execute(); + + /// + /// Validates Request Id. + /// + /// True if valid, false otherwise. + private bool ValidateRequestId() + { + bool RetValue = false; + if (!HaveRequestId) + { + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_MISSING_REQUEST_ID, null, + PayflowConstants.SEVERITY_FATAL, IsXmlPayRequest, + null); + if (!mContext.IsCommunicationErrorContained(Err)) + { + CommContext.AddError(Err); + } + } + else + { + RetValue = true; + } + + return RetValue; + } + + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/PaymentStateMachine.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/PaymentStateMachine.cs new file mode 100644 index 0000000..64776bb --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/PaymentStateMachine.cs @@ -0,0 +1,534 @@ +#region "Imports" + +using System; +using System.Xml; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Logging; +using PayPal.Payments.DataObjects; +using System.Collections; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// Payment State Driver class. + /// + internal sealed class PaymentStateMachine + { + #region "Member Variables" + + /// + /// OS Name + /// + private String mVitOSName; + + /// + /// OS Architecture. + /// + private String mVitOSArch; + + /// + /// OS Version. + /// + private String mVitOSVersion; + + /// + /// .NET Version. + /// + private String mVitRuntimeVersion = PayflowConstants.EMPTY_STRING; + + /// + /// Proxy Used (Y/N) + /// + private String mVitProxy; + + /// + /// Payment State object. + /// + private PaymentState mPaymentState; + + /// + /// Connection object. + /// + private PaymentConnection mConnection; + + /// + /// Context object. + /// + private Context psmContext; + /// + /// Client information. + /// + private ClientInfo mClientInfo; + #endregion + + #region "Properties" + + /// + /// Gets the instance of PaymentStateMachine. + /// + public static PaymentStateMachine Instance + { + get { return new PaymentStateMachine(); } + + } + + + /// + /// Gets transaction response. + /// + public String Response + { + get + { + String RetVal = null; + if (mPaymentState != null) + { + RetVal = mPaymentState.TransactionResponse; + } + return RetVal; + } + } + + /// + /// Gets the Request Id + /// + public String RequestId + { + get + { + String RetVal = null; + if (mPaymentState != null) + { + RetVal = mPaymentState.Connection.RequestId; + } + return RetVal; + } + } + + /// + /// Gets the transaction start time. + /// + public long StartTime + { + get + { + long RetVal = 0; + if (mPaymentState != null) + { + RetVal = mPaymentState.Connection.StartTime; + } + return RetVal; + } + } + + /// + /// Gets, Sets the transaction timeout. + /// + public long TimeOut + { + get + { + long RetVal = 0; + if (mPaymentState != null) + { + RetVal = mPaymentState.Connection.TimeOut; + } + return RetVal; + } + set { mPaymentState.Connection.TimeOut = value; } + } + + /// + /// Gets the context object. + /// + internal Context PsmContext + { + get { return psmContext; } + } + + /// + /// Gets XML Pay Request flag. + /// + public bool IsXmlPayRequest + { + get + { + bool RetVal = false; + if (mPaymentState != null) + { + RetVal = mPaymentState.IsXmlPayRequest; + } + return RetVal; + + } + } + + /// + /// Gets the Inprogress status of transaction. + /// + public bool InProgress + { + get + { + bool RetVal = false; + if (mPaymentState != null) + { + RetVal = mPaymentState.InProgress; + } + return RetVal; + } + } + + /// + /// Client information. + /// + public ClientInfo ClientInfo + { + get { return mClientInfo;} + //set { mClientInfo = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Private constructor for PaymentStateMachine + /// + private PaymentStateMachine() + { + psmContext = new Context(); + mConnection = new PaymentConnection(ref psmContext); + } + + #endregion + + #region "Functions" + + /// + /// Sets the Version Tracking information + /// in NV Request. + /// + private void SetVersionTracking() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.SetVersionTracking(): Entered.", + PayflowConstants.SEVERITY_DEBUG); + + + mVitOSVersion = Environment.OSVersion.Version.ToString(); + mVitOSName = Environment.OSVersion.ToString(); + mVitOSArch = Environment.OSVersion.Platform.ToString(); + mVitRuntimeVersion = Environment.Version.ToString(); + if (this.mConnection.IsProxy) + { + mVitProxy = "Y"; + } + else + { + mVitProxy = "N"; + } + + //Check whether OS Version string is also present + // in the Os name string value. If found, remove it + //from the string. + if(mVitOSVersion != null && mVitOSName != null) + { + int IndexOfVersion = mVitOSName.IndexOf(mVitOSVersion); + if(IndexOfVersion > 0) + { + mVitOSName = mVitOSName.Remove(IndexOfVersion,mVitOSVersion.Length); + } + } + + mClientInfo.OsVersion = mVitOSVersion ; + mClientInfo.OsName = mVitOSName; + mClientInfo.OsArchitecture = mVitOSArch; + mClientInfo.RunTimeVersion = mVitRuntimeVersion; + mClientInfo.Proxy = mVitProxy; + } + + + + /// + /// Initializes transaction context. + /// + /// Payflow Host Address. + /// Payflow Host Port. + /// Transaction timeout. + /// Proxy Address. + /// Proxy Port. + /// Proxy Logon Id. + /// Proxy Password. + /// Client Info + public void InitializeContext(String HostAddress, int HostPort, int TimeOut, String ProxyAddress, int ProxyPort, String ProxyLogon, String ProxyPassword,ClientInfo ClientInfo) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.InitializeContext(String, int, int, String, int, String, String): Entered.", + PayflowConstants.SEVERITY_DEBUG); + try + { + this.mConnection.InitializeConnection(HostAddress, HostPort, TimeOut, ProxyAddress, ProxyPort, ProxyLogon, ProxyPassword); + if(ClientInfo != null) + { + mClientInfo = ClientInfo; + } + else + { + mClientInfo = new ClientInfo(); + } + + this.SetVersionTracking(); + this.mConnection.ClientInfo = mClientInfo; + } + catch (Exception Ex) + { + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_EMPTY_PARAM_LIST, Ex, + PayflowConstants.SEVERITY_ERROR, mPaymentState.IsXmlPayRequest, + null); + if (!PsmContext.IsCommunicationErrorContained(Err)) + { + PsmContext.AddError(Err); + } + } + finally + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.InitializeContext(String,int,int,String, nt,String,String): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + } + + + /// + /// Initialized Transaction. + /// + /// Parameter List + /// Request Id + public void InitTrans(String ParamList, String RequestId) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.InitTrans(String): Entered.", + PayflowConstants.SEVERITY_DEBUG); + + try + { + this.mConnection.RequestId = RequestId; + this.mPaymentState = new SendInitState(this.mConnection, ParamList, ref psmContext); + } + catch (Exception Ex) + { + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_CONTXT_INIT_FAILED, Ex, + PayflowConstants.SEVERITY_ERROR, mPaymentState.IsXmlPayRequest, + null); + if (!PsmContext.IsCommunicationErrorContained(Err)) + { + PsmContext.AddError(Err); + } + } + finally + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.InitTrans(String): Exiting.", + PayflowConstants.SEVERITY_DEBUG); + } + } + + /// + /// Executes the transaction. + /// + public void Execute() + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.Execute(): Entered.", + PayflowConstants.SEVERITY_DEBUG); + + try + { + if (PsmContext.HighestErrorLvl == PayflowConstants.SEVERITY_FATAL) + { + String TrxResponse = mPaymentState.TransactionResponse; + String Message; + if (TrxResponse != null && TrxResponse.Length > 0) + { + Message = TrxResponse; + } + else + { + ArrayList ErrorList = psmContext.GetErrors(PayflowConstants.SEVERITY_FATAL); + ErrorObject FirstFatalError = (ErrorObject) ErrorList[0]; + Message = FirstFatalError.ToString(); + } + mPaymentState.SetTransactionFail = Message; + } + else + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.Execute(): Current State = " + mPaymentState, + PayflowConstants.SEVERITY_DEBUG); + mPaymentState.Execute(); + } + } + catch (Exception Ex) + { + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE, Ex, PayflowConstants.SEVERITY_ERROR, + mPaymentState.IsXmlPayRequest, + null); + if (!PsmContext.IsCommunicationErrorContained(Err)) + { + PsmContext.AddError(Err); + } + } + finally + { + // perform state transition + mPaymentState = GetNextState(mPaymentState); + mClientInfo = mConnection.ClientInfo; + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.Execute(): Exiting. Current State = " + mPaymentState.GetType().ToString(), + PayflowConstants.SEVERITY_DEBUG); + } + } + + /// + /// Changes the Payment States depending upon + /// the current state status. + /// + /// Current Payment State. + /// Next Payment State + private PaymentState GetNextState(PaymentState CurrentPmtState) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState): Entered.", + PayflowConstants.SEVERITY_DEBUG); + + if (CurrentPmtState.Success && CurrentPmtState.InProgress) + { + if (CurrentPmtState is TransactionReceiveState) + { + // exit state + CurrentPmtState.SetTransactionSuccess(); + } + else if (CurrentPmtState is SendInitState) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Success): SentInitState Entered.", + PayflowConstants.SEVERITY_DEBUG); + + CurrentPmtState = new TransactionSendState(CurrentPmtState); + } + else if (CurrentPmtState is TransactionSendState) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Success): TransactionSentState Entered.", + PayflowConstants.SEVERITY_DEBUG); + CurrentPmtState = new TransactionReceiveState(CurrentPmtState); + } + else if (CurrentPmtState is SendRetryState) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Success): SendRetryState Entered.", + PayflowConstants.SEVERITY_DEBUG); + CurrentPmtState = new SendReconnectState(CurrentPmtState); + } + else if (CurrentPmtState is SendReconnectState) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState.Success): SendReconnectState Entered.", + PayflowConstants.SEVERITY_DEBUG); + CurrentPmtState = new SendInitState(CurrentPmtState); + } + // unknown state + else + { + String AddlMessage = "Unknown State, Current State = " + mPaymentState.ToString(); + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE, null, + PayflowConstants.SEVERITY_FATAL, mPaymentState.IsXmlPayRequest, + AddlMessage); + if (!PsmContext.IsCommunicationErrorContained(Err)) + { + PsmContext.AddError(Err); + } + } + } + else if (CurrentPmtState.Failed && CurrentPmtState.InProgress) + { + Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.GetNextState(PaymentState): Current Payment State Failed. Current State = " + mPaymentState.ToString(), + PayflowConstants.SEVERITY_DEBUG); + if (CurrentPmtState is ReconnectState) + { + // exit state + if (!PsmContext.IsErrorContained()) + { + String AddlMessage = "Exceeded Reconnect attempts, check context for error, Current reconnect attempt = " + mPaymentState.AttemptNo.ToString(); + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_TIMEOUT_WAIT_RESP, null, + PayflowConstants.SEVERITY_FATAL, mPaymentState.IsXmlPayRequest, + AddlMessage); + if (!PsmContext.IsCommunicationErrorContained(Err)) + { + PsmContext.AddError(Err); + } + } + else + { + ArrayList ErrList = new ArrayList(); + ErrList.AddRange(PsmContext.GetErrors()); + int HighestSevLevel = PsmContext.HighestErrorLvl; + + int ErrorListIndex; + int ErrorListSize = ErrList.Count; + for(ErrorListIndex=0;ErrorListIndex + /// Represent Receive State. + /// + abstract internal class ReceiveState : PaymentState + { + #region "Constructors" + + /// + /// Copy Constructor for RecieveState. + /// + ///Current Payment State. + public ReceiveState(PaymentState CurrentPmtState) : base(CurrentPmtState) + { + } + + #endregion + + #region "Functions" + + /// + /// Execute function. + /// + public override void Execute() + { + bool IsReceiveSuccess = false; + Logger.Instance.Log("PayPal.Payments.Communication.ReceiveState.Execute(): Entered.", PayflowConstants.SEVERITY_DEBUG); + if (!InProgress) + return; + try + { + //Begin Payflow Timeout Check Point 4 + long TimeRemainingMsec; + if (PayflowUtility.IsTimedOut(mConnection.TimeOut, mConnection.StartTime, out TimeRemainingMsec)) + { + String AddlMessage = "Input timeout value in millisec = " + Connection.TimeOut.ToString(); + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_TIMEOUT_WAIT_RESP, null, PayflowConstants.SEVERITY_FATAL, IsXmlPayRequest, AddlMessage); + if (!CommContext.IsCommunicationErrorContained(Err)) + { + CommContext.AddError(Err); + } + } + else + { + mConnection.TimeOut = TimeRemainingMsec; + } + //End Payflow Timeout Check Point 4 + String ResponseValue = mConnection.ReceiveResponse(); + IsReceiveSuccess = SetReceiveResponse(ResponseValue); + } + catch (Exception Ex) + { + Logger.Instance.Log("PayPal.Payments.Communication.ReceiveState.Execute(): Error occurred While Receiving Response.", PayflowConstants.SEVERITY_ERROR); + Logger.Instance.Log("PayPal.Payments.Communication.ReceiveState.Execute(): Exception " + Ex.ToString(), PayflowConstants.SEVERITY_ERROR); + IsReceiveSuccess = false; + } + //catch + //{ + // IsReceiveSuccess = false; + //} + finally + { + if (IsReceiveSuccess) + { + Logger.Instance.Log("PayPal.Payments.Communication.ReceiveState.Execute(): Receive Response = Success ", PayflowConstants.SEVERITY_INFO); + SetStateSuccess(); + } + else + { + Logger.Instance.Log("PayPal.Payments.Communication.ReceiveState.Execute(): Receive Response = Failure ", PayflowConstants.SEVERITY_INFO); + SetStateFail(); + } + } + Logger.Instance.Log("PayPal.Payments.Communication.ReceiveState.Execute(): Exiting.", PayflowConstants.SEVERITY_DEBUG); + } + + + /// + /// Abstract declaration of SetReceiveResponse + /// + /// Response String. + /// True if response set,false otherwise. + public abstract bool SetReceiveResponse(String response); + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/ReconnectState.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/ReconnectState.cs new file mode 100644 index 0000000..1dd52a1 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/ReconnectState.cs @@ -0,0 +1,61 @@ +#region "Imports" + +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Logging; +using System.Threading; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// Represents Reconnect State. + /// + abstract internal class ReconnectState : PaymentState + { + #region "Constructors" + + /// + /// Copy Constructor for ReconnectState. + /// + /// Current Payment State. + public ReconnectState(PaymentState CurrentPmtState) : base(CurrentPmtState) + { + } + + #endregion + + #region "Functions" + + /// + /// Execute function. + /// + public override void Execute() + { + Logger.Instance.Log("PayPal.Payments.Communication.ReconnectState.Execute(): Entered.", PayflowConstants.SEVERITY_DEBUG); + + if (!InProgress) + return; + + mAttemptNo++; + bool IsConnected = false; + Logger.Instance.Log("PayPal.Payments.Communication.ReconnectState.Execute(): Current Reconnect Attempt No. = " + mAttemptNo.ToString(), PayflowConstants.SEVERITY_INFO); + Logger.Instance.Log("PayPal.Payments.Communication.ReconnectState.Execute(): Maximum Number of Reconnect Attempts Allowed = " + PayflowConstants.MAX_RETRY.ToString(), PayflowConstants.SEVERITY_INFO); + if (mAttemptNo > PayflowConstants.MAX_RETRY) + { + Logger.Instance.Log("PayPal.Payments.Communication.ReconnectState.Execute(): Maximum Number of Reconnect Attempts Exceeded.", PayflowConstants.SEVERITY_WARN); + SetStateFail(); + } + else + { + mConnection.Disconnect(); + IsConnected = mConnection.ConnectToServer(); + Thread.Sleep(PayflowConstants.DEFAULT_RETRYCONNECTIONTIME); + SetStateSuccess(); + } + Logger.Instance.Log("PayPal.Payments.Communication.ReconnectState.Execute(): Exiting.", PayflowConstants.SEVERITY_DEBUG); + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/RetryState.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/RetryState.cs new file mode 100644 index 0000000..4595c6a --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/RetryState.cs @@ -0,0 +1,42 @@ +#region "Imports" + +using PayPal.Payments.Common.Logging; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// Represents RetryState. + /// + abstract internal class RetryState : PaymentState + { + #region "Constructors" + + /// + /// Copy Constructor for RetryState. + /// + /// Current Payment State. + public RetryState(PaymentState CurrentPmtState) : base(CurrentPmtState) + { + } + + #endregion + + #region "Functions" + + /// + /// Execute function. + /// + public override void Execute() + { + Logger.Instance.Log("PayPal.Payments.Communication.RetryState.Execute(): Entered.", PayflowConstants.SEVERITY_DEBUG); + mConnection.Disconnect(); + SetStateSuccess(); + Logger.Instance.Log("PayPal.Payments.Communication.RetryState.Execute(): Exiting.", PayflowConstants.SEVERITY_DEBUG); + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendInitState.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendInitState.cs new file mode 100644 index 0000000..d4aa226 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendInitState.cs @@ -0,0 +1,42 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// Represents SendInitState. + /// + internal class SendInitState : InitState + { + #region "Properties" + + #endregion + + #region "Constructors" + + /// + /// Constructor for SendInitState Object. + /// + /// PaymentConnection Object. + /// Parameter List + /// Context Object by reference. + public SendInitState(PaymentConnection Connection, String InitialParameterList, ref Context PsmContext) : base(Connection, InitialParameterList, ref PsmContext) + { + } + + /// + /// Copy Constructor for SendInitState + /// + /// Current Payment State object. + public SendInitState(PaymentState CurrentPaymentState) : base(CurrentPaymentState) + { + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendReconnectState.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendReconnectState.cs new file mode 100644 index 0000000..9751921 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendReconnectState.cs @@ -0,0 +1,24 @@ +#region "Imports" + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// Represents SendReconnectState + /// + internal class SendReconnectState : ReconnectState + { + #region "Construcotrs" + + /// + /// Copy Constructor for SendInitState + /// + /// Current Payment State object. + public SendReconnectState(PaymentState CurrentPaymentState) : base(CurrentPaymentState) + { + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendRetryState.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendRetryState.cs new file mode 100644 index 0000000..38cafb1 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendRetryState.cs @@ -0,0 +1,9 @@ +namespace PayPal.Payments.Communication +{ + internal class SendRetryState : RetryState + { + public SendRetryState(PaymentState CurrentPaymentState) : base(CurrentPaymentState) + { + } + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendState.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendState.cs new file mode 100644 index 0000000..97dba8a --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/SendState.cs @@ -0,0 +1,96 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Logging; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// Represents SendState. + /// + abstract internal class SendState : PaymentState + { + #region "Constructors" + + /// + /// Copy constructor for SendState. + /// + /// Current Payment State object. + public SendState(PaymentState CurrentPaymentState) : base(CurrentPaymentState) + { + } + + #endregion + + #region "Functions" + + /// + /// Abstract Declaration of + /// GetSendRequest + /// + /// request to be sent + public abstract String GetSendRequest(); + + /// + /// Execute function + /// + public override void Execute() + { + bool IsSendSuccess = false; + + Logger.Instance.Log("PayPal.Payments.Communication.SendState.Execute(): Entered.", PayflowConstants.SEVERITY_DEBUG); + if (!InProgress) + return; + try + { + //Begin Payflow Timeout Check Point 3 + long TimeRemainingMsec; + if (PayflowUtility.IsTimedOut(mConnection.TimeOut, mConnection.StartTime, out TimeRemainingMsec)) + { + String AddlMessage = "Input timeout value in millisec = " + Connection.TimeOut.ToString(); + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_TIMEOUT_WAIT_RESP, null, PayflowConstants.SEVERITY_FATAL, IsXmlPayRequest, AddlMessage); + if (!CommContext.IsCommunicationErrorContained(Err)) + { + CommContext.AddError(Err); + } + } + else + { + mConnection.TimeOut = TimeRemainingMsec; + } + //End Payflow Timeout Check Point 3 + IsSendSuccess = mConnection.SendToServer(GetSendRequest()); + } + catch (Exception Ex) + { + Logger.Instance.Log("PayPal.Payments.Communication.SendState.Execute(): Error occurred While Initializing Connection.", PayflowConstants.SEVERITY_ERROR); + Logger.Instance.Log("PayPal.Payments.Communication.SendState.Execute(): Exception " + Ex.ToString(), PayflowConstants.SEVERITY_ERROR); + IsSendSuccess = false; + } + //catch + //{ + // IsSendSuccess = false; + //} + finally + { + if (IsSendSuccess) + { + Logger.Instance.Log("PayPal.Payments.Communication.SendState.Execute(): Send Data = Success ", PayflowConstants.SEVERITY_INFO); + SetStateSuccess(); + } + else + { + Logger.Instance.Log("PayPal.Payments.Communication.SendState.Execute(): Send Data = Failure ", PayflowConstants.SEVERITY_INFO); + SetStateFail(); + } + } + Logger.Instance.Log("PayPal.Payments.Communication.SendState.Execute(): Exiting.", PayflowConstants.SEVERITY_DEBUG); + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/TransactionReceiveState.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/TransactionReceiveState.cs new file mode 100644 index 0000000..32eba28 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/TransactionReceiveState.cs @@ -0,0 +1,67 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Logging; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using System.Collections; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// Represents transaction receive state. + /// + internal class TransactionReceiveState : ReceiveState + { + #region "Constructors" + + /// + /// Copy constructor for TransactionReceiveState. + /// + /// Current Payment State object. + public TransactionReceiveState(PaymentState CurrentPaymentState) : base(CurrentPaymentState) + { + } + + #endregion + + #region "Functions" + + /// + /// Sets the received response + /// + /// response + /// true if response set, false otherwise. + public override bool SetReceiveResponse(String Response) + { + bool RetVal = false; + Logger.Instance.Log("PayPal.Payments.Communication.TransactionReceiveState.SetReceiveResponse(String): Entered.", PayflowConstants.SEVERITY_DEBUG); + if (Response == null) + { + Logger.Instance.Log("PayPal.Payments.Communication.TransactionReceiveState.SetReceiveResponse(String): Response = null", PayflowConstants.SEVERITY_WARN); + RetVal = false; + } + else if (Response.Length == 0) + { + Logger.Instance.Log("PayPal.Payments.Communication.TransactionReceiveState.SetReceiveResponse(String): Response.Length = 0", PayflowConstants.SEVERITY_WARN); + RetVal = false; + } + else + { + TransactionResponse = Response; + Logger.Instance.Log("PayPal.Payments.Communication.TransactionReceiveState.SetReceiveResponse(String): Response = " + TransactionResponse, PayflowConstants.SEVERITY_INFO); + RetVal = true; + } + + SetProgressComplete(); + + + Logger.Instance.Log("PayPal.Payments.Communication.TransactionReceiveState.SetReceiveResponse(String): Exiting.", PayflowConstants.SEVERITY_DEBUG); + return RetVal; + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Communication/TransactionSendState.cs b/dotNET/PayflowProSDK/PayPal/Payments/Communication/TransactionSendState.cs new file mode 100644 index 0000000..72a235f --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Communication/TransactionSendState.cs @@ -0,0 +1,50 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Logging; + +#endregion + +namespace PayPal.Payments.Communication +{ + /// + /// Represents transaction send state. + /// + internal class TransactionSendState : SendState + { + #region "Constructors" + + /// + /// Copy constructor for TransactionSendState. + /// + /// Current Payment State object. + public TransactionSendState(PaymentState CurrentPaymentState) : base(CurrentPaymentState) + { + } + + #endregion + + #region "Functions" + + /// + /// Gets the request to be sent. + /// + /// Request to be sent. + override public String GetSendRequest() + { + Logger.Instance.Log("PayPal.Payments.Communication.TransactionSendState.GetSendRequest(): Entered.", PayflowConstants.SEVERITY_DEBUG); + + String LogRequest = base.TransactionRequest; + LogRequest = PayflowUtility.MaskSensitiveFields(LogRequest); + + + Logger.Instance.Log("PayPal.Payments.Communication.TransactionSendState.GetSendRequest(): Request = " + LogRequest, PayflowConstants.SEVERITY_INFO); + Logger.Instance.Log("PayPal.Payments.Communication.TransactionSendState.GetSendRequest(): Exiting.", PayflowConstants.SEVERITY_DEBUG); + return base.TransactionRequest; + + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ACHTender.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ACHTender.cs new file mode 100644 index 0000000..b996ef5 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ACHTender.cs @@ -0,0 +1,185 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// This class is used to create and use an ACH + /// ( Automatic Clearing House ) Tender type. + /// + /// BankAcct is the Payment device associated with this + /// tender type. + /// + public sealed class ACHTender : BaseTender + { + #region "Member Variables" + + /// + /// ACH Auth Type + /// + private String mAuthType; + + /// + /// ACH Prenote (Y/N) + /// + private String mPreNote; + + /// + /// ACH Term City + /// + private String mTermCity; + + /// + /// ACH Term State + /// + private String mTermState; + + #endregion + + #region "Constructors" + + /// + /// Constructor + /// + /// Bank Account object. + /// + /// ACHTender should be used to perform the transactions + /// in which the user provides his bank account details for + /// the online payment processing. + /// Maps to Payflow Parameter: + /// TENDER + /// + /// + /// + /// ............. + /// //BnkAcct is the populated BankAcct object. + /// ............. + /// + /// //Create the Tender object + /// ACHTender Tender = new ACHTender(BnkAcct); + /// + /// ............. + /// + /// + /// ............. + /// //BnkAcct is the populated BankAcct object. + /// ............. + /// + /// 'Create the Tender object + /// Dim Tender As ACHTender = new ACHTender(BnkAcct) + /// + /// ............. + /// + /// + /// + public ACHTender(BankAcct BnkAcct) : base(PayflowConstants.TENDERTYPE_ACH, BnkAcct) + { + } + + #endregion + + #region "Properties" + + /// + /// Gets, Sets the Prenote. + /// + /// + /// Prenote indicates a prenotification payment with no amount. + /// Used to verify bank account validity. Receiving banks are not required + /// to respond to prenotification payments. + /// Allowed Prenote values are: + /// + /// + /// PRENOTE + /// Description + /// + /// + /// N + /// Default. AMT needs to be passed. + /// + /// + /// Y + /// Default. AMT does not need to be passed. + /// + /// + /// Maps to Payflow Parameter: + /// PRENOTE + /// + public String PreNote + { + get { return mPreNote; } + + set { mPreNote = value; } + } + + /// + /// Gets, Sets the Termcity. + /// + /// + /// City where the merchant's terminal is located. + /// Used only for POP. + /// Maps to Payflow Parameter: + /// TERMCITY + /// + public String TermCity + { + get { return mTermCity; } + + set { mTermCity = value; } + } + + /// + /// Gets, Sets the Termstate. + /// + /// + /// State where the merchant's terminal is located. + /// Used only for POP. + /// Maps to Payflow Parameter: + /// TERMSTATE + /// + public String TermState + { + get { return mTermState; } + + set { mTermState = value; } + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_AUTHTYPE, mAuthType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PRENOTE, mPreNote)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_TERMCITY, mTermCity)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_TERMSTATE, mTermState)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + } + + #endregion + + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Address.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Address.cs new file mode 100644 index 0000000..9184c47 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Address.cs @@ -0,0 +1,219 @@ +#region "Imports" + +using System; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Abstract class to hold the + /// Address information. + /// + /// This class can be extended to create a new address type. + public abstract class Address : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Holds Street + /// + private String mStreet; + + /// + /// Holds Street2 + /// + private String mStreet2; + + /// + /// Holds City + /// + private String mCity; + + /// + /// Holds State + /// + private String mState; + + /// + /// Holds Zip + /// + private String mZip; + + /// + /// Holds Country + /// + private String mCountry; + + /// + /// Holds Phonenum + /// + private String mPhone; + + /// + /// Holds Phone2 + /// + private String mPhone2; + + /// + /// Holds Email + /// + private String mEmail; + + /// + /// Holds Fax + /// + private String mFax; + + /// + /// Holds First Name + /// + private String mFirstName; + + /// + /// Holds Middle Name + /// + private String mMiddleName; + + /// + /// Holds Last Name + /// + private String mLastName; + + #endregion + + #region "Properties" + + /// + /// Gets, Sets Street + /// + internal String AddressStreet + { + get { return mStreet; } + set { mStreet = value; } + } + + /// + /// Gets, Sets Street2 + /// + internal String AddressStreet2 + { + get { return mStreet2; } + set { mStreet2 = value; } + } + + /// + /// Gets, Sets City + /// + internal String AddressCity + { + get { return mCity; } + set { mCity = value; } + } + + /// + /// Gets, Sets State + /// + internal String AddressState + { + get { return mState; } + set { mState = value; } + } + + /// + /// Gets, Sets Zip + /// + internal String AddressZip + { + get { return mZip; } + set { mZip = value; } + } + + /// + /// Gets, Sets Country + /// + internal String AddressCountry + { + get { return mCountry; } + set { mCountry = value; } + } + + /// + /// Gets, Sets Phonenum + /// + internal String AddressPhone + { + get { return mPhone; } + set { mPhone = value; } + } + + /// + /// Gets, Sets Phone2 + /// + internal String AddressPhone2 + { + get { return mPhone2; } + set { mPhone2 = value; } + } + + /// + /// Gets, Sets Email + /// + internal String AddressEmail + { + get { return mEmail; } + set { mEmail = value; } + } + + /// + /// Gets, Sets Fax + /// + internal String AddressFax + { + get { return mFax; } + set { mFax = value; } + } + + /// + /// Gets, Sets Firstname + /// + internal String AddressFirstName + { + get { return mFirstName; } + set { mFirstName = value; } + } + + /// + /// Gets, Sets Middlename + /// + internal String AddressMiddleName + { + get { return mMiddleName; } + set { mMiddleName = value; } + } + + /// + /// Gets, Sets Lastname + /// + internal String AddressLastName + { + get { return mLastName; } + set { mLastName = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor for Address. + /// + /// Abstract class. Instance cannot be created directly. + protected Address() + { + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/AdviceDetail.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/AdviceDetail.cs new file mode 100644 index 0000000..79a4f17 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/AdviceDetail.cs @@ -0,0 +1,191 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for advice detail items. + /// + /// + /// This class holds the advice detail related information. + /// Detail of a charge where *n* is a value from 1 - 5. Use for additional breakdown of the amount. + /// For example ADDLAMT1=1 is the amount for the additional amount for advice detail item 1 and is equal to 1, + /// + /// + /// Following example shows how to use AdviceDetail. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// // Set the Advice Detail items. + /// AdviceDetail AddDetail1 = new AdviceDetail(); + /// AddDetail1.AddLAmt = "1"; + /// AddDetail1.AddLAmtType = "1"; + /// Inv.AddAdviceDetailItem(AddDetail1); + /// // To add another item, just do the same as above but increment the value of AddDetail to 2: AddDetail2 + /// ................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// ' Set the Advice Detail items. + /// Dim AddDetail1 As AdviceDetail = New AdviceDetail + /// AddDetail1.AddLAmt = "1" + /// AddDetail1.AddLAmtType = "1" + /// Inv.AddAdviceDetailItem(AddDetail1) + /// ' To add another item, just do the same as above but increment the value of AddDetail to 2: AddDetail2 + /// ................. + /// + /// + public sealed class AdviceDetail : BaseRequestDataObject + { + #region "Member Variables" + + + /// + /// Advice Detail Number + /// + private String mAdviceDetailNumber; + + /// + /// Advice Detail Amount + /// + private String mAddLAmt; + + /// + /// Advice Detail Amount Type + /// + private String mAddLAmtType; + + + #endregion + + #region "Properties" + + /// + /// Gets, Sets advice detail amount + /// + /// + /// Maps to Payflow Parameter: + /// ADDLAMTn + /// + public String AddLAmt + { + get { return mAddLAmt; } + set { mAddLAmt = value; } + } + + /// + /// Gets, Sets advice detail amount type + /// + /// + /// Maps to Payflow Parameter: + /// ADDLAMTTYPEn + /// + public String AddLAmtType + { + get { return mAddLAmtType; } + set { mAddLAmtType = value; } + } + + + + /// ------------------------------------------------------ + + + /// + /// Gets, Sets advice detail line item number. + /// + /// + /// + /// Maps to Payflow Parameter: + /// ADDLxxxxn + /// + public String AdviceDetailNumber + { + get { return mAdviceDetailNumber; } + set { mAdviceDetailNumber = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Used for advice detail items. + /// + /// + /// This class holds the advice detail related information. + /// Detail of a charge where *n* is a value from 1 - 5. Use for additional breakdown of the amount. + /// For example ADDLAMT1=1 is the amount for the additional amount for advice detail item 1 and is equal to 1, + /// + /// + /// Following example shows how to use AdviceDetail. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// // Set the Advice Detail items. + /// AdviceDetail AddDetail1 = new AdviceDetail(); + /// AddDetail1.AddLAmt = "1"; + /// AddDetail1.AddLAmtType = "1"; + /// Inv.AddAdviceDetailItem(AddDetail1); + /// // To add another item, just do the same as above but increment the value of AddDetail to 2: AddDetail2 + /// ................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// ' Set the Advice Detail items. + /// Dim AddDetail1 As AdviceDetail = New AdviceDetail + /// AddDetail1.AddLAmt = "1" + /// AddDetail1.AddLAmtType = "1" + /// Inv.AddAdviceDetailItem(AddDetail1) + /// ' To add another item, just do the same as above but increment the value of AddDetail to 2: AddDetail2 + /// ................. + /// + /// + public AdviceDetail() + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates advice detail item request + /// + /// index number of advice detail item + internal void GenerateRequest(int Index) + { + try + { + String IndexVal = (Index + 1).ToString(); // adding +1 as range is 1 to 5. + + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ADDLAMT+ IndexVal, mAddLAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ADDLAMTTYPE + IndexVal, mAddLAmtType)); + + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + } + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BankAcct.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BankAcct.cs new file mode 100644 index 0000000..9dfa379 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BankAcct.cs @@ -0,0 +1,165 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for BankAcct information. + /// + /// + /// BankAcct is associated with ACHTender. + /// + /// + public sealed class BankAcct : PaymentDevice + { + #region "Member Variables" + + /// + /// Holds Aba + /// + private String mAba; + + /// + /// Holds Bank Acct type + /// + private String mAcctType; + + #endregion + + #region "Constructors" + + /// + /// Constructor for BankAcct + /// + /// Bank Account number + /// Aba number + /// + /// BankAcct should be used to perform the transactions + /// in which the user provides his bank account details for + /// the online payment processing. + /// + /// + /// + /// ............. + /// + /// //Create the BankAcct object + /// BankAcct Account = new BankAcct("XXXXXXXXXXX","XXXXXXXXXXX"); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the BankAcct object + /// Dim Account As BankAcct = new BankAcct("XXXXXXXXXXX","XXXXXXXXXXX") + /// + /// ............. + /// + /// + public BankAcct(String Acct, String Aba) : base(Acct) + { + mAba = Aba; + } + + #endregion + + #region "Properties" + + /// + /// Gets Acct. + /// + /// + /// Customer’s bank account number. + /// Maps to Payflow Parameter: + /// ACCT + /// + public override String Acct + { + get { return base.Acct; } + } + + /// + /// Gets, Sets Aba. + /// + /// + /// Target Bank's transit ABA routing number. + /// Appies only to ACH transactions.(8-digit number) + /// Maps to Payflow Parameter: + /// ABA + /// + public String Aba + { + get { return mAba; } + set { mAba = value; } + } + + /// + /// Gets, Sets Acct type + /// + /// + /// Customer's bank account type + /// Allowed AcctType values are: + /// + /// + /// ACCTTYPE + /// Description + /// + /// + /// C + /// Checking account + /// + /// + /// S + /// Savings account + /// + /// + /// Maps to Payflow Parameter: + /// ACCTTYPE + /// + public String AcctType + { + get { return mAcctType; } + set { mAcctType = value; } + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + //Get the request from base. + base.GenerateRequest(); + //Add ABA and ACCTTYPE to parameter list. + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ABA, mAba)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ACCTTYPE, mAcctType)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + + } + + #endregion + + + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BaseRequestDataObject.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BaseRequestDataObject.cs new file mode 100644 index 0000000..7bac16b --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BaseRequestDataObject.cs @@ -0,0 +1,90 @@ +#region "Imports" + +using PayPal.Payments.Common; +using System.Text; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Abstract base Class of all request data objects. + /// + /// This class can be used to create a new request data + /// object. + public abstract class BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Static context + /// + private Context mContext; + + /// + /// Static request buffer + /// + private StringBuilder mRequestBuffer; + + #endregion + + #region "Constructors" + + /// + /// Constructor. + /// + /// Abstract class. Instance cannot be created directly. + protected BaseRequestDataObject() + { + } + + #endregion + + #region "Properties" + + /// + /// Gets, Sets context + /// + internal virtual Context Context + { + get { return mContext; } + set { mContext = value; } + } + + /// + /// Gets, Sets Requestbuffer + /// + internal virtual StringBuilder RequestBuffer + { + get { return mRequestBuffer; } + set { mRequestBuffer = value; } + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal virtual void GenerateRequest() + { + // This function is not called. All the + //address information is validated and generated + //in its respective derived classes. + + } + + /// + /// Resets the context + /// + /// Not supported. + public static void ResetContext() + { + } + + #endregion + } + + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BaseResponseDataObject.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BaseResponseDataObject.cs new file mode 100644 index 0000000..524fa8f --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BaseResponseDataObject.cs @@ -0,0 +1,30 @@ +#region "Imports" + +using System; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Abstract base Class of all response data objects. + /// + /// This class can be used to create a new response data + /// object. + public class BaseResponseDataObject + { + #region "Core Functions" + + /// + /// Sets the Response params in + /// response data objects. + /// + /// Response String + internal virtual void SetParams(String Response) + { + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BaseTender.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BaseTender.cs new file mode 100644 index 0000000..e5d14bc --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BaseTender.cs @@ -0,0 +1,425 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// This abstract class serves as base class + /// of all tender objects. + /// + /// + /// Each tender type is associated with a Payment Device. + /// Following are the Payment Devices associated with + /// different tender types: + /// + /// + /// Tender type + /// Payment Device Data Object + /// + /// + /// ACHTender + /// BankAcct Class + /// + /// + /// CardTender + /// + /// CreditCard Class + /// PurchaseCard Class + /// SwipeCard Class + /// + /// + /// + /// CheckTender + /// CheckPayment Class + /// + /// + /// + public class BaseTender : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Holds the tender type. + /// + private String mTender; + + /// + /// Holds the associated + /// payment device. + /// + private PaymentDevice mPaymentDevice; + + /// + /// Holds Check number + /// + private String mChkNum; + + /// + /// Holds Check type + /// + private String mChkType; + + /*/// + /// Holds Dl State + /// + ///private String mDlState; + + /// + /// Holds Consent medium + /// + ///private String mConsentMedium; + + /// + /// Holds Customer type + /// + ///private String mCustomerType; + + /// + /// Holds Bank Name + /// + ///private String mBankName; + + /// + /// Holds Bank State + /// + ///private String mBankState;*/ + /// + /// Holds DL + /// + private String mDL; + + /// + /// Holds SS + /// + private String mSS; + + /// + /// Holds AuthType + /// + private String mAuthType; + + #endregion + + #region "Constructors" + + /// + /// Constructor for BaseTender. + /// + /// Tender Type ("C"/"A"/"K") + /// Payment Device + /// Abstract class. Instance cannot be created directly. + public BaseTender(String Tender, PaymentDevice PayDevice) + { + mTender = Tender; + mPaymentDevice = PayDevice; + + } + + #endregion + + #region "Properties" + + /// + /// Gets, Sets Tender Type. + /// + /// + /// Maps to Payflow Parameter: + /// TENDER + /// + protected String Tender + { + get { return mTender; } +// set { mTender = value; } + } + +// /// +// /// Gets, Sets Payment Device. +// /// +// /// +// /// This is the Payment Device associated with +// /// this tender object. +// /// Following are the Payment Devices associated with +// /// different tender types: +// /// +// /// +// /// Tender type +// /// Payment Device Data Object +// /// +// /// +// /// ACHTender +// /// BankAcct +// /// +// /// +// /// CardTender +// /// +// /// CreditCard +// /// PurchaseCard +// /// SwipeCard +// /// +// /// +// /// +// /// CheckTender +// /// CheckPayment +// /// +// /// +// /// +// internal PaymentDevice PayDevice +// { +// get { return mPaymentDevice; } +// set { mPaymentDevice = value; } +// } + + /// + /// Gets, Sets Check number. + /// + /// + /// For ACH - The check serial number. + /// Required for POP, ARC, and RCK. + /// + /// For TeleCheck - Account holder’s next unused + /// (available) check number. + /// + /// Maps to Payflow Parameter: + /// CHKNUM + /// + public virtual String ChkNum + { + get { return mChkNum; } + set { mChkNum = value; } + } + + /// + /// Gets, Sets Check type. + /// + /// + /// Check type. + /// Allowed CheckTypes are: + /// + /// + /// CHKTYPE + /// Description + /// + /// + /// P + /// Personal. + /// + /// + /// C + /// Company. + /// + /// + /// + public virtual String ChkType + { + get { return mChkType; } + set { mChkType = value; } + } + +/* /// + /// Gets, Sets DlState + /// + /// Not Supported. +// public virtual String DlState +// { +// get { return mDlState; } +// set { mDlState = value; } +// } + + /// + /// Gets, Sets Consent Medium + /// + /// Not Supported. +// public virtual String ConsentMedium +// { +// get { return mConsentMedium; } +// set { mConsentMedium = value; } +// } + + /// + /// Gets, Sets Customer Type + /// + /// Not Supported. +// public virtual String CustomerType +// { +// get { return mCustomerType; } +// set { mCustomerType = value; } +// } + + /// + /// Gets, Sets Bank Name + /// + /// Not Supported. +// public virtual String BankName +// { +// get { return mBankName; } +// set { mBankName = value; } +// } + + /// + /// Gets, Sets Bank State + /// + /// Not Supported. +// public virtual String BankState +// { +// get { return mBankState; } +// set { mBankState = value; } +// }*/ + + /// + /// Gets, Sets DL + /// + /// + /// Driver’s license number. + /// Format: XXnnnnnnnn + /// XX = State Code, nnnnnnnn = DL Number + /// Maps to Payflow Parameter: + /// DL + /// + public virtual String DL + { + get { return mDL; } + set { mDL = value; } + } + + /// + /// Gets, Sets SS + /// + /// + /// Account holder’s social security number. + /// Maps to Payflow Parameter: + /// SS + /// + + public virtual String SS + { + get { return mSS; } + set { mSS = value; } + } + + + /// + /// Sets,gets the AuthType. + /// + /// + /// The type of authorization received from the payer. For both ACH and TeleCheck. + /// Allowed AuthTypes for ACH are: + /// + /// + /// AUTHTYPE + /// Description + /// + /// + /// CCD + /// Default for B2B format accounts. + /// + /// + /// PPD + /// Standard customer authorization method for B2C format accounts. + /// + /// + /// ARC + /// Accounts Receivables check entry for a single entry debit. + /// + /// + /// RCK + /// Re-presented check entry for a single entry debit. + /// + /// + /// WEB + /// The customer authorized the payment over the Internet. + /// + /// + /// TEL + /// Debit authorization obtained by telephone. + /// + /// + /// POP + /// Point of Purchase check entry for a single entry debit. + /// + /// + /// Allowed AuthTypes for TeleCheck are: + /// + /// + /// AUTHTYPE + /// Description + /// + /// + /// I + /// Internet Check Acceptance (ICA) provides the capability to authorize and electronically settle checks over the Internet. + /// + /// + /// P + /// Checks By Phone (CBP) provides the capability to authorize and electronically settle checks over the phone. + /// + /// + /// D + /// Prearranged Deposit Services (PPD) debits the customer's account provided the customer has previously accepted a written authorization. + /// + /// + /// Maps to Payflow Parameter: + /// AUTHTYPE + /// + public virtual String AuthType + { + get { return mAuthType; } + set { mAuthType = value; } + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + if (mPaymentDevice != null) + { + mPaymentDevice.RequestBuffer = RequestBuffer; + mPaymentDevice.GenerateRequest(); + } + + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_TENDER, mTender)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CHKNUM, mChkNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CHKTYPE, mChkType)); +// RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DLSTATE , mDlState)); +// RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CONSENTMEDIUM, mConsentMedium)); +// RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTOMERTYPE, mCustomerType)); +// RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BANKNAME, mBankName)); +// RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BANKSTATE, mBankState)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DL, mDL)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SS, mSS)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_AUTHTYPE, mAuthType)); + + + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + + } + + #endregion + + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BillTo.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BillTo.cs new file mode 100644 index 0000000..2840e2b --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BillTo.cs @@ -0,0 +1,427 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Billing Address information + /// + /// Billing address is Cardholder's address information. + /// + /// Following example shows how to use BillTo. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// + /// //Set the Billing Address details. + /// BillTo Bill = new BillTo(); + /// Bill.BillToStreet = "123 Main St."; + /// Bill.BillToZip = "12345"; + /// Inv.BillTo = Bill; + /// ................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// + /// 'Set the Billing Address details. + /// Dim Bill As BillTo = New BillTo + /// Bill.BillToStreet = "123 Main St." + /// Bill.BillToZip = "12345" + /// Inv.BillTo = Bill + /// ................. + /// + /// + public sealed class BillTo : Address + { + #region "Member variables" + + /// + /// Home phone + /// + private String mBillToHomePhone; + + /// + /// Company Name + /// + private String mBillToCompanyName; + + #endregion + + #region "Properties" + + /// + /// Gets, Sets Billing City. + /// + /// + /// Cardholder’s billing city. + /// Maps to Payflow Parameter: + /// BILLTOCITY + /// + public String BillToCity + { + get { return base.AddressCity; } + set { base.AddressCity = value; } + } + + /// + /// Gets, Sets Billing Country. + /// + /// + /// Cardholder’s billing country code + /// Maps to Payflow Parameter: + /// BILLTOCOUNTRY + /// + public String BillToCountry + { + get { return base.AddressCountry; } + set { base.AddressCountry = value; } + } + + /// + /// Gets, Sets Billing Email. + /// + /// + /// Cardholder’s e-mail address + /// Maps to Payflow Parameter: + /// BILLTOEMAIL + /// + public String BillToEmail + { + get { return base.AddressEmail; } + set { base.AddressEmail = value; } + } + + /// + /// Gets, Sets Billing Fax + /// + /// + /// Cardholder’s fax address. + /// Maps to Payflow Parameter: + /// BILLTOFAX + /// + public String BillToFax + { + get { return base.AddressFax; } + set { base.AddressFax = value; } + } + + /// + /// Gets, Sets Billing Firstname. + /// + /// + /// Cardholder’s first name. + /// Maps to Payflow Parameter: + /// BILLTOFIRSTNAME + /// + public String BillToFirstName + { + get { return base.AddressFirstName; } + set { base.AddressFirstName = value; } + } + + /// + /// Gets, Sets Billing Lastname. + /// + /// + /// Cardholder’s last name. + /// Maps to Payflow Parameter: + /// BillTOLASTNAME + /// + public String BillToLastName + { + get { return base.AddressLastName; } + set { base.AddressLastName = value; } + } + + /// + /// Gets, Sets Billing Middlename. + /// + /// + /// Cardholder’s middle name. + /// Maps to Payflow Parameter: + /// BILLTOMIDDLENAME + /// + public String BillToMiddleName + { + get { return base.AddressMiddleName; } + set { base.AddressMiddleName = value; } + } + + /// + /// Gets, Sets Billing Phone2. + /// + /// + /// Cardholder’s 2nd telephone number. + /// Maps to Payflow Parameter: + /// BILLTOPHONE2 + /// + public String BillToPhone2 + { + get { return base.AddressPhone2; } + set { base.AddressPhone2 = value; } + } + + /// + /// Gets, Sets Billing Phonenum + /// + /// + /// Cardholder’s telephone number. + /// Maps to Payflow Parameter: + /// BILLTOPHONENUM + /// + public String BillToPhone + { + get { return base.AddressPhone; } + set { base.AddressPhone = value; } + } + + /// + /// Gets, Sets Billing State. + /// + /// + /// Cardholder’s billing state code. + /// Maps to Payflow Parameter: + /// BILLTOSTATE + /// + public String BillToState + { + get { return base.AddressState; } + set { base.AddressState = value; } + } + + /// + /// Gets, Sets Billing Street. + /// + /// + /// Cardholder’s billing street address + /// (used for AVS and reporting). + /// Maps to Payflow Parameter: + /// BILLTOSTREET + /// + public String BillToStreet + { + get { return base.AddressStreet; } + set { base.AddressStreet = value; } + } + + /// + /// Gets, Sets Billing Street2 + /// + /// + /// Cardholder’s billing street 2 address + /// (used for AVS and reporting). + /// Maps to Payflow Parameter: + /// BILLTOSTREET2 + /// + public String BillToStreet2 + { + get { return base.AddressStreet2; } + set { base.AddressStreet2 = value; } + } + + /// + /// Gets, Sets Billing Zip. + /// + /// + /// Account holder’s 5- to 9-digit postal code + /// (called ZIP code in the USA). + /// Do not use spaces, dashes, + /// or non-numeric characters. + /// The postal code is verified by the + /// AVS service. + /// Maps to Payflow Parameter: + /// BILLTOZIP + /// + public String BillToZip + { + get { return base.AddressZip; } + set { base.AddressZip = value; } + } + + /// + /// Gets, Sets Billing HomePhone. + /// + /// + /// Cardholder’s home telephone number. + /// Maps to Payflow Parameter: + /// HOMEPHONE + /// + public String BillToHomePhone + { + get { return mBillToHomePhone; } + set { mBillToHomePhone = value; } + } + + /// + /// Gets, Sets CompanyName. + /// + /// + /// Company Name. + /// Maps to Payflow Parameter: + /// COMPANYNAME + /// + public String BillToCompanyName + { + get { return mBillToCompanyName; } + set { mBillToCompanyName = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor. + /// + /// Billing address is Cardholder's address information. + /// + /// Following example shows how to use BillTo. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// + /// //Set the Billing Address details. + /// BillTo Bill = new BillTo(); + /// Bill.BillToStreet = "123 Main St."; + /// Bill.BillToZip = "12345"; + /// Inv.BillTo = Bill; + /// ................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// + /// 'Set the Billing Address details. + /// Dim Bill As BillTo = New BillTo + /// Bill.BillToStreet = "123 Main St." + /// Bill.BillToZip = "12345" + /// Inv.BillTo = Bill + /// ................. + /// + /// + public BillTo() + { + } + + #endregion + + #region "Utility function" + + /// + /// This method copies the common contents + /// from billing to shipping address. + /// + /// ShipTo object + /// This method can be used to + /// populate the shipping addresses directly + /// from the billing addresses when + /// both are the same. + /// + /// + /// + /// ................ + /// //Bill is the object of + /// //BillTo populated with + /// //the billing addresses. + /// ................ + /// + /// + /// ShipTo Ship; + /// + /// //Populate shipping addresses + /// //from billing addresses. + /// Ship = Bill.Copy(); + /// + /// ................ + /// + /// + /// + /// + /// ................ + /// 'Bill is the object of + /// 'BillTo populated with + /// 'the billing addresses. + /// ................ + /// + /// + /// Dim Ship As ShipTo + /// + /// 'Populate shipping addresses + /// 'from billing addresses. + /// Ship = Bill.Copy() + /// + /// ................ + /// + /// + /// + /// + public ShipTo Copy() + { + ShipTo CopyObject = new ShipTo(); + CopyObject.AddressCity = AddressCity; + CopyObject.AddressCountry = AddressCountry; + CopyObject.AddressEmail = AddressEmail; + CopyObject.AddressFax = AddressFax; + CopyObject.AddressFirstName = AddressFirstName; + CopyObject.AddressLastName = AddressLastName; + CopyObject.AddressMiddleName = AddressMiddleName; + CopyObject.AddressPhone2 = AddressPhone2; + CopyObject.AddressPhone = AddressPhone; + CopyObject.AddressState = AddressState; + CopyObject.AddressStreet = AddressStreet; + CopyObject.AddressStreet2 = AddressStreet2; + CopyObject.AddressZip = AddressZip; + return CopyObject; + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_STREET, this.BillToStreet)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BILLTOSTREET2, this.BillToStreet2)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CITY, this.BillToCity)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_STATE, this.BillToState)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BILLTOCOUNTRY, this.BillToCountry)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ZIP, this.BillToZip)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PHONENUM, this.BillToPhone)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BILLTOPHONE2, this.BillToPhone2)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_EMAIL, this.BillToEmail)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_FAX, this.BillToFax)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_FIRSTNAME, this.BillToFirstName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MIDDLENAME, this.BillToMiddleName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_LASTNAME, this.BillToLastName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_HOMEPHONE, mBillToHomePhone)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_COMPANYNAME, mBillToCompanyName)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BrowserInfo.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BrowserInfo.cs new file mode 100644 index 0000000..dacd739 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BrowserInfo.cs @@ -0,0 +1,245 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Browser related information. + /// + /// Use the BrowserInfo object for the user + /// browser related information. + /// + /// Following example shows how to use a + /// Browser Info object. + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Browser Info details. + /// BrowserInfo Browser = New BrowserInfo(); + /// Browser.BrowserCountryCode = "USA"; + /// Browser.BrowserUserAgent = "IE 6.0"; + /// Inv.BrowserInfo = Browser; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Browser Info details. + /// Dim Browser As BrowserInfo = New BrowserInfo + /// Browser.BrowserCountryCode = "USA" + /// Browser.BrowserUserAgent = "IE 6.0" + /// Inv.BrowserInfo = Browser + /// ................. + /// + /// + public sealed class BrowserInfo : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Holds Browser time. + /// + private String mBrowserTime; + /// + /// Holds Browser Country code. + /// + private String mBrowserCountryCode; + /// + /// Holds Browser User Agent + /// + private String mBrowserUserAgent; + /// + /// Holds Buttonsource + /// + private String mButtonSource; + /// + /// Holds notify url + /// + private String mNotifyURL; + /// + /// Holds custom + /// + private String mCustom; + /// + /// Holds merchant session id + /// + private String mMerchantSessionId; + #endregion + + #region "Constructors" + + /// + /// Constructor for BrowserInfo + /// + /// Use the BrowserInfo object for the user + /// browser related information. + /// + /// Following example shows how to use a + /// Browser Info object. + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Browser Info details. + /// BrowserInfo Browser = New BrowserInfo(); + /// Browser.BrowserCountryCode = "USA"; + /// Browser.BrowserUserAgent = "IE 6.0"; + /// Inv.BrowserInfo = Browser; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Browser Info details. + /// Dim Browser As BrowserInfo = New BrowserInfo + /// Browser.BrowserCountryCode = "USA" + /// Browser.BrowserUserAgent = "IE 6.0" + /// Inv.BrowserInfo = Browser + /// ................. + /// + /// + public BrowserInfo() + { + } + + #endregion + + #region "Properties" + + /// + /// Gets, Sets Browser time. + /// + /// + /// Browser's local time. + /// Maps to Payflow Parameter: + /// BROWSERTIME + /// + public String BrowserTime + { + get { return mBrowserTime; } + set { mBrowserTime = value; } + } + + /// + /// Gets, Sets Browser Country code. + /// + /// + /// Browser's local Country Code. + /// Maps to Payflow Parameter: + /// BROWSERCOUNTRYCODE + /// + public String BrowserCountryCode + { + get { return mBrowserCountryCode; } + set { mBrowserCountryCode = value; } + } + + /// + /// Gets, Sets Browser user agent. + /// + /// + /// Browser's user agent. + /// Maps to Payflow Parameter: + /// BROWSERUSERAGENT + /// + public String BrowserUserAgent + { + get { return mBrowserUserAgent; } + set { mBrowserUserAgent = value; } + } + + /// + /// Gets or Sets the custom parameter for Direct Payment and Express checkout. + /// + /// + /// Maps to Payflow Parameter: + /// CUSTOM + /// + public String Custom + { + get{return mCustom; } + set{mCustom= value;} + } + + /// + /// Gets or Sets the buttonsource parameter for Direct Payment and Express checkout. + /// + /// + /// Maps to Payflow Parameter: + /// BUTTONSOURCE + /// + public String ButtonSource + { + get{return mButtonSource; } + set{mButtonSource = value;} + } + + /// + /// Gets or Sets the NotifyUrl parameter for Direct Payment and Express checkout. + /// + /// + /// Maps to Payflow Parameter: + /// NOTIFYURL + /// + public String NotifyURL + { + get{return mNotifyURL; } + set{mNotifyURL = value;} + } + /// + /// Gets or Sets the MerchantSessionId parameter for Direct Payment. + /// + /// + /// Maps to Payflow Parameter: + /// MERCHANTSESSIONID + /// + public String MerchantSessionId + { + get{return mMerchantSessionId; } + set{mMerchantSessionId = value;} + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BROWSERTIME, mBrowserTime)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BROWSERCOUNTRYCODE, mBrowserCountryCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BROWSERUSERAGENT, mBrowserUserAgent)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTOM, mCustom)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BUTTONSOURCE, mButtonSource)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_NOTIFYURL, mNotifyURL)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTSESSIONID, mMerchantSessionId)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BuyerAuthResponse.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BuyerAuthResponse.cs new file mode 100644 index 0000000..abeebe8 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BuyerAuthResponse.cs @@ -0,0 +1,197 @@ +#region "Imports" + +using System; +using System.Collections; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for the Buyer Authorization operation + /// + public class BuyerAuthResponse : BaseResponseDataObject + { + #region "CONSTRUCTOR" + + internal BuyerAuthResponse() + {} + + #endregion + + #region "Member Variables" + + /// + /// Holds Acs Url + /// + private String mAcsUrl; + + /// + /// Holds Authentication Id + /// + private String mAuthenticationId; + + /// + /// Holds Authentication status + /// + private String mAuthenticationStatus; + + /// + /// Holds CAVV + /// + private String mCavv; + + /// + /// Holds ECI + /// + private String mEci; + + /// + /// Holds PAREQ + /// + private String mPaReq; + + /// + /// Holds XID + /// + private String mXid; + + /// + /// Holds MD + /// + private String mMd; + + #endregion + + #region "Properties" + + /// + /// Gets the AcsUrl parameter. + /// + /// + /// Maps to Payflow Parameter: + /// ACSURL + /// + public String AcsUrl + { + get { return mAcsUrl; } + } + + /// + /// Gets the authentication_id parameter. + /// + /// + /// Maps to Payflow Parameter: + /// AUTHENTICATION_ID + /// + public String Authentication_Id + { + get { return mAuthenticationId; } + } + + /// + /// Gets the authentication_status parameter. + /// + /// + /// Maps to Payflow Parameter: + /// AUTHENTICATION_STATUS + /// + public String Authentication_Status + { + get { return mAuthenticationStatus; } + } + + /// + /// Gets the CAVV parameter. + /// + /// + /// Maps to Payflow Parameter: + /// CAVV + /// + public String CAVV + { + get { return mCavv; } + } + + /// + /// Gets the ECI parameter. + /// + /// + /// Maps to Payflow Parameter: + /// ECI + /// + public String ECI + { + get { return mEci; } + } + + /// + /// Gets the PaReq parameter. + /// + /// + /// Maps to Payflow Parameter: + /// PAREQ + /// + public String PaReq + { + get { return mPaReq; } + } + + /// + /// Gets the XID parameter. + /// + /// + /// Maps to Payflow Parameter: + /// XID + /// + public String XID + { + get { return mXid; } + } + + /// + /// Gets the MD parameter. + /// + /// + /// Maps to Payflow Parameter: + /// MD + /// + public String MD + { + get { return mMd; } + } + + #endregion + + #region "Functions" + + /// + /// Sets the Response parameters in Response data objects. + /// + ///Response Hash table by ref + internal void SetParams(ref Hashtable ResponseHashTable) + { + mAcsUrl = (String) ResponseHashTable[PayflowConstants.PARAM_ACSURL]; + mAuthenticationId = (String) ResponseHashTable[PayflowConstants.PARAM_AUTHENICATION_ID]; + mAuthenticationStatus = (String) ResponseHashTable[PayflowConstants.PARAM_AUTHENICATION_STATUS]; + mCavv = (String) ResponseHashTable[PayflowConstants.PARAM_CAVV]; + mEci = (String) ResponseHashTable[PayflowConstants.PARAM_ECI]; + mMd = (String) ResponseHashTable[PayflowConstants.PARAM_MD]; + mPaReq = (String) ResponseHashTable[PayflowConstants.PARAM_PAREQ]; + mXid = (String) ResponseHashTable[PayflowConstants.PARAM_XID]; + + ResponseHashTable.Remove(PayflowConstants.PARAM_ACSURL); + ResponseHashTable.Remove(PayflowConstants.PARAM_AUTHENICATION_ID); + ResponseHashTable.Remove(PayflowConstants.PARAM_AUTHENICATION_STATUS); + ResponseHashTable.Remove(PayflowConstants.PARAM_CAVV); + ResponseHashTable.Remove(PayflowConstants.PARAM_ECI); + ResponseHashTable.Remove(PayflowConstants.PARAM_MD); + ResponseHashTable.Remove(PayflowConstants.PARAM_PAREQ); + ResponseHashTable.Remove(PayflowConstants.PARAM_XID); + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BuyerAuthStatus.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BuyerAuthStatus.cs new file mode 100644 index 0000000..98c8685 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/BuyerAuthStatus.cs @@ -0,0 +1,204 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for BuyerAuth Status information. + /// + /// Use this class to set the BuyerAuth Status related + /// information. + public sealed class BuyerAuthStatus : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Holds AuthenticationId + /// + private String mAuthenticationId; + + /// + /// Holds Authentication Status + /// + private String mAuthenticationStatus; + + /// + /// Holds ECI value + /// + private String mECI; + + /// + /// Holds CAVV + /// + private String mCAVV; + + /// + /// Holds XID + /// + private String mXID; + + /// + /// Holds Directory Server Transaction Id + /// + private String mDSTransactionId; + + /// + /// Holds 3D-Secure version + /// + private String mThreeDSVersion; + + #endregion + + #region "Constructor" + /// + /// Constructor + /// + /// Use this class to set the BuyerAuth Status + /// information. + public BuyerAuthStatus() + {} + #endregion + + #region "Properties" + + /// + /// Gets, Sets AuthenticationId. + /// + /// + /// AuthenticationId. + /// Maps to Payflow Parameter: + /// AUTHENTICATION_ID + /// + public String AuthenticationId + { + get { return mAuthenticationId; } + set { mAuthenticationId = value; } + } + + /// + /// Gets, Sets AuthenticationStatus. + /// + /// + /// Authentication Status + /// Maps to Payflow Parameter: + /// AUTHENTICATION_STATUS + /// + public String AuthenticationStatus + { + get { return mAuthenticationStatus; } + set { mAuthenticationStatus = value; } + } + + /// + /// Gets, Sets ECI. + /// + /// + /// ECI + /// Maps to Payflow Parameter: + /// ECI + /// + public String ECI + { + get { return mECI; } + set { mECI = value; } + } + + /// + /// Gets, Sets CAVV. + /// + /// + /// CAVV + /// Maps to Payflow Parameter: + /// CAVV + /// + public String CAVV + { + get { return mCAVV; } + set { mCAVV = value; } + } + + /// + /// Gets, Sets XID. + /// + /// + /// XID + /// Maps to Payflow Parameter: + /// XID + /// + public String XID + { + get { return mXID; } + set { mXID = value; } + } + + /// + /// Gets, Sets Directory Server Transaction Id. + /// + /// + /// Directory Server Transaction Id + /// Maps to Payflow Parameter: + /// DSTRANSACTIONID + /// + public String DSTransactionId + { + get { return mDSTransactionId; } + set { mDSTransactionId = value; } + } + + /// + /// Gets, Sets 3D-Secure Version. + /// + /// + /// 3D-Secure Version + /// Maps to Payflow Parameter: + /// THREEDSVERSION + /// + public String ThreeDSVersion + { + get { return mThreeDSVersion; } + set { mThreeDSVersion = value; } + } + + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_AUTHENICATION_ID, mAuthenticationId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_AUTHENICATION_STATUS, mAuthenticationStatus)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ECI, mECI)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CAVV, mCAVV)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_XID, mXID)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DSTRANSACTIONID, mDSTransactionId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_THREEDSVERSION, mThreeDSVersion)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CardTender.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CardTender.cs new file mode 100644 index 0000000..01d55c1 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CardTender.cs @@ -0,0 +1,117 @@ +#region "Imports" + +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Card tender related information + /// + /// CreditCard, PurchaseCard and SwipeCard are + /// the Payment devices associated with this tender type. + /// + /// + /// + /// + public sealed class CardTender : BaseTender + { + #region "Constructors" + + /// + /// Constructor + /// + /// Credit Card object + /// This constructor is used to create a CardTender + /// with CreditCard as the payment device + /// + /// + /// ............. + /// //CredCard is the CreditCard object. + /// ............. + /// + /// CardTender Tender = new CardTender(CredCard); + /// + /// .............. + /// + /// + /// ............. + /// 'CredCard is the CreditCard object. + /// ............. + /// + /// Dim Tender As CardTender = new CardTender(CredCard) + /// + /// .............. + /// + /// + /// + public CardTender(CreditCard CredCard):base(PayflowConstants.TENDERTYPE_CARD,CredCard) + { + } + + /// + /// Constructor + /// + /// Purchase Card object + /// This constructor is used to create a CardTender + /// with PurchaseCard as the payment device + /// + /// + /// ............. + /// //PurCard is the PurchaseCard object. + /// ............. + /// + /// CardTender Tender = new CardTender(PurCard); + /// + /// .............. + /// + /// + /// ............. + /// 'PurCard is the PurchaseCard object. + /// ............. + /// + /// Dim Tender As CardTender = new CardTender(PurCard) + /// + /// .............. + /// + /// + /// + public CardTender(PurchaseCard PurCard):base(PayflowConstants.TENDERTYPE_CARD,PurCard) + { + } + + /// + /// Constructor + /// + /// Swipe Card object + /// This constructor is used to create a CardTender + /// with SwipeCard as the payment device + /// + /// + /// ............. + /// //SwpCard is the SwipeCard object. + /// ............. + /// + /// CardTender Tender = new CardTender(SwpCard); + /// + /// .............. + /// + /// + /// ............. + /// 'SwpCard is the SwipeCard object. + /// ............. + /// + /// Dim Tender As CardTender = new CardTender(SwpCard) + /// + /// .............. + /// + /// + /// + public CardTender(SwipeCard SwpCard):base(PayflowConstants.TENDERTYPE_CARD, SwpCard) + { + } + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CheckPayment.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CheckPayment.cs new file mode 100644 index 0000000..ed67b02 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CheckPayment.cs @@ -0,0 +1,84 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Check Payment related information + /// + /// + /// CheckPayment is associated with CheckTender. + /// + /// + public sealed class CheckPayment : PaymentDevice + { + #region "Constructors" + + /// + /// Constructor. + /// + /// This is used as Payment Device for the CheckTender. + /// Maps to Payflow Parameter: + /// Micr --> MICR + /// + /// + /// + /// ............. + /// + /// CheckPayment PayDevice = new CheckPayment("XXXXXXXXXX"); + /// + /// .............. + /// + /// + /// ............. + /// + /// Dim PayDevice As CheckPayment = new CheckPayment("XXXXXXXXXX") + /// + /// .............. + /// + /// + /// + /// MICR value + public CheckPayment(String Micr) : base(Micr) + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + //Put the base field Acct as MICR. + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MICR, base.Acct)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_NAME, base.Name)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CheckTender.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CheckTender.cs new file mode 100644 index 0000000..150bd80 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CheckTender.cs @@ -0,0 +1,53 @@ +#region "Imports" + +using PayPal.Payments.Common.Utility; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Check tender related information. + /// + /// CheckPayment is the Payment device associated with + /// this tender type. + /// + /// + public sealed class CheckTender : BaseTender + { + + #region "Constructors" + + /// + /// Constructor for CheckTender + /// + /// Check Payment object. + /// This constructor is used to create a CheckTender + /// with CheckPayment as the payment device + /// + /// + /// ............. + /// //Check is the CheckPayment object. + /// ............. + /// + /// CheckTender Tender = new CheckTender(Check); + /// + /// .............. + /// + /// + /// ............. + /// 'Check is the CheckPayment object. + /// ............. + /// + /// Dim Tender As CheckTender = new CheckTender(Check) + /// + /// .............. + /// + /// + /// + public CheckTender(CheckPayment Check) : base(PayflowConstants.TENDERTYPE_TELECHECK, Check) + { + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ClientInfo.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ClientInfo.cs new file mode 100644 index 0000000..a7be2d6 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ClientInfo.cs @@ -0,0 +1,235 @@ +#region "Imports" +using System; +using System.Collections; +using PayPal.Payments.Common.Utility; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// This class is used to store the + /// Payflow Client related properties + /// + public sealed class ClientInfo : BaseRequestDataObject + { + private Hashtable mClientInfoHash = null; + /// + /// Constructor + /// + public ClientInfo() + { + mClientInfoHash = new Hashtable(); + } + + #region "Properties and getter, setter Methods" + + #region "Properties" + /// + /// Gets the client info hash table + /// + internal Hashtable ClientInfoHash + { + get { return mClientInfoHash;} + } + + /// + /// Gets client version + /// + /// + /// Client version. + /// Maps to HTTP Header: + /// PAYFLOW-CLIENT-VERSION + /// + public String ClientVersion + { + get { return (String) GetHeaderFromHash(PayflowConstants.PAYFLOWHEADER_CLIENT_VERSION);} + } + /// + /// Gets, sets OS architecture + /// + internal String OsArchitecture + { + get { return (String) GetHeaderFromHash(PayflowConstants.PAYFLOWHEADER_OS_ARCHITECTURE);} + set { AddHeaderToHash(PayflowConstants.PAYFLOWHEADER_OS_ARCHITECTURE, value); } + } + /// + /// Gets, sets OS version + /// + internal String OsVersion + { + get{ return (String) GetHeaderFromHash(PayflowConstants.PAYFLOWHEADER_OS_VERSION);} + set { AddHeaderToHash(PayflowConstants.PAYFLOWHEADER_OS_VERSION, value); } + } + /// + /// Gets, sets OS Name + /// + internal String OsName + { + get{ return (String) GetHeaderFromHash(PayflowConstants.PAYFLOWHEADER_OS_NAME);} + set { AddHeaderToHash(PayflowConstants.PAYFLOWHEADER_OS_NAME, value); } + } + /// + /// Gets, sets Proxy + /// + internal String Proxy + { + get{ return (String) GetHeaderFromHash(PayflowConstants.PAYFLOWHEADER_PROXY);} + set { AddHeaderToHash(PayflowConstants.PAYFLOWHEADER_PROXY, value); } + } + /// + /// Gets, sets runtime version + /// + internal String RunTimeVersion + { + get{ return (String) GetHeaderFromHash(PayflowConstants.PAYFLOWHEADER_RUNTIME_VERSION);} + set { AddHeaderToHash(PayflowConstants.PAYFLOWHEADER_RUNTIME_VERSION, value); } + } + /// + /// Sets integration product + /// + /// + /// Integration product. + /// Maps to HTTP Header: + /// PAYFLOW-INTEGRATION-PRODUCT + /// + public String IntegrationProduct + { + set { AddHeaderToHash(PayflowConstants.PAYFLOWHEADER_INTEGRATION_PRODUCT, value); } + } + /// + /// Sets integration version + /// + /// + /// Integration product. + /// Maps to HTTP Header: + /// PAYFLOW-INTEGRATION-VERSION + /// + public String IntegrationVersion + { + set { AddHeaderToHash(PayflowConstants.PAYFLOWHEADER_INTEGRATION_VERSION, value); } + } + + /// + /// Gets Client Type + /// + /// + /// Client type. + /// Maps to HTTP Header: + /// PAYFLOW-CLIENT-TYPE + /// + public String ClientType + { + get { return (String) GetHeaderFromHash(PayflowConstants.PAYFLOWHEADER_CLIENT_TYPE);} + } + + /// + /// Sets Request Type + /// + /// + /// Request type. + /// Maps to HTTP Header: + /// PAYFLOW-ASSEMBLY + /// + internal String RequestType + { + set { AddHeaderToHash(PayflowConstants.PAYFLOWHEADER_ASSEMBLY, value);} + } + + #endregion + + #region "Getters and setter" + /// + /// Sets client version + /// + /// String value of client version + internal void SetClientVersion(String Version) + { + AddHeaderToHash(PayflowConstants.PAYFLOWHEADER_CLIENT_VERSION, Version); + } + /// + /// Gets integration product + /// + /// String value of integration product + internal String GetIntegrationProduct() + { + return (String) GetHeaderFromHash(PayflowConstants.PAYFLOWHEADER_INTEGRATION_PRODUCT); + } + /// + /// Gets integration version + /// + /// String value of integration version + internal String GetIntegrationVersion() + { + return (String) GetHeaderFromHash(PayflowConstants.PAYFLOWHEADER_INTEGRATION_VERSION); + } + + /// + /// Sets client type + /// + /// String value of Client Type + internal void SetClientType(String ClientType) + { + AddHeaderToHash(PayflowConstants.PAYFLOWHEADER_CLIENT_TYPE, ClientType); + } + #endregion + + #endregion + + #region "Private and internal methods" + /// + /// Adds a header to the header hash table + /// + /// Header name + /// Header value + internal void AddHeaderToHash(String HeaderName, Object HeaderValue) + { + // Null Header Names & Values are not allowed. + // Empty Header Names are not allowed. + if (HeaderName == null || HeaderName.Length == 0 ||HeaderValue == null) + { + return; + } + + ClientInfoHeader CurrHeader + = new ClientInfoHeader(HeaderName, HeaderValue); + + if (mClientInfoHash == null) + { + mClientInfoHash = new Hashtable(); + } + + if (mClientInfoHash.ContainsKey(HeaderName)) + { + mClientInfoHash.Remove(HeaderName); + } + + mClientInfoHash.Add(HeaderName, CurrHeader); + } + + /// + /// Gets a header value from hash + /// + /// Header name + /// Header value object + internal Object GetHeaderFromHash(String HeaderName) + { + if (mClientInfoHash == null) + { + return null; + } + + ClientInfoHeader CurrHeader = (ClientInfoHeader) mClientInfoHash[HeaderName]; + + if (CurrHeader == null) + { + return null; + } + + return CurrHeader.HeaderValue; + + + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ClientInfoHeader.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ClientInfoHeader.cs new file mode 100644 index 0000000..d729093 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ClientInfoHeader.cs @@ -0,0 +1,48 @@ +#region "Imports" +using System; +using PayPal.Payments.DataObjects; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// This class is used to store the complete information + /// about a client information header. + /// + internal sealed class ClientInfoHeader : BaseRequestDataObject + { + /// + /// Stores Header name + /// + private String mHeaderName; + /// + /// Stores Header value + /// + private Object mHeaderValue; + /// + /// Constructor + /// + /// Header name + /// Header value + internal ClientInfoHeader(String HeaderName,Object HeaderValue) + { + mHeaderName = HeaderName; + mHeaderValue = HeaderValue; + } + + /// + /// Gets header name + /// + internal String HeaderName + { + get { return mHeaderName; } + } + /// + /// Gets header value + /// + internal Object HeaderValue + { + get { return mHeaderValue; } + } + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CreditCard.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CreditCard.cs new file mode 100644 index 0000000..ccc366d --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CreditCard.cs @@ -0,0 +1,53 @@ +#region "Imports" + +using System; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Credit Card related information + /// + /// + /// CreditCard is associated with CardTender. + /// + /// + public sealed class CreditCard : PaymentCard + { + #region "Constructors" + + /// + /// Constructor. + /// + /// Credit card number + /// Card expiry date + /// This is used as Payment Device for the CardTender. + /// Maps to Payflow Parameter: + /// Acct --> ACCT, ExpDate --> EXPDATE + /// + /// + /// + /// ............. + /// + /// CreditCard PayDevice = new CreditCard("XXXXXXXXXX","XXXX"); + /// + /// .............. + /// + /// + /// ............. + /// + /// Dim PayDevice As CreditCard = new CreditCard("XXXXXXXXXX","XXXX") + /// + /// .............. + /// + /// + /// + public CreditCard(String Acct, String ExpDate) : base(Acct, ExpDate) + { + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Currency.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Currency.cs new file mode 100644 index 0000000..dde62f4 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Currency.cs @@ -0,0 +1,443 @@ +#region "Imports" + +using System; +using System.Globalization; +using System.Threading; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// 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 amount object. + /// // Currency Code USD is US ISO currency code. If no code passed, USD is default. + /// // See the Developer's Guide regarding the CURRENCY parameter for the list of + /// // three-character currency codes available. + /// Currency Amt = new Currency(new decimal(25.25), "USD"); + /// + /// // A valid amount has either no decimal value or only a two decimal value. + /// // An invalid amount will generate a result code 4. + /// // + /// // For values which have more than two decimal places such as: + /// // Currency Amt = new Currency(new Decimal(25.2575)); + /// // You will either need to truncate or round as needed using the following properties: + /// // + /// // If the NoOfDecimalDigits property is used then it is mandatory to set one of the following + /// // properties to true. + /// // + /// //Amt.Round = true; + /// //Amt.Truncate = true; + /// // + /// // For Currencies without a decimal, you'll need to set the NoOfDecimalDigits = 0. + /// //Amt.NoOfDecimalDigits = 0; + /// + /// //Set the amount in the invoice object + /// Inv.Amt = Amt; + /// ............. + /// + /// + /// ............. + /// 'Inv is the Invoice object + /// ............. + /// + /// ' Set the amount object. + /// ' Currency Code USD is US ISO currency code. If no code passed, USD is default. + /// ' See the Developer's Guide for the list of three-character currency codes available. + /// Dim Amt As New Currency(New Decimal(25.25), "USD") + /// + /// ' A valid amount has either no decimal value or only a two decimal value. + /// ' An invalid amount will generate a result code 4. + /// ' + /// ' For values which have more than two decimal places such as: + /// ' Dim Amt As New Currency(New Decimal(25.2575)) + /// ' You will either need to truncate or round as needed using the following property: Amt.NoOfDecimalDigits + /// ' + /// ' If the NoOfDecimalDigits property is used then it is mandatory to set one of the following + /// ' properties to true. + /// ' + /// 'Amt.Round = true + /// 'Amt.Truncate = true + /// ' + /// ' For Currencies without a decimal, you'll need to set the NoOfDecimalDigits = 0. + /// 'Amt.NoOfDecimalDigits = 0 + /// + /// 'Set the amount in the invoice object + /// Inv.Amt = Amt; + /// ............. + /// + /// + public sealed class Currency : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Currency Value + /// + private decimal mCurrencyValue; + + /// + /// Currency code, default USD + /// + private String mCurrencyCode = PayflowConstants.CURRENCYCODE_DEFAULT; + private bool mRound = false; + private bool mTruncate = false; + private int mNoOfDecimalDigits = 2; + #endregion + + #region "Constructors" + + /// + /// Constructor + /// + /// Currency value + /// Currency code is set as default USD. + /// + /// + /// ............. + /// //Inv is the Invoice object + /// ............. + /// + /// //Set the invoice amount. + /// Inv.Amt = new Currency(new Decimal(25.12)); + /// + /// ............. + /// + /// + /// ............. + /// 'Inv is the Invoice object + /// ............. + /// + /// 'Set the invoice amount. + /// Inv.Amt = New Currency(New Decimal(25.12)) + /// + /// ............. + /// + /// + public Currency(decimal CurrencyValue) + { + mCurrencyValue = CurrencyValue; + } + + /// + /// Constructor. + /// + /// Currency value + /// 3 letter Currency code + /// Currency code if not given is set as default USD. + /// + /// + /// ............. + /// //Inv is the Invoice object + /// ............. + /// + /// //Set the invoice amount. + /// Inv.Amt = new Currency(new Decimal(25.12),"USD"); + /// + /// ............. + /// + /// + /// ............. + /// 'Inv is the Invoice object + /// ............. + /// + /// 'Set the invoice amount. + /// Inv.Amt = New Currency(New Decimal(25.12),"USD") + /// + /// ............. + /// + /// + public Currency(decimal CurrencyValue, String CurrencyCode) : this(CurrencyValue) + { + if(CurrencyCode != null && CurrencyCode.Length > 0) + { + mCurrencyCode = CurrencyCode; + } + } + + #endregion + + #region "Properties" + /// + /// Sets Currency value rounding flag to true. + /// Note that only one of round OR truncate can be set to true. + /// + public bool Round + { + set { mRound = value; } + } + /// + /// Sets Currency value truncation flag to true. + /// Note that only one of round OR truncate can be set to true. + /// + public bool Truncate + { + set { mTruncate = value; } + } + /// + /// Sets the number of decimal digits required after rounding or truncation. + /// + public int NoOfDecimalDigits + { + set { mNoOfDecimalDigits = value; } + } + /// + /// Gets the currency code.. + /// + public String CurrencyCode + { + get {return mCurrencyCode ;} + } + #endregion + + #region "Core functions" + + + #endregion + + #region "Rounding and Truncation Methods" + /// + /// Rounds the currency String value + /// + /// Currency String Value + /// Number of decimal digits to round to + /// Rounded Currency String value + internal String RoundCurrencyValue(String CurrStringValue,int NoOfdecimalDigits) + { + + String RetVal; + RetVal = CurrStringValue; + if(RetVal == null || RetVal.Length == 0) + { + return PayflowConstants.EMPTY_STRING; + } + + int IndexOfDecimal = RetVal.IndexOf("."); + int Length = RetVal.Length; + + if(IndexOfDecimal > 0 && IndexOfDecimal < Length) + { + if(IndexOfDecimal == Length -1) + { + for(int i=0;i Length) + { + int Padding = LenAfterTruncate - Length; + for(int i=0; i= 5) + { + int RoundVal = int.Parse(RetVal.Substring(EndLen-1,1)); + RoundVal += 1; + if(RoundVal >= 10) + { + RoundVal = 1; + } + RetVal = RetVal.Remove(EndLen-1,2); + RetVal = RetVal.Insert(EndLen-1,RoundVal.ToString()); + } + else + { + RetVal = RetVal.Remove(EndLen,1); + } + EndLen -= 1; + } + } + } + + } + return RetVal; + } + + /// + /// Truncates the currency String value + /// + /// Currency String Value + /// Number of decimal digits to round to + /// Truncated Currency String value + internal String TruncateCurrencyValue(String CurrStringValue,int NoOfdecimalDigits) + { + + String RetVal; + RetVal = CurrStringValue; + if(RetVal == null || RetVal.Length == 0) + { + return PayflowConstants.EMPTY_STRING; + } + + int IndexOfDecimal = RetVal.IndexOf("."); + int Length = RetVal.Length ; + if(IndexOfDecimal >0 && IndexOfDecimal <= Length - 1) + { + if(IndexOfDecimal == Length - 1) + { + for(int i=0; i Length) + { + int Padding = LenAfterTruncate - Length; + for(int i=0; i + /// Overrides ToString + /// + /// String value of currency + /// Formats string value of currency in format "$.CC" + /// + /// + /// ............. + /// //Inv is the Invoice object + /// ............. + /// + /// //Set the invoice amount. + /// Inv.Amt = new Currency(new Decimal(25.12),"USD"); + /// String CurrValue = Inv.ToString(); + /// ............. + /// + /// + /// ............. + /// 'Inv is the Invoice object + /// ............. + /// + /// 'Set the invoice amount. + /// Inv.Amt = New Currency(New Decimal(25.12),"USD") + /// CurrValue As String = Inv.ToString + /// ............. + /// + /// + public override string ToString() + { + try + { + //Overridden ToString. Returns held Currency Value. + String RetVal = PayflowConstants.EMPTY_STRING; + // We need to double check here whether currency value + // is non-zero positive before converting it. + + if(mNoOfDecimalDigits < 0 ) + { + mNoOfDecimalDigits = 2; + } + + if(mRound && mTruncate) + { + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_CURRENCY_PROCESS_ERROR,null,PayflowConstants.SEVERITY_FATAL,false,null); + throw new DataObjectException(Err); + } + else if(mRound) + { + mCurrencyValue = decimal.Round(mCurrencyValue,mNoOfDecimalDigits); + RetVal = RoundCurrencyValue(mCurrencyValue.ToString(),mNoOfDecimalDigits); + //RetVal = mCurrencyValue.ToString("c", LocalFormat); + + } + else if(mTruncate) + { + //RetVal = TruncateCurrencyValue(mCurrencyValue.ToString("c", LocalFormat),mNoOfDecimalDigits); + RetVal = TruncateCurrencyValue(mCurrencyValue.ToString(), mNoOfDecimalDigits); + } + else + { + //RetVal = mCurrencyValue.ToString("c", LocalFormat); + RetVal = mCurrencyValue.ToString(); + } + + int IndexOfDecimal = RetVal.IndexOf(".",1); + if(IndexOfDecimal < 0 && mNoOfDecimalDigits != 0) + { + RetVal += ".00"; + } + string TempStr = RetVal.Substring(IndexOfDecimal+1,RetVal.Length-IndexOfDecimal-1); + int Len = TempStr.Length; + if (Len < 2) + { + for (int i=Len;i<2;i++) + RetVal = RetVal + "0"; + } + return RetVal; + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CustomerInfo.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CustomerInfo.cs new file mode 100644 index 0000000..aab154b --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/CustomerInfo.cs @@ -0,0 +1,333 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Customer related information. + /// + /// Use this class to set the customer related + /// information. + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Customer Info details. + /// CustomerInfo Cust = new CustomerInfo(); + /// Cust.CustCode = "CustXXXXX"; + /// Cust.CustIP = "255.255.255.255"; + /// Inv.CustomerInfo = Cust; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Customer Info details. + /// Dim Cust As CustomerInfo = New CustomerInfo + /// Cust.CustCode = "CustXXXXX" + /// Cust.CustIP = "255.255.255.255" + /// Inv.CustomerInfo = Cust + /// ................. + /// + /// + public sealed class CustomerInfo : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Holds customer code + /// + private String mCustCode; + + /// + /// Holds customer host name + /// + private String mCustHostName; + + /// + /// Holds customer browser + /// + private String mCustBrowser; + + /// + /// Holds customer IP + /// + private String mCustIP; + + /// + /// Holds Customer Vat registration number + /// + private String mCustVatRegNum; + + /// + /// Holds Customer's date of birth + /// + private String mDob; + + /// + /// Holds customer id + /// + private String mCustId; + + /// + /// Holds ReqName + /// + private String mReqName; + + /// + /// Holds Customer Data + /// + private String mCustData; + + /// + /// Holds Customer Id + /// + private String mCustomerId; + + /// + /// Holds Customer Number + /// + private String mCustomerNumber; + + #endregion + + #region "Constructor" + /// + /// Constructor + /// + /// Use this class to set the customer related + /// information. + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Customer Info details. + /// CustomerInfo Cust = New CustomerInfo(); + /// Cust.CustCode = "CustXXXXX"; + /// Cust.CustIP = "255.255.255.255"; + /// Inv.CustomerInfo = Cust; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Customer Info details. + /// Dim Cust As CustomerInfo = New CustomerInfo + /// Cust.CustCode = "CustXXXXX" + /// Cust.CustIP = "255.255.255.255" + /// Inv.CustomerInfo = Cust + /// ................. + /// + /// + public CustomerInfo() + { + } + #endregion + + #region "Properties" + + /// + /// Gets, Sets ReqName. + /// + /// + /// Requester Name. + /// Maps to Payflow Parameter: + /// REQNAME + /// + public String ReqName + { + get { return mReqName; } + set { mReqName = value; } + } + + /// + /// Gets, Sets CustCode. + /// + /// + /// Customer code/customer reference ID. + /// Maps to Payflow Parameter: + /// CUSTCODE + /// + public String CustCode + { + get { return mCustCode; } + set { mCustCode = value; } + } + + /// + /// Gets, Sets CustIP. + /// + /// + /// Customer's IP address. + /// Maps to Payflow Parameter: + /// CUSTIP + /// + public String CustIP + { + get { return mCustIP; } + set { mCustIP = value; } + } + + /// + /// Gets, Sets CustHostName. + /// + /// + /// Customer's name of server that the account holder is connected to. + /// Maps to Payflow Parameter: + /// CUSTHOSTNAME + /// + public String CustHostName + { + get { return mCustHostName; } + set { mCustHostName = value; } + } + + /// + /// Gets, Sets CustBrowser. + /// + /// + /// Account holder’s HTTP browser type. Example: + /// MOZILLA/4.0~(COMPATIBLE;~MSIE~5.0;~WINDOWS~95) + /// Maps to Payflow Parameter: + /// CUSTBROWSER + /// + public String CustBrowser + { + get { return mCustBrowser; } + set { mCustBrowser = value; } + } + + /// + /// Gets, Sets CustVatRegNum. + /// + /// + /// Customer's VAT registrations number. + /// Maps to Payflow Parameter: + /// CUSTVATREGNUM + /// + public String CustVatRegNum + { + get { return mCustVatRegNum; } + set { mCustVatRegNum = value; } + } + + /// + /// Gets, Sets DOB. + /// + /// + /// Account holder’s date of birth. + /// Format: mmddyyyy. + /// mm - Month, dd - Day, yy - Year. + /// Maps to Payflow Parameter: + /// DOB + /// + public String DOB + { + get { return mDob; } + set { mDob = value; } + } + + + /// + /// Gets, Sets CustId. + /// + /// + /// Customer's Id. + /// Maps to Payflow Parameter: + /// CUSTID + /// + public String CustId + { + get { return mCustId; } + set { mCustId = value; } + } + + /// + /// Gets, Sets Customer Data + /// + /// + /// Requester Name. + /// Maps to Payflow Parameter: + /// CUSTDATAE + /// + public String CustData + { + get { return mCustData; } + set { mCustData = value; } + } + + /// + /// Gets, Sets Customer identification. + /// + /// + /// Maps to Payflow Parameter: + /// CUSTOMERID + /// + public String CustomerId + { + get { return mCustomerId; } + set { mCustomerId = value; } + } + + /// + /// Gets, Sets Customer Number. + /// + /// + /// Maps to Payflow Parameter: + /// CUSTOMERNUMBER + /// + public String CustomerNumber + { + get { return mCustomerNumber; } + set { mCustomerNumber = value; } + } + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_REQNAME, mReqName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTCODE, mCustCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTIP, mCustIP)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTVATREGNUM, mCustVatRegNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DOB, mDob)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTID, mCustId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTHOSTNAME, mCustHostName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTBROWSER, mCustBrowser)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTDATA, mCustData)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTOMERID, mCustomerId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTOMERNUMBER, mCustomerNumber)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Devices.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Devices.cs new file mode 100644 index 0000000..aa61833 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Devices.cs @@ -0,0 +1,150 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Constructor + /// + /// Items that reflect what type of device; either terminal or card is used or presented. + /// + /// Following example shows how to use Devices. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// // Create a new Devices object. + /// Devices UsedDevices = new Devices(); + /// UsedDevices.CatType = "3"; + /// UsedDevices.Contactless = "RFD"; + /// Inv.Devices = UsedDevices; + /// ................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// ' Set the device/card capabilities + /// Dim UsedDevices As Devices = New Devices + /// UsedDevices.CatType = "3" + /// UsedDevices.Contactless = "RFD" + /// Inv.Devices = UsedDevices + /// ................. + /// + /// + + public sealed class Devices : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Type of Terminal + /// + private String mCatType; + + /// + /// Card Input Capability + /// + private String mContactless; + + #endregion + + #region "Properties" + + /// + /// Gets, Sets Terminal type + /// + /// + /// Maps to Payflow Parameter: + /// CATTYPE + /// + public String CatType + { + get { return mCatType; } + set { mCatType = value; } + } + + /// + /// Gets, Sets Card Input Capability + /// + /// + /// Maps to Payflow Parameter: + /// CONTACTLESS + /// + public String Contactless + { + get { return mContactless; } + set { mContactless = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor + /// + /// Items that reflect what type of device; either terminal or card is used or presented. + /// + /// Following example shows how to use Devices. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// // Create a new Devices object. + /// Devices UsedDevices = new Devices(); + /// UsedDevices.CatType = "3"; + /// UsedDevices.Contactless = "RFD"; + /// Inv.Devices = UsedDevices; + /// ................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// ' Set the device/card capabilities + /// Dim UsedDevices As Devices = New Devices + /// UsedDevices.CatType = "3" + /// UsedDevices.Contactless = "RFD" + /// Inv.Devices = UsedDevices + /// ................. + /// + /// + public Devices() + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CATTYPE, mCatType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CONTACTLESS, mContactless)); + + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECDoBARequest.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECDoBARequest.cs new file mode 100644 index 0000000..7b117b2 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECDoBARequest.cs @@ -0,0 +1,53 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility ; +using PayPal.Payments.Common; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for ExpressCheckout with Billing Agreement (Reference Transaction) without Purchase DO operation. + /// + /// + /// + /// + /// + public class ECDoBARequest : ECDoRequest + { + #region "Constructor" + + /// + /// Constructor for ECDoBARequest + /// + /// String + /// String + /// + /// ECDoBARequest is used to set the data required for a Express Checkout DO operation + /// with Billing Agreement (Reference Transaction) without Purchase. + /// + /// + /// + /// ............. + /// + /// //Create the ECDoBARequest object + /// ECDoBARequest DoEC = new ECDoBARequest("[tokenid]","[payerid]"); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECDoBARequest object + /// Dim DoEC As ECDoBARequest = new ECDoBARequest("[tokenid]","[payerid]") + /// + /// ............. + /// + /// + public ECDoBARequest(String Token, String PayerId) : base(Token, PayerId, PayflowConstants.ACTIONTYPE_DOBA) + { + } + #endregion + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECDoRequest.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECDoRequest.cs new file mode 100644 index 0000000..9ead95c --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECDoRequest.cs @@ -0,0 +1,93 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility ; +using PayPal.Payments.Common; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for ExpressCheckout DO operation. + /// + /// + /// + /// + /// + public class ECDoRequest : ExpressCheckoutRequest + { + #region "Member Variables" + private String mPayerId; + #endregion + + #region "Constructors" + /// + /// Constructor for ECDoRequest + /// + /// String + /// String + /// + /// ECDoRequest is used to set the data required for a Express Checkout DO operation. + /// + /// + /// + /// ............. + /// + /// //Create the ECDoRequest object + /// ECDoRequest DoEC = new ECDoRequest("[tokenid]","[payerid]"); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECDoRequest object + /// Dim DoEC As ECDoRequest = new ECDoRequest("[tokenid]","[payerid]") + /// + /// ............. + /// + /// + public ECDoRequest(String Token, String PayerId) : base(PayflowConstants.ACTIONTYPE_DO, Token) + { + mPayerId = PayerId; + } + protected ECDoRequest(String Token, String PayerId, String Action) : base(PayflowConstants.ACTIONTYPE_DOBA, Token) + { + mPayerId = PayerId; + } + + #endregion + + #region "Properties" + + /// + /// Gets or Sets the payerid parameter. + /// + /// + /// Maps to Payflow Parameter: + /// PAYERID + /// + public String PayerId + { + get{return mPayerId; } + set{mPayerId = value;} + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + // This function is not called. All the + //address information is validated and generated + //in its respective derived classes. + base.GenerateRequest (); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PAYERID , mPayerId)); + } + #endregion + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECDoResponse.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECDoResponse.cs new file mode 100644 index 0000000..ac4bda8 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECDoResponse.cs @@ -0,0 +1,174 @@ +#region "Imports" + +using System; +using System.Collections ; +using PayPal.Payments.Common.Exceptions ; +using PayPal.Payments.Common.Utility ; + +#endregion + + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for ExpressCheckout Do operation. + /// + /// + /// + /// + /// + public class ECDoResponse : ExpressCheckoutResponse + { + #region "Member variable" + + private String mAmt; + private String mSettleAmt; + private String mTaxAmt; + private String mExchangeRate; + private String mPaymentDate; + private String mPaymentStatus; + private String mBAId; + + #endregion + + #region "Constructor" + /// + /// constructor + /// + internal ECDoResponse() : base() + { + } + #endregion + + #region "properties" + + /// + /// Gets the amt parameter + /// + /// + /// Maps to Payflow Parameter: + /// AMT + /// + public String Amt + { + get {return mAmt;} + } + /// + /// Gets the settleamt parameter + /// + /// + /// Maps to Payflow Parameter: + /// SETTLEAMT + /// + public String SettleAmt + { + get {return mSettleAmt;} + } + /// + /// Gets the taxamt parameter + /// + /// + /// Maps to Payflow Parameter: + /// TAXAMT + /// + public String TaxAmt + { + get {return mTaxAmt;} + } + /// + /// Gets the exchangerate parameter + /// + /// + /// Maps to Payflow Parameter: + /// EXCHANGERATE + /// + public String ExchangeRate + { + get {return mExchangeRate;} + } + /// + /// Gets the PaymentDate parameter + /// + /// + /// Maps to Payflow Parameter: + /// PAYMENTDATE + /// + public String PaymentDate + { + get {return mPaymentDate;} + } + /// + /// Gets the PaymentStatus parameter + /// + /// + /// Maps to Payflow Parameter: + /// PAYMENTSTATUS + /// + public String PaymentStatus + { + get {return mPaymentStatus;} + } + /// + /// Gets the BAID parameter + /// + /// + /// Maps to Payflow Parameter: + /// BAID + /// + public String BAId + { + get {return mBAId;} + } + + #endregion + + #region "Core functions" + + /// + /// Sets Response params + /// + ///Response Hash table by ref + internal override void SetParams(ref Hashtable ResponseHashTable) + { + try + { + mAmt = (String) ResponseHashTable[PayflowConstants.PARAM_AMT]; + mSettleAmt = (String) ResponseHashTable[PayflowConstants.PARAM_SETTLEAMT]; + mTaxAmt = (String) ResponseHashTable[PayflowConstants.PARAM_TAXAMT]; + mExchangeRate = (String) ResponseHashTable[PayflowConstants.PARAM_EXCHANGERATE]; + mPaymentDate = (String) ResponseHashTable[PayflowConstants.PARAM_PAYMENTDATE ]; + mPaymentStatus = (String) ResponseHashTable[PayflowConstants.PARAM_PAYMENTSTATUS]; + mBAId = (String) ResponseHashTable[PayflowConstants.PARAM_BAID]; + + ResponseHashTable.Remove(PayflowConstants.PARAM_AMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_FEEAMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_SETTLEAMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_TAXAMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_EXCHANGERATE); + ResponseHashTable.Remove(PayflowConstants.PARAM_PENDINGREASON); + ResponseHashTable.Remove(PayflowConstants.PARAM_PAYMENTDATE); + ResponseHashTable.Remove(PayflowConstants.PARAM_PAYMENTSTATUS); + ResponseHashTable.Remove(PayflowConstants.PARAM_PAYMENTTYPE); + ResponseHashTable.Remove(PayflowConstants.PARAM_BAID); + + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + + } + + #endregion + + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECGetBARequest.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECGetBARequest.cs new file mode 100644 index 0000000..137a5f4 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECGetBARequest.cs @@ -0,0 +1,50 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common ; +using PayPal.Payments.Common.Utility ; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for ExpressCheckout with Billing Agreement (Reference Transaction) without Purchase GET operation. + /// + /// + /// + /// + /// + public class ECGetBARequest : ECGetRequest + { + #region "Constructor" + /// + /// Constructor for ECGetBARequest + /// + /// + /// ECGetBARequest is used to set the data required for a Express Checkout GET operation + /// with Billing Agreement (Reference Transaction) without Purchase. + /// + /// + /// + /// ............. + /// + /// //Create the ECGetBARequest object + /// ECGetBARequest GetEC = new ECGetRequest("[tokenid]"); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECGetBARequest object + /// Dim GetEC As ECGetBARequest = new ECGetBARequest("[tokenid]") + /// + /// ............. + /// + /// + public ECGetBARequest(String Token) : base(Token, PayflowConstants.ACTIONTYPE_GETBA) + { + } + #endregion + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECGetRequest.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECGetRequest.cs new file mode 100644 index 0000000..4f61d39 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECGetRequest.cs @@ -0,0 +1,53 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common ; +using PayPal.Payments.Common.Utility ; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for ExpressCheckout GET operation. + /// + /// + /// + /// + /// + public class ECGetRequest : ExpressCheckoutRequest + { + #region "Constructor" + /// + /// Constructor for ECGetRequest + /// + /// String + /// + /// ECGetRequest is used to set the data required for a Express Checkout GET operation. + /// + /// + /// + /// ............. + /// + /// //Create the ECGetRequest object + /// ECGetRequest GetEC = new ECGetRequest("[tokenid]"); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECGetRequest object + /// Dim GetEC As ECGetRequest = new ECGetRequest("[tokenid]") + /// + /// ............. + /// + /// + public ECGetRequest(String Token) : base(PayflowConstants.ACTIONTYPE_GET, Token) + { + } + protected ECGetRequest(String Token, String Action) : base(PayflowConstants.ACTIONTYPE_GETBA, Token) + { + } + #endregion + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECGetResponse.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECGetResponse.cs new file mode 100644 index 0000000..d6c66d1 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECGetResponse.cs @@ -0,0 +1,323 @@ +#region "Imports" + +using System; +using System.Collections; +using PayPal.Payments.Common.Exceptions; +using PayPal.Payments.Common.Utility ; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for ExpressCheckout get operation. + /// + /// + /// + /// + /// + public class ECGetResponse : ExpressCheckoutResponse + { + #region "Member variables" + + private String mEMail; + private String mPayerId; + private String mPayerStatus; + private String mShipToFirstName; + private String mShipToLastName; + private String mShipToCountryCode; + private String mShipToBusiness; + private String mAddrStatus; + private String mFirstName; + private String mLastName; + private String mStreet; + private String mStreet2; + private String mCity; + private String mState; + private String mPostalCode; + private String mCountryCode; + private String mPhoneNum; + private String mBA_Flag; + + #endregion + + #region "Constructor" + /// + /// constructor + /// + internal ECGetResponse() + { + } + #endregion + + #region "properties" + /// + /// Gets the EMail parameter + /// + /// + /// Maps to Payflow Parameter: + /// EMAIL + /// + public String EMail + { + get {return mEMail;} + } + /// + /// Gets the payerid parameter + /// + /// + /// Maps to Payflow Parameter: + /// PAYERID + /// + public String PayerId + { + get {return mPayerId;} + } + + /// + /// Gets the payerstatus parameter + /// + /// + /// Maps to Payflow Parameter: + /// PAYERSTATUS + /// + public String PayerStatus + { + get {return mPayerStatus;} + } + /// + /// Gets the shiptofirstname parameter + /// + /// + /// Maps to Payflow Parameter: + /// SHIPTOFIRSTNAME + /// + public String ShipToFirstName + { + get {return mShipToFirstName;} + } + /// + /// Gets the shiptolastname parameter + /// + /// + /// Maps to Payflow Parameter: + /// SHIPTOLASTNAME + /// + public String ShipToLastName + { + get {return mShipToLastName;} + } + /// + /// Gets the ShipToCountry parameter + /// + /// + /// Maps to Payflow Parameter: + /// SHIPTOCOUNTRY + /// + public String ShipToCountry + { + get {return mShipToCountryCode;} + } + /// + /// Gets the ShipToBusiness parameter + /// + /// + /// Maps to Payflow Parameter: + /// SHIPTOBUSINESS + /// + public String ShipToBusiness + { + get {return mShipToBusiness;} + } + /// + /// Gets the AddressStatus parameter + /// + /// + /// Maps to Payflow Parameter: + /// ADDRSTATUS + /// + public String AddressStatus + { + get {return mAddrStatus;} + } + /// + /// Gets the FirstName parameter + /// + /// + /// Maps to Payflow Parameter: + /// FIRSTNAME + /// + public String FirstName + { + get {return mFirstName;} + } + /// + /// Gets the LastName parameter + /// + /// + /// Maps to Payflow Parameter: + /// LASTNAME + /// + public String LastName + { + get {return mLastName;} + } + /// + /// Gets the ShipToStreet parameter + /// + /// + /// Maps to Payflow Parameter: + /// SHIPTOSTREET + /// + public String ShipToStreet + { + get {return mStreet;} + } + /// + /// Gets the ShipToStreet2 parameter + /// + /// + /// Maps to Payflow Parameter: + /// SHIPTOSTREET2 + /// + public String ShipToStreet2 + { + get {return mStreet2;} + } + /// + /// Gets the ShipToCity parameter + /// + /// + /// Maps to Payflow Parameter: + /// SHIPTOCITY + /// + public String ShipToCity + { + get {return mCity;} + } + /// + /// Gets the ShipToState parameter + /// + /// + /// Maps to Payflow Parameter: + /// SHIPTOSTATE + /// + public String ShipToState + { + get {return mState;} + } + /// + /// Gets the ShipToZip parameter + /// + /// + /// Maps to Payflow Parameter: + /// SHIPTOZIP + /// + public String ShipToZip + { + get {return mPostalCode;} + } + /// + /// Gets the CountryCode parameter + /// + /// + /// Maps to Payflow Parameter: + /// COUNTRYCODE + /// + public String CountryCode + { + get {return mCountryCode;} + } + /// + /// Gets the PHONENUM parameter + /// + /// + /// Maps to Payflow Parameter: + /// PHONENUM + /// + public String PhoneNum + { + get {return mPhoneNum;} + } + /// + /// Gets the BA_FLAG parameter + /// + /// + /// Maps to Payflow Parameter: + /// BA_FLAG + /// + public String BA_Flag + { + get {return mBA_Flag;} + } + + #endregion + + #region "Core functions" + + /// + /// Sets Response params + /// + ///Response Hash table by ref + internal override void SetParams(ref Hashtable ResponseHashTable) + { + try + { + mEMail = (String) ResponseHashTable[PayflowConstants.PARAM_EMAIL]; + mPayerId = (String) ResponseHashTable[PayflowConstants.PARAM_PAYERID]; + mPayerStatus = (String) ResponseHashTable[PayflowConstants.PARAM_PAYERSTATUS]; + mShipToFirstName = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOFIRSTNAME]; + mShipToLastName = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOLASTNAME]; + mShipToCountryCode = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOCOUNTRY]; + mShipToBusiness = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOBUSINESS]; + mAddrStatus = (String) ResponseHashTable[PayflowConstants.PARAM_ADDRSTATUS]; + mFirstName = (String) ResponseHashTable[PayflowConstants.PARAM_FIRSTNAME]; + mLastName = (String) ResponseHashTable[PayflowConstants.PARAM_LASTNAME]; + mStreet = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOSTREET]; + mStreet2 = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOSTREET2]; + mCity = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOCITY]; + mState = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOSTATE]; + mPostalCode = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOZIP]; + mCountryCode = (String) ResponseHashTable[PayflowConstants.PARAM_COUNTRYCODE]; + mPhoneNum = (String) ResponseHashTable[PayflowConstants.PARAM_PHONENUM]; + mBA_Flag = (String) ResponseHashTable[PayflowConstants.PARAM_BA_FLAG]; + + + ResponseHashTable.Remove(PayflowConstants.PARAM_EMAIL); + ResponseHashTable.Remove(PayflowConstants.PARAM_PAYERID); + ResponseHashTable.Remove(PayflowConstants.PARAM_PAYERSTATUS); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOFIRSTNAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOLASTNAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOCOUNTRY); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOBUSINESS); + ResponseHashTable.Remove(PayflowConstants.PARAM_ADDRSTATUS); + ResponseHashTable.Remove(PayflowConstants.PARAM_FIRSTNAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_LASTNAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOSTREET); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOSTREET2); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOCITY); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOSTATE); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOZIP); + ResponseHashTable.Remove(PayflowConstants.PARAM_COUNTRYCODE); + ResponseHashTable.Remove(PayflowConstants.PARAM_PHONENUM); + ResponseHashTable.Remove(PayflowConstants.PARAM_BA_FLAG); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + + } + + #endregion + + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECSetBARequest.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECSetBARequest.cs new file mode 100644 index 0000000..af5d8ab --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECSetBARequest.cs @@ -0,0 +1,57 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common ; +using PayPal.Payments.Common.Utility ; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for ExpressCheckout with Billing Agreement (Reference Transaction) without Purchase SET operation. + /// + /// + /// + /// + /// + public class ECSetBARequest : ECSetRequest + { + #region "Constructor" + /// + /// Constructor for ECSetBARequest + /// + /// String + /// String + /// String + /// String + /// String + /// String + /// + /// ECSetBARequest is used to set the data required for a Express Checkout Billing Agreement SET operation + /// with Billing Agreement (Reference Transaction) without Purchase. + /// + /// + /// + /// ............. + /// + /// //Create the ECSetBARequest object + /// ECSetBARequest SetEC = new ECSetBARequest(ReturnUrl, CancelUrl, BillingType, BA_Desc, PaymentType, BA_Custom); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECSetBARequest object + /// Dim SetEC As ECSetBARequest = new ECSetBARequest(ReturnUrl, CancelUrl, BillingType, BA_Desc, PaymentType, BA_Custom) + /// + /// ............. + /// + /// + public ECSetBARequest(String ReturnUrl, String CancelUrl, String BillingType, String BA_Desc, String PaymentType, String BA_Custom) + : base(ReturnUrl, CancelUrl, BillingType, BA_Desc, PaymentType, BA_Custom, PayflowConstants.ACTIONTYPE_SETBA) + { + } + #endregion + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECSetRequest.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECSetRequest.cs new file mode 100644 index 0000000..00fcd25 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECSetRequest.cs @@ -0,0 +1,459 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common ; +using PayPal.Payments.Common.Utility ; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for ExpressCheckout SET operation. + /// + /// + /// + /// + /// + public class ECSetRequest : ExpressCheckoutRequest + { + #region "Member variables" + private String mReturnURL; + private String mCancelURL; + private String mReqConfirmShipping; + private String mReqBillingAddress; + private String mNoShipping; + private String mAddrOverride; + private String mLocalecode; + private Currency mMaxAmt; + private String mPageStyle; + private String mHdrImg ; //"cpp-headerimage" + private String mHdrBorderColor; //"cpp-header-border-color"; + private String mHdrBackColor; //"cpp-header-back-color"; + private String mPayFlowColor; //"cpp-payflow-color"; + private String mBillingType; + private String mBA_Desc; + private String mPaymentType; + private String mBA_Custom; + private String mShipToName; + private String mAllowNote; + + // Transaction PayLater object. Has parameters like PromoCode, ProductCategory, etc. + private PayLater mPayLater; + + #endregion + + #region "Constructor" + /// + /// Constructor for ECSetRequest + /// + /// String + /// String + /// + /// ECSetRequest is used to set the data required for a Express Checkout SET operation. + /// + /// + /// + /// ............. + /// + /// //Create the ECSetrequest object + /// ECSetRequest SetEC = new ECSetRequest("http://www.yourwebsitereturnurl.com","http://www.yourwebsitecancelurl.com"); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECSetrequest object + /// Dim SetEC As ECSetRequest = new ECSetRequest("http://www.yourwebsitereturnurl.com","http://www.yourwebsitecancelurl.com") + /// + /// ............. + /// + /// + public ECSetRequest(String ReturnUrl ,String CancelUrl) + : base(PayflowConstants.ACTIONTYPE_SET) + { + mReturnURL = ReturnUrl; + mCancelURL = CancelUrl; + } + /// + /// Constructor for ECSetRequest + /// + /// String + /// String + /// String + /// + /// ECSetRequest is used to set the data required for a Express Checkout SET operation. + /// + /// + /// + /// ............. + /// + /// //Create the ECSetrequest object + /// ECSetRequest SetEC = new ECSetRequest("http://www.yourwebsitereturnurl.com", "http://www.yourwebsitecancelurl.com", PayLater); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECSetrequest object + /// Dim SetEC As ECSetRequest = new ECSetRequest("http://www.yourwebsitereturnurl.com", "http://www.yourwebsitecancelurl.com", PayLater) + /// + /// ............. + /// + /// + public ECSetRequest(String ReturnUrl ,String CancelUrl, PayLater PayLater) + : base(PayflowConstants.ACTIONTYPE_SET) + { + mReturnURL = ReturnUrl; + mCancelURL = CancelUrl; + mPayLater = PayLater; + } + /// + /// Constructor for ECSetRequest + /// + /// String + /// String + /// String + /// String + /// String + /// String + /// + /// ECSetRequest is used to set the data required for a Express Checkout SET operation. + /// + /// + /// + /// ............. + /// + /// //Create the ECSetRequest object. + /// ECSetRequest SetEC = new ECSetRequest("http://www.yourwebsitereturnurl.com","http://www.yourwebsitecancelurl.com", + /// "MerchantInitiatedBilling", "Test Transaction", "any", "Something"); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECSetRequest object for Reference Transaction with Purchase. + /// Dim SetEC As ECSetRequest = new ECSetRequest("http://www.yourwebsitereturnurl.com","http://www.yourwebsitecancelurl.com" + /// "MerchantInitiatedBilling", "Test Transaction", "any", "Something") + /// + /// ............. + /// + /// + public ECSetRequest(String ReturnUrl, String CancelUrl, String BillingType, String BA_Desc, String PaymentType, String BA_Custom) + : base(PayflowConstants.ACTIONTYPE_SET) + { + mReturnURL = ReturnUrl; + mCancelURL = CancelUrl; + mBillingType = BillingType; + mBA_Desc = BA_Desc; + mPaymentType = PaymentType; + mBA_Custom = BA_Custom; + } + protected ECSetRequest(String ReturnUrl, String CancelUrl, String BillingType, String BA_Desc, String PaymentType, String BA_Custom, String Action) + : base(PayflowConstants.ACTIONTYPE_SETBA) + { + mReturnURL = ReturnUrl; + mCancelURL = CancelUrl; + mBillingType = BillingType; + mBA_Desc = BA_Desc; + mPaymentType = PaymentType; + mBA_Custom = BA_Custom; + } + #endregion + + #region "Properties" + + /// + /// Gets or Sets the returnurl. + /// + /// + /// Maps to Payflow Parameter: + /// RETURNURL + /// + public String ReturnURL + { + get{return mReturnURL; } + set{mReturnURL = value;} + } + + /// + /// Gets or Sets the cancelurl. + /// + /// + /// Maps to Payflow Parameter: + /// CANCELURL + /// + public String CancelURL + { + get{return mCancelURL; } + set{mCancelURL = value;} + } + + /// + /// Gets or Sets the ReqConfirmShipping parameter. + /// + /// + /// Maps to Payflow Parameter: + /// REQCONFIRMSHIPPING + /// + public String ReqConfirmShipping + { + get{return mReqConfirmShipping; } + set{mReqConfirmShipping = value;} + } + + /// + /// Gets or Sets the ReqBillingAddress parameter. + /// + /// + /// Maps to Payflow Parameter: + /// REQBILLINGADDRESS + /// + public String ReqBillingAddress + { + get { return mReqBillingAddress; } + set { mReqBillingAddress = value; } + } + + /// + /// Gets or Sets the NoShipping parameter. + /// + /// + /// Maps to Payflow Parameter: + /// NOSHIPPING + /// + public String NoShipping + { + get{return mNoShipping; } + set{mNoShipping = value;} + } + + /// + /// Gets or Sets the AddrOveride Parameter. + /// + /// + /// Maps to Payflow Parameter: + /// ADDROVERRIDE + /// + public String AddrOverride + { + get{return mAddrOverride; } + set{mAddrOverride = value;} + } + + /// + /// Gets or Sets the LocaleCode Parameter. + /// + /// + /// Maps to Payflow Parameter: + /// LOCALECODE + /// + public String LocaleCode + { + get{return mLocalecode; } + set{mLocalecode = value;} + } + + /// + /// Gets or Sets the MaxAmt Parameter. + /// + /// + /// Maps to Payflow Parameter: + /// MAXAMT + /// + public Currency MaxAmt + { + get{return mMaxAmt; } + set{mMaxAmt = value;} + } + + /// + /// Gets or Sets the PageStyle Parameter. + /// + /// + /// Maps to Payflow Parameter: + /// PAGESTYLE + /// + public String PageStyle + { + get{return mPageStyle; } + set{mPageStyle = value;} + } + + /// + /// Gets or Sets the HdrImg Parameter. + /// + /// + /// Maps to Payflow Parameter: + /// cpp-header-image + /// + public String HeaderImage + { + get{return mHdrImg; } + set{mHdrImg = value;} + } + + /// + /// Gets or Sets the HdrBorderColor Parameter. + /// + /// + /// Maps to Payflow Parameter: + /// cpp-header-border-color + /// + public String HeaderBorderColor + { + get{return mHdrBorderColor; } + set{mHdrBorderColor = value;} + } + + /// + /// Gets or Sets the HdrBackColor Parameter. + /// + /// + /// Maps to Payflow Parameter: + /// cpp-header-back-color + /// + public String HeaderBackColor + { + get{return mHdrBackColor; } + set{mHdrBackColor = value;} + } + + /// + /// Gets or Sets the PayFlowColor Parameter. + /// + /// + /// Maps to Payflow Parameter: + /// cpp-paflow-color + /// + public String PayFlowColor + { + get{return mPayFlowColor; } + set{mPayFlowColor = value;} + } + /// + /// Gets or Sets the Billing Type Parameter. + /// + /// + /// Sets up automated recurring billing for the customer. The + /// value is MerchantInitiatedBilling. + /// Maps to Payflow Parameter: + /// BILLINGTYPE + /// + public String BillingType + { + get{return mBillingType; } + set{mBillingType = value;} + } + /// + /// Gets or Sets the Description Parameter. + /// + /// + /// Description of goods or services associated with the + /// billing agreement. + /// Maps to Payflow Parameter: + /// BA_DESC + /// + public String BA_Desc + { + get{return mBA_Desc; } + set{mBA_Desc = value;} + } + /// + /// Gets or Sets the Payment Type Parameter. + /// + /// + /// Type of payment you require. + /// Maps to Payflow Parameter: + /// PAYMENTTYPE + /// + public String PaymentType + { + get{return mPaymentType; } + set{mPaymentType = value;} + } + /// + /// Gets or Sets the Custom field Parameter. + /// + /// + /// Custom annotation field for your exclusive use. + /// Maps to Payflow Parameter: + /// BA_CUSTOM + /// + public String BA_Custom + { + get{return mBA_Custom; } + set{mBA_Custom = value;} + } + /// + /// Gets or Sets the Ship to Name Parameter. + /// + /// + /// Custom annotation field for your exclusive use. + /// Maps to Payflow Parameter: + /// SHIPTONAME + /// + public String ShipToName + { + get { return mShipToName; } + set { mShipToName = value; } + } + /// + /// Gets or Sets the Allow Note Parameter. + /// + /// + /// Custom annotation field for your exclusive use. + /// Maps to Payflow Parameter: + /// ALLOWNOTE + /// + public String AllowNote + { + get { return mAllowNote; } + set { mAllowNote = value; } + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + // This function is not called. All the + // address information is validated and generated + // in its respective derived classes. + base.GenerateRequest (); + + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_RETURNURL, mReturnURL)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CANCELURL, mCancelURL)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_REQCONFIRMSHIPPING, mReqConfirmShipping)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_REQBILLINGADDRESS, mReqBillingAddress)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_NOSHIPPING, mNoShipping)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ADDROVERRIDE, mAddrOverride)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_LOCALECODE, mLocalecode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MAXAMT, mMaxAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PAGESTYLE, mPageStyle)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_HDRIMG, mHdrImg)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_HDRBORDERCOLOR, mHdrBorderColor)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_HDRBACKCOLOR, mHdrBackColor)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PAYFLOWCOLOR, mPayFlowColor)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BILLINGTYPE, mBillingType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BA_DESC, mBA_Desc)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PAYMENTTYPE, mPaymentType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BA_CUSTOM, mBA_Custom)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTONAME, mShipToName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ALLOWNOTE, mAllowNote)); + + if (mPayLater != null) + { + mPayLater.RequestBuffer = RequestBuffer; + mPayLater.GenerateRequest();; + } + } + #endregion + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECUpdateBARequest.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECUpdateBARequest.cs new file mode 100644 index 0000000..93d5c08 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECUpdateBARequest.cs @@ -0,0 +1,184 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility ; +using PayPal.Payments.Common; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for ExpressCheckout with Billing Agreement (Reference Transaction) without Purchase DO operation. + /// + /// + /// + /// + /// + /// + public class ECUpdateBARequest : ExpressCheckoutRequest + { + #region "Member Variables" + private String mBAId; + private String mBA_Status; + private String mBA_Desc; + #endregion + + #region "Properties" + + /// + /// Gets or Sets the ba_status parameter. + /// + /// + /// Maps to Payflow Parameter: + /// BA_STATUS + /// + public String BA_Status + { + get{return mBA_Status; } + set{mBA_Status = value;} + } + /// + /// Gets or Sets the baid parameter. + /// + /// + /// Maps to Payflow Parameter: + /// BAID + /// + public String BAId + { + get{return mBAId; } + set{mBAId = value;} + } + /// + /// Gets or Sets the ba_desc parameter. + /// + /// + /// Maps to Payflow Parameter: + /// BA_DESC + /// + public String BA_Desc + { + get{return mBA_Desc; } + set{mBA_Desc = value;} + } + + #endregion + + #region "Constructor" + + /// + /// Constructor for ECDoBARequest + /// + /// String + /// + /// ECDoBARequest is used to set the data required for a Express Checkout UPDATE operation + /// with Billing Agreement (Reference Transaction) without Purchase. + /// + /// + /// + /// ............. + /// + /// //Create the ECUpdateBARequest object + /// ECUpdateBARequest UpdateEC = new ECUpdateBARequest("[baid]"); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECUpdateBARequest object + /// Dim UpdateEC As ECUpdateBARequest = new ECUpdateBARequest("[baid]") + /// + /// ............. + /// + /// + public ECUpdateBARequest(String BAId) : base(PayflowConstants.ACTIONTYPE_UPDATEBA) + { + mBAId = BAId; + } + /// + /// Constructor for ECDoBARequest + /// + /// String + /// String + /// + /// ECDoBARequest is used to set the data required for a Express Checkout UPDATE operation + /// with Billing Agreement (Reference Transaction) without Purchase. + /// + /// + /// + /// ............. + /// + /// //Create the ECUpdateBARequest object + /// ECUpdateBARequest UpdateEC = new ECUpdateBARequest("[baid]", "[ba_status]"); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECUpdateBARequest object + /// Dim UpdateEC As ECUpdateBARequest = new ECUpdateBARequest("[baid]", "[ba_status]") + /// + /// ............. + /// + /// + public ECUpdateBARequest(String BAId, String BA_Status) : base(PayflowConstants.ACTIONTYPE_UPDATEBA) + { + mBAId = BAId; + mBA_Status = BA_Status; + } + /// + /// Constructor for ECDoBARequest + /// + /// String + /// String + /// String + /// + /// ECDoBARequest is used to set the data required for a Express Checkout UPDATE operation + /// with Billing Agreement (Reference Transaction) without Purchase. + /// + /// + /// + /// ............. + /// + /// //Create the ECUpdateBARequest object + /// ECUpdateBARequest UpdateEC = new ECUpdateBARequest("[baid]", "[ba_status]", ["ba_desc"]); + /// + /// ............. + /// + /// + /// ............. + /// + /// //Create the ECUpdateBARequest object + /// Dim UpdateEC As ECUpdateBARequest = new ECUpdateBARequest("[baid]", "[ba_status]", ["ba_desc"]) + /// + /// ............. + /// + /// + public ECUpdateBARequest(String BAId, String BA_Status, String BA_Desc) : base(PayflowConstants.ACTIONTYPE_UPDATEBA) + { + mBAId = BAId; + mBA_Status = BA_Status; + mBA_Desc = BA_Desc; + } + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + // This function is not called. All the + //address information is validated and generated + //in its respective derived classes. + base.GenerateRequest (); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BA_STATUS, mBA_Status)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BA_DESC, mBA_Desc)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_BAID, mBAId)); + } + #endregion + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECUpdateResponse.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECUpdateResponse.cs new file mode 100644 index 0000000..619b30f --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ECUpdateResponse.cs @@ -0,0 +1,98 @@ +#region "Imports" + +using System; +using System.Collections ; +using PayPal.Payments.Common.Exceptions ; +using PayPal.Payments.Common.Utility ; + +#endregion + + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for ExpressCheckout Update operation. + /// + /// + /// + /// + public class ECUpdateResponse : ExpressCheckoutResponse + { + #region "Member variable" + + private String mBA_Status; + private String mBA_Desc; + + #endregion + + #region "Constructor" + /// + /// constructor + /// + internal ECUpdateResponse() : base() + { + } + #endregion + + #region "Properties" + /// + /// Gets the BA_STATUS parameter + /// + /// + /// Maps to Payflow Parameter: + /// BA_STATUS + /// + public String BA_Status + { + get {return mBA_Status;} + } + /// + /// Gets the BA_DESC parameter + /// + /// + /// Maps to Payflow Parameter: + /// BA_DESC + /// + public String BA_Desc + { + get {return mBA_Desc;} + } + + #endregion + + #region "Core functions" + + /// + /// Sets Response params + /// + ///Response Hash table by ref + internal override void SetParams(ref Hashtable ResponseHashTable) + { + try + { + mBA_Status = (String) ResponseHashTable[PayflowConstants.PARAM_BA_STATUS]; + mBA_Desc = (String) ResponseHashTable[PayflowConstants.PARAM_BA_DESC]; + + ResponseHashTable.Remove(PayflowConstants.PARAM_BA_STATUS); + ResponseHashTable.Remove(PayflowConstants.PARAM_BA_DESC); + + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + + } + + #endregion + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/EncSwipeCard.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/EncSwipeCard.cs new file mode 100644 index 0000000..1fd2c0e --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/EncSwipeCard.cs @@ -0,0 +1,88 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for swipe card information + /// + /// + /// Used to pass the Track 1 or Track 2 data (the card’s + /// magnetic stripe information) for card-present + /// transactions. Include either Track 1 or Track 2 + /// data—not both. If Track 1 is physically damaged, the + /// POS application can send Track 2 data instead. + /// SwipeCard is associated with CardTender. + /// + /// + public sealed class MagTEncSwipeCard : PaymentDevice + { + #region "Constructors" + + /// + /// Constructor for SwipeCard + /// + /// Card Swipe value + /// This is used as Payment Device for the CardTender. + /// Maps to Payflow Parameter: + /// Swipe --> SWIPE + /// + /// + /// + /// ............. + /// + /// MagTEncSwipeCard PayDevice = new MagTEncSwipeCard(""); + /// + /// .............. + /// + /// + /// ............. + /// + /// Dim PayDevice As MagTEncSwipeCard = New MagTEncSwipeCard("") + /// + /// .............. + /// + /// + /// + public MagTEncSwipeCard(String MagTEncSwipe) : base(MagTEncSwipe) + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + //Set the base acct field as swipe in the request. + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SWIPE, base.Acct)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ExpressCheckoutRequest.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ExpressCheckoutRequest.cs new file mode 100644 index 0000000..94aba3b --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ExpressCheckoutRequest.cs @@ -0,0 +1,107 @@ +namespace PayPal.Payments.DataObjects +{ + using PayPal.Payments.Common.Utility; + using System; + + /// + /// This class serves as base class of all ExpressCheckout request classes. + /// + public class ExpressCheckoutRequest : BaseRequestDataObject + { + private String mAction; + + private String mCountryCode; + + private String mDoReauthorization; + + private String mPostalCode; + + private String mToken; + + /// + /// Constructor + /// + internal ExpressCheckoutRequest(String Action) + { + mAction = Action; + } + + /// + /// Constructor + /// + internal ExpressCheckoutRequest(String Action, String Token) + { + mAction = Action; + mToken = Token; + } + + /// + /// Gets and sets the country Code. + /// + /// + /// Maps to Payflow Parameter: + /// COUNTRYCODE + /// + public String CountryCode + { + get { return mCountryCode; } + set { mCountryCode = value; } + } + + /// + /// Gets and sets the do reauthorization flag. + /// + /// + /// Maps to Payflow Parameter: + /// DOREAUTHORIZATION + /// + public String DoReauthorization + { + get { return mDoReauthorization; } + set { mDoReauthorization = value; } + } + + /// + /// Gets and sets the postal code. + /// + /// + /// Maps to Payflow Parameter: + /// POSTALCODE + /// + public String PostalCode + { + get { return mPostalCode; } + set { mPostalCode = value; } + } + + /// + /// Gets and sets the value of the token. + /// + /// + /// Maps to Payflow Parameter: + /// TOKEN + /// + public String Token + { + get { return mToken; } + set { mToken = value; } + } + + /// + /// Generates the transaction request. + /// + internal new virtual void GenerateRequest() + { + // This function is not called. All the + // address information is validated and generated + // in its respective derived classes. + base.GenerateRequest(); + + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_TOKEN, mToken)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_COUNTRYCODE, mCountryCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_POSTALCODE, mPostalCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ACTION, mAction)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DOREAUTHORIZATION, mDoReauthorization)); + } + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ExpressCheckoutResponse.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ExpressCheckoutResponse.cs new file mode 100644 index 0000000..3c1cf60 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ExpressCheckoutResponse.cs @@ -0,0 +1,99 @@ +#region "Imports" + +using System; +using System.Collections; +using PayPal.Payments.Common.Exceptions ; +using PayPal.Payments.Common.Utility ; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// This class serves as base class of all ExpressCheckout response classes. + /// + /// + /// Each response object is associated with a particular type of expressCheckout operation. + /// Following are the reponse objects associated with + /// different operations of ExpressChecout: + /// + /// + /// ExpressCheckout operation. + /// Request data object + /// + /// + /// SET operation for ExpressCheckout. + /// ExpressCheckoutResponse + /// + /// + /// GET operation for ExpressCheckout. + /// ECGetResponse + /// + /// + /// DO operation for ExpressCheckout. + /// ECDoResponse + /// + /// + /// + public class ExpressCheckoutResponse : BaseResponseDataObject + { + #region "Member Variable" + private String mToken; + #endregion + + #region "Constructor" + /// + /// constructor + /// + internal ExpressCheckoutResponse() + { + } + #endregion + + #region "Properties" + /// + /// Retuns the token for the transaction. + /// + /// + /// Maps to Payflow Parameter: + /// TOKEN + /// + public String Token + { + get {return mToken;} + } + + #endregion + + #region "Core functions" + + /// + /// Sets Response params + /// + ///Response Hash table by ref + internal virtual void SetParams(ref Hashtable ResponseHashTable) + { + try + { + mToken = (String) ResponseHashTable[PayflowConstants.PARAM_TOKEN ]; + ResponseHashTable.Remove(PayflowConstants.PARAM_TOKEN); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + + } + + #endregion + + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ExtendData.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ExtendData.cs new file mode 100644 index 0000000..ccf2cf6 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ExtendData.cs @@ -0,0 +1,156 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Extended param information + /// + /// Extended data are the Payflow parameters which are + /// not mapped through the data objects. + /// This class can be used to send such extended parameter information + /// in the transaction request. + /// + /// Following example shows how to use this class. + /// + /// ............. + /// // Trans is the transaction object. + /// ............. + /// + /// // Set the extended data value. + /// ExtendData ExtData = new ExtendData("PAYFLOW_PARAM_NAME","Param Value"); + /// + /// // Add extended data to transaction. + /// Trans.AddToExtendData(ExtData); + /// + /// + /// + /// ............. + /// ' Trans is the transaction object. + /// ............. + /// + /// ' Set the extended data value. + /// Dim ExtData As ExtendData = new ExtendData("PAYFLOW_PARAM_NAME","Param Value") + /// + /// ' Add extended data to transaction. + /// Trans.AddToExtendData(ExtData) + /// + /// + /// + public sealed class ExtendData : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Payflow Param name + /// + private String mParamName; + + /// + /// Param value + /// + private String mParamValue; + + #endregion + + #region Properties" + /// + /// ParamName + /// + public String ParamName + { + get { return(mParamName); } + } + + /// + /// ParamValue + /// + public String ParamValue + { + get { return(mParamValue); } + } + + #endregion + #region "Constructors" + + /// + /// Constructor + /// + /// Payflow pram name + /// param value + /// Extended data are the Payflow parameters which are + /// not mapped through the data objects. + /// This class can be used to send such extended parameter information + /// in the transaction request. + /// + /// Following example shows how to use this class. + /// + /// ............. + /// // Trans is the transaction object. + /// ............. + /// + /// // Set the extended data value. + /// ExtendData ExtData = new ExtendData("PFPRO_PARAM_NAME","Param Value"); + /// + /// // Add extended data to transaction. + /// Trans.AddToExtendData(ExtData); + /// + /// + /// + /// ............. + /// ' Trans is the transaction object. + /// ............. + /// + /// ' Set the extended data value. + /// Dim ExtData As ExtendData = new ExtendData("PFPRO_PARAM_NAME","Param Value") + /// + /// ' Add extended data to transaction. + /// Trans.AddToExtendData(ExtData) + /// + /// + /// + public ExtendData(String ParamName, String ParamValue) + { + mParamName = ParamName; + mParamValue = ParamValue; + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(mParamName, mParamValue)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + + } + + #endregion + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/FpsXmlData.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/FpsXmlData.cs new file mode 100644 index 0000000..423c75a --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/FpsXmlData.cs @@ -0,0 +1,548 @@ +#region "Imports" + +using System.Collections; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for storing Fraud Protection Services + /// XML response message after parsing them. + /// + /// If the VERBOSITY set for the transaction is HIGH, + /// Fraud Protection Services return FPS_PREXMLDATA and/or + /// FPS_POSTXMLDATA response messages. This are xml messages. + /// While parsing the response, these xml messages are parsed + /// and populated into Rule data objects. These Rule objects are rules applied + /// by the Fraud Protection Services.. FpsXmlData is the container class + /// for all such rules. + /// FpsXmlData data objects instances are contained in + /// FraduResponse and populated if obtained. + /// + /// + /// + /// + /// + /// Following example shows how to obtained and use FpsXmlData. + /// + /// .............................. + /// // Resp is the Response object + /// // obtained after submitting the transaction. + /// .............................. + /// + /// FpsXmlData mFpsXmlData; + /// ArrayList mRules = new ArrayList(); + /// Rule mRuleType; + /// RuleParameter mRuleVendorParamType; + /// ArrayList mRuleVendorParams = new ArrayList(); + /// int i; + /// + /// if(Resp != null) + /// { + /// // Get the Fraud Response + /// FraudResponse FraudResp = Resp.FraudResult; + /// + /// if(FraudResp == null) + /// { + /// return; + /// } + /// + /// FpsPreXmlData = FraudResp.Fps_PreXmlData; + /// mRules = FpsPreXmlData.Rules; + /// foreach (PayPal.Payments.DataObjects.Rule tempLoopVar_mRuleType in mRules) + /// { + /// mRuleType = tempLoopVar_mRuleType; + /// + /// Console.WriteLine("ACTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Action); + /// Console.WriteLine("NUM FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Num); + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleAlias); + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleDescription); + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + mRuleType.RuleId+ mRuleType.TriggeredMessage); + /// + /// mRuleVendorParams = mRuleType.RuleVendorParms; + /// i=0; + /// foreach (RuleParameter tempLoopVar_mRuleVendorParamType in mRuleVendorParams) + /// { + /// mRuleVendorParamType = tempLoopVar_mRuleVendorParamType; + /// Console.WriteLine("Name_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Name); + /// Console.WriteLine("Num_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Num); + /// Console.WriteLine("Type_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Type); + /// Console.WriteLine("Value_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Value); + /// i++; + /// } + /// } + /// + /// FpsPreXmlData = mFraudResp.Fps_PostXmlData; + /// mRules = FpsPreXmlData.Rules; + /// foreach (PayPal.Payments.DataObjects.Rule tempLoopVar_mRuleType in mRules) + /// { + /// mRuleType = tempLoopVar_mRuleType; + /// + /// Console.WriteLine("RuleId"+ mRuleType.RuleId); + /// Console.WriteLine("ACTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Action); + /// Console.WriteLine("NUM FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Num); + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleAlias); + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleDescription); + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + mRuleType.RuleId+ mRuleType.TriggeredMessage); + /// + /// mRuleVendorParams = mRuleType.RuleVendorParms; + /// i=0; + /// foreach (RuleParameter tempLoopVar_mRuleVendorParamType in mRuleVendorParams) + /// { + /// mRuleVendorParamType = tempLoopVar_mRuleVendorParamType; + /// Console.WriteLine("NAME_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Name); + /// Console.WriteLine("NUM "+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Num); + /// Console.WriteLine("TYPE "+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Type); + /// Console.WriteLine("VALUE "+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Value); + /// i++; + /// } + /// } + /// + /// + /// .............................. + /// ' Resp is the Response object + /// ' obtained after submitting the transaction. + /// .............................. + /// + /// Dim FpsXmlData As FpsXmlData + /// Dim Rules As New ArrayList + /// Dim RuleType As Rule + /// Dim RuleVendorParamType As RuleParameter + /// Dim RuleVendorParams As New ArrayList + /// + /// if(Resp != null) + /// { + /// ' Get the Fraud Response + /// Dim FraudResp As FraudResponse = Resp.FraudResult + /// + /// If Object.Equals(FraudResp, Nothing) Then + /// return + /// EndIf + /// + /// FpsPreXmlData = FraudResp.Fps_PreXmlData + /// Rules = FpsPreXmlData.Rules() + /// Dim iCount As Integer + /// iCount = 0 + /// For Each RuleType In Rules + /// + /// Console.WriteLine("ACTION FOR RULE ID - " + RuleType.RuleId + RuleType.Action) + /// Console.WriteLine("NUM FOR RULE ID - " + RuleType.RuleId + RuleType.Num) + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + RuleType.RuleId + RuleType.RuleAlias) + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + RuleType.RuleId + RuleType.RuleDescription) + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + RuleType.RuleId + RuleType.TriggeredMessage) + /// + /// RuleVendorParams = RuleType.RuleVendorParms + /// For Each RuleVendorParamType In RuleVendorParams + /// Console.WriteLine("NAME_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Name) + /// Console.WriteLine("NUM_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Num) + /// Console.WriteLine("TYPE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Type) + /// Console.WriteLine("VALUE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Value) + /// iCount = iCount + 1 + /// Next + /// Next + /// + /// FpsPostXmlData = FraudResp.Fps_PostXmlData + /// Rules = FpsPostXmlData.Rules() + /// For Each RuleType In Rules + /// + /// Console.WriteLine("RuleId" + RuleType.RuleId) + /// Console.WriteLine("ACTION FOR RULE ID - " + RuleType.RuleId + RuleType.Action) + /// Console.WriteLine("NUM FOR RULE ID - " + RuleType.RuleId + RuleType.Num) + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + RuleType.RuleId + RuleType.RuleAlias) + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + RuleType.RuleId + RuleType.RuleDescription) + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + RuleType.RuleId + RuleType.TriggeredMessage) + /// + /// RuleVendorParams = RuleType.RuleVendorParms + /// + /// iCount = 0 + /// For Each RuleVendorParamType In RuleVendorParams + /// Console.WriteLine("NAME_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Name) + /// Console.WriteLine("NUM_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Num) + /// Console.WriteLine("TYPE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Type) + /// Console.WriteLine("VALUE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Value) + /// iCount = iCount + 1 + /// Next + /// Next + /// + /// + public class FpsXmlData + { + #region "Member Variables" + + /// + /// Holds applied Rules. + /// + private ArrayList mRules; + + #endregion + + #region "Properties" + + /// + /// Gets, Sets the Rule list + /// + /// If the VERBOSITY set for the transaction is HIGH, + /// Fraud Protection Services return FPS_PREXMLDATA and/or + /// FPS_POSTXMLDATA response messages. This are xml messages. + /// While parsing the response, these xml messages are parsed + /// and populated into Rule data objects. These Rule objects are rules applied + /// by the Fraud Protection Services.. FpsXmlData is the container class + /// for all such rules. + /// FpsXmlData data objects instances are contained in + /// FraduResponse and populated if obtained. + /// + /// + /// + /// + /// + /// Following example shows how to obtained and use FpsXmlData. + /// + /// .............................. + /// // Resp is the Response object + /// // obtained after submitting the transaction. + /// .............................. + /// + /// FpsXmlData mFpsXmlData; + /// ArrayList mRules = new ArrayList(); + /// Rule mRuleType; + /// RuleParameter mRuleVendorParamType; + /// ArrayList mRuleVendorParams = new ArrayList(); + /// int i; + /// + /// if(Resp != null) + /// { + /// // Get the Fraud Response + /// FraudResponse FraudResp = Resp.FraudResult; + /// + /// if(FraudResp == null) + /// { + /// return; + /// } + /// + /// FpsPreXmlData = FraudResp.Fps_PreXmlData; + /// mRules = FpsPreXmlData.Rules; + /// foreach (PayPal.Payments.DataObjects.Rule tempLoopVar_mRuleType in mRules) + /// { + /// mRuleType = tempLoopVar_mRuleType; + /// + /// Console.WriteLine("ACTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Action); + /// Console.WriteLine("NUM FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Num); + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleAlias); + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleDescription); + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + mRuleType.RuleId+ mRuleType.TriggeredMessage); + /// + /// mRuleVendorParams = mRuleType.RuleVendorParms; + /// i=0; + /// foreach (RuleParameter tempLoopVar_mRuleVendorParamType in mRuleVendorParams) + /// { + /// mRuleVendorParamType = tempLoopVar_mRuleVendorParamType; + /// Console.WriteLine("Name_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Name); + /// Console.WriteLine("Num_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Num); + /// Console.WriteLine("Type_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Type); + /// Console.WriteLine("Value_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Value); + /// i++; + /// } + /// } + /// + /// FpsPreXmlData = mFraudResp.Fps_PostXmlData; + /// mRules = FpsPreXmlData.Rules; + /// foreach (PayPal.Payments.DataObjects.Rule tempLoopVar_mRuleType in mRules) + /// { + /// mRuleType = tempLoopVar_mRuleType; + /// + /// Console.WriteLine("RuleId"+ mRuleType.RuleId); + /// Console.WriteLine("ACTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Action); + /// Console.WriteLine("NUM FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Num); + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleAlias); + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleDescription); + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + mRuleType.RuleId+ mRuleType.TriggeredMessage); + /// + /// mRuleVendorParams = mRuleType.RuleVendorParms; + /// i=0; + /// foreach (RuleParameter tempLoopVar_mRuleVendorParamType in mRuleVendorParams) + /// { + /// mRuleVendorParamType = tempLoopVar_mRuleVendorParamType; + /// Console.WriteLine("NAME_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Name); + /// Console.WriteLine("NUM "+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Num); + /// Console.WriteLine("TYPE "+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Type); + /// Console.WriteLine("VALUE "+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Value); + /// i++; + /// } + /// } + /// + /// + /// .............................. + /// ' Resp is the Response object + /// ' obtained after submitting the transaction. + /// .............................. + /// + /// Dim FpsXmlData As FpsXmlData + /// Dim Rules As New ArrayList + /// Dim RuleType As Rule + /// Dim RuleVendorParamType As RuleParameter + /// Dim RuleVendorParams As New ArrayList + /// + /// if(Resp != null) + /// { + /// ' Get the Fraud Response + /// Dim FraudResp As FraudResponse = Resp.FraudResult + /// + /// If Object.Equals(FraudResp, Nothing) Then + /// return + /// EndIf + /// + /// FpsPreXmlData = FraudResp.Fps_PreXmlData + /// Rules = FpsPreXmlData.Rules() + /// Dim iCount As Integer + /// iCount = 0 + /// For Each RuleType In Rules + /// + /// Console.WriteLine("ACTION FOR RULE ID - " + RuleType.RuleId + RuleType.Action) + /// Console.WriteLine("NUM FOR RULE ID - " + RuleType.RuleId + RuleType.Num) + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + RuleType.RuleId + RuleType.RuleAlias) + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + RuleType.RuleId + RuleType.RuleDescription) + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + RuleType.RuleId + RuleType.TriggeredMessage) + /// + /// RuleVendorParams = RuleType.RuleVendorParms + /// For Each RuleVendorParamType In RuleVendorParams + /// Console.WriteLine("NAME_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Name) + /// Console.WriteLine("NUM_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Num) + /// Console.WriteLine("TYPE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Type) + /// Console.WriteLine("VALUE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Value) + /// iCount = iCount + 1 + /// Next + /// Next + /// + /// FpsPostXmlData = FraudResp.Fps_PostXmlData + /// Rules = FpsPostXmlData.Rules() + /// For Each RuleType In Rules + /// + /// Console.WriteLine("RuleId" + RuleType.RuleId) + /// Console.WriteLine("ACTION FOR RULE ID - " + RuleType.RuleId + RuleType.Action) + /// Console.WriteLine("NUM FOR RULE ID - " + RuleType.RuleId + RuleType.Num) + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + RuleType.RuleId + RuleType.RuleAlias) + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + RuleType.RuleId + RuleType.RuleDescription) + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + RuleType.RuleId + RuleType.TriggeredMessage) + /// + /// RuleVendorParams = RuleType.RuleVendorParms + /// + /// iCount = 0 + /// For Each RuleVendorParamType In RuleVendorParams + /// Console.WriteLine("NAME_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Name) + /// Console.WriteLine("NUM_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Num) + /// Console.WriteLine("TYPE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Type) + /// Console.WriteLine("VALUE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Value) + /// iCount = iCount + 1 + /// Next + /// Next + /// + /// + public ArrayList Rules + { + get { return mRules; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor for FpsXmlData + /// + /// If the VERBOSITY set for the transaction is HIGH, + /// Fraud Protection Services return FPS_PREXMLDATA and/or + /// FPS_POSTXMLDATA response messages. This are xml messages. + /// While parsing the response, these xml messages are parsed + /// and populated into Rule data objects. These Rule objects are rules applied + /// by the Fraud Protection Services.. FpsXmlData is the container class + /// for all such rules. + /// FpsXmlData data objects instances are contained in + /// FraduResponse and populated if obtained. + /// + /// + /// + /// + /// + /// Following example shows how to obtained and use FpsXmlData. + /// + /// .............................. + /// // Resp is the Response object + /// // obtained after submitting the transaction. + /// .............................. + /// + /// FpsXmlData mFpsXmlData; + /// ArrayList mRules = new ArrayList(); + /// Rule mRuleType; + /// RuleParameter mRuleVendorParamType; + /// ArrayList mRuleVendorParams = new ArrayList(); + /// int i; + /// + /// if(Resp != null) + /// { + /// // Get the Fraud Response + /// FraudResponse FraudResp = Resp.FraudResult; + /// + /// if(FraudResp == null) + /// { + /// return; + /// } + /// + /// FpsPreXmlData = FraudResp.Fps_PreXmlData; + /// mRules = FpsPreXmlData.Rules; + /// foreach (PayPal.Payments.DataObjects.Rule tempLoopVar_mRuleType in mRules) + /// { + /// mRuleType = tempLoopVar_mRuleType; + /// + /// Console.WriteLine("ACTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Action); + /// Console.WriteLine("NUM FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Num); + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleAlias); + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleDescription); + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + mRuleType.RuleId+ mRuleType.TriggeredMessage); + /// + /// mRuleVendorParams = mRuleType.RuleVendorParms; + /// i=0; + /// foreach (RuleParameter tempLoopVar_mRuleVendorParamType in mRuleVendorParams) + /// { + /// mRuleVendorParamType = tempLoopVar_mRuleVendorParamType; + /// Console.WriteLine("Name_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Name); + /// Console.WriteLine("Num_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Num); + /// Console.WriteLine("Type_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Type); + /// Console.WriteLine("Value_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Value); + /// i++; + /// } + /// } + /// + /// FpsPreXmlData = mFraudResp.Fps_PostXmlData; + /// mRules = FpsPreXmlData.Rules; + /// foreach (PayPal.Payments.DataObjects.Rule tempLoopVar_mRuleType in mRules) + /// { + /// mRuleType = tempLoopVar_mRuleType; + /// + /// Console.WriteLine("RuleId"+ mRuleType.RuleId); + /// Console.WriteLine("ACTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Action); + /// Console.WriteLine("NUM FOR RULE ID - " + mRuleType.RuleId+ mRuleType.Num); + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleAlias); + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + mRuleType.RuleId+ mRuleType.RuleDescription); + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + mRuleType.RuleId+ mRuleType.TriggeredMessage); + /// + /// mRuleVendorParams = mRuleType.RuleVendorParms; + /// i=0; + /// foreach (RuleParameter tempLoopVar_mRuleVendorParamType in mRuleVendorParams) + /// { + /// mRuleVendorParamType = tempLoopVar_mRuleVendorParamType; + /// Console.WriteLine("NAME_"+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Name); + /// Console.WriteLine("NUM "+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Num); + /// Console.WriteLine("TYPE "+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Type); + /// Console.WriteLine("VALUE "+i.ToString()+" FOR RULE ID -"+mRuleType.RuleId+ mRuleVendorParamType.Value); + /// i++; + /// } + /// } + /// + /// + /// .............................. + /// ' Resp is the Response object + /// ' obtained after submitting the transaction. + /// .............................. + /// + /// Dim FpsXmlData As FpsXmlData + /// Dim Rules As New ArrayList + /// Dim RuleType As Rule + /// Dim RuleVendorParamType As RuleParameter + /// Dim RuleVendorParams As New ArrayList + /// + /// if(Resp != null) + /// { + /// ' Get the Fraud Response + /// Dim FraudResp As FraudResponse = Resp.FraudResult + /// + /// If Object.Equals(FraudResp, Nothing) Then + /// return + /// EndIf + /// + /// FpsPreXmlData = FraudResp.Fps_PreXmlData + /// Rules = FpsPreXmlData.Rules() + /// Dim iCount As Integer + /// iCount = 0 + /// For Each RuleType In Rules + /// + /// Console.WriteLine("ACTION FOR RULE ID - " + RuleType.RuleId + RuleType.Action) + /// Console.WriteLine("NUM FOR RULE ID - " + RuleType.RuleId + RuleType.Num) + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + RuleType.RuleId + RuleType.RuleAlias) + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + RuleType.RuleId + RuleType.RuleDescription) + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + RuleType.RuleId + RuleType.TriggeredMessage) + /// + /// RuleVendorParams = RuleType.RuleVendorParms + /// For Each RuleVendorParamType In RuleVendorParams + /// Console.WriteLine("NAME_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Name) + /// Console.WriteLine("NUM_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Num) + /// Console.WriteLine("TYPE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Type) + /// Console.WriteLine("VALUE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Value) + /// iCount = iCount + 1 + /// Next + /// Next + /// + /// FpsPostXmlData = FraudResp.Fps_PostXmlData + /// Rules = FpsPostXmlData.Rules() + /// For Each RuleType In Rules + /// + /// Console.WriteLine("RuleId" + RuleType.RuleId) + /// Console.WriteLine("ACTION FOR RULE ID - " + RuleType.RuleId + RuleType.Action) + /// Console.WriteLine("NUM FOR RULE ID - " + RuleType.RuleId + RuleType.Num) + /// Console.WriteLine("RULEALIAS FOR RULE ID - " + RuleType.RuleId + RuleType.RuleAlias) + /// Console.WriteLine("RULEDESCRIPTION FOR RULE ID - " + RuleType.RuleId + RuleType.RuleDescription) + /// Console.WriteLine("TRIGGEREDMESSAGE FOR RULE ID - " + RuleType.RuleId + RuleType.TriggeredMessage) + /// + /// RuleVendorParams = RuleType.RuleVendorParms + /// + /// iCount = 0 + /// For Each RuleVendorParamType In RuleVendorParams + /// Console.WriteLine("NAME_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Name) + /// Console.WriteLine("NUM_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Num) + /// Console.WriteLine("TYPE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Type) + /// Console.WriteLine("VALUE_" + iCount.ToString + " FOR RULE ID - " + RuleType.RuleId + RuleVendorParamType.Value) + /// iCount = iCount + 1 + /// Next + /// Next + /// + /// + public FpsXmlData() + { + mRules = new ArrayList(); + } + + #endregion + + #region "Functions" + + /* /// + /// Adds a rule to Rule list + /// + /// Rule object + internal void AddToRules(Rule RuleObject) + { + mRules.Add(RuleObject); + }*/ + +// /// +// /// Clears the rule list +// /// +// internal void ClearRules() +// { +// mRules.Clear(); +// } + + /// + /// Sets the rule list with another + /// rule list + /// + /// Rulelist + internal void SetRuleList(ArrayList RuleList) + { + mRules = RuleList; + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/FraudResponse.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/FraudResponse.cs new file mode 100644 index 0000000..e72cec3 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/FraudResponse.cs @@ -0,0 +1,302 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; +using PayPal.Payments.Common; +using System.Collections; +using System.Xml; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Container class for response messages + /// specific Fraud Protections Services + /// + /// This class contains the fraud protection + /// services related response messages and data objects parsed + /// from the xml data in the fraud response. + /// + /// + public sealed class FraudResponse : BaseResponseDataObject + { + /// + /// Holds PreFpsMsg + /// + private String mPreFpsMsg; + + /// + /// Holds PostFpsMsg + /// + private String mPostFpsMsg; + + /// + /// Holds Fps Pre Xml Data + /// + private FpsXmlData mFpsPreXmlData; + + /// + /// Holds Fps Post Xml Data + /// + private FpsXmlData mFpsPostXmlData; + + #region "Constructors" + + /// + /// Constructor for Fraud response. + /// + internal FraudResponse () + { + + } + + + #endregion + + #region "Properties" + + + /// + /// Gets, Sets PreFpsMsg + /// + /// + /// Gets the FPS Pre FPS message. + /// Maps to Payflow Parameter: + /// PREFPSMSG + /// + public String PreFpsMsg + { + get { return mPreFpsMsg; } + } + + /// + /// Gets, Sets PostFpsMsg + /// + /// + /// Gets the FPS Post FPS message. + /// Maps to Payflow Parameter: + /// POSTFPSMSG + /// + public String PostFpsMsg + { + get { return mPostFpsMsg; } + } + + /// + /// Gets, Sets Fps_PreXmlData + /// + /// + /// Gets the FPS Pre Xml data message populated in + /// FpsXmlData object. + /// Its an itemized list of responses for trigerred filters + /// Maps to Payflow Parameter: + /// FPS_PREXMLDATA + /// + /// + public FpsXmlData Fps_PreXmlData + { + get { return mFpsPreXmlData; } + } + + /// + /// Gets, Sets Fps_PostXmlData + /// + /// + /// Gets the FPS Post Xml data message populated in + /// FpsXmlData object. + /// Maps to Payflow Parameter: + /// FPS_POSTXMLDATA + /// + /// + public FpsXmlData Fps_PostXmlData + { + get { return mFpsPostXmlData; } + } + + #endregion + + #region "Functions" + + /// + /// Sets the Response params in + /// response data objects. + /// + ///Response Hash table by ref + internal void SetParams(ref Hashtable ResponseHashTable) + { + try + { + + mPreFpsMsg = (String) ResponseHashTable[PayflowConstants.PARAM_PREFPSMSG]; + mPostFpsMsg = (String) ResponseHashTable[PayflowConstants.PARAM_POSTFPSMSG]; + + + ResponseHashTable.Remove(PayflowConstants.PARAM_PREFPSMSG); + ResponseHashTable.Remove(PayflowConstants.PARAM_POSTFPSMSG); + + SetFpsXmlData(ref ResponseHashTable); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + /// + /// Sets the Fps Xml data + /// + ///Response Hash table by ref + private void SetFpsXmlData(ref Hashtable ResponseHashTable) + { + String XmlData = null; + try + { + XmlData = (String) ResponseHashTable[PayflowConstants.PARAM_FPS_PREXMLDATA]; + mFpsPreXmlData = SetRules(XmlData); + XmlData = (String) ResponseHashTable[PayflowConstants.PARAM_FPS_POSTXMLDATA]; + mFpsPostXmlData = SetRules(XmlData); + ResponseHashTable.Remove(PayflowConstants.PARAM_FPS_PREXMLDATA); + ResponseHashTable.Remove(PayflowConstants.PARAM_FPS_POSTXMLDATA); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + + } + + /// + /// Sets the FPS rules applied. + /// + /// Xml String + /// FPS Xml Data object + private FpsXmlData SetRules(String XmlData) + { + try + { + FpsXmlData FpsData = new FpsXmlData(); + if (XmlData != null && XmlData.Length > 0) + { + ArrayList RuleList = null; + + RuleList = ParseXmlData(XmlData); + if (RuleList != null && RuleList.Count > 0) + { + FpsData.SetRuleList(RuleList); + } + + } + return FpsData; + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + /// + /// Parses FPS Xml String Data + /// + /// Xml String Data + /// Rulelist + private ArrayList ParseXmlData(String XmlData) + { + try + { + ArrayList RuleList = new ArrayList(); + XmlDocument FpsXmlRules = new XmlDocument(); + FpsXmlRules.LoadXml(XmlData); + XmlNodeList RuleNodeList = FpsXmlRules.GetElementsByTagName(PayflowConstants.XML_PARAM_RULE); + if (RuleNodeList != null && RuleNodeList.Count > 0) + { + foreach (XmlNode RuleNode in RuleNodeList) + { + String TempValue; + Rule FraudRule = new Rule(); + TempValue = RuleNode.Attributes.GetNamedItem(PayflowConstants.XML_PARAM_NUM).Value; + if (TempValue != null) + { + FraudRule.Num = Int32.Parse(TempValue); + } + FraudRule.RuleId = RuleNode.SelectSingleNode(PayflowConstants.XML_PARAM_RULEID).InnerText; + FraudRule.RuleAlias = RuleNode.SelectSingleNode(PayflowConstants.XML_PARAM_RULEALIAS).InnerText; + FraudRule.RuleDescription = RuleNode.SelectSingleNode(PayflowConstants.XML_PARAM_RULEDESCRIPTION).InnerText; + FraudRule.Action = RuleNode.SelectSingleNode(PayflowConstants.XML_PARAM_ACTION).InnerText; + FraudRule.TriggeredMessage = RuleNode.SelectSingleNode(PayflowConstants.XML_PARAM_TRIGGEREDMESSAGE).InnerText; + XmlNode RuleVendorParamNode = RuleNode.SelectSingleNode(PayflowConstants.XML_PARAM_RULEVENDORPARMS); + if (RuleVendorParamNode != null) + { + XmlNodeList RuleParamList = RuleVendorParamNode.SelectNodes(PayflowConstants.XML_PARAM_RULEPARAMETER); + if (RuleParamList != null) + { + foreach (XmlNode RuleParamNode in RuleParamList) + { + RuleParameter RuleParam = new RuleParameter(); + String TempValue1; + TempValue1 = RuleParamNode.Attributes.GetNamedItem(PayflowConstants.XML_PARAM_NUM).Value; + if (TempValue1 != null) + RuleParam.Num = Int32.Parse(TempValue); + RuleParam.Name = RuleParamNode.SelectSingleNode(PayflowConstants.XML_PARAM_NAME).InnerText; + RuleParam.Type = RuleParamNode.SelectSingleNode(PayflowConstants.XML_PARAM_VALUE).Attributes.GetNamedItem(PayflowConstants.XML_PARAM_TYPE).Value; + RuleParam.Value = RuleParamNode.SelectSingleNode(PayflowConstants.XML_PARAM_VALUE).InnerText; + FraudRule.RuleVendorParms.Add(RuleParam); + } + } + } + RuleList.Add(FraudRule); + } + } + + return RuleList; + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + ErrorObject Error = new PayPal.Payments.Common.ErrorObject("Error While parsing XmlData", Ex.Message); + DataObjectException DEx = new DataObjectException(Error); + throw DEx; + } + //catch + //{ + // ErrorObject Error = new PayPal.Payments.Common.ErrorObject("Error While parsing XmlData", ""); + // DataObjectException DEx = new DataObjectException(Error); + // throw DEx; + //} + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/IRequestDataObject.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/IRequestDataObject.cs new file mode 100644 index 0000000..0ba0766 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/IRequestDataObject.cs @@ -0,0 +1,28 @@ + + +#region "Imports" + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Interface for all request data objects. + /// + /// This interface can be used to create a new + /// request data object. + public interface IRequestDataObject + { + #region "Functions" + + /// + /// Generates the transaction request. + /// + /// When implemented in the derived class, this method + /// should be preferred to be made as an internal method. + void GenerateRequest(); + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/IResponseDataObject.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/IResponseDataObject.cs new file mode 100644 index 0000000..9eb127e --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/IResponseDataObject.cs @@ -0,0 +1,26 @@ +#region "Imports" + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Interface for all response data objects. + /// + /// This interface can be used to create a new + /// response data object. + public interface IResponseDataObject + { + #region "Functions" + + /// + /// Sets response params. + /// + /// When implemented in the derived class, this method + /// should be preferred to be made as an internal method. + void SetParams(); + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Invoice.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Invoice.cs new file mode 100644 index 0000000..2239bc5 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Invoice.cs @@ -0,0 +1,1757 @@ +#region "Imports" + +using System; +using System.Collections; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used as the Purchase Invoice class. All the purchase + /// related information can be stored in this class. + /// + /// + /// Following transactions do require invoice object: + /// + /// Sale Transaction + /// Authorization Transaction + /// Voice Authorization Transaction + /// Primary Credit Transaction + /// Recurring Transaction : Action --> Add, Payment + /// + /// However, Invoice information can also be passed + /// in the following transactions: + /// + /// Delayed Capture Transaction + /// Credit Transaction + /// Void Authorization Transaction + /// Reference Credit Transaction + /// + /// By default, the following fields are copied from the + /// primary transaction (if they exist) into the reference + /// transaction: + /// + /// Account number Amount City + /// Comment1 Comment2 Company Name + /// Country Cust_Code CustIP DL + /// Num DOB Duty amount + /// EMail Expiration date First name + /// Freight amount Invoice number Last name + /// Middle Name Purchase order number Ship To City + /// Ship To Country Ship To First Name Ship To Last Name + /// Ship To Middle Name Ship To State Ship To Street + /// Ship To ZIP SS Num State + /// Street Suffix Swipe data + /// Tax amount Tax exempt Telephone + /// Title ZIP + /// + /// If the invoice is passed in the reference transaction, then the + /// new values (if they exist in invoice) are used (except Account number, + /// Expiration date, or Swipe data). + /// + /// + /// Following example shows how to use invoice. + /// + /// ................. + /// // Create a new Invoice data object with the Amount, Billing Address etc. details. + /// Invoice Inv = new Invoice(); + /// // Set Amount. + /// Currency Amt = new Currency(new decimal(25.12)); + /// Inv.Amt = Amt; + /// Inv.PoNum = "PO12345"; + /// Inv.InvNum = "INV12345"; + /// Inv.AltTaxAmt = new Currency(new decimal(25.14)); + /// // Set the Billing Address details. + /// BillTo Bill = new BillTo(); + /// Bill.BillToStreet = "123 Main St."; + /// Bill.BillToZip = "12345"; + /// Inv.BillTo = Bill; + /// ................. + /// + /// + /// ................. + /// ' Create a new Invoice data object with the Amount, Billing Address etc. details. + /// Dim Inv As Invoice = New Invoice + /// ' Set Amount. + /// Dim Amt As Currency = New Currency(New Decimal(25.12)) + /// Inv.Amt = Amt + /// Inv.PoNum = "PO12345" + /// Inv.InvNum = "INV12345" + /// ' Set the Billing Address details. + /// Dim Bill As BillTo = New BillTo + /// Bill.BillToStreet = "123 Main St." + /// Bill.BillToZip = "12345" + /// Inv.BillTo = Bill + /// ................. + /// + /// + public class Invoice : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Billing Addresses + /// + private BillTo mBillTo; + + /// + /// Shipping Addresses + /// + private ShipTo mShipTo; + + /// + /// List of line items + /// + private ArrayList mItemList; + + /// + /// Invoice number + /// + private String mInvNum; + + /// + /// Amount + /// + private Currency mAmt; + + /// + /// Tax Amount + /// + private Currency mTaxAmt; + + /// + /// Duty amount + /// + private Currency mDutyAmt; + + /// + /// Freight amount + /// + private Currency mFreightAmt; + + /// + /// Handling amount + /// + private Currency mHandlingAmt; + + /// + /// Shipping amount + /// + ///private Currency mShippingAmt; + + /// + /// Discount + /// + private Currency mDiscount; + + /// + /// Description + /// + private String mDesc; + + /// + /// Comment1 + /// + private String mComment1; + + /// + /// Comment2 + /// + private String mComment2; + + /// + /// Description 1 + /// + private String mDesc1; + + /// + /// Description 2 + /// + private String mDesc2; + + /// + /// Description 3 + /// + private String mDesc3; + + /// + /// Description 3 + /// + private String mDesc4; + + /// + /// Customer Reference + /// + private String mCustRef; + + /// + /// Invoice date + /// + private String mInvoiceDate; + + /// + /// Start time + /// + private String mStartTime; + + /// + /// End time + /// + private String mEndTime; + + /// + /// Purchase order number + /// + private String mPoNum; + + /// + /// Vat reg number + /// + private String mVatRegNum; + + /// + /// Vat tax amount + /// + private Currency mVatTaxAmt; + + /// + /// Local tax amount + /// + private Currency mLocalTaxAmt; + + /// + /// National tax amount + /// + private Currency mNationalTaxAmt; + + /// + /// Alt tax amount + /// + private Currency mAltTaxAmt; + + /// + /// Is Tax Exempt + /// + private String mTaxExempt; + + /// + /// Browser information object + /// + private BrowserInfo mBrowserInfo; + + /// + /// Customer information object + /// + private CustomerInfo mCustomerInfo; + + /// + /// Merchant information object + /// + private MerchantInfo mMerchantInfo; + + /// + /// User information object + /// + private UserItem mUserItem; + + /// + /// Order Date + /// + private String mOrderDate; + + /// + /// Order Time + /// + private String mOrderTime; + + /// + /// Comm Code + /// + private String mCommCode; + + /// + /// VatTax Percent + /// + private String mVatTaxPercent; + + /// + /// Recurring + /// + private String mRecurring; + + /// + /// line item amount + /// + private Currency mItemAmt; + + /// + /// OrderDesc + /// + private String mOrderDesc; + + /// + /// RecurringType + /// + private String mRecurringType; + + /// + /// Order Id + /// + private String mOrderId; + /// + /// Echo data + /// + private String mEchoData; + /// + /// VAT Invoice Number + /// + private String mVatInvNum; + /// + /// VAT Tax Rate + /// + private String mVatTaxRate; + /// + /// Report Group + /// + private String mReportGroup; + /// + /// AdviceDetailList + /// + private ArrayList mAdviceDetailList; + /// + /// Devices + /// + private Devices mDevices; + /// + /// Miscellaneous Data + /// + private String mMiscData; + ///a + ///Secure Token, used for Inquiry transaction + /// + private String mSecureToken; + + #endregion + + #region "Constructors" + + /// + /// Constructor. + /// + /// + /// Following transactions do require invoice object: + /// + /// Sale Transaction + /// Authorization Transaction + /// Voice Authorization Transaction + /// Primary Credit Transaction + /// Recurring Transaction : Action --> Add, Payment + /// + /// However, Invoice information can also be passed + /// in the following transactions: + /// + /// Delayed Capture Transaction + /// Credit Transaction + /// Void Authorization Transaction + /// Reference Credit Transaction + /// + /// By default, the following fields are copied from the + /// primary transaction (if they exist) into the reference + /// transaction: + /// + /// Account number Amount City + /// Comment1 Comment2 Company Name + /// Country Cust_Code CustIP DL + /// Num DOB Duty amount + /// EMail Expiration date First name + /// Freight amount Invoice number Last name + /// Middle Name Purchase order number Ship To City + /// Ship To Country Ship To First Name Ship To Last Name + /// Ship To Middle Name Ship To State Ship To Street + /// Ship To ZIP SS Num State + /// Street Suffix Swipe data + /// Tax amount Tax exempt Telephone + /// Title ZIP + /// UK: Capture Complete Recurring Type + /// + /// If the invoice is passed in the reference transaction, then the + /// new values (if they exist in invoice) are used (except Account number, + /// Expiration date, or Swipe data). + /// + /// + /// Following example shows how to use invoice. + /// + /// ................. + /// // Create a new Invoice data object with the Amount, Billing Address etc. details. + /// Invoice Inv = new Invoice(); + /// // Set Amount. + /// Currency Amt = new Currency(new decimal(25.12)); + /// Inv.Amt = Amt; + /// Inv.PoNum = "PO12345"; + /// Inv.InvNum = "INV12345"; + /// Inv.AltTaxAmt = new Currency(new decimal(25.14)); + /// // Set the Billing Address details. + /// BillTo Bill = new BillTo(); + /// Bill.BillToStreet = "123 Main St."; + /// Bill.BillToZip = "12345"; + /// Inv.BillTo = Bill; + /// ................. + /// + /// + /// ................. + /// ' Create a new Invoice data object with the Amount, Billing Address etc. details. + /// Dim Inv As Invoice = New Invoice + /// ' Set Amount. + /// Dim Amt As Currency = New Currency(New Decimal(25.12)) + /// Inv.Amt = Amt + /// Inv.PoNum = "PO12345" + /// Inv.InvNum = "INV12345" + /// ' Set the Billing Address details. + /// Dim Bill As BillTo = New BillTo + /// Bill.BillToStreet = "123 Main St." + /// Bill.BillToZip = "12345" + /// Inv.BillTo = Bill + /// ................. + /// + /// + public Invoice() + { + mItemList = new ArrayList(); + mAdviceDetailList = new ArrayList(); + } + + #endregion + + #region "Properties" + + /// + /// Gets, Sets BillTo. + /// + /// + /// Use this property to set the billing + /// addresses of the purchase order. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Billing Address details. + /// BillTo Bill = New BillTo(); + /// Bill.BillToStreet = "123 Main St."; + /// Bill.BillToZip = "12345"; + /// Inv.BillTo = Bill; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Billing Address details. + /// Dim Bill As BillTo = New BillTo + /// Bill.BillToStreet = "123 Main St." + /// Bill.BillToZip = "12345" + /// Inv.BillTo = Bill + /// ................. + /// + /// + public BillTo BillTo + { + get { return mBillTo; } + set { mBillTo = value; } + + } + + /// + /// Gets, Sets ShipTo. + /// + /// + /// Use this property to set the shipping + /// addresses of the purchase order. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Shipping Address details. + /// ShipTo Ship = New ShipTo(); + /// Ship.ShipToStreet = "685A E. Middlefield Rd."; + /// Ship.ShipToZip = "94043"; + /// Inv.ShipTo = Ship; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Shipping Address details. + /// Dim Ship As ShipTo = New ShipTo + /// Ship.ShipToStreet = "685A E. Middlefield Rd." + /// Ship.ShipToZip = "94043" + /// Inv.ShipTo = Ship + /// ................. + /// + /// + public ShipTo ShipTo + { + get { return mShipTo; } + set { mShipTo = value; } + + } + + /// + /// Gets, Sets TaxExempt. + /// + /// + /// Is the customer tax exempt? Y or N + /// Maps to Payflow Parameter: + /// TAXEXEMPT + /// + public String TaxExempt + { + get { return mTaxExempt; } + set { mTaxExempt = value; } + } + + /// + /// Gets, Sets InvNum + /// + /// + /// Merchant invoice number. This reference number + /// (PNREF—generated by PayPal) is used for authorizations + /// and settlements. + /// The Acquire decides if this information will + /// appear on the merchant’s bank reconciliation statement. + /// + /// Maps to Payflow Parameter: + /// INVNUM + /// + public String InvNum + { + get { return mInvNum; } + set { mInvNum = value; } + } + + /// + /// Gets, Sets Amt. + /// + /// + /// Amount (US Dollars) U.S. based currency. + /// Specify the exact amount to the cent using a decimal + /// point—use 34.00, not 34. Do not include comma + /// separators—use 1199.95 not 1,199.95. + /// Your processor and/or Internet merchant account + /// provider may stipulate a maximum amount. + /// Maps to Payflow Parameter: + /// AMT + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Amount for the invoice. + /// // A valid amount is a two decimal value. + /// Currency Amt = new Currency(new decimal(25.12)) + /// //For values which have more than two decimal places + /// Currency Amt = new Currency(new decimal(25.1214)); + /// Amt.NoOfDecimalDigits = 2; + /// //If the NoOfDecimalDigits property is used then it is mandatory to set one of the following properties to true. + /// Amt.Round = true; + /// Amt.Truncate = true; + /// Inv.Amt = Amt; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// 'Set the Amount for the invoice. + /// 'A valid amount is a two decimal value. + /// Dim Amt as new Currency(new decimal(25.12)) + /// 'For values which have more than two decimal places + /// Dim Amt as new Currency(new decimal(25.1214)) + /// Amt.NoOfDecimalDigits = 2 + /// 'If the NoOfDecimalDigits property is used then it is mandatory to set one of the following properties to true. + /// Amt.Round = true + /// Amt.Truncate = true + /// Inv.Amt = Amt; + /// ................ + /// + /// + public Currency Amt + { + get { return mAmt; } + set { mAmt = value; } + } + + /// + /// Gets, Sets TaxAmt. + /// + /// + /// Tax Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// TAXAMT + /// + public Currency TaxAmt + { + get { return mTaxAmt; } + set { mTaxAmt = value; } + } + + /// + /// Gets, Sets DutyAmt. + /// + /// + /// Sometimes called import tax. + /// Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// DUTYAMT + /// + public Currency DutyAmt + { + get { return mDutyAmt; } + set { mDutyAmt = value; } + } + + /// + /// Gets, Sets FreightAmt. + /// + /// + /// Freight Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// FREIGHTAMT + /// + public Currency FreightAmt + { + get { return mFreightAmt; } + set { mFreightAmt = value; } + } + + /// + /// Gets, Sets HandlingAmt + /// + /// + /// Handling Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// HANDLINGAMT + /// + public Currency HandlingAmt + { + get { return mHandlingAmt; } + set { mHandlingAmt = value; } + } + + /// + /// Gets, Sets ShippingAmt + /// + /// + /// Shipping Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// SHIPPINGAMT + /// + ///public Currency ShippingAmt + ///{ + /// get { return mShippingAmt; } + /// set { mShippingAmt = value; } + ///} + + + + /// + /// Gets, Sets Discount. + /// + /// + /// Discount amount on total sale. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// DISCOUNT + /// + public Currency Discount + { + get { return mDiscount; } + set { mDiscount = value; } + } + + /// + /// Gets, Sets Desc. + /// + /// + /// General description of the transaction. + /// Maps to Payflow Parameter: + /// DESC + /// + public String Desc + { + get { return mDesc; } + set { mDesc = value; } + } + + /// + /// Gets, Sets Comment1 + /// + /// + /// Merchant-defined value for reporting and auditing + /// purposes. + /// Maps to Payflow Parameter: + /// COMMENT1 + /// + public String Comment1 + { + get { return mComment1; } + set { mComment1 = value; } + } + + /// + /// Gets, Sets Comment2 + /// + /// + /// Merchant-defined value for reporting and auditing + /// purposes. + /// Maps to Payflow Parameter: + /// COMMENT2 + /// + public String Comment2 + { + get { return mComment2; } + set { mComment2 = value; } + } + + /// + /// Gets, Sets Desc1. + /// + /// + /// Up to 4 lines of additional description of + /// the charge. + /// Maps to Payflow Parameter: + /// DESC1 + /// + public String Desc1 + { + get { return mDesc1; } + set { mDesc1 = value; } + } + + /// + /// Gets, Sets Desc2. + /// + /// + /// Up to 4 lines of additional description of + /// the charge. + /// Maps to Payflow Parameter: + /// DESC2 + /// + public String Desc2 + { + get { return mDesc2; } + set { mDesc2 = value; } + } + + /// + /// Gets, Sets Desc3. + /// + /// + /// Up to 4 lines of additional description of + /// the charge. + /// Maps to Payflow Parameter: + /// DESC3 + /// + public String Desc3 + { + get { return mDesc3; } + set { mDesc3 = value; } + } + + /// + /// Gets, Sets Desc4. + /// + /// + /// Up to 4 lines of additional description of + /// the charge. + /// Maps to Payflow Parameter: + /// DESC4 + /// + public String Desc4 + { + get { return mDesc4; } + set { mDesc4 = value; } + } + + /// + /// Gets, Sets CustRef. + /// + /// + /// Merchant-defined identifier for reporting and auditing + /// purposes. For example, you can set CUSTREF to the + /// invoice number. + /// You can use CUSTREF when performing Inquiry + /// transactions. To ensure that you can always access + /// the correct transaction when performing an Inquiry, + /// you must provide a unique CUSTREF when + /// submitting any transaction, including retries. + /// Maps to Payflow Parameter: + /// CUSTREF + /// + public String CustRef + { + get { return mCustRef; } + set { mCustRef = value; } + } + + /// + /// Gets, Sets InvoiceDate. + /// + /// + /// Transaction Date. + /// Format: yyyymmdd. + /// yyyy - Year, mm - Month, dd - Day. + /// Maps to Payflow Parameter: + /// INVOICEDATE + /// + public String InvoiceDate + { + get { return mInvoiceDate; } + set { mInvoiceDate = value; } + } + + /// + /// Gets, Sets StartTime + /// + /// + /// STARTTIME specifies the beginning of the time + /// period during which the transaction specified by the + /// CUSTREF occurred. + /// If you set STARTTIME, and not ENDTIME, then + /// ENDTIME is defaulted to 30 days after STARTTIME. + /// If neither STARTTIME nor ENDTIME is specified, then + /// the system searches the last 30 days. + /// Format: yyyymmddhhmmss + /// yyyy - Year, mm - Month dd - Day, hh - Hours, mm - Minutes ss - Seconds. + /// Maps to Payflow Parameter: + /// STARTTIME + /// + public String StartTime + { + get { return mStartTime; } + set { mStartTime = value; } + } + + /// + /// Gets, Sets EndTime. + /// + /// + /// ENDTIME specifies the end of the time period during + /// which the transaction specified by the CUSTREF occurred. + /// ENDTIME must be less than 30 days after STARTTIME. + /// An inquiry cannot be performed across a date range + /// greater than 30 days. + /// If you set ENDTIME, and not STARTTIME, then STARTTIME is + /// defaulted to 30 days before ENDTIME. If neither + /// STARTTIME nor ENDTIME is specified, then the + /// system searches the last 30 days. + /// Format: yyyymmddhhmmss + ///yyyy - Year, mm - Month dd - Day, hh - Hours, mm - Minutes ss - Seconds. + /// Maps to Payflow Parameter: + /// ENDTIME + /// + public String EndTime + { + get { return mEndTime; } + set { mEndTime = value; } + } + + /// + /// Gets, Sets PoNum. + /// + /// + /// Purchase Order Number / Merchant related + /// data. + /// Maps to Payflow Parameter: + /// PONUM + /// + public String PoNum + { + get { return mPoNum; } + set { mPoNum = value; } + } + + /// + /// Gets, Sets VatRegNum + /// + /// + /// VAT registration number. + /// Maps to Payflow Parameter: + /// VATREGNUM + /// + public String VatRegNum + { + get { return mVatRegNum; } + set { mVatRegNum = value; } + } + + /// + /// Gets, Sets VatTaxAmt. + /// + /// + /// VAT Tax Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// VATTAXAMT + /// + public Currency VatTaxAmt + { + get { return mVatTaxAmt; } + set { mVatTaxAmt = value; } + } + + /// + /// Gets, Sets LocalTaxAmt. + /// + /// + /// Local Tax Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// LOCALTAXAMT + /// + public Currency LocalTaxAmt + { + get { return mLocalTaxAmt; } + set { mLocalTaxAmt = value; } + } + + /// + /// Gets, Sets NationalTaxAmt. + /// + /// + /// National Tax Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// NATIONALTAXAMT + /// + public Currency NationalTaxAmt + { + get { return mNationalTaxAmt; } + set { mNationalTaxAmt = value; } + } + + /// + /// Gets, Sets AltTaxAmt. + /// + /// + /// Alternate Tax Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// ALTTAXAMT + /// + public Currency AltTaxAmt + { + get { return mAltTaxAmt; } + set { mAltTaxAmt = value; } + } + + /// + /// Gets, Sets BrowserInfo. + /// + /// + /// Use this property to set the browser + /// related information of the purchase order. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Browser Info details. + /// BrowserInfo Browser = New BrowserInfo(); + /// Browser.BrowserCountryCode = "USA"; + /// Browser.BrowserUserAgent = "IE 6.0"; + /// Inv.BrowserInfo = Browser; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Browser Info details. + /// Dim Browser As BrowserInfo = New BrowserInfo + /// Browser.BrowserCountryCode = "USA" + /// Browser.BrowserUserAgent = "IE 6.0" + /// Inv.BrowserInfo = Browser + /// ................. + /// + /// + public BrowserInfo BrowserInfo + { + get { return mBrowserInfo; } + set { mBrowserInfo = value; } + } + + /// + /// Gets, Sets CustomerInfo. + /// + /// + /// Use this property to set the customer + /// related information of the purchase order. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Customer Info details. + /// CustomerInfo Cust = New CustomerInfo(); + /// Cust.CustCode = "CustXXXXX"; + /// Cust.CustIP = "255.255.255.255"; + /// Inv.CustomerInfo = Cust; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Customer Info details. + /// Dim Cust As CustomerInfo = New CustomerInfo + /// Cust.CustCode = "CustXXXXX" + /// Cust.CustIP = "255.255.255.255" + /// Inv.CustomerInfo = Cust + /// ................. + /// + /// + public CustomerInfo CustomerInfo + { + get { return mCustomerInfo; } + set { mCustomerInfo = value; } + } + + /// + /// Used for Merchant related information. + /// + /// Use this class to set the Merchant related + /// information. Used for Soft Descriptors. + /// + /// Refer to the Payflow Gateway Developer's Guide for your processor + /// for more information related to this fields. + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Merchant Info details. + /// MerchantInfo Merchant = New MerchantInfo(); + /// Merchant.MerchantCode = "MerchantXXXXX"; + /// Merchant.MerchantCity = "Anywhere"; + /// Inv.MerchantInfo = Merchant; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Merchant Info details. + /// Dim Merchant As MerchantInfo = New MerchantInfo + /// Merchant.MerchantCode = "MerchantXXXXX" + /// Merchant.MerchantCity = "Anywhere" + /// Inv.MerchantInfo = Merchant + /// ................. + /// + /// + public MerchantInfo MerchantInfo + { + get { return mMerchantInfo; } + set { mMerchantInfo = value; } + } + + /// + /// Gets, Sets UserItem. + /// + /// + /// Use this property to set the user + /// related information that is echoed back in the response. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the User Item details. + /// UserItem nUser = new UserItem(); + /// nUser.UserItem1 = "ABCDEF"; + /// nUser.UserItem2 = "GHIJKL"; + /// Inv.UserItem = nUser; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the User Item details. + /// Dim nUser As New UserItem + /// nUser.UserItem1 = "ABCDEF" + /// nUser.UserItem2 = "GHIJKL" + /// Inv.UserItem = nUser + /// ................. + /// + /// + public UserItem UserItem + { + get { return mUserItem; } + set { mUserItem = value; } + } + + /// + /// Gets, Sets OrderDate. + /// + /// + /// Order date. + /// Format: mmddyy + /// mm - Month, dd - Day, yy - Year. + /// Maps to Payflow Parameter: + /// ORDERDATE + /// + public String OrderDate + { + get { return mOrderDate; } + set { mOrderDate = value; } + } + + /// + /// Gets, Sets OrderTime. + /// + /// + /// Order Time. + /// Maps to Payflow Parameter: + /// ORDERTIME + /// + public String OrderTime + { + get { return mOrderTime; } + set { mOrderTime = value; } + } + + /// + /// Gets, Sets CommCode. + /// + /// + /// Commodity Code. + /// Maps to Payflow Parameter: + /// COMMCODE + /// + public String CommCode + { + get { return mCommCode; } + set { mCommCode = value; } + } + + /// + /// Gets, Sets VATTAXPERCENT. + /// + /// + /// VAT Tax percentage. + /// Maps to Payflow Parameter: + /// VATTAXPERCENT + /// + public String VatTaxPercent + { + get { return mVatTaxPercent; } + set { mVatTaxPercent = value; } + } + + /// + /// Gets, Sets Recurring. + /// + /// + /// Is a recurring transaction? Y or N. + /// Maps to Payflow Parameter: + /// RECURRING + /// + public String Recurring + { + get { return mRecurring; } + set { mRecurring = value; } + } + + /// + /// Gets, Sets line item Amount. + /// + /// + /// Item Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// ITEMAMT + /// + public Currency ItemAmt + { + get { return mItemAmt; } + set { mItemAmt = value; } + } + + /// + /// Gets, Sets OrderDesc. + /// + /// + /// Maps to Payflow Parameter: + /// ORDERDESC + /// + public String OrderDesc + { + get { return mOrderDesc; } + set { mOrderDesc = value; } + } + + /// + /// Gets, Sets RecurringType. + /// + /// + /// UK Only: The type of transaction occurrence. + /// Values are: F = First occurrence, S = Subsequent + /// occurrence (default). + /// Maps to Payflow Parameter: + /// RECURRINGTYPE + /// + public String RecurringType + { + get { return mRecurringType; } + set { mRecurringType = value; } + } + + /// + /// Gets, Sets OrderId + /// + /// + /// Order ID is used to prevent duplicate "orders" from being processed. + /// This is NOT the same as Request ID; which is used at the transaction level. + /// Order ID (ORDERID) is used to check for a duplicate order in the future. + /// For example, if you pass ORDERID=10101 and in two weeks another order is processed + /// with the same ORDERID, a duplicate condition will occur. The results you receive + /// will be from the original order with DUPLICATE=2 to show that it was ORDERID that + /// triggered the duplicate. The order id is stored for 3 years. + /// + /// Important Note: Order ID functionality to catch duplicate orders processed withing + /// seconds of each other is limited. Order ID should be used in conjunction with Request ID + /// to prevent duplicates due to processing / communication errors. DO NOT use ORDERID + /// as your only means to check for duplicate transactions. + /// Maps to Payflow Parameter: + /// ORDERID + /// + public String OrderId + { + get { return mOrderId; } + set { mOrderId = value; } + } + + /// + /// Gets, Sets EchoData + /// + /// + /// Echo Data is used to "echo" back data sent for processing in the response. + /// For example, if you send "ECHODATA=ADDRESS" then the Billing Address fields + /// will be returned in the response. + /// Maps to Payflow Parameter: + /// ECHODATA + /// + public String EchoData + { + get { return mEchoData; } + set { mEchoData = value; } + } + + /// + /// Gets, Sets VAT Invoice Number. + /// + /// + /// Value added tax invoice number. + /// Maps to Payflow Parameter: + /// VATINVNUM + /// + public String VatInvNum + { + get { return mVatInvNum; } + set { mVatInvNum = value; } + } + + /// + /// Gets, Sets VAT Tax Rate. + /// + /// + /// Maps to Payflow Parameter: + /// VATTAXRATE + /// + public String VatTaxRate + { + get { return mVatTaxRate; } + set { mVatTaxRate = value; } + } + + /// + /// Gets, Sets Report Group. + /// + /// + /// Category that the transaction is in, for example: coffee mugs. + /// Maps to Payflow Parameter: + /// REPORTGROUP + /// + public String ReportGroup + { + get { return mReportGroup; } + set { mReportGroup = value; } + } + + /// + /// Gets, Sets Devices. + /// + /// + /// + /// Items that reflect what type of device; either termainal or card is used or presented. + /// + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Create a new Devices object. + /// Devices UsedDevices = new Devices(); + /// UsedDevices.CatType = "3"; + /// UsedDevices.Contactless = "RFD"; + /// Inv.Devices = UsedDevices; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the device/card capabilities + /// Dim UsedDevices As Devices = New Devices + /// UsedDevices.CatType = "3" + /// UsedDevices.Contactless = "RFD" + /// Inv.Devices = UsedDevices + /// ................. + /// + /// + public Devices Devices + { + get { return mDevices; } + set { mDevices = value; } + } + + /// + /// Gets, Sets Miscellaneous Data. + /// + /// + /// Maps to Payflow Parameter: + /// MISCDATA + /// + public String MiscData + { + get { return mMiscData; } + set { mMiscData = value; } + } + + /// + /// Gets, Sets SecureToken. + /// + /// + /// Merchant-defined identifier used in the Secure Token flow. + /// + /// You can use SECURETOKEN when performing Inquiry transactions. To ensure that you can always access + /// the correct transaction when performing an Inquiry, you must use CREATESECURETOKEN when + /// submitting any transaction. + /// Maps to Payflow Parameter: + /// SECURETOKEN + /// + public String SecureToken + { + get { return mSecureToken; } + set { mSecureToken = value; } + } + #endregion + + #region "AdviceDetailItem related Methods" + + /// + /// Used for advice detail items. + /// + /// + /// This class holds the advice detail related information. + /// Detail of a charge where *n* is a value from 1 - 5. Use for additional breakdown of the amount. + /// For example ADDLAMT1=1 is the amount for the additional amount for advice detail item 1 and is equal to 1, + /// + /// + /// Following example shows how to use AdviceDetail. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// // Set the Advice Detail items. + /// AdviceDetail AddDetail1 = new AdviceDetail(); + /// AddDetail1.AddLAmt = "1"; + /// AddDetail1.AddLAmtType = "1"; + /// Inv.AddAdviceDetailItem(AddDetail1); + /// // To add another item, just do the same as above but increment the value of AddDetail to 2: AddDetail2 + /// ................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// ' Set the Advice Detail items. + /// Dim AddDetail1 As AdviceDetail = New AdviceDetail + /// AddDetail1.AddLAmt = "1" + /// AddDetail1.AddLAmtType = "1" + /// Inv.AddAdviceDetailItem(AddDetail1) + /// ' To add another item, just do the same as above but increment the value of AddDetail to 2: AddDetail2 + /// ................. + /// + /// + public void AddAdviceDetailItem(AdviceDetail Item) + { + mAdviceDetailList.Add(Item); + } + + /// + /// Removes a advice detail item from line item list. + /// + /// Index of line item to be removed. + /// + /// Use this method to remove an advice detail item at a particular + /// index in the purchase order. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Remove item at index 0 + /// Inv.RemoveAdviceDetailItem(0); + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Remove item at index 0; + /// Inv.RemoveAdviceDetailItem(0) + /// ................. + /// + /// + public void RemoveAdviceDetailItem(int Index) + { + mAdviceDetailList.RemoveAt(Index); + } + + /// + /// Clears the advice detail item list. + /// + /// + /// Use this method to clear all the + /// advice detail items added to the purchase order. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Remove all advice detail items. + /// Inv.RemoveAllAdviceDetailItems(); + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Remove all advice detail items. + /// Inv.RemoveAllAdviceDetailItems() + /// ................. + /// + /// + public void RemoveAllAdviceDetailItems() + { + mAdviceDetailList.Clear(); + } + #endregion + + #region "LineItem related Methods" + + /// + /// Adds a line item to line item list. + /// + /// Lineitem object + /// + /// Use this method to add a line item in + /// the purchase order. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the line item details. + /// LineItem Item = New LineItem(); + /// Item.PickupStreet = "685A E. Middlefield Rd."; + /// Item.PickupState = "CA"; + /// Inv.AddLineItem(Item); + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Customer Info details. + /// Dim Item As LineItem = New LineItem + /// Item.PickupStreet = "685A E. Middlefield Rd." + /// Item.PickupState = "CA" + /// Inv.AddLineItem(Item); + /// ................. + /// + /// + public void AddLineItem(LineItem Item) + { + mItemList.Add(Item); + } + + /// + /// Removes a line item from line item list. + /// + /// Index of lineitem to be removed. + /// + /// Use this method to remove a line item at a particular + /// index in the purchase order. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Remove item at index 0 + /// Inv.RemoveLineItem(0); + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Remove item at index 0; + /// Inv.RemoveLineItem(0) + /// ................. + /// + /// + public void RemoveLineItem(int Index) + { + mItemList.RemoveAt(Index); + } + + /// + /// Clears the line item list. + /// + /// + /// Use this method to clear all the + /// line items added to the purchase order. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Remove all line items. + /// Inv.RemoveAllLineItems(); + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Remove all line items. + /// Inv.RemoveAllLineItems() + /// ................. + /// + /// + public void RemoveAllLineItems() + { + mItemList.Clear(); + } + + /// + /// Generates transaction request for line items + /// + private void GenerateItemRequest() + { + for (int Index = 0; Index < mItemList.Count; Index++) + { + LineItem Item = (LineItem) mItemList[Index]; + if (Item != null) + { + Item.RequestBuffer = RequestBuffer; + Item.GenerateRequest(Index); + } + } + } + + /// + /// Generates transaction request for advice detail items + /// + private void GenerateAdviceDetailRequest() + { + for (int Index = 0; Index < mAdviceDetailList.Count; Index++) + { + AdviceDetail Item = (AdviceDetail) mAdviceDetailList[Index]; + if (Item != null) + { + Item.RequestBuffer = RequestBuffer; + Item.GenerateRequest(Index); + } + } + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_INVNUM, mInvNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_AMT, mAmt)); + // if no Amt passed, skip CurrencyCode. + if (mAmt != null) + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CURRENCY,mAmt.CurrencyCode)); + } + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_TAXEXEMPT, mTaxExempt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_TAXAMT, mTaxAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DUTYAMT, mDutyAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_FREIGHTAMT, mFreightAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_HANDLINGAMT, mHandlingAmt)); + //RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPPINGAMT, mShippingAmt )); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DISCOUNT, mDiscount)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DESC, mDesc)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_COMMENT1, mComment1)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_COMMENT2, mComment2)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DESC1, mDesc1)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DESC2, mDesc2)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DESC3, mDesc3)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_DESC4, mDesc4)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CUSTREF, mCustRef)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PONUM, mPoNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_VATREGNUM, mVatRegNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_VATTAXAMT, mVatTaxAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_LOCALTAXAMT, mLocalTaxAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_NATIONALTAXAMT, mNationalTaxAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ALTTAXAMT, mAltTaxAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_COMMCODE, mCommCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_VATTAXPERCENT, mVatTaxPercent)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_INVOICEDATE, mInvoiceDate)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_STARTTIME, mStartTime)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ENDTIME, mEndTime)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORDERDATE, mOrderDate)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORDERTIME, mOrderTime)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_RECURRING, mRecurring)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ITEMAMT, mItemAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORDERDESC, mOrderDesc)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_RECURRINGTYPE, mRecurringType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORDERID, mOrderId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ECHODATA, mEchoData)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_VATINVNUM, mVatInvNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_VATTAXRATE, mVatTaxRate)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_REPORTGROUP, mReportGroup)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MISCDATA, mMiscData)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SECURETOKEN, mSecureToken)); + + + + if (mBillTo != null) + { + mBillTo.RequestBuffer = RequestBuffer; + mBillTo.GenerateRequest(); + } + if (mShipTo != null) + { + mShipTo.RequestBuffer = RequestBuffer; + mShipTo.GenerateRequest(); + } + if (mBrowserInfo != null) + { + mBrowserInfo.RequestBuffer = RequestBuffer; + mBrowserInfo.GenerateRequest(); + } + if (mCustomerInfo != null) + { + mCustomerInfo.RequestBuffer = RequestBuffer; + mCustomerInfo.GenerateRequest(); + } + if (mMerchantInfo != null) + { + mMerchantInfo.RequestBuffer = RequestBuffer; + mMerchantInfo.GenerateRequest(); + } + if (mItemList != null && mItemList.Count > 0) + { + GenerateItemRequest(); + } + if (mUserItem != null) + { + mUserItem.RequestBuffer = RequestBuffer; + mUserItem.GenerateRequest(); + } + if (mAdviceDetailList != null && mAdviceDetailList.Count > 0) + { + GenerateAdviceDetailRequest(); + } + if (mDevices!= null) + { + mDevices.RequestBuffer = RequestBuffer; + mDevices.GenerateRequest(); + } + + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/LineItem.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/LineItem.cs new file mode 100644 index 0000000..e8a28bc --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/LineItem.cs @@ -0,0 +1,864 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// This class holds the Invoice Line Item item related information. + /// + /// + /// Line item data describes the details of the item purchased and can be can be passed + /// for each transaction. The convention for passing line item data in name/value pairs + /// is that each name/value starts with L_ and ends with n where n is the line item number. + /// For example L_QTY0=1 is the quantity for line item 0 and is equal to 1, + /// with n starting at 0 + /// + /// + /// Following example shows how to use line item. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// + /// //Create a line item. + /// LineItem Item = new LineItem(); + /// + /// //Add info to line item. + /// Item.Amt = new Currency(new Decimal(25.12)); + /// Item.PickupStreet = "685A E. Middlefield Rd."; + /// + /// //Add line item to invoice. + /// Inv.AddLineItem(Item); + /// + /// .................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// + /// //Create a line item. + /// Dim Item As LineItem = New LineItem + /// + /// 'Add info to line item. + /// Item.Amt = New Currency(new Decimal(25.12)) + /// Item.PickupStreet = "685A E. Middlefield Rd." + /// + /// 'Add line item to invoice. + /// Inv.AddLineItem(Item) + /// + /// .................. + /// + /// + public sealed class LineItem : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// line item amount + /// + private Currency mAmt; + + /// + /// line item cost + /// + private Currency mCost; + + /// + /// line item freight amount + /// + private Currency mFreightAmt; + + /// + /// line item tax amount + /// + private Currency mTaxAmt; + + /// + /// line item uom + /// + private String mUom; + + /// + /// line item pickup street + /// + private String mPickupStreet; + + /// + /// line item pickup state + /// + private String mPickupState; + + /// + /// line item pickup country + /// + private String mPickupCountry; + + /// + /// line item pickup city + /// + private String mPickupCity; + + /// + /// line item pickup zip + /// + private String mPickupZip; + + /// + /// line item desc + /// + private String mDesc; + + /// + /// line item discount + /// + private Currency mDiscount; + + /// + /// line item manufacturer + /// + private String mManufacturer; + + /// + /// line item prodcode + /// + private String mProdCode; + + /// + /// line item qty + /// + private long mQty = PayflowConstants.INVALID_NUMBER; + + /// + /// line item sku + /// + private String mSku; + + /// + /// line item taxrate + /// + private Currency mTaxRate; + + /// + /// line item tax type + /// + private String mTaxType; + + /// + /// line item type + /// + private String mType; + + /// + /// line item commcode + /// + private String mCommCode; + + /// + /// line item tracking number + /// + private String mTrackingNum; + + /// + /// line item cost center number + /// + private String mCostCenterNum; + + /// + /// line item catalog number + /// + private String mCatalogNum; + + /// + /// line item upc + /// + private String mUpc; + + /// + /// line item handlingamount + /// + private Currency mHandlingAmt; + + /// + /// line item unspsc code + /// + private String mUnspscCode; + + /// + /// line item alternate tax amount + /// + private String mAltTaxAmt; + /// + /// line item alternate tax Id + /// + private String mAltTaxId; + /// + /// line item alternate tax rate + /// + private String mAltTaxRate; + /// + /// line item carrier service level code + /// + private String mCarrierServiceLevelCode; + /// + /// line item extra amount + /// + private String mExtAmt; + + + /// -------------------------------------- + /// + /// + /// line item name + /// + private String mName; + + + /// + /// line item number + /// + private String mItemNumber; + + #endregion + + #region "Properties" + + /// + /// Gets, Sets line item Amt. + /// + /// + /// Total line item amount including tax and + /// discount. + for debit, - for credits. + /// Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// L_AMTn + /// + public Currency Amt + { + get { return mAmt; } + set { mAmt = value; } + } + + /// + /// Gets, Sets line item Cost. + /// + /// + /// Cost per item, excluding tax. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// L_COSTn + /// + public Currency Cost + { + get { return mCost; } + set { mCost = value; } + } + + /// + /// Gets, Sets line item FreightAmt. + /// + /// + /// Freight Amount per item. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// L_FREIGHTAMTn + /// + public Currency FreightAmt + { + get { return mFreightAmt; } + set { mFreightAmt = value; } + } + + /// + /// Gets, Sets line item TaxAmt. + /// + /// + /// Tax Amount per item. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// L_TAXAMTn + /// + public Currency TaxAmt + { + get { return mTaxAmt; } + set { mTaxAmt = value; } + } + + /// + /// Gets, Sets line item UOM. + /// + /// + /// Item unit of measure. + /// Maps to Payflow Parameter: + /// L_UOMn + /// + public String UOM + { + get { return mUom; } + set { mUom = value; } + } + + /// + /// Gets, Sets line item PickupStreet. + /// + /// + /// Item drop-off address1. + /// Maps to Payflow Parameter: + /// L_PICKUPSTREETn + /// + public String PickupStreet + { + get { return mPickupStreet; } + set { mPickupStreet = value; } + } + + /// + /// Gets, Sets line item PickupState. + /// + /// + /// Item drop-off state. + /// Maps to Payflow Parameter: + /// L_PICKUPSTATEn + /// + public String PickupState + { + get { return mPickupState; } + set { mPickupState = value; } + } + + /// + /// Gets, Sets line item PickupCountry. + /// + /// + /// Item drop-off country. + /// Maps to Payflow Parameter: + /// L_PICKUPCOUNTRYn + /// + public String PickupCountry + { + get { return mPickupCountry; } + set { mPickupCountry = value; } + } + + /// + /// Gets, Sets line item PickupCity. + /// + /// + /// Item drop-off city. + /// Maps to Payflow Parameter: + /// L_PICKUPCITYn + /// + public String PickupCity + { + get { return mPickupCity; } + set { mPickupCity = value; } + } + + /// + /// Gets, Sets line item PickupZip. + /// + /// + /// Item drop-off zip. + /// Maps to Payflow Parameter: + /// L_PICKUPZIPn + /// + public String PickupZip + { + get { return mPickupZip; } + set { mPickupZip = value; } + } + + /// + /// Gets, Sets line item Desc. + /// + /// + /// Item description. + /// Maps to Payflow Parameter: + /// L_DESCn + /// + public String Desc + { + get { return mDesc; } + set { mDesc = value; } + } + + /// + /// Gets, Sets line item Discount. + /// + /// + /// Discount Amount per item. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// L_DISCOUNTn + /// + public Currency Discount + { + get { return mDiscount; } + set { mDiscount = value; } + } + + /// + /// Gets, Sets line item Manufacturer. + /// + /// + /// Item manufacturer. + /// Maps to Payflow Parameter: + /// L_MANUFACTURERn + /// + public String Manufacturer + { + get { return mManufacturer; } + set { mManufacturer = value; } + } + + /// + /// Gets, Sets line item ProdCode. + /// + /// + /// Item product code. + /// Maps to Payflow Parameter: + /// L_PRODCODEn + /// + public String ProdCode + { + get { return mProdCode; } + set { mProdCode = value; } + } + + /// + /// Gets, Sets line item Qty. + /// + /// + /// Quantity per item. + /// Maps to Payflow Parameter: + /// L_QTYn + /// + public long Qty + { + get { return mQty; } + set { mQty = value; } + } + + /// + /// Gets, Sets line item SKU. + /// + /// + /// Item SKU. + /// Maps to Payflow Parameter: + /// L_SKUn + /// + public String SKU + { + get { return mSku; } + set { mSku = value; } + } + + /// + /// Gets, Sets line item TaxRate. + /// + /// + /// Tax Rate Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// L_TAXRATEn + /// + public Currency TaxRate + { + get { return mTaxRate; } + set { mTaxRate = value; } + } + + /// + /// Gets, Sets line item TaxType. + /// + /// + /// Item tax type. + /// Maps to Payflow Parameter: + /// L_TAXTYPEn + /// + public String TaxType + { + get { return mTaxType; } + set { mTaxType = value; } + } + + /// + /// Gets, Sets line item Type. + /// + /// + /// Item type. + /// Maps to Payflow Parameter: + /// L_TYPEn + /// + public String Type + { + get { return mType; } + set { mType = value; } + } + + /// + /// Gets, Sets line item CommCode. + /// + /// + /// Item commodity code. + /// Maps to Payflow Parameter: + /// L_COMMCODEn + /// + public String CommCode + { + get { return mCommCode; } + set { mCommCode = value; } + } + + /// + /// Gets, Sets line item TrackingNum. + /// + /// + /// Item tracking number. + /// Maps to Payflow Parameter: + /// L_TRACKINGNUMn + /// + public String TrackingNum + { + get { return mTrackingNum; } + set { mTrackingNum = value; } + } + + /// + /// Gets, Sets line item CostCenterNum. + /// + /// + /// Item cost center number. + /// Maps to Payflow Parameter: + /// L_COSTCENTERNUMn + /// + public String CostCenterNum + { + get { return mCostCenterNum; } + set { mCostCenterNum = value; } + } + + /// + /// Gets, Sets line item CatalogNum. + /// + /// + /// Item catalog number. + /// Maps to Payflow Parameter: + /// L_CATALOGNUMn + /// + public String CatalogNum + { + get { return mCatalogNum; } + set { mCatalogNum = value; } + } + + /// + /// Gets, Sets line item UPC. + /// + /// + /// Item universal product code. + /// Maps to Payflow Parameter: + /// L_UPCn + /// + public String UPC + { + get { return mUpc; } + set { mUpc = value; } + } + + /// + /// Gets, Sets line item HandlingAmt. + /// + /// + /// Item Handling Amount. Amount should always be a decimal. + /// Exact amount to the cent (34.00, not 34). + /// Do not include comma separators. Use 1199.95 + /// instead of 1,199.95. + /// Maps to Payflow Parameter: + /// L_HANDLINGAMTn + /// + public Currency HandlingAmt + { + get { return mHandlingAmt; } + set { mHandlingAmt = value; } + } + + /// + /// Gets, Sets line item unspsc code. + /// + /// + /// Item UnspscCode. + /// Maps to Payflow Parameter: + /// L_UNSPSCCODEn + /// + public String UnspscCode + { + get { return mUnspscCode; } + set { mUnspscCode = value; } + } + + /// + /// Gets, Sets line item alternate tax code. + /// + /// + /// Item AltTaxAmt. + /// Maps to Payflow Parameter: + /// L_ALTTAXAMT + /// + public String AltTaxAmt + { + get { return mAltTaxAmt; } + set { mAltTaxAmt = value; } + } + + /// + /// Gets, Sets line item alternate tax Id. + /// + /// + /// Item AltTaxId. + /// Maps to Payflow Parameter: + /// L_ALTTAXID + /// + public String AltTaxId + { + get { return mAltTaxId; } + set { mAltTaxId = value; } + } + + /// + /// Gets, Sets line item alternate tax rate. + /// + /// + /// Item AltTaxRate. + /// Maps to Payflow Parameter: + /// L_ALTTAXRATE + /// + public String AltTaxRate + { + get { return mAltTaxRate; } + set { mAltTaxRate = value; } + } + + /// + /// Gets, Sets line item carrier service level code + /// + /// + /// Item CarrierServiceLevelCode. + /// Maps to Payflow Parameter: + /// L_CARRIERSERVICELEVELCODE + /// + public String CarrierServiceLevelCode + { + get { return mCarrierServiceLevelCode; } + set { mCarrierServiceLevelCode = value; } + } + + /// + /// Gets, Sets line item extended amount + /// + /// Item ExtAmt + /// Maps to Payflow Parameter: + /// L_EXTAMT + /// + /// + public String ExtAmt + { + get { return mExtAmt; } + set { mExtAmt = value; } + } + + + + + + + + + + + + + + + + + + + + + + /// ------------------------------------------------------ + + /// + /// Gets, Sets line item name. + /// + /// + /// Item UnspscCode. + /// Maps to Payflow Parameter: + /// L_NAMEn + /// + public String Name + { + get { return mName; } + set { mName = value; } + } + + /// + /// Gets, Sets line item number. + /// + /// + /// + /// Maps to Payflow Parameter: + /// L_xxxxn + /// + public String ItemNumber + { + get { return mItemNumber; } + set { mItemNumber = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor. + /// + /// + /// Line item data describes the details of the item purchased and can be can be passed + /// for each transaction. The convention for passing line item data in name/value pairs + /// is that each name/value starts with L_ and ends with n where n is the line item number. + /// For example L_QTY0=1 is the quantity for line item 0 and is equal to 1, + /// with n starting at 0 + /// + /// + /// Following example shows how to use line item. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// + /// //Create a line item. + /// LineItem Item = new LineItem(); + /// + /// //Add info to line item. + /// Item.Amt = new Currency(new Decimal(25.12)); + /// Item.PickupStreet = "685A E. Middlefield Rd."; + /// + /// //Add line item to invoice. + /// Inv.AddLineItem(Item); + /// + /// .................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// + /// //Create a line item. + /// Dim Item As LineItem = New LineItem + /// + /// 'Add info to line item. + /// Item.Amt = New Currency(new Decimal(25.12)) + /// Item.PickupStreet = "685A E. Middlefield Rd." + /// + /// 'Add line item to invoice. + /// Inv.AddLineItem(Item) + /// + /// .................. + /// + /// + public LineItem() + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates line item request + /// + /// index number of line item + internal void GenerateRequest(int Index) + { + try + { + String IndexVal = Index.ToString(); + + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_AMT + IndexVal, mAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_COST + IndexVal, mCost)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_FREIGHTAMT + IndexVal, mFreightAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_HANDLINGAMT + IndexVal, mHandlingAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_TAXAMT + IndexVal, mTaxAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_UOM + IndexVal, mUom)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_PICKUPSTREET + IndexVal, mPickupStreet)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_PICKUPSTATE + IndexVal, mPickupState)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_PICKUPCOUNTRY + IndexVal, mPickupCountry)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_PICKUPCITY + IndexVal, mPickupCity)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_PICKUPZIP + IndexVal, mPickupZip)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_DESC + IndexVal, mDesc)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_DISCOUNT + IndexVal, mDiscount)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_MANUFACTURER + IndexVal, mManufacturer)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_PRODCODE + IndexVal, mProdCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_ITEMNUMBER + IndexVal, mItemNumber)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_NAME + IndexVal, mName)); + if (mQty != PayflowConstants.INVALID_NUMBER) + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_QTY + IndexVal, mQty)); + } + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_SKU + IndexVal, mSku)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_TAXRATE + IndexVal, mTaxRate)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_TAXTYPE + IndexVal, mTaxType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_TYPE + IndexVal, mType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_COMMCODE + IndexVal, mCommCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_TRACKINGNUM + IndexVal, mTrackingNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_COSTCENTERNUM + IndexVal, mCostCenterNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_CATALOGNUM + IndexVal, mCatalogNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_UPC + IndexVal, mUpc)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_UNSPSCCODE + IndexVal, mUnspscCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_ALTTAXAMT + IndexVal, mAltTaxAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_ALTTAXID + IndexVal, mAltTaxId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_ALTTAXRATE + IndexVal, mAltTaxRate)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_CARRIERSERVICELEVELCODE + IndexVal, mCarrierServiceLevelCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_L_EXTAMT + IndexVal, mExtAmt)); + + + + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + } + + #endregion + + + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/MagtekInfo.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/MagtekInfo.cs new file mode 100644 index 0000000..5bc4919 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/MagtekInfo.cs @@ -0,0 +1,483 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Magtek related information. + /// + /// Use the MagtekInfo object for the Magtek + /// encrypted card reader related information. + /// + /// Following example shows how to use the MagtekInfo object. + /// + /// ................. + /// // Swipe is the SwipeCard object + /// ................. + /// // Set the Magtek Info details. + /// MagtekInfo MT = new MagtekInfo(); + /// MT.DeviceSN = "Device Serial Number from reader"; + /// MT.EncMP = "ENCMP from reader"; + /// MT.EncryptionBlockType = "1"; + /// MT.EncTrack1 = "Track 1 data from reader"; + /// MT.EncTrack2 = "Track 2 data from reader"; + /// MT.EncTrack3 = ""; + /// MT.KSN = "KSN from reader"; + /// MT.MagtekCardType = "1"; + /// MT.MPStatus = "MPStatus from reader"; + /// MT.RegisteredBy = "PayPal"; + /// MT.SwipedECRHost = "MAGT"; + /// // When using Encrypted Card Readers you do not populate the SwipeCard object as the data from the Magtek object + /// // will be used instead. + /// SwipeCard Swipe = new SwipeCard(""); + /// Swipe.MagtekInfo = MT; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Browser Info details. + /// Dim Browser As BrowserInfo = New BrowserInfo + /// Browser.BrowserCountryCode = "USA" + /// Browser.BrowserUserAgent = "IE 6.0" + /// Inv.BrowserInfo = Browser + /// ................. + /// + /// + public sealed class MagtekInfo : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Holds Encrypted MagnePrint Information + /// + private String mEncMP; + /// + /// Holds Encryption Block + /// + private String mEncryptionBlockType; + /// + /// Holds Encrypted Track 1 + /// + private String mEncTrack1; + /// + /// Holds Encrypted Track 2 + /// + private String mEncTrack2; + /// + /// Holds Encrypted Track 3 + /// + private String mEncTrack3; + /// + /// Holds KSN + /// + private String mKSN; + /// + /// Holds Card Type + /// /// + private String mMagtekCardType; + /// + /// Holds MP Status + /// + private String mMPStatus; + /// + /// Holds Registered By + /// + private String mRegisteredBy; + /// + /// Holds Swiped ECR Host + /// + private String mSwipedECRHost; + /// + /// Holds Device Serial Number + /// + private String mDeviceSN; + /// + /// Holds Merchant Id + /// + private String mMerchantId; + /// + /// Holds 4-digit PAN + /// + private String mPAN4; + /// + /// Holds Protection Code + /// + private String mPCode; + /// + /// Holds Authorization Value 1 + /// + private String mAuthValue1; + /// + /// Holds Authorization Value 2 + /// + private String mAuthValue2; + /// + /// Holds Authorization Value 3 + /// + private String mAuthValue3; + /// + /// Holds Magtek User Name + /// + private String mMagtekUserName; + /// + /// Holds Magtek Password + /// + private String mMagtekPassword; + + #endregion + + #region "Constructors" + + /// + /// Constructor for BrowserInfo + /// + /// Use the MagtekInfo object for the Magtek + /// encrypted card reader related information. + /// + /// Following example shows how to use a + /// Magtek Info object. + /// + /// ................. + /// // Swipe is the SwipeCard object + /// ................. + /// // Set the MagtekInfo object. + /// MagtekInfo MT = new MagtekInfo(); + /// MT.DeviceSN = "Device Serial Number from reader"; + /// MT.EncMP = "ENCMP from reader"; + /// MT.EncryptionBlockType = "1"; + /// MT.EncTrack1 = "Track 1 data from reader"; + /// // When using Encrypted Card Readers you do not populate the SwipeCard object as the data from the Magtek object + /// // will be used instead. + /// SwipeCard Swipe = new SwipeCard(""); + /// Swipe.MagtekInfo = MT; + /// ................. + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Browser Info details. + /// Dim Browser As BrowserInfo = New BrowserInfo + /// Browser.BrowserCountryCode = "USA" + /// Browser.BrowserUserAgent = "IE 6.0" + /// Inv.BrowserInfo = Browser + /// ................. + /// + /// + public MagtekInfo() + { + } + + #endregion + + #region "Properties" + + /// + /// Gets, Sets Magtek Encrypted MagnePrint Information. + /// + /// + /// Encrypted MagnePrint Information returned by a MagneSafe device when a card is swiped. + /// Maps to Payflow Parameter: + /// ENCMP + /// + public String EncMP + { + get { return mEncMP; } + set { mEncMP = value; } + } + + /// + /// Gets, Sets Magtek Encryption Block. + /// + /// + /// The code which indicates what type of Encryption Block is used. + /// Maps to Payflow Parameter: + /// ENCRYPTIONBLOCKTYPE + /// + public String EncryptionBlockType + { + get { return mEncryptionBlockType; } + set { mEncryptionBlockType = value; } + } + + /// + /// Gets, Sets Magtek Encrypted Track 1. + /// + /// + /// Encrypted Track 1 information returned by a MagneSafe device when a card is swiped. + /// Maps to Payflow Parameter: + /// ENCTRACKE1 + /// + public String EncTrack1 + { + get { return mEncTrack1; } + set { mEncTrack1 = value; } + } + /// + /// Gets, Sets Magtek Encrypted Track 2. + /// + /// + /// Encrypted Track 2 information returned by a MagneSafe device when a card is swiped. + /// Maps to Payflow Parameter: + /// ENCTRACKE2 + /// + public String EncTrack2 + { + get { return mEncTrack2; } + set { mEncTrack2 = value; } + } + /// + /// Gets, Sets Magtek Encrypted Track 3. + /// + /// + /// Encrypted Track 3 information returned by a MagneSafe device when a card is swiped. + /// Maps to Payflow Parameter: + /// ENCTRACKE2 + /// + public String EncTrack3 + { + get { return mEncTrack3; } + set { mEncTrack3 = value; } + } + + /// + /// Gets or Sets Magtek KSN + /// + /// + /// 20 character string returned by a MagneSafe device when a card is swiped. + /// Maps to Payflow Parameter: + /// KSN + /// + public String KSN + { + get { return mKSN; } + set { mKSN = value; } + } + + /// + /// Gets or Sets Magtek Card Data Format + /// + /// + /// The code which indicates what type of Card Data Format is being submitted. + /// Maps to Payflow Parameter: + /// MAGTEKCARDTYPE + /// + public String MagtekCardType + { + get { return mMagtekCardType; } + set { mMagtekCardType = value; } + } + + /// + /// Gets or Sets Magtek MagnePrint Status + /// + /// + /// MagnePrint Status of Card Swipe. This is an alpha numeric string, returned by a MagneSafe device when a card is swiped. + /// Maps to Payflow Parameter: + /// MPSTATUS + /// + public String MPStatus + { + get { return mMPStatus; } + set { mMPStatus = value; } + } + /// + /// Gets or Sets Magtek Registered By + /// + /// + /// An alpha numeric entry between 1 and 20 characters long. + /// Maps to Payflow Parameter: + /// REGISTEREDBY + /// + public String RegisteredBy + { + get { return mRegisteredBy; } + set { mRegisteredBy = value; } + } + /// + /// Gets or Sets Magtek Swipe ECR Host + /// + /// + /// MAGT is the only value that is accepted in the SWIPEDECRHOST parameter. + /// Maps to Payflow Parameter: + /// SWIPEDECRHOST + /// + public String SwipedECRHost + { + get { return mSwipedECRHost; } + set { mSwipedECRHost = value; } + } + + /// + /// Gets or Sets Magtek device serial number + /// + /// + /// The device serial number of the Magtek card reader. + /// Maps to Payflow Parameter: + /// DEVICESN + /// + public String DeviceSN + { + get { return mDeviceSN; } + set { mDeviceSN = value; } + } + /// + /// Gets or Sets Magtek Merchant Id + /// + /// + /// Your Merchant ID or the Merchant ID of the merchant redeeming the Protection Code. + /// Maps to Payflow Parameter: + /// MERCHANTID + /// + public String MerchantId + { + get { return mMerchantId; } + set { mMerchantId = value; } + } + /// + /// Gets or Sets Magtek PAN4 + /// + /// + /// The last four digits of the PAN / account number encoded in the card. + /// Maps to Payflow Parameter: + /// PAN4 + /// + public String PAN4 + { + get { return mPAN4; } + set { mPAN4 = value; } + } + /// + /// Gets or Sets Magtek Protection Code + /// + /// + /// The generated Protection Code. + /// Maps to Payflow Parameter: + /// PCODE + /// + public String PCode + { + get { return mPCode; } + set { mPCode = value; } + } + /// + /// Gets or Sets Magtek Authentication Value 1 + /// + /// + /// Authentication Value 1 generated with the PCode. + /// Maps to Payflow Parameter: + /// AUTHVALUE1 + /// + public String AuthValue1 + { + get { return mAuthValue1; } + set { mAuthValue1 = value; } + } + /// + /// Gets or Sets Magtek Authentication Value 2 + /// + /// + /// Authentication Value 2 generated with the PCode. + /// Maps to Payflow Parameter: + /// AUTHVALUE2 + /// + public String AuthValue2 + { + get { return mAuthValue2; } + set { mAuthValue2 = value; } + } + /// + /// Gets or Sets Magtek Authentication Value 3 + /// + /// + /// Authentication Value 3 generated with the PCode. + /// Maps to Payflow Parameter: + /// AUTHVALUE3 + /// + public String AuthValue3 + { + get { return mAuthValue3; } + set { mAuthValue3 = value; } + } + /// + /// Gets or Sets MagTek User Name + /// + /// + /// MagTek user name. + /// Maps to Payflow Parameter: + /// MAGTEKUSERNAME + /// + public String MagtekUserName + { + get { return mMagtekUserName; } + set { mMagtekUserName = value; } + } + /// + /// Gets or Sets Magtek password + /// + /// + /// Magtek password. + /// Maps to Payflow Parameter: + /// MAGTEKPWD + /// + public String MagtekPassword + { + get { return mMagtekPassword; } + set { mMagtekPassword = value; } + } + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_ENCMP, mEncMP)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_ENCRYPTIONBLOCKTYPE, mEncryptionBlockType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_ENCTRACK1, mEncTrack1)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_ENCTRACK2, mEncTrack2)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_ENCTRACK3, mEncTrack3)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_KSN, mKSN)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_MAGTEKCARDTYPE, mMagtekCardType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_REGISTEREDBY, mRegisteredBy)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_SWIPEDECRHOST, mSwipedECRHost)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_DEVICESN, mDeviceSN)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_MPSTATUS, mMPStatus)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_MERCHANTID, mMerchantId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_PAN4, mPAN4)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_PCODE, mPCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_AUTHVALUE1, mAuthValue1)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_AUTHVALUE2, mAuthValue2)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_AUTHVALUE3, mAuthValue3)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_MAGTEKUSERNAME, mMagtekUserName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.MAGTEK_PARAM_MAGTEKPWD, mMagtekPassword)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/MerchantInfo.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/MerchantInfo.cs new file mode 100644 index 0000000..90ce5c9 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/MerchantInfo.cs @@ -0,0 +1,375 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Merchant related information. + /// + /// Use this class to set the Merchant related + /// information. Used for Soft Descriptors. + /// + /// Refer to the Payflow Gateway Developer's Guide for your processor + /// for more information related to this fields. + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Merchant Info details. + /// MerchantInfo Merchant = new MerchantInfo(); + /// Merchant.MerchantName = "MerchantXXXXX"; + /// Merchant.MerchantCity = "Anywhere"; + /// Inv.MerchantInfo = Merchant; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Merchant Info details. + /// Dim Merchant As MerchantInfo = new MerchantInfo + /// Merchant.MerchantName = "MerchantXXXXX" + /// Merchant.MerchantCity = "Anywhere" + /// Inv.MerchantInfo = Merchant + /// ................. + /// + /// + public sealed class MerchantInfo : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Merchant Description + /// + private String mMerchDescr; + /// + /// Merchant Telephone + /// + private String mMerchSvc; + /// + /// Holds Merchant Name + /// + private String mMerchantName; + /// + /// Holds Merchant Street + /// + private String mMerchantStreet; + /// + /// Holds Merchant City + /// + private String mMerchantCity; + /// + /// Holds Merchant State + /// + private String mMerchantState; + /// + /// Holds Merchant CountryCode + /// + private String mMerchantCountryCode; + /// + /// Holds Merchant Zip + /// + private String mMerchantZip; + /// + /// Holds Merchant Url + /// + private String mMerchantUrl; + /// + /// Holds Merchant VAT Number + /// + private String mMerchantVatNum; + /// + /// Holds Merchant Invoice Number + /// + private String mMerchantInvNum; + /// + /// MerrchantLocationId + /// + private String mMerchantLocationId; + /// + /// MerchantId + /// + private String mMerchantId; + /// + /// MerchantContactInfo + /// + private String mMerchantContactInfo; + + #endregion + + #region "Constructor" + /// + /// Constructor + /// + /// + /// Use this class to set the Soft merchant information which is detailed data about a merchant such + /// as the merchant's name, business address, business location identifier, and contact information. + /// + /// + /// + /// ................. + /// // Inv is the Invoice object + /// ................. + /// // Set the Merchant Info details. + /// MerchantInfo Merchant = New MerchantInfo(); + /// Merchant.MerchantName = "MerchantXXXXX"; + /// Merchant.MerchantCity = "Somewhere"; + /// Inv.MerchantInfo = Merchant; + /// ................. + /// + /// + /// ................. + /// ' Inv is the Invoice object + /// ................. + /// ' Set the Merchant Info details. + /// Dim Merchant As MerchantInfo = New MerchantInfo + /// Merchant.MerchantName = "MerchantXXXXX" + /// Merchant.MerchantCity = "Somewhere" + /// Inv.MerchantInfo = Merchant + /// ................. + /// + /// + public MerchantInfo() + { + } + #endregion + + #region "Properties" + + /// + /// Gets, Sets Merchant Name + /// + /// + /// Name of Merchant + /// Maps to Payflow Parameter: + /// MERCHANTNAME + /// + public String MerchantName + { + get { return mMerchantName; } + set { mMerchantName = value; } + } + /// + /// Gets, Sets Merchant Street + /// + /// + /// Merchant's Street Address (Number and Street Name) + /// Maps to Payflow Parameter: + /// MERCHANTSTREET + /// + public String MerchantStreet + { + get { return mMerchantStreet; } + set { mMerchantStreet = value; } + } + /// + /// Gets, Sets Merchant City + /// + /// + /// Merchant's City + /// Maps to Payflow Parameter: + /// MERCHANTCITY + /// + public String MerchantCity + { + get { return mMerchantCity; } + set { mMerchantCity = value; } + } + /// + /// Gets, Sets Merchant State + /// + /// + /// Merchant's State + /// Maps to Payflow Parameter: + /// MERCHANTSTATE + /// + public String MerchantState + { + get { return mMerchantState; } + set { mMerchantState = value; } + } + /// + /// Gets, Sets Merchant Country Code + /// + /// + /// Merchant's Numeric Country Code. Example: USA = 840 + /// Maps to Payflow Parameter: + /// MERCHANTCOUNTRYCODE + /// + public String MerchantCountryCode + { + get { return mMerchantCountryCode; } + set { mMerchantCountryCode = value; } + } + /// + /// Gets, Sets Merchant Zip + /// + /// + /// Merchant's 5- to 9-digit ZIP (postal) code excluding + /// spaces, dashes, and non-numeric characters. + /// Maps to Payflow Parameter: + /// MERCHANTZIP + /// + public String MerchantZip + { + get { return mMerchantZip; } + set { mMerchantZip = value; } + } + + /// + /// Gets, Sets Merchant Url + /// + /// + /// Merchant's website (URL) + /// Maps to Payflow Parameter: + /// MERCHANTURL + /// + public String MerchantUrl + { + get { return mMerchantUrl; } + set { mMerchantUrl = value; } + } + + /// + /// Gets, Sets Merchant VAT Number + /// + /// + /// Merchant's VAT Number + /// Maps to Payflow Parameter: + /// MERCHANTVATNUM + /// + public String MerchantVatNum + { + get { return mMerchantVatNum; } + set { mMerchantVatNum = value; } + } + + /// + /// Gets, Sets Merchant Invoice Number + /// + /// + /// Merchant's Invoice Number + /// Maps to Payflow Parameter: + /// MERCHANTINVNUM + /// + public String MerchantInvNum + { + get { return mMerchantInvNum; } + set { mMerchantInvNum = value; } + } + + /// + /// Gets, Sets the Merchant Location Id. + /// + /// Merchant assigned store or location number. + /// + /// Maps to Payflow Parameter: + /// MERCHANTLOCATIONID + /// + public String MerchantLocationId + { + get { return mMerchantLocationId; } + set { mMerchantLocationId = value; } + } + /// + /// Gets, Sets the Merchant Id. + /// + /// Processor assigned number. + /// + /// Maps to Payflow Parameter: + /// MERCHANTID + /// + public String MerchantId + { + get { return mMerchantId; } + set { mMerchantId = value; } + } + /// + /// Gets, Sets the Merchant Contact Information. + /// + /// Merchants telephone, URl or email. + /// + /// Maps to Payflow Parameter: + /// MERCHANTCONTACTINFO + /// + public String MerchantContactInfo + { + get { return mMerchantContactInfo; } + set { mMerchantContactInfo = value; } + } + + /// + /// Gets, Sets MerchDescr + /// + /// + /// Merchant's description. + /// Maps to Payflow Parameter: + /// MERCHDESCR + /// + /// + public String MerchDescr + { + get { return mMerchDescr; } + set { mMerchDescr = value; } + } + + /// + /// Gets, Sets MerchSvc + /// + /// + /// Merchant's contact number. + /// Maps to Payflow Parameter: + /// MERCHSVC + /// + public String MerchSvc + { + get { return mMerchSvc; } + set { mMerchSvc = value; } + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTNAME, mMerchantName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTSTREET, mMerchantStreet)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTCITY, mMerchantCity)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTSTATE, mMerchantState)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTZIP, mMerchantZip)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTCOUNTRYCODE, mMerchantCountryCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTURL, mMerchantUrl)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTVATNUM, mMerchantVatNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTINVNUM, mMerchantInvNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTLOCATIONID, mMerchantLocationId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTID, mMerchantId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHANTCONTACTINFO, mMerchantContactInfo)); + + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHDESCR, mMerchDescr)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MERCHSVC, mMerchSvc)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + } + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/NamespaceDoc.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/NamespaceDoc.cs new file mode 100644 index 0000000..241f9a8 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/NamespaceDoc.cs @@ -0,0 +1,318 @@ + +namespace PayPal.Payments.DataObjects +{ + /// + /// This is the Payflow Parameter Mapping supported in current release. + /// Payflow ParamData ObjectProperty ReferenceData type + /// ABABankAcctAbaString + /// ACCTBankAcct , CreditCard , PurchaseCard , SwipeCard , CheckPayment , RecurringResponse, TransactionResponseAcctString + /// ACCTTYPEBankAcctAcctTypeString + /// ACITransactionResponseAciString + /// ACSURLBuyerAuthResponseAcsUrlString + /// ACTIONValue is set based on Transaction object used:RecurringAddTransaction, RecurringModifyTransaction, RecurringCancelTransaction, RecurringInquiryTransaction, RecurringReActivateTransaction, RecurringPaymentTransactionNAString + /// ADDLAMTnAdviceDetailAddLAmtString + /// ADDLAMTTYPEnAdviceDetailAddLAmtTypeString + /// ADDLMSGSTransactionResponseAddlMsgsString + /// ADDROVERRIDEECSetRequestAddrOverrideString + /// ADDRSTATUSECGetResponseAddressStatusString + /// AGGREGATEAMTRecurringResponseAggregateAmtString + /// AGGREGATEOPTIONALAMTRecurringResponseAggregateOptionalAmtString + /// ALTTAXAMTInvoiceAltTaxAmtCurrency + /// AMEXIDTransactionResponseAmexIDString + /// AMEXPOSIDTransactionResponseAmexPosDataString + /// AMTInvoice, RecurringResponse ,BuyerAuthVETransaction ,ECDoResponse, TransactionResponseAmtCurrency (Invoice) ,String(RecurringResponse),Currency + /// AUTHCODEVoiceAuthTransaction, TransactionResponseAuthCodeString + /// AUTHENTICATION_IDBuyerAuthResponseAuthentication_IdString + /// AUTHENTICATION_STATUSBuyerAuthResponseAuthentication_StatusString + /// AUTHTYPEACHTenderAuthTypeString + /// AVSADDRTransactionResponseAVSAddrString + /// AVSZIPTransactionResponseAVSZipString + /// BA_CUSTOMECSetRequestBA_CustomString + /// BA_DESCECSetRequestBA_DescString + /// BAIDECDoResponseBAIdString + /// BALAMTTransactionResponseBalAmtString + /// BILLINGTYPEECSetRequestBillingTypeString + /// BATCHIDTransactionResponseBatchIdString + /// BILLINGTYPEECSetRequestBillingTypeString + /// BILLTOCITYBillTo, RecurringResponseBillToCityString + /// BILLTOCOUNTRYBillTo, RecurringResponseBillToCountryString + /// BILLTOEMAILBillTo,RecurringResponse,ECGetResponseBillToEmailString + /// BILLTOFAXBillToBillToFaxString + /// BILLTOFIRSTNAMEBillTo, RecurringResponse ,ECGetResponse, TransactionResponseBillToFirstNameString + /// BILLTOHOMEPHONEBillToBillToHomePhoneString + /// BILLTOLASTNAMEBillTo, RecurringResponse,ECGetResponse, TransactionResponseBillToLastNameString + /// BILLTOMIDDLENAMEBillTo, RecurringResponseBillToMiddleNameString + /// BillToPHONENUMBillTo, RecurringResponseBillToPhoneNumString + /// BILLTOPHONE2BillToBillToPhone2String + /// BILLTOSTATEBillTo, RecurringResponseBillToStateString + /// BILLTOSTREETBillTo, RecurringResponseBillToStreetString + /// BILLTOSTREET2BillToBillToStreet2String + /// BILLTOZIPBillTo, RecurringResponseBillToZipString + /// BROWSERCOUNTRYCODEBrowserInfoBrowserCountryCodeString + /// BROWSERTIMEBrowserInfoBrowserTimeString + /// BROWSERUSERAGENTBrowserInfoBrowserUserAgentString + /// BUTTONSOURCEBrowserInfoButtonSourceString + /// CANCELURLECSetRequestCancelURLString + /// CAPTURECOMPLETECaptureTransactionString + /// CARDISSUEPurchaseCard, CreditCardCardIssueString + /// CARDSECURETransactionResponseCardSecureString + /// CARDSTARTPurchaseCard, CreditCardCardStartString + /// CARDTYPETransactionResponseCardTypeString + /// CATTYPEDevicesCatTypeString + /// CAVVBuyerAuthResponseCAVVString + /// CCTRANSIDTransactionResponseCCTransIdString + /// CCTRANS_POSDATATransactionResponseCCTrans_POSDataString + /// CHKNUMACHTender, CheckTender, CardTenderChkNumString + /// CHKTYPEACHTender, CheckTender, CardTenderChkTypeString + /// COMMCARDPurchaseCardString + /// COMMCODEInvoiceCommCodeString + /// COMMENT1InvoiceComment1String + /// COMMENT2InvoiceComment2String + /// COMPANYNAMEBillTo, RecurringResponseCompanyNameString + /// CONTACTLESSDevicesContactlessString + /// COUNTRYCODEBillTo,ECGetResponseCountryCodeString + /// COUNTRYCODEExpressCheckoutRequestCountryCodeString + /// CURRENCYBuyerAuthVETransactionCurrency + /// CUSTCODECustomerInfoCustCodeString + /// CUSTDATACustomerInfoCustDataString + /// CUSTIDCustomerInfoCustIdString + /// CUSTIPCustomerInfoCustIPString + /// CUSTOMBrowserInfoCustomString + /// CUSTOMERIDCustomerInfoCustomerIdString + /// CUSTOMERNUMBERCustomerInfoCustomerNumberString + /// CUSTREFInvoice, TransactionResponseCustRefString + /// CUSTVATREGNUMCustomerInfoCustVatRegNumString + /// CVV2PurchaseCard, CreditCardCVV2String + /// CVV2MATCHTransactionResponseCVV2MatchString + /// DATETOSETTLETransactionResponseDateToSettleString + /// DESCInvoiceDescString + /// DESC1InvoiceDesc1String + /// DESC2InvoiceDesc2String + /// DESC3InvoiceDesc3String + /// DESC4InvoiceDesc4String + /// DISCOUNTInvoiceDiscountCurrency + /// DLBaseTenderDLString + /// DOBCustomerInfoDOBString + /// DUPLICATETransactionResponseDuplicateString + /// DUTYAMTInvoiceDutyAmtCurrency + /// ECIBuyerAuthResponseECIString + /// EMAILMATCHTransactionResponseEmailMatchString + /// ENDTIMEInvoice, TransactionResponseEndTimeDateTime + /// EXCHANGERATEECDoResponseExchangeRateString + /// EXPDATECreditCard, PurchaseCard, RecurringResponse, TransactionResponseExpDateString + /// EXTRSPMSGTransactionResponseExtRspMsgString + /// FEEAMTTransactionResponseFeeAmtString + /// FPS_POSTXMLDATAFraudResponseFps_PostXmlDataFpsXmlData object + /// FPS_PREXMLDATAFraudResponseFps_PreXmlDataFpsXmlData object + /// FREIGHTAMTInvoiceFreightAmtCurrency + /// HANDLINGAMTInvoiceHandlingAmtCurrency + /// HDRBACKCOLORECSetRequestHeaderBackColorString + /// HDRBORDERCOLORECSetRequestHeaderBorderColorString + /// HDRIMGECSetRequestHeaderImageString + /// HOSTADDRESSPayflowConnectionDataHostAddressString + /// HOSTCODETransactionResponseHostCodeString + /// HOSTPORTPayflowConnectionDataHostPortint + /// IAVSTransactionResponseIAVSString + /// INVNUMInvoiceInvNumString + /// INVOICEDATEInvoiceInvoiceDateDate + /// L_ALTTAXAMTnLineItemAltTaxAmtCurrency + /// L_ALTTAXIDnLineItemAltTaxIdCurrency + /// L_ALTTAXRATEnLineItemAltTaxRateCurrency + /// L_AMTnLineItemAmtCurrency + /// L_CARRIERSERVICELEVELCODEnLineItemCarrierServiceLevelCodeCurrency + /// L_CATALOGNUMnLineItemCatalogNumString + /// L_COMMCODEnLineItemCommCodeString + /// L_COSTCENTERNUMnLineItemCostCenterNumString + /// L_COSTnLineItemCostCurrency + /// L_DESCnLineItemDescString + /// L_DISCOUNTnLineItemDiscountCurrency + /// L_EXTAMTnLineItemExtAmtCurrency + /// L_FREIGHTAMTnLineItemFreightAmtCurrency + /// L_HANDLINGAMTnLineItemHandlingAmtCurrency + /// L_MANUFACTURERnLineItemManufacturerString + /// L_PICKUPCITYnLineItemPickupCityString + /// L_PICKUPCOUNTRYnLineItemPickupCountryString + /// L_PICKUPSTATEnLineItemPickupStateString + /// L_PICKUPSTREETnLineItemPickupStreetString + /// L_PICKUPZIPnLineItemPickupZipString + /// L_PRODCODEnLineItemProdCodeString + /// L_QTYnLineItemQtyint + /// L_SKUnLineItemSKUString + /// L_TAXAMTnLineItemTaxAmtCurrency + /// L_TAXRATEnLineItemTaxRateCurrency + /// L_TAXTYPEnLineItemTaxTypeString + /// L_TRACKINGNUMnLineItemTrackingNumString + /// L_TYPEnLineItemTypeString + /// L_UNSPSCCODEnLineItemUnspscCodeString + /// L_UOMnLineItemUOMString + /// L_UPCnLineItemUPCString + /// LOCALECODEECSetRequestLocaleCodeString + /// LOCALTAXAMTInvoiceLocalTaxAmtCurrency + /// MAXAMTECSetRequestMaxAmtString + /// MAXFAILPAYMENTSRecurringResponse, RecurringInfoMaxFailPaymentsString + /// MDBuyerAuthResponseMDString + /// MERCHDESCRPurchaseCard, CreditCardMerchDescrString + /// MERCHSVCPurchaseCard, CreditCardMerchSvcString + /// MERCHANTCITYCMerchantInfoMerchantCityString + /// MERCHANTCONTACTINFOMerchantInfoMerchantContactInfoString + /// MERCHANTIDMerchantInfoMerchantIdString + /// MERCHANTINVNUMMerchantInfo>MerchantInvNumString + /// MERCHANTLOCATIONIDMerchantInfoMerchantLocationIdString + /// MERCHANTNAMEMerchantInfoMerchantNameString + /// MERCHANTSTATEMerchantInfoMerchantStateString + /// MERCHANTSTREETMerchantInfoMerchantStreetString + /// MERCHANTURLMerchantInfoMerchantUrlString + /// MERCHANTVATNUMMerchantInfoMerchantVatNumString + /// MERCHANTZIPMerchantInfoMerchantZipString + /// MICRCheckPaymentString + /// MISCDATAInvoiceMiscDataCurrency + /// NAMEBankAcct, CreditCard, PurchaseCard, SwipeCard, CheckPayment, RecurringResponseNameString + /// NATIONALTAXAMTInvoiceNationalTaxAmtCurrency + /// NEXTPAYMENTRecurringResponseNextPaymentString + /// NOSHIPPINGECSetRequestNoShippingString + /// NOTIFYURLBrowserInfoNotifyURLString + /// OPTIONALTRXRecurringInfoOptionalTrxString + /// OPTIONALTRXAMTRecurringInfoOptionalTrxAmtCurrency + /// ORDERDATEInvoiceOrderDateString + /// ORDERDESCInvoiceOrderDescString + /// ORDERIDInvoiceOrderIdString + /// ORDERTIMEInvoiceOrderTimeString + /// ORIGAMTTransactionResponseOrigAmtString + /// ORIGIDReferenceTransaction, CaptureTransaction, FraudReviewTransaction, InquiryTransaction, VoidTransactionOrigIdString + /// ORIGPROFILEIDRecurringInfoOrigProfileIdString + /// ORIGRESULTTransactionResponseOrigResultString + /// P_AMTnRecurringResponseInquiryParamsString + /// P_PNREFnRecurringResponseInquiryParamsString + /// P_RESULTnRecurringResponseInquiryParamsString + /// P_TENDERnRecurringResponseInquiryParamsString + /// P_TRANSTATEnRecurringResponseInquiryParamsString + /// P_TRANSTIMEnRecurringResponseInquiryParamsString + /// PAGESTYLEECSetRequestPageStyleString + /// PAREQBuyerAuthResponsePaReqString + /// PARESBuyerAuthVATransactionString + /// PARTIALAUTHAuthorizationTransactionString + /// PARTNERUserInfoString + /// PAYERIDECDoRequest ,ECGetResponsePayerIdString + /// PAYERSTATUSECGetResponsePayerStatusString + /// PAYFLOWCOLORECSetRequestPayFlowColorString + /// PAYMENTDATEECDoResponsePaymentDateString + /// PAYMENTHISTORYRecurringInfoPaymentHistoryString + /// PAYMENTNUMRecurringInfoPaymentNumString + /// PAYMENTSLEFTRecurringResponsePaymentsLeftString + /// PAYMENTSTATUSECDoResponsePaymentStatusString + /// PAYMENTTYPETransactionResponsePaymentTypeString + /// PAYPALCHECKOUTBTNTYPEPayLaterPayPalCheckoutBtnTypeString + /// PAYPERIODRecurringResponse, RecurringInfoPayPeriodString + /// PENDINGREASONTransactionResponsePendingReasonString + /// PHONEMATCHTransactionResponsePhoneMatchString + /// PNREFTransactionResponsePnrefString + /// PONUMInvoicePoNumString + /// POSTALCODEExpressCheckoutRequestPostalCodeString + /// POSTFPSMSGFraudResponsePostFpsMsgString + /// PPREFTransactionResponsePPrefString + /// PREFPSMSGFraudResponsePreFpsMsgString + /// PRENOTEACHTenderPreNoteString + /// PROCAVSTransactionResponseProcAVSString + /// PROCCARDSECURETransactionResponseProcCardSecureString + /// PROCCVV2TransactionResponseProcCVV2String + /// PRODUCTCATEGORYPayLaterProductCategoryString + /// PROFILEADDRESSCHANGEDATEPayLaterProfileAddressChangeDateString + /// PROFILEIDRecurringResponseProfileIdString + /// PROFILENAMERecurringResponse, RecurringInfoProfileNameString + /// PROMOCODEPayLaterLineItemPromoCodeString + /// PROMOCODEOVERRIDEPayLaterPromoCodeOverrideString + /// PROXYADDRESSPayflowConnectionDataProxyAddressString + /// PROXYLOGONPayflowConnectionDataProxyLogonString + /// PROXYPASSWORDPayflowConnectionDataProxyPasswordString + /// PROXYPORTPayflowConnectionDataProxyPortint + /// PUR_DESCBuyerAuthVETransactionString + /// PWDUserInfoString + /// RECURRINGRecurringInfo, InvoiceRecurringString + /// RECURRINGTYPEInvoiceRecurringTypeString + /// REPORTGROUPInvoiceReportGroupCurrency + /// REQCONFIRMSHIPPINGECSetRequestReqConfirmShippingString + /// REQNAMECustomerInfoReqNameString + /// RESPMSGTransactionResponseRespMsgString + /// RESPTEXTTransactionResponseRespTextString + /// RESULTTransactionResponseResultString + /// RETRYNUMDAYSRecurringResponse, RecurringInfoRetryNumDaysString + /// RETURNURLECSetRequestReturnURLString + /// RPREFRecurringResponseRPRefString + /// RRNTransactionResponseRrnString + /// SECURETOKENTransactionResponseSecureTokenString + /// SECURETOKENIDTransactionResponseSecureTokenIdString + /// SETTLEAMTECDoResponseSettleAmtString + /// SHIPCARRIERShipToShipCarrierString + /// SHIPFROMZIPShipToShipFromZipString + /// SHIPMETHODShipToShipMethodString + /// SHIPPEDFROMZIPShipToShipFromZipString + /// SHIPPINGMETHODPayLaterShippingMethodString + /// SHIPTOBUSINESSECGetResponseShipToBusinessString + /// SHIPTOCITYShipTo, RecurringResponse,ECGetResponseShipToCityString + /// SHIPTOCOUNTRYShipTo, RecurringResponse,ECGetResponseShipToCountryString + /// SHIPTOEMAILShipToShipToEmailString + /// SHIPTOFIRSTNAMEShipTo, RecurringResponse ,ECGetResponseShipToFirstNameString + /// SHIPTOLASTNAMEShipTo, RecurringResponse,ECGetResponseShipToLastNameString + /// SHIPTOMIDDLENAMEShipTo, RecurringResponseShipToMiddleNameString + /// SHIPTOPHONEShipToShipToPhoneString + /// SHIPTOPHONE2ShipToShipToPhone2String + /// SHIPTOSTATEShipTo, RecurringResponse,ECGetResponseShipToStateString + /// SHIPTOSTREETShipTo, RecurringResponse,ECGetResponseShipToStreetString + /// SHIPTOSTREET2ShipTo, ECGetResponseShipToStreet2String + /// SHIPTOZIPShipTo, RecurringResponse,ECGetResponseShipToZipString + /// SSCheckTenderString + /// STANTransactionResponseStanString + /// STARTRecurringResponse, RecurringInfoStartString + /// STARTTIMEInvoice, TransactionResponseStartTimeString + /// STATUSRecurringResponseStatusString + /// SWIPESwipeCardString + /// TAXAMTInvoice ,ECDoResponseTaxAmtCurrency + /// TAXEXEMPT InvoiceTaxExemptBoolean + /// TENDERValue is set based on Data object used:ACHTender, CardTender, CheckTender. Used in RecurringResponse also.TenderString + /// TERMRecurringResponse, RecurringInfoTermString + /// TERMCITYACHTenderTermCityString + /// TERMSTATEACHTenderTermStateString + /// TIMEOUTPayflowConnectionDataTimeOutint + /// TOKENExpressCheckoutRequestTokenString + /// TRANSSTATETransactionResponseTransStateString + /// TRANSTIMETransactionResponseTransTimeString + /// TRXPNREFRecurringResponseTrxPNRefString + /// TRXRESPMSGRecurringResponseTrxRespMsgString + /// TRXRESULTRecurringResponseTrxResultString + /// TRXTYPEValue is set based on the Transaction object used:SaleTransaction, CreditTransaction, VoidTransaction, CaptureTransaction etc.TrxTypeString + /// TXIDBuyerAuthResponseTxIdString + /// USERUserInfoString + /// USER1UserItemUserItem1String + /// USER2UserItemUserItem2String + /// USER3UserItemUserItem3String + /// USER4UserItemUserItem4String + /// USER5UserItemUserItem5String + /// USER6UserItemUserItem6String + /// USER7UserItemUserItem7String + /// USER8UserItemUserItem8String + /// USER9UserItemUserItem9String + /// USER10UserItemUserItem10String + /// VALIDATRIONCODETransactionResponseValidationCodeString + /// VATINVNUMInvoiceVatInvNumString + /// VATREGNUMInvoiceVatRegNumString + /// VATTAXAMTInvoiceVatTaxAmtCurrency + /// VATTAXPERCENTInvoiceVatTaxPercentString + /// VATTAXRATEInvoiceVatTaxRateString + /// VENDORUserInfoString + /// VERBOSITYValue is set based on the Transaction object used:SaleTransaction, CreditTransaction, VoidTransaction, CaptureTransaction, AuthorizationTransaction, VoiceAuthTransaction, InquiryTransaction, FraudReviewTransaction, RecurringAddTransaction, RecurringModifyTransaction, RecurringCancelTransaction, RecurringInquiryTransaction, RecurringReActivateTransaction, RecurringPaymentTransactionVerbosityString + /// VIT_INTGTYPEValue is set from all the Transaction objects: SaleTransaction, CreditTransaction, VoidTransaction, CaptureTransaction etc.Vit_IntgTypeString + /// VIT_INTGVERSIONValue is set from all the Transaction objects: SaleTransaction, CreditTransaction, VoidTransaction, CaptureTransaction etc.Vit_IntgVersionString + /// VIT_OSARCHInternal to the SDK.String + /// VIT_OSNAMEInternal to the SDK.String + /// VIT_OSVERSIONInternal to the SDK.String + /// VIT_PROXYInternal to the SDK.String + /// VIT_SDKRUNTIMEVERSIONInternal to the SDK.String + /// XIDBuyerAuthResponseXIDString + /// PAYFLOW-REQUEST-ID (Header)Value is set from all the transactions:SaleTransaction, CaptureTransaction, VoidTransaction etc.RequestIdString + /// + /// + + internal class NamespaceDoc + { + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayLater.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayLater.cs new file mode 100644 index 0000000..888dbee --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayLater.cs @@ -0,0 +1,419 @@ +#region "Imports" + +using System; +using System.Collections; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used as the PayPal PayLater class. All the customers promotional financing + /// related information can be stored in this class. + /// + /// + /// PayPal Pay Later is a new, convenient, and secure service that allows you to offer your + /// customers promotional financing. Buyers that choose the promotional offer can defer + /// payments for purchases on participating merchant web sites, allowing them to shop now and + /// pay later. + /// The PayPal Pay Later service allows online merchants to offer promotional financing to + /// buyers at checkout - even if a buyer doesn't have a PayPal account. Promotional offers, such as + /// no payments for 90 days, give merchants new and powerful ways to market to online + /// shoppers. + /// + /// PayPal's new promotional financing is currently available to consumers and select merchants + /// in the U.S. If you are a merchant and would like to add this service, please contact your sales + /// representative for information and additional documentation. + /// + /// + /// Following example shows how to use PayLater in the Express Checkout Set call. + /// + /// ................. + /// //Create the data object for PayLater + /// PayLater setPayLater = new PayLater(); + /// setPayLater.ShippingMethod = "UPSGround"; + /// setPayLater.ProductCategory = "E"; // Camera and Photos + /// setPayLater.PayPalCheckoutBtnType = "P"; + /// // You can combine up to 10 promotions for PayPal Promotional Financing. + /// // L_PROMOCODE0 + /// PayLaterLineItem setPayLaterLineItem = new PayLaterLineItem(); + /// setPayLaterLineItem.PromoCode = "101"; + /// setPayLater.PayLaterAddLineItem(setPayLaterLineItem); + /// // L_PROMOCODE1 + /// PayLaterLineItem setPayLaterLineItem1 = new PayLaterLineItem(); + /// setPayLaterLineItem1.PromoCode = "102"; + /// setPayLater.PayLaterAddLineItem(setPayLaterLineItem1); + /// // If using Pay Later, you would create the data object as below. + /// ECSetRequest setRequest = new ECSetRequest("http://www.myreturnurl.com", "http://www.mycancelurl.com", setPayLater); + /// ................. + /// + /// + /// ................. + /// Dim SetPayLater As New PayLater + /// SetPayLater.ShippingMethod = "UPSGround" + /// SetPayLater.ProductCategory = "E" ' Camera and Photos + /// SetPayLater.PayPalCheckoutBtnType = "P" + /// ' You can combine up to 10 promotions for PayPal Promotional Financing. + /// ' L_PROMOCODE0 + /// Dim SetPayLaterLineItem As New PayLaterLineItem + /// SetPayLaterLineItem.PromoCode = "101" + /// SetPayLater.PayLaterAddLineItem(SetPayLaterLineItem) + /// ' L_PROMOCODE1 + /// Dim SetPayLaterLineItem1 As New PayLaterLineItem + /// SetPayLaterLineItem1.PromoCode = "102" + /// SetPayLater.PayLaterAddLineItem(SetPayLaterLineItem1) + /// ' If using Pay Later, you would create the data object as below. + /// Dim SetRequest As New ECSetRequest("http://www.myreturnurl.com", "http://www.mycancelurl.com", setPayLater) + /// ................. + /// + /// + public class PayLater : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Product Category + /// + private String mProductCategory; + + /// + /// Shipping Method + /// + private String mShippingMethod; + + /// + /// PayPal Checkout Button Type + /// + private String mPayPalCheckoutBtnType; + + /// + /// Profile Address Change Date + /// + private String mProfileAddressChangeDate; + + /// + /// Promo Code Override + /// + private String mPromoCodeOverride; + + /// + /// List of Line Items + /// + private ArrayList mItemList; + + #endregion + + #region "Constructors" + + /// + /// Constructor. + /// + /// + /// PayPal Pay Later is a new, convenient, and secure service that allows you to offer your + /// customers promotional financing. Buyers that choose the promotional offer can defer + /// payments for purchases on participating merchant web sites, allowing them to shop now and + /// pay later. + /// The PayPal Pay Later service allows online merchants to offer promotional financing to + /// buyers at checkout - even if a buyer doesn't have a PayPal account. Promotional offers, such as + /// no payments for 90 days, give merchants new and powerful ways to market to online + /// shoppers. + /// + /// PayPal's new promotional financing is currently available to consumers and select merchants + /// in the U.S. If you are a merchant and would like to add this service, please contact your sales + /// representative for information and additional documentation. + /// + /// + /// Following example shows how to use PayLater in the Express Checkout Set call. + /// + /// ................. + /// //Create the data object for PayLater + /// PayLater setPayLater = new PayLater(); + /// setPayLater.ShippingMethod = "UPSGround"; + /// setPayLater.ProductCategory = "E"; // Camera and Photos + /// setPayLater.PayPalCheckoutBtnType = "P"; + /// // You can combine up to 10 promotions for PayPal Promotional Financing. + /// // L_PROMOCODE0 + /// PayLaterLineItem setPayLaterLineItem = new PayLaterLineItem(); + /// setPayLaterLineItem.PromoCode = "101"; + /// setPayLater.PayLaterAddLineItem(setPayLaterLineItem); + /// // L_PROMOCODE1 + /// PayLaterLineItem setPayLaterLineItem1 = new PayLaterLineItem(); + /// setPayLaterLineItem1.PromoCode = "102"; + /// setPayLater.PayLaterAddLineItem(setPayLaterLineItem1); + /// // If using Pay Later, you would create the data object as below. + /// ECSetRequest setRequest = new ECSetRequest("http://www.myreturnurl.com", "http://www.mycancelurl.com", setPayLater); + /// ................. + /// + /// + /// ................. + /// Dim SetPayLater As New PayLater + /// SetPayLater.ShippingMethod = "UPSGround" + /// SetPayLater.ProductCategory = "E" ' Camera and Photos + /// SetPayLater.PayPalCheckoutBtnType = "P" + /// ' You can combine up to 10 promotions for PayPal Promotional Financing. + /// ' L_PROMOCODE0 + /// Dim SetPayLaterLineItem As New PayLaterLineItem + /// SetPayLaterLineItem.PromoCode = "101" + /// SetPayLater.PayLaterAddLineItem(SetPayLaterLineItem) + /// ' L_PROMOCODE1 + /// Dim SetPayLaterLineItem1 As New PayLaterLineItem + /// SetPayLaterLineItem1.PromoCode = "102" + /// SetPayLater.PayLaterAddLineItem(SetPayLaterLineItem1) + /// ' If using Pay Later, you would create the data object as below. + /// Dim SetRequest As New ECSetRequest("http://www.myreturnurl.com", "http://www.mycancelurl.com", setPayLater) + /// ................. + /// + /// + public PayLater() + { + mItemList = new ArrayList(); + } + + #endregion + + #region "Properties" + + /// + /// Gets, Sets ShippingMethod + /// + /// + /// Use this method to set the Shipping method + /// for this transaction. + /// Maps to Payflow Parameter: + /// SHIPPINGMETHOD + /// + public String ShippingMethod + { + get { return mShippingMethod; } + set { mShippingMethod = value; } + } + + /// + /// Gets, Sets PromoCodeOverride + /// + /// + /// Value is 0 or 1. Default value is 0. + /// Set to 1 to override promotions from Set Express + /// Checkout request. Otherwise, promotions will not be + /// overridden. + /// Maps to Payflow Parameter: + /// PROMOCODEOVERRIDE + /// + public String PromoCodeOverride + { + get { return mPromoCodeOverride; } + set { mPromoCodeOverride = value; } + } + + /// + /// Gets, Sets ProfileAddressChangeDate + /// + /// + /// The last date that the billing address + /// stored in the customers profile with the merchant + /// was changed. The date must be in UTC/GMT format. + /// For example, 2007-12-15T17:23:15Z. + /// Maps to Payflow Parameter: + /// PROFILEADDRESSCHANGEDATE + /// + public String ProfileAddressChangeDate + { + get { return mProfileAddressChangeDate; } + set { mProfileAddressChangeDate = value; } + } + + /// + /// Gets, Sets PayPalCheckoutBtnType + /// + /// + /// Only for the No payment 90 days button, you + /// must set this variable to P, which allows PayPal + /// to make 90 days no payments the default payment + /// option in the PayPal checkout flow. + /// Maps to Payflow Parameter: + /// PAYPALCHECKOUTBTNTYPE + /// + public String PayPalCheckoutBtnType + { + get { return mPayPalCheckoutBtnType; } + set { mPayPalCheckoutBtnType = value; } + } + + /// + /// Gets, Sets ProductCategory + /// + /// + /// The product category for this order. If the + /// customers cart contains more than one item, use + /// the product category for the most expensive item. + /// Maps to Payflow Parameter: + /// PRODUCTCATEGORY + /// + public String ProductCategory + { + get { return mProductCategory; } + set { mProductCategory = value; } + } + + #endregion + + #region "LineItem related Methods" + + /// + /// Add a promo code to promo code. + /// + /// Lineitem object + /// + /// Use this method to add a promo code to the request. A promotion code for + /// PayPal Promotional Financing where n is a value from 0 to 9. The first promotion + /// must be specified as L_PROMOCODE0. Combine promotions by using additonal parameters, + /// such as L_PROMOCODE1 and L_PROMOCODE2. + /// + /// + /// + /// // You can combine up to 10 promotions for PayPal Promotional Financing. + /// // L_PROMOCODE0 + /// PayLaterLineItem setPayLaterLineItem = new PayLaterLineItem(); + /// setPayLaterLineItem.PromoCode = "101"; + /// setPayLater.PayLaterAddLineItem(setPayLaterLineItem); + /// // L_PROMOCODE1 + /// PayLaterLineItem setPayLaterLineItem1 = new PayLaterLineItem(); + /// setPayLaterLineItem1.PromoCode = "102"; + /// setPayLater.PayLaterAddLineItem(setPayLaterLineItem1); + /// ................. + /// + /// + /// ' You can combine up to 10 promotions for PayPal Promotional Financing. + /// ' L_PROMOCODE0 + /// Dim SetPayLaterLineItem As New PayLaterLineItem + /// SetPayLaterLineItem.PromoCode = "101" + /// SetPayLater.PayLaterAddLineItem(SetPayLaterLineItem) + /// ' L_PROMOCODE1 + /// Dim SetPayLaterLineItem1 As New PayLaterLineItem + /// SetPayLaterLineItem1.PromoCode = "102" + /// SetPayLater.PayLaterAddLineItem(SetPayLaterLineItem1) + /// ................. + /// + /// + public void PayLaterAddLineItem(PayLaterLineItem Item) + { + mItemList.Add(Item); + } + + /// + /// Removes a promo code from line item list. + /// + /// Index of promo code to be removed. + /// + /// Use this method to remove a promo code at a particular index + /// in the requester. + /// + /// + /// + /// ................. + /// // SetPayLaterLineItem is the PayLater object + /// ................. + /// // Remove item at index 0 + /// setPayLater.PayLaterRemoveLineItem(0); + /// ................. + /// + /// + /// ................. + /// ' SetPayLaterLineItem is the PayLater object + /// ................. + /// ' Remove item at index 0; + /// SetPayLater.PayLaterRemoveLineItem(0) + /// ................. + /// + /// + public void PayLaterRemoveLineItem(int Index) + { + mItemList.RemoveAt(Index); + } + + /// + /// Clears the promo code list. + /// + /// + /// Use this method to clear all the + /// promo codes added to the request. + /// + /// + /// + /// ................. + /// // SetPayLaterLineItem is the PayLater object + /// ................. + /// // Remove all line items. + /// setPayLater.PayLaterRemoveAllLineItems(); + /// ................. + /// + /// + /// ................. + /// ' SetPayLaterLineItem is the PayLater object + /// ................. + /// ' Remove all line items. + /// SetPayLater.PayLaterRemoveAllLineItems() + /// ................. + /// + /// + public void PayLaterRemoveAllLineItems() + { + mItemList.Clear(); + } + + /// + /// Generates transaction request for promo codes + /// + private void GenerateItemRequest() + { + for (int Index = 0; Index < mItemList.Count; Index++) + { + PayLaterLineItem Item = (PayLaterLineItem) mItemList[Index]; + if (Item != null) + { + Item.RequestBuffer = RequestBuffer; + Item.GenerateRequest(Index); + } + } + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPPINGMETHOD, mShippingMethod)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PROMOCODEOVERRIDE, mPromoCodeOverride)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PROFILEADDRESSCHANGEDATE, mProfileAddressChangeDate)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PAYPALCHECKOUTBTNTYPE, mPayPalCheckoutBtnType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PRODUCTCATEGORY, mProductCategory)); + if (mItemList != null && mItemList.Count > 0) + { + GenerateItemRequest(); + } + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayLaterLineItem.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayLaterLineItem.cs new file mode 100644 index 0000000..a2304bc --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayLaterLineItem.cs @@ -0,0 +1,169 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// This class holds the PayLater Line Item related information. + /// + /// + /// Line item data describes the details of the PayLater promo codes and can be can be passed + /// for each transaction. The convention for passing line item data in name/value pairs + /// is that each name/value starts with L_ and ends with n where n is the line item number. + /// For example L_PROMOCODEn=101 is promo code 101, with n starting at 0 + /// + /// + /// Following example shows how to use line item. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// + /// //Create a line item. + /// LineItem Item = new LineItem(); + /// + /// //Add info to line item. + /// Item.Amt = new Currency(new Decimal(25.12)); + /// Item.PickupStreet = "685A E. Middlefield Rd."; + /// + /// //Add line item to invoice. + /// Inv.AddLineItem(Item); + /// + /// .................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// + /// //Create a line item. + /// Dim Item As LineItem = New LineItem + /// + /// 'Add info to line item. + /// Item.Amt = New Currency(new Decimal(25.12)) + /// Item.PickupStreet = "685A E. Middlefield Rd." + /// + /// 'Add line item to invoice. + /// Inv.AddLineItem(Item) + /// + /// .................. + /// + /// + public sealed class PayLaterLineItem : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Promo Code + /// + private String mPromoCode; + + #endregion + + #region "Properties" + + /// + /// Gets, Sets Promo Code + /// + /// + /// The product category for this order. If the + /// customers cart contains more than one item, use + /// the product category for the most expensive item. + /// Maps to Payflow Parameter: + /// PROMOCODE + /// + public String PromoCode + { + get { return mPromoCode; } + set { mPromoCode = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor. + /// + /// + /// Line item data describes the details of the item purchased and can be can be passed + /// for each transaction. The convention for passing line item data in name/value pairs + /// is that each name/value starts with L_ and ends with n where n is the line item number. + /// For example L_QTY0=1 is the quantity for line item 0 and is equal to 1, + /// with n starting at 0 + /// + /// + /// Following example shows how to use line item. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// + /// //Create a line item. + /// LineItem Item = new LineItem(); + /// + /// //Add info to line item. + /// Item.Amt = new Currency(new Decimal(25.12)); + /// Item.PickupStreet = "685A E. Middlefield Rd."; + /// + /// //Add line item to invoice. + /// Inv.AddLineItem(Item); + /// + /// .................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// + /// //Create a line item. + /// Dim Item As LineItem = New LineItem + /// + /// 'Add info to line item. + /// Item.Amt = New Currency(new Decimal(25.12)) + /// Item.PickupStreet = "685A E. Middlefield Rd." + /// + /// 'Add line item to invoice. + /// Inv.AddLineItem(Item) + /// + /// .................. + /// + /// + public PayLaterLineItem() + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates line item request + /// + /// index number of line item + internal void GenerateRequest(int Index) + { + try + { + String IndexVal = Index.ToString(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PROMOCODE + IndexVal, mPromoCode)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + } + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayPalTender.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayPalTender.cs new file mode 100644 index 0000000..48445ad --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayPalTender.cs @@ -0,0 +1,127 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects ; +using PayPal.Payments.Common.Utility ; +using PayPal.Payments.Common; +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for PayPal tender related information + /// + /// + /// CreditCard is the the Payment device associated with this tender type. + /// ExpressCheckoutRequest is the DataObject associated with this tendet + /// in case of a exprecc Checout operation. + /// + /// + /// + public class PayPalTender : BaseTender + { + #region "Member Variables" + + private ExpressCheckoutRequest mExpressCheckoutRequest = null; + + + #endregion + + #region "Properties" + + /// + /// + /// + public ExpressCheckoutRequest ExpressCheckoutRequest + { + get {return mExpressCheckoutRequest ;} + set {mExpressCheckoutRequest = value;} + } + #endregion + + #region "Constructor" + /// + /// Constructor + /// + /// Credit Card object + /// This constructor is used to create a PayPalTender + /// with CreditCard as the payment device + /// + /// + /// ............. + /// //CredCard is the CreditCard object. + /// ............. + /// + /// PayPalTender Tender = new PayPalTender(CredCard); + /// + /// .............. + /// + /// + /// ............. + /// 'CredCard is the CreditCard object. + /// ............. + /// + /// Dim Tender As PayPalTender = new PayPalTender(CredCard) + /// + /// .............. + /// + /// + /// + + + public PayPalTender(CreditCard CreditCard) : base( "P", CreditCard) + { + + } + + /// + /// Constructor + /// + /// ExpressCheckoutRequest object + /// This constructor is used to create a PayPalTender + /// with ExpressCheckoutRequest dataobject. + /// + /// + /// ............. + /// //ECReq could be one of these ECSetRequest ,ECGetRequest or ECDoRequest. + /// ............. + /// + /// PayPalTender Tender = new PayPalTender(ECReq); + /// + /// .............. + /// + /// + /// ............. + /// 'ECReq could be one of these ECSetRequest ,ECGetRequest or ECDoRequest. + /// ............. + /// + /// Dim Tender As PayPalTender = new PayPalTender(ECReq) + /// + /// .............. + /// + /// + /// + /// + /// + /// + public PayPalTender(ExpressCheckoutRequest ECReq) : base(PayflowConstants.TENDERTYPE_PAYPAL, null) + { + mExpressCheckoutRequest = ECReq; + } + + #endregion + + #region "Methods" + + internal override void GenerateRequest() + { + base.GenerateRequest (); + if (mExpressCheckoutRequest != null) + { + mExpressCheckoutRequest.RequestBuffer = RequestBuffer ; + mExpressCheckoutRequest.GenerateRequest (); + } + } + #endregion + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayflowConnectionData.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayflowConnectionData.cs new file mode 100644 index 0000000..cbfdcc2 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PayflowConnectionData.cs @@ -0,0 +1,476 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Payflow Host related information. + /// + /// This class stores the information related to connection to the + /// PayPal payment gateway. If the empty constructor of this class + /// is used to create the object, or + /// passed values are empty, then The following values (if empty) are looked for + /// as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// PAYFLOW_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + public sealed class PayflowConnectionData : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Payflow Host address + /// + private String mHostAddress; + + /// + /// Payflow Host port + /// + private int mHostPort; + + /// + /// Proxy Address + /// + private String mProxyAddress; + + /// + /// Proxy Port + /// + private int mProxyPort; + + /// + /// Proxy Logon Id + /// + private String mProxyLogon; + + /// + /// Proxy Password + /// + private String mProxyPassword; + + /// + /// Transaction TimeOut + /// + private int mTimeOut; + + #endregion + + #region "Properties" + + /// + /// Gets HostAddress. It is PayPal's HostName + /// + /// Read-only property. + public String HostAddress + { + get { return mHostAddress; } + } + + /// + /// Gets HostPort. Use port 443 + /// + /// Read-only property. + public int HostPort + { + get { return mHostPort; } + } + + /// + /// Gets Time-out period for the transaction. The minimum recommended + /// time-out value is 30 seconds. The client begins tracking + /// from the time that it sends the transaction request to the server. + /// + /// Read-only property. + public int TimeOut + { + get { return mTimeOut; } + } + + /// + /// Gets Proxy server address. Use the PROXY parameters for servers + /// behind a firewall. Your network administrator can provide the + /// values. + /// + /// Read-only property. + public String ProxyAddress + { + get { return mProxyAddress; } + } + + /// + /// Gets ProxyPort + /// + /// Read-only property. + public int ProxyPort + { + get { return mProxyPort; } + } + + /// + /// Gets ProxyLogon + /// + /// Read-only property. + public String ProxyLogon + { + get { return mProxyLogon; } + } + + /// + /// Gets ProxyPassword + /// + /// Read-only property. + public String ProxyPassword + { + get { return mProxyPassword; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor + /// + /// + /// The following values (if empty) are looked for + /// as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// Payflow_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + public PayflowConnectionData() : this(null, 0, 0, null, 0, null, null) + { + } + + /// + /// Constructor + /// + /// Payflow Host Address + /// + /// The following values (if empty) are looked for + /// as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// Payflow_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + public PayflowConnectionData(String HostAddress) : this(HostAddress, 0, 0, null, 0, null, null) + { + } + + /// + /// Constructor + /// + /// Payflow Host Address + /// Payflow Host port + /// Transaction time out + /// + /// The following values (if empty) are looked for + /// as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// Payflow_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + public PayflowConnectionData(String HostAddress, int HostPort, int TimeOut) : this(HostAddress, HostPort, TimeOut, null, 0, null, null) + { + } + + /// + /// Constructor + /// + /// Payflow Host Address + /// >Payflow Host port + /// Transaction timeout + /// Proxy Address + /// Proxy Port + /// Proxy Logon Id + /// ProxyPwd + /// + /// The following values (if empty) are looked for + /// as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// Payflow_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + public PayflowConnectionData(String HostAddress, int HostPort, int TimeOut, String ProxyAddress, int ProxyPort, String ProxyLogon, String ProxyPassword) + { + if (Context == null) + { + Context = new Context(); + } + + mHostAddress = HostAddress; + mHostPort = HostPort; + mTimeOut = TimeOut; + mProxyAddress = ProxyAddress; + mProxyPort = ProxyPort; + mProxyLogon = ProxyLogon; + mProxyPassword = ProxyPassword; + InitDefaultValues(); + } + + /// + /// Constructor + /// + /// Payflow Host Address + /// >Payflow Host port + /// + /// The following values (if empty) are looked for + /// as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// Payflow_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + public PayflowConnectionData(String HostAddress, int HostPort) : this(HostAddress, HostPort, 0, null, 0, null, null) + { + } + + /// + /// Constructor + /// + /// Payflow Host Address + /// >Payflow Host port + /// Proxy Address + /// Proxy Port + /// Proxy Logon Id + /// ProxyPwd + /// + /// The following values (if empty) are looked for + /// as follows: + /// + /// + /// Property + /// From Internal Default + /// From App.config key + /// + /// + /// Payflow Host + /// NA + /// Payflow_HOST + /// + /// + /// Payflow Port + /// 443 + /// NA + /// + /// + /// Transaction timeout + /// 45 seconds + /// NA + /// + /// + /// + public PayflowConnectionData(String HostAddress, int HostPort, String ProxyAddress, int ProxyPort, String ProxyLogon, String ProxyPassword) : this(HostAddress, HostPort, 0, ProxyAddress, ProxyPort, ProxyLogon, ProxyPassword) + { + } + + #endregion + + /// + /// Initializes the default values + /// + private void InitDefaultValues() + { + //Check if the values held + //in the PayPal server + //connection related params + //if they are passed null or + //0 (for int values) then + //initialize them to appropriate + //default values. + + //set the timeout to default timeout. + if (mTimeOut == 0) + { + mTimeOut = PayflowConstants.DEFAULT_TIMEOUT; + } + + try + { + if (mHostAddress == null || mHostAddress.Length == 0) + { + String HostAddress = PayflowUtility.AppSettings(PayflowConstants.INTL_PARAM_PAYFLOW_HOST); + if (HostAddress != null && HostAddress.Length > 0) + { + HostAddress = HostAddress.TrimStart().TrimEnd(); + if (HostAddress.Length == 0) + { + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_CONFIG_ERROR] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_CONFIG_ERROR] + + "Tag " + + PayflowConstants.INTL_PARAM_PAYFLOW_HOST + + " is not present in the config file or config file is missing."; + ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, "",RespMessage); + Context.AddError(Error); + } + else + { + mHostAddress = HostAddress; + } + } + else + { + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_CONFIG_ERROR] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_CONFIG_ERROR] + + "Tag " + + PayflowConstants.INTL_PARAM_PAYFLOW_HOST + + " is not present in the config file or config file is missing."; + ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, "",RespMessage); + Context.AddError(Error); + } + } + } + catch (Exception Ex) + { + String StackTrace = PayflowConstants.EMPTY_STRING; + PayflowUtility.InitStackTraceOn(); + if(PayflowConstants.TRACE_ON.Equals(PayflowConstants.TRACE)) + { + StackTrace = ": " + Ex.Message + Ex.StackTrace; + } + String RespMessage = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_CONFIG_ERROR] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_CONFIG_ERROR] + + "Tag " + + PayflowConstants.INTL_PARAM_PAYFLOW_HOST + + " is not present in the config file or config file is missing." + + StackTrace; + ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, "",RespMessage); + Context.AddError(Error); + } + } + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PaymentCard.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PaymentCard.cs new file mode 100644 index 0000000..bbe3cd2 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PaymentCard.cs @@ -0,0 +1,170 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// This abstract class serves as base + /// class for Card Payment devices. + /// + /// This class can be extended to create a new payment device type. + public class PaymentCard : PaymentDevice + { + #region "Member Variables" + + /// + /// Card Expiry Date + /// + private String mExpDate; + + /// + /// Card CVV2 code + /// + private String mCvv2; + + /// + /// CardStart + /// + private String mCardStart; + + /// + /// Card Issue + /// + private String mCardIssue; + + /// + /// Card on File + /// + private String mCardonFile; + + /// + /// Card on File Transaction ID + /// + private String mTxId; + + + #endregion + + #region "Constructors" + + /// + /// Constructor + /// + /// Card number + /// Card expiry date + /// Abstract class. Instance cannot be created directly. + public PaymentCard(String Acct, String ExpDate) : base(Acct) + { + mExpDate = ExpDate; + } + + #endregion + + #region "Properties" + + /// + /// Gets, Sets Cvv2 + /// + /// + /// Card validation code. This is the 3 or 4 digit code + /// present at the back side of the card. + /// Maps to Payflow Parameter: + /// CVV2 + /// + public String Cvv2 + { + get { return mCvv2; } + set { mCvv2 = value; } + } + /// + /// Gets, Sets CardStart + /// + /// + /// Used for Switch/Solo Cards. + /// Maps to Payflow Parameter: + /// CARDSTART + /// + public String CardStart + { + get { return mCardStart; } + set { mCardStart= value; } + } + /// + /// Gets, Sets CardIssue + /// + /// + /// Used for Switch/Solo Cards. + /// Maps to Payflow Parameter: + /// CARDISSUE + /// + public String CardIssue + { + get { return mCardIssue; } + set { mCardIssue = value; } + } + + /// + /// Gets, Sets Card on File + /// + /// + /// Used to flag if the card is on file. + /// Maps to Payflow Parameter: + /// CARDONFILE + /// + public String CardonFile + { + get { return mCardonFile; } + set { mCardonFile = value; } + } + + /// + /// Gets, Sets Transaction ID + /// + /// + /// Used to flag if the card is on file. + /// Maps to Payflow Parameter: + /// TXID + /// + public String TxId + { + get { return mTxId; } + set { mTxId = value; } + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_EXPDATE, mExpDate)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CVV2, mCvv2)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CARDSTART, mCardStart)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CARDISSUE, mCardIssue)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CARDONFILE, mCardonFile)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_TXID, mTxId)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + } + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PaymentDevice.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PaymentDevice.cs new file mode 100644 index 0000000..0ee88dc --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PaymentDevice.cs @@ -0,0 +1,193 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// This abstract class serves as base class of all + /// payment devices. + /// + /// + /// Each Payment Device is associated with a tender type . + /// Following are the Payment Devices associated with + /// different tender types: + /// + /// + /// Payment Device Data Object + /// Tender type + /// + /// + /// BankAcct + /// ACHTender + /// + /// + /// CreditCard, PurchaseCard, SwipeCard + /// + /// CardTender + /// + /// + /// + /// CheckPayment + /// CheckTender + /// + /// + /// + public class PaymentDevice : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Payment Device number + /// + private String mAcct; + + /// + /// Payment Device Holder's name + /// + private String mName; + /// + /// Payment Device Magtek Information + /// + public MagtekInfo mMagtekInfo; + + #endregion + + #region "Constructors" + + /// + /// Constructor + /// + /// Abstract class. Instance cannot be created directly. + internal PaymentDevice() + { + } + + /// + /// Constructor + /// + /// Payment device Number + /// Abstract class. Instance cannot be created directly. + public PaymentDevice(String Acct) + { + mAcct = Acct; + } + + /// + /// Constructor + /// + /// Payment device Number + /// Payment device holder's name + /// Abstract class. Instance cannot be created directly. + public PaymentDevice(String Acct, String Name) + { + mAcct = Acct; + mName = Name; + } + + + #endregion + + #region "Properties" + + /// + /// Gets, Sets Acct + /// + /// Account holder's account number. + /// Maps to Payflow Parameter:s as follows: + /// + /// + /// + /// Specific transaction + /// Payflow Parameter + /// + /// + /// Transactions with CreditCard, PurchaseCard, BankAcct payment devices + /// ACCT + /// + /// + /// Transactions with CheckPayment + /// MICR + /// + /// + /// Transactions with SwipeCard + /// SWIPE + /// + /// + /// + /// + public virtual String Acct + { + get { return mAcct; } + } + + /// + /// Gets, Sets Name + /// + /// Account holder's name. + /// Maps to Payflow Parameter: + /// NAME + /// + public String Name + { + get { return mName; } + set { mName = value; } + } + + /// + /// Gets, Sets MagtekInfo + /// + /// + /// Used to hold the Magtek Data. + /// + public MagtekInfo MagtekInfo + { + get { return mMagtekInfo; } + set { mMagtekInfo = value; } + } + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + //Generate default NV Pair for Acct field. + //This is with Name as ACCT. Used for CC, ACH trxns. + //In case of TeleCheck, this will be MICR. Handled from derived class. + //In case of Swipe, this will be SWIPE. Handled from derived class. + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ACCT, mAcct)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_NAME, mName)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + + } + + + #endregion + + + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PurchaseCard.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PurchaseCard.cs new file mode 100644 index 0000000..0c981d5 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/PurchaseCard.cs @@ -0,0 +1,96 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for Purchase card related information + /// + /// + /// PurchaseCard is associated with CardTender. + /// + /// + public sealed class PurchaseCard : PaymentCard + { + #region "Member Variables" + + /// + /// Purchase card type + /// + private String mCommCard; + + #endregion + + #region "Constructors" + + /// + /// Constructor for PurchaseCard + /// + /// Purchase Card number + /// Card expiry date + /// Purchase Card type + /// This is used as Payment Device for the CardTender. + /// Maps to Payflow Parameter: + /// Acct --> ACCT, ExpDate --> EXPDATE, CommCard --> COMMCARD + /// + /// + /// + /// ............. + /// + /// PurchaseCard PayDevice = new PurchaseCard("XXXXXXXXXX","XXXX","C"); + /// + /// .............. + /// + /// + /// ............. + /// + /// Dim PayDevice As PurchaseCard = new PurchaseCard("XXXXXXXXXX","XXXX","C") + /// + /// .............. + /// + /// + /// + public PurchaseCard(String Acct, String ExpDate, String CommCard) : base(Acct, ExpDate) + { + mCommCard = CommCard; + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_COMMCARD, mCommCard)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/RecurringInfo.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/RecurringInfo.cs new file mode 100644 index 0000000..0737bab --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/RecurringInfo.cs @@ -0,0 +1,551 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for recurring transaction related information + /// + /// RecurringInfo contains the required and optional parameters + /// specific to all the recurring transactions. + /// Following examples shows how to use the + /// RecurringInfo. + /// + /// ............................ + /// //Populate other data objects. + /// ............................ + /// + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Add Transaction. + /// RecurringAddTransaction Trans = new RecurringAddTransaction( + /// User, Connection, Inv, Card, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + /// Console.ReadLine(); + /// } + /// + /// + /// ............................ + /// 'Populate other data objects. + /// ............................ + /// + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Add Transaction. + /// Dim Trans As RecurringAddTransaction = New RecurringAddTransaction(User, Connection, Inv, Card, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public sealed class RecurringInfo : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// Profile name + /// + private String mProfileName; + + /// + /// Start Date + /// + private String mStart; + + /// + /// Payment Term + /// + private long mTerm = PayflowConstants.INVALID_NUMBER; + + /// + /// Payment Period + /// + private String mPayPeriod; + + /// + /// Optional transaction type + /// + private String mOptionalTrx; + + /// + /// Optional transaction amount + /// + private Currency mOptionalTrxAmt; + + /// + /// Retry number of days + /// + private long mRetryNumDays; + + /// + /// Max failed payments + /// + private long mMaxFailPayments = PayflowConstants.INVALID_NUMBER; + + /// + /// Profile id of the original profile. + /// + private String mOrigProfileId; + + /// + /// Payment history + /// + private String mPaymentHistory; + + /// + /// Payment number + /// + private String mPaymentNum; + + /// + /// Frequency + /// + private String mFrequency; + + //private String mRecurring = "Y"; + + #endregion + + #region "Constructors" + + /// + /// Constructor for RecurringInfo + /// + /// RecurringInfo contains the required and optional parameters + /// specific to all the recurring transactions. + /// Following examples shows how to use the + /// RecurringInfo. + /// + /// ............................ + /// //Populate other data objects. + /// ............................ + /// + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Add Transaction. + /// RecurringAddTransaction Trans = new RecurringAddTransaction( + /// User, Connection, Inv, Card, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + /// Console.ReadLine(); + /// } + /// + /// + /// ............................ + /// 'Populate other data objects. + /// ............................ + /// + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Add Transaction. + /// Dim Trans As RecurringAddTransaction = New RecurringAddTransaction(User, Connection, Inv, Card, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public RecurringInfo() + { + } + + #endregion + + #region "Properties" + + /// + /// Gets, Sets ProfileName + /// + /// + /// Name for the profile. + /// Maps to Payflow Parameter: + /// PROFILENAME + /// + public String ProfileName + { + get { return mProfileName; } + set { mProfileName = value; } + } + + /// + /// Gets, Sets Start + /// + /// + /// Beginning date for the recurring billing cycle. + /// Maps to Payflow Parameter: + /// START + /// + public String Start + { + get { return mStart; } + set { mStart = value; } + } + + /// + /// Gets, Sets Term + /// + /// + /// Number of payments to be made over the life of the agreement. + /// Maps to Payflow Parameter: + /// TERM + /// + public long Term + { + get { return mTerm; } + set { mTerm = value; } + } + + /// + /// Gets, Sets PayPeriod + /// + /// + /// Specifies how often the payment occurs. + /// Allowed PayPeriods are: + /// + /// + /// Value + /// Description + /// + /// WEEKWeekly - Every week on the same day of the week as the first payment. + /// BIWKEvery Two Weeks - Every other week on the same day of the week as the first payment. + /// SMMOTwice Every Month - The 1st and 15th of the month.Results in 24 payments per year. SMMO can start on 1st to 15th of the month, second payment 15 days later or on the last day of the month. + /// FRWKEvery Four Weeks - Every 28 days from the previous payment date beginning with the first payment date. Results in 13 payments per year. + /// MONTMonthly - Every month on the same date as the first payment. Results in 12 payments per year. + /// QTERQuarterly - Every three months on the same date as the first payment. + /// SMYRTwice Every Year - Every six months on the same date as the first payment. + /// YEARYearly - Every twelve months on the same date as the first payment. + /// + /// Maps to Payflow Parameter: + /// PAYPERIOD + /// + public String PayPeriod + { + get { return mPayPeriod; } + set { mPayPeriod = value; } + } + + /// + /// Gets, Sets OptionalTrx + /// + /// + /// Defines an optional Authorization for validating the account + /// information or for charging an initial fee. If this transaction + /// fails, then the profile is not generated. + /// A represents an optional Authorization transaction ($1 by + /// default). OPTIONALTRX=A only applies to credit card transactions. + /// S represents an initial fee. + /// Maps to Payflow Parameter: + /// OPTIONALTRX + /// + public String OptionalTrx + { + get { return mOptionalTrx; } + set { mOptionalTrx = value; } + } + + /// + /// Gets, Sets OptionalTrxAmt + /// + /// + /// Amount of the Optional Transaction. Required only when OPTIONALTRX=S. + /// Optional when OPTIONALTRX=A ($1 Authorization by default) + /// Maps to Payflow Parameter: + /// OPTIONALTRXAMT + /// + public Currency OptionalTrxAmt + { + get { return mOptionalTrxAmt; } + set { mOptionalTrxAmt = value; } + } + + /// + /// Gets, Sets RetryNumDays + /// + /// + /// The number of consecutive days that Gateway should + /// attempt to process a failed transaction until Approved + /// status is received. + /// Maps to Payflow Parameter: + /// RETRYNUMDAYS + /// + public long RetryNumDays + { + get { return mRetryNumDays; } + set { mRetryNumDays = value; } + } + + /// + /// Gets, Sets MaxFailPayments + /// + /// + /// The number of payment periods (specified by + /// PAYPERIOD) for which the transaction is allowed to fail + /// before PayPal cancels a profile. + /// Maps to Payflow Parameter: + /// MAXFAILPAYMENTS + /// + public long MaxFailPayments + { + get { return mMaxFailPayments; } + set { mMaxFailPayments = value; } + } + + /// + /// Gets, Sets OrigProfileId + /// + /// Required for Modify/Cancel/Inquiry/Retry action. + /// Profile IDs for test profiles start with RT. + /// Profile IDs for live profiles start with RP. + /// Maps to Payflow Parameter: + /// ORIGPROFILEID + /// + public String OrigProfileId + { + get { return mOrigProfileId; } + set { mOrigProfileId = value; } + } + + /// + /// Gets, Sets PaymentHistory + /// + /// Used for recurring inquiry. + /// Allowed values are: + /// + /// + /// Value + /// Description + /// + /// YTo view the full set of payment information for a profile, include the name/value pair with the Inquiry action. + /// NTo view the status of a customer’s profile, submit an Inquiry action that does not include the PAYMENTHISTORY parameter (alternatively, submit PAYMENTHISTORY=N). + /// + /// Maps to Payflow Parameter: + /// PAYMENTHISTORY + /// + public String PaymentHistory + { + get { return mPaymentHistory; } + set { mPaymentHistory = value; } + } + + /// + /// Gets, Sets PaymentNum + /// + /// + /// Payment number identifying the failed payment to be retried. + /// Maps to Payflow Parameter: + /// PAYMENTNUM + /// + public String PaymentNum + { + get { return mPaymentNum; } + set { mPaymentNum = value; } + } + + /// + /// Gets, Sets Frequency + /// + /// + /// Set the number of days between payments. Used with PAYPERIOD=DAYS. + /// Maps to Payflow Parameter: + /// FREQUENCY + /// + public String Frequency + { + get { return mFrequency; } + set { mFrequency = value; } + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PROFILENAME, mProfileName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_START, mStart)); + + if (mTerm != PayflowConstants.INVALID_NUMBER) + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_TERM, mTerm)); + } + + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PAYPERIOD, mPayPeriod)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_OPTIONALTRX, mOptionalTrx)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_OPTIONALTRXAMT, mOptionalTrxAmt)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_RETRYNUMDAYS, mRetryNumDays)); + if (mMaxFailPayments != PayflowConstants.INVALID_NUMBER) + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_MAXFAILPAYMENTS, mMaxFailPayments)); + } + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORIGPROFILEID, mOrigProfileId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PAYMENTHISTORY, mPaymentHistory)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PAYMENTNUM, mPaymentNum)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_FREQUENCY, mFrequency)); + //RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_RECURRING, mRecurring)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/RecurringResponse.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/RecurringResponse.cs new file mode 100644 index 0000000..cc11bcd --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/RecurringResponse.cs @@ -0,0 +1,1040 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; +using System.Collections; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Container class for all the messages related to + /// recurring transactions. + /// + /// This class contains response messages specific to + /// the recurring transactions. + /// + /// + /// Following example shows how to obtain and use the recurring + /// response. + /// + /// ................... + /// // Trans is the recurring transaction. + /// ................... + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// ................... + /// + /// + /// .......................... + /// ' Trans is the transaction object + /// .......................... + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// .......................... + /// + /// + public sealed class RecurringResponse : BaseResponseDataObject + { + #region "Member variables" + + /// + /// Profile id + /// + private String mProfileId; + + /// + /// RPRef + /// + private String mRPRef; + + /// + /// TrxPNref + /// + private String mTrxPNRef; + + /// + /// Transaction result + /// + private String mTrxResult; + + /// + /// Transaction response msg + /// + private String mTrxRespMsg; + + //Additional fields for Inquiry transaction + /// + /// Profile name + /// + private String mProfileName; + + /// + /// Start + /// + private String mStart; + + /// + /// Term + /// + private String mTerm; + + /// + ///Payment period + /// + private String mPayPeriod; + + /// + /// Status + /// + private String mStatus; + + /// + /// Tender type + /// + private String mTenderType; + + /// + /// Payments left + /// + private String mPaymentsLeft; + + /// + /// Next Payment + /// + private String mNxtPayment; + + /// + /// End payment + /// + private String mEnd; + + /// + /// Agrregate amount + /// + private String mAggregateAmt; + + /// + /// Aggregate optional amount + /// + private String mAggregateOptionalAmt; + + /// + /// amount + /// + private String mAmt; + + /// + /// account + /// + private String mAcct; + + /// + /// Expiry date + /// + private String mExpDate; + + /// + /// Max failed payments + /// + private String mMaxFailPayments; + + /// + /// Number of fail payments + /// + private String mNumFailPayments; + + /// + /// Retry number of days + /// + private String mRetryNumDays; + + /// + /// Email + /// + private String mEmail; + + /// + /// Company name + /// + private String mCompanyName; + + /// + /// Name + /// + private String mName; + + /// + /// First name + /// + private String mFirstName; + + /// + /// Middle name + /// + private String mMiddleName; + + /// + /// Last name + /// + private String mLastName; + + /// + /// Street + /// + private String mStreet; + + /// + /// City + /// + private String mCity; + + /// + /// State + /// + private String mState; + + /// + /// Zip + /// + private String mZip; + + /// + /// Country + /// + private String mCountry; + + /// + /// Phone num + /// + private String mPhoneNum; + + /// + /// Ship to first name + /// + private String mShipToFName; + + /// + /// Ship to middle name + /// + private String mShipToMName; + + /// + /// Ship to last name + /// + private String mShipToLName; + + /// + /// Ship to street + /// + private String mShipToStreet; + + /// + /// Ship to city + /// + private String mShipToCity; + + /// + /// Ship to state + /// + private String mShipToState; + + /// + /// Ship to zip + /// + private String mShipToZip; + + /// + /// Ship to country + /// + private String mShipToCountry; + + /// + /// Inquiry Response Array list. + /// + private Hashtable mInquiryParams; + + #endregion + + #region "Properties" + + /// + /// Gets ProfileId + /// + /// + /// The Profile ID of the original profile. + /// Maps to Payflow Parameter: + /// PROFILEID + /// + public String ProfileId + { + get { return mProfileId; } + } + + /// + /// Gets RPRef + /// + /// + /// Reference number to this particular action request. + /// Maps to Payflow Parameter: + /// RPREF + /// + public String RPRef + { + get { return mRPRef; } + } + + /// + /// Gets TrxPNRef + /// + /// + /// PNREF of the optional transaction. + /// Maps to Payflow Parameter: + /// TRXPNREF + /// + public String TrxPNRef + { + get { return mTrxPNRef; } + } + + /// + /// Gets TrxResult + /// + /// + /// RESULT of the optional transaction. + /// Maps to Payflow Parameter: + /// TRXRESULT + /// + public String TrxResult + { + get { return mTrxResult; } + } + + /// + /// Gets TrxRespMsg + /// + /// + /// RESPMSG of the optional transaction + /// Maps to Payflow Parameter: + /// TRXRESPMSG + /// + public String TrxRespMsg + { + get { return mTrxRespMsg; } + } + + //Additional fields for Inquiry transaction + /// + /// Gets ProfileName + /// + /// + /// Name for the profile. + /// Maps to Payflow Parameter: + /// PROFILENAME + /// + public String ProfileName + { + get { return mProfileName; } + } + + /// + /// Gets Start + /// + /// + /// Beginning date for the recurring billing cycle. + /// Maps to Payflow Parameter: + /// START + /// + public String Start + { + get { return mStart; } + } + + /// + /// Gets Term + /// + /// + /// Number of payments to be made over the life of the agreement. + /// Maps to Payflow Parameter: + /// TERM + /// + public String Term + { + get { return mTerm; } + } + + /// + /// Gets PayPeriod + /// + /// + /// Specifies how often the payment occurs. + /// Maps to Payflow Parameter: + /// PAYPERIOD + /// + public String PayPeriod + { + get { return mPayPeriod; } + } + + /// + /// Gets Status + /// + /// + /// Current status of the profile. + /// Maps to Payflow Parameter: + /// STATUS + /// + public String Status + { + get { return mStatus; } + } + + /// + /// Gets TenderType + /// + /// + /// Tender Type + /// Maps to Payflow Parameter: + /// TENDER + /// + public String Tender + { + get { return mTenderType; } + } + + /// + /// Gets PaymentsLeft + /// + /// + /// Number of payments left to be billed. + /// Maps to Payflow Parameter: + /// PAYMENTSLEFT + /// + public String PaymentsLeft + { + get { return mPaymentsLeft; } + } + + /// + /// Gets NxtPayment + /// + /// + /// Date that the next payment is due. + /// Maps to Payflow Parameter: + /// NEXTPAYMENT + /// + public String NextPayment + { + get { return mNxtPayment; } + } + + /// + /// Gets End + /// + /// + /// Date that the last payment is due. Present only if this is + /// not an unlimited-term subscription. + /// Maps to Payflow Parameter: + /// END + /// + public String End + { + get { return mEnd; } + } + + /// + /// Gets AggregateAmt + /// + /// + /// Amount collected so far for scheduled payments. + /// Maps to Payflow Parameter: + /// AGGREGATEAMT + /// + public String AggregateAmt + { + get { return mAggregateAmt; } + } + + /// + /// Gets AggregateOptAmt + /// + /// + /// Amount collected through sending optional transactions. + /// Maps to Payflow Parameter: + /// AGGREGATEOPTIONALAMT + /// + public String AggregateOptionalAmt + { + get { return mAggregateOptionalAmt; } + } + + /// + /// Gets Amt + /// + /// + /// Base dollar amount to be billed. + /// Maps to Payflow Parameter: + /// AMT + /// + public String Amt + { + get { return mAmt; } + } + + /// + /// Gets Acct + /// + /// + /// Masked credit card number. + /// Maps to Payflow Parameter: + /// ACCT + /// + public String Acct + { + get { return mAcct; } + } + + /// + /// Gets ExpDate + /// + /// + /// Expiration date of the credit card account. + /// Maps to Payflow Parameter: + /// EXPDATE + /// + public String ExpDate + { + get { return mExpDate; } + } + + /// + /// Gets MaxFailPayments + /// + /// + /// The number of payment periods (specified by + /// PAYPERIOD) for which the transaction is allowed to fail + /// before PayPal cancels a profile. + /// Maps to Payflow Parameter: + /// MAXFAILPAYMENTS + /// + public String MaxFailPayments + { + get { return mMaxFailPayments; } + } + + /// + /// Gets NumFailPayments + /// + /// + /// Number of payments that failed. + /// Maps to Payflow Parameter: + /// NUMFAILPAYMENTS + /// + public String NumFailPayments + { + get { return mNumFailPayments; } + } + + /// + /// Gets RetryNumDays + /// + /// + /// The number of consecutive days that PayPal should + /// attempt to process a failed transaction until Approved + /// status is received. + /// Maps to Payflow Parameter: + /// RETRYNUMDAYS + /// + public String RetryNumDays + { + get { return mRetryNumDays; } + } + + /// + /// Gets Email + /// + /// + /// Customer e-mail address. + /// Maps to Payflow Parameter: + /// EMAIL + /// + public String Email + { + get { return mEmail; } + } + + /// + /// Gets CompanyName + /// + /// + /// Recurring Profile Company Name. + /// Maps to Payflow Parameter: + /// COMPANYNAME + /// + public String CompanyName + { + get { return mCompanyName; } + } + + /// + /// Gets Name + /// + /// + /// Name of account holder + /// Maps to Payflow Parameter: + /// NAME + /// + public String Name + { + get { return mName; } + } + + /// + /// Gets FirstName + /// + /// + /// First name of card holder. + /// Maps to Payflow Parameter: + /// FIRSTNAME + /// + public String FirstName + { + get { return mFirstName; } + } + + /// + /// Gets MiddleName + /// + /// + /// Middle name of card holder + /// Maps to Payflow Parameter: + /// MIDDLENAME + /// + public String MiddleName + { + get { return mMiddleName; } + } + + /// + /// Gets Lastname + /// + /// + /// Last name of card holder + /// Maps to Payflow Parameter: + /// LASTNAME + /// + public String LastName + { + get { return mLastName; } + } + + /// + /// Gets Street + /// + /// + /// Billing address + /// Maps to Payflow Parameter: + /// STREET + /// + public String Street + { + get { return mStreet; } + } + + /// + /// Gets City + /// + /// + /// Billing city + /// Maps to Payflow Parameter: + /// CITY + /// + public String City + { + get { return mCity; } + } + + /// + /// Gets State + /// + /// + /// Billing state + /// Maps to Payflow Parameter: + /// STATE + /// + public String State + { + get { return mState; } + } + + /// + /// Gets Zip + /// + /// + /// Billing zip + /// Maps to Payflow Parameter: + /// ZIP + /// + public String Zip + { + get { return mZip; } + } + + /// + /// Gets Country + /// + /// + /// Billing country + /// Maps to Payflow Parameter: + /// COUNTRY + /// + public String Country + { + get { return mCountry; } + } + + /// + /// Gets PhoneNum + /// + /// + /// Billing phonenum + /// Maps to Payflow Parameter: + /// PHONENUM + /// + public String PhoneNum + { + get { return mPhoneNum; } + } + + /// + /// Gets ShipToFirstName + /// + /// + /// First name of the ship-to person + /// Maps to Payflow Parameter: + /// SHIPTOFIRSTNAME + /// + public String ShipToFirstName + { + get { return mShipToFName; } + } + + /// + /// Gets ShipToMiddleName + /// + /// + /// Middle name of the ship-to person + /// Maps to Payflow Parameter: + /// SHIPTOMIDDLENAME + /// + public String ShipToMiddleName + { + get { return mShipToMName; } + } + + /// + /// Gets ShipToLastName + /// + /// + /// Last name of the ship-to person + /// Maps to Payflow Parameter: + /// SHIPTOLASTNAME + /// + public String ShipToLastName + { + get { return mShipToLName; } + } + + /// + /// Gets ShipToStreet + /// + /// + /// Shipping street + /// Maps to Payflow Parameter: + /// SHIPTOSTREET + /// + public String ShipToStreet + { + get { return mShipToStreet; } + } + + /// + /// Gets ShipToCity + /// + /// + /// Shipping city + /// Maps to Payflow Parameter: + /// SHIPTOCITY + /// + public String ShipToCity + { + get { return mShipToCity; } + } + + /// + /// Gets ShipToState + /// + /// + /// Shipping state + /// Maps to Payflow Parameter: + /// SHIPTOSTATE + /// + public String ShipToState + { + get { return mShipToState; } + } + + /// + /// Gets ShipToZip + /// + /// + /// Shipping zip + /// Maps to Payflow Parameter: + /// SHIPTOZIP + /// + public String ShipToZip + { + get { return mShipToZip; } + } + + /// + /// Gets ShipToCountry + /// + /// + /// Shipping country + /// Maps to Payflow Parameter: + /// SHIPTOCOUNTRY + /// + public String ShipToCountry + { + get { return mShipToCountry; } + } + + + /// + /// Gets recurring inquiry + /// param hash table + /// + /// + /// This hash table contains the response messages + /// when the recurring transaction is with + /// PAYMENTHISTORY=Y + /// Maps to following Payflow Parameters: + /// + /// + /// + /// Payflow param + /// Description + /// + /// + /// P_RESULTn + /// Result code of the financial transaction. + /// + /// + /// P_PNREFn + /// PNREF of the particular payment. + /// + /// + /// P_TRANSTATEn + /// TRANS_STATE of the particular payment. + /// + /// + /// P_TENDERn + /// Tender type + /// + /// + /// P_TRANSTIMEn + /// The timestamp for the transaction in the dd-mmm-yy hh:mm AM/PM format. + /// + /// + /// P_AMTn + /// Dollar amount (US dollars) that was billed. Specifies dollars and cents using a decimal point. + /// + /// + /// + /// + public Hashtable InquiryParams + { + get { return mInquiryParams; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor for RecurringResponse + /// + internal RecurringResponse() + { + mInquiryParams = new Hashtable(); + } + + #endregion + + #region "Methods" + + /// + /// Sets Response params + /// + ///Response Hash table by ref + internal void SetParams(ref Hashtable ResponseHashTable) + { + try + { + mProfileId = (String) ResponseHashTable[PayflowConstants.PARAM_PROFILEID]; + mRPRef = (String) ResponseHashTable[PayflowConstants.PARAM_RPREF]; + mTrxPNRef = (String) ResponseHashTable[PayflowConstants.PARAM_TRXPNREF]; + mTrxResult = (String) ResponseHashTable[PayflowConstants.PARAM_TRXRESULT]; + mTrxRespMsg = (String) ResponseHashTable[PayflowConstants.PARAM_TRXRESPMSG]; + + //Additional fields for Inquiry transaction + mProfileName = (String) ResponseHashTable[PayflowConstants.PARAM_PROFILENAME]; + mStart = (String) ResponseHashTable[PayflowConstants.PARAM_START]; + mTerm = (String) ResponseHashTable[PayflowConstants.PARAM_TERM]; + mPayPeriod = (String) ResponseHashTable[PayflowConstants.PARAM_PAYPERIOD]; + mStatus = (String) ResponseHashTable[PayflowConstants.PARAM_STATUS]; + mTenderType = (String) ResponseHashTable[PayflowConstants.PARAM_TENDER]; + mPaymentsLeft = (String) ResponseHashTable[PayflowConstants.PARAM_PAYMENTSLEFT]; + mNxtPayment = (String) ResponseHashTable[PayflowConstants.PARAM_NEXTPAYMENT]; + mEnd = (String) ResponseHashTable[PayflowConstants.PARAM_END]; + mAggregateAmt = (String) ResponseHashTable[PayflowConstants.PARAM_AGGREGATEAMT]; + mAggregateOptionalAmt = (String) ResponseHashTable[PayflowConstants.PARAM_AGGREGATEOPTIONALAMT]; + mAmt = (String) ResponseHashTable[PayflowConstants.PARAM_AMT]; + mAcct = (String) ResponseHashTable[PayflowConstants.PARAM_ACCT]; + mExpDate = (String) ResponseHashTable[PayflowConstants.PARAM_EXPDATE]; + mMaxFailPayments = (String) ResponseHashTable[PayflowConstants.PARAM_MAXFAILPAYMENTS]; + mNumFailPayments = (String) ResponseHashTable[PayflowConstants.PARAM_NUMFAILPAYMENTS]; + mRetryNumDays = (String) ResponseHashTable[PayflowConstants.PARAM_RETRYNUMDAYS]; + mEmail = (String) ResponseHashTable[PayflowConstants.PARAM_EMAIL]; + mCompanyName = (String) ResponseHashTable[PayflowConstants.PARAM_COMPANYNAME]; + mName = (String) ResponseHashTable[PayflowConstants.PARAM_NAME]; + mFirstName = (String) ResponseHashTable[PayflowConstants.PARAM_FIRSTNAME]; + mMiddleName = (String) ResponseHashTable[PayflowConstants.PARAM_MIDDLENAME]; + mLastName = (String) ResponseHashTable[PayflowConstants.PARAM_LASTNAME]; + mStreet = (String) ResponseHashTable[PayflowConstants.PARAM_STREET]; + mCity = (String) ResponseHashTable[PayflowConstants.PARAM_CITY]; + mState = (String) ResponseHashTable[PayflowConstants.PARAM_STATE]; + mZip = (String) ResponseHashTable[PayflowConstants.PARAM_ZIP]; + mCountry = (String) ResponseHashTable[PayflowConstants.PARAM_COUNTRY]; + mPhoneNum = (String) ResponseHashTable[PayflowConstants.PARAM_PHONENUM]; + mShipToFName = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOFIRSTNAME]; + mShipToMName = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOMIDDLENAME]; + mShipToLName = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOLASTNAME]; + mShipToStreet = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOSTREET]; + mShipToCity = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOCITY]; + mShipToState = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOSTATE]; + mShipToZip = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOZIP]; + mShipToCountry = (String) ResponseHashTable[PayflowConstants.PARAM_SHIPTOCOUNTRY]; + + + ResponseHashTable.Remove(PayflowConstants.PARAM_PROFILEID); + ResponseHashTable.Remove(PayflowConstants.PARAM_RPREF); + ResponseHashTable.Remove(PayflowConstants.PARAM_TRXPNREF); + ResponseHashTable.Remove(PayflowConstants.PARAM_TRXRESULT); + ResponseHashTable.Remove(PayflowConstants.PARAM_TRXRESPMSG); + ResponseHashTable.Remove(PayflowConstants.PARAM_PROFILENAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_START); + ResponseHashTable.Remove(PayflowConstants.PARAM_TERM); + ResponseHashTable.Remove(PayflowConstants.PARAM_PAYPERIOD); + ResponseHashTable.Remove(PayflowConstants.PARAM_STATUS); + ResponseHashTable.Remove(PayflowConstants.PARAM_TENDER); + ResponseHashTable.Remove(PayflowConstants.PARAM_PAYMENTSLEFT); + ResponseHashTable.Remove(PayflowConstants.PARAM_NEXTPAYMENT); + ResponseHashTable.Remove(PayflowConstants.PARAM_END); + ResponseHashTable.Remove(PayflowConstants.PARAM_AGGREGATEAMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_AGGREGATEOPTIONALAMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_AMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_ACCT); + ResponseHashTable.Remove(PayflowConstants.PARAM_EXPDATE); + ResponseHashTable.Remove(PayflowConstants.PARAM_MAXFAILPAYMENTS); + ResponseHashTable.Remove(PayflowConstants.PARAM_NUMFAILPAYMENTS); + ResponseHashTable.Remove(PayflowConstants.PARAM_RETRYNUMDAYS); + ResponseHashTable.Remove(PayflowConstants.PARAM_EMAIL); + ResponseHashTable.Remove(PayflowConstants.PARAM_COMPANYNAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_NAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_FIRSTNAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_MIDDLENAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_LASTNAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_STREET); + ResponseHashTable.Remove(PayflowConstants.PARAM_CITY); + ResponseHashTable.Remove(PayflowConstants.PARAM_STATE); + ResponseHashTable.Remove(PayflowConstants.PARAM_ZIP); + ResponseHashTable.Remove(PayflowConstants.PARAM_COUNTRY); + ResponseHashTable.Remove(PayflowConstants.PARAM_PHONENUM); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOFIRSTNAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOMIDDLENAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOLASTNAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOSTREET); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOCITY); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOSTATE); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOZIP); + ResponseHashTable.Remove(PayflowConstants.PARAM_SHIPTOCOUNTRY); + ResponseHashTable.Remove(PayflowConstants.PARAM_P_RESULTn); + ResponseHashTable.Remove(PayflowConstants.PARAM_P_PNREFn); + ResponseHashTable.Remove(PayflowConstants.PARAM_P_TRANSTATEn); + ResponseHashTable.Remove(PayflowConstants.PARAM_P_TENDERn); + ResponseHashTable.Remove(PayflowConstants.PARAM_P_TRANSTIMEn); + ResponseHashTable.Remove(PayflowConstants.PARAM_P_AMTn); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + + } + + #endregion + } + + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Response.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Response.cs new file mode 100644 index 0000000..fe69d3a --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Response.cs @@ -0,0 +1,769 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; +using System.Collections; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Container class for response messages. + /// + /// This class enclosed response data objects specific to + /// following: + /// + /// Transaction response + /// --> Response messages common to all transactions. + /// Fraud response + /// --> Fraud Filters response messages. + /// Recurring response + /// --> Recurring transaction response messages. + /// Buyerauth response + /// --> Buyer auth response messages. (Not supported.) + /// + /// Additionally the Response class also contains the + /// transaction context, full request response string values. + /// + /// + /// + /// + /// + /// + /// Following example shows, how to obtain response + /// of a transaction and how to use it. + /// + /// .......... + /// // Trans is the transaction object. + /// .......... + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// ' Trans is the transaction object. + /// .......... + /// + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public sealed class Response + { + #region "Member Variables" + + /// + /// Fraud Response + /// + private FraudResponse mFraudResponse; + + /// + /// Buyer auth response + /// + private BuyerAuthResponse mBuyerAuthResponse; + + /// + /// Recurring response + /// + private RecurringResponse mRecurringResponse; + + /// + /// Get express checkout details response + /// + private ECGetResponse mGetExpressCheckoutDetailsResponse; + + /// + /// DoExpressCheckoutResponse + /// + private ECDoResponse mDoExpressCheckoutPaymentResponse; + + /// + /// ExpressCheckoutResponse + /// + private ExpressCheckoutResponse mSetExpressCheckoutPaymentResponse; + + /// + /// UpdateExpressCheckoutResponse + /// + private ECUpdateResponse mUpdateExpressCheckoutPaymentResponse; + + /// + /// Transaction response + /// + private TransactionResponse mTransactionResponse; + + /// + /// Holds the transaction context + /// + private Context mContext; + + /// + /// Holds parsed response hash table + /// + private Hashtable mResponseHashTable; + + /// + /// Holds Extended data from response + /// if any + /// populated into extend data objects + /// + private ArrayList mExtDataList; + /// + /// Request + /// + private String mRequestString; + + /// + /// Response string + /// + private String mResponseString; + + /// + /// Request id + /// + private String mRequestId; + + #endregion + + #region "Properties" + + /// + /// Gets FraudResult + /// + /// Gets the container object for all the fraud filters + /// related response messages. + /// + /// + public FraudResponse FraudResponse + { + get { return mFraudResponse; } + } + + /// + /// Gets BuyerAuthResult + /// + /// Gets the container object for all the buyer auth + /// related response messages. + /// + /// + public BuyerAuthResponse BuyerAuthResponse + { + get { return mBuyerAuthResponse; } + } + + /// + /// Gets RecurringResult + /// + /// Gets the container object for all the recurring + /// transaction related response messages. + /// + /// + public RecurringResponse RecurringResponse + { + get { return mRecurringResponse; } + } + + /// + /// Gets ExpressCheckout Response for GET action + /// + /// Gets the container object for all the express + /// checkout related response messages for GET. + /// + /// + public ECGetResponse ExpressCheckoutGetResponse + { + get { return mGetExpressCheckoutDetailsResponse; } + } + + /// + /// Gets ExpressCheckout Response for DO action + /// + /// Gets the container object for all the express + /// checkout related response messages for DO. + /// + /// + public ECDoResponse ExpressCheckoutDoResponse + { + get { return mDoExpressCheckoutPaymentResponse; } + } + + /// + /// Gets ExpressCheckout Response for Set action + /// + /// Gets the container object for all the express + /// checkout related response messages for SET. + /// + /// + public ExpressCheckoutResponse ExpressCheckoutSetResponse + { + get { return mSetExpressCheckoutPaymentResponse; } + } + /// + /// Gets ExpressCheckout Response for Update action + /// + /// Gets the container object for all the express + /// checkout related response messages for UPDATE. + /// + /// + public ECUpdateResponse ExpressCheckoutUpdateResponse + { + get { return mUpdateExpressCheckoutPaymentResponse; } + } + /// + /// Gets TransactionResult + /// + /// Gets the container object for response messages common to + /// all the transactions. + /// + /// + public TransactionResponse TransactionResponse + { + get { return mTransactionResponse; } + } + + /// + /// Gets transaction context + /// + /// Gets the transaction context + /// populated with errors, if any. + /// + /// + public Context TransactionContext + { + get { return mContext; } + } + + /// + /// Gets extended response + /// list. + /// + /// This arraylist contains the extend data objects populated + /// with the response messages. + /// + /// + public ArrayList ExtendDataList + { + get { return mExtDataList; } + } + // moved from transaction response to response obj + /// + /// Gets Request + /// + /// This is the request string as sent to the + /// PayPal payment gateway. + public String RequestString + { + get { return mRequestString; } + //set { mRequestString = value; } + } + + /// + /// Gets RequestId + /// + /// This is the request id set + /// for the transaction as sent to the PayPal payment + /// gateway. + /// + public String RequestId + { + get { return mRequestId; } + } + + /// + /// Gets Response + /// + /// This is the response string as obtained from the + /// PayPal payment gateway. + public String ResponseString + { + get { return mResponseString; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor for Response + /// + public Response() + { + } + + /// + /// Constructor for Response + /// + /// Request Id + /// Transaction Context object + public Response(String RequestId, Context TrxContext) + { + mContext = TrxContext; + //mTransactionResponse = new TransactionResponse(RequestId, ResponseId);\ + mRequestId = RequestId; + } + + #endregion + + #region "Core Functions" + + /// + /// Sets the response params + /// + /// Response string + internal void SetParams(String Response) + { + try + { + mResponseString = Response; + if (Response != null) + { + int ResultIndex = Response.IndexOf(PayflowConstants.PARAM_RESULT); + if (ResultIndex >= 0) + { + if (ResultIndex > 0) + { + Response = Response.Substring(ResultIndex); + } + ParseResponse(Response); + SetResultParams(ref mResponseHashTable); + SetFraudResultParams(ref mResponseHashTable); + SetBuyerAuthResultParams(ref mResponseHashTable); + String TrxType = PayflowUtility.LocateValueForName (RequestString , + PayflowConstants.PARAM_TRXTYPE, false ); + if (String.Equals (TrxType ,PayflowConstants.TRXTYPE_RECURRING )) + { + SetRecurringResultParams(ref mResponseHashTable); + } + else + { + SetExpressCheckoutDOResultParams (ref mResponseHashTable); + SetExpressCheckoutGETResultParams (ref mResponseHashTable); + SetExpressCheckoutSETResultParams (ref mResponseHashTable); + SetExpressCheckoutUPDATEResultParams (ref mResponseHashTable); + } + mResponseHashTable.Remove(PayflowConstants.INTL_PARAM_FULLRESPONSE); + SetExtDataList(); + mResponseHashTable = null; + } + else + { + //Append the RESULT and RESPMSG for error code + //E_UNKNOWN_STATE and create a message. + //Call SetParams again on it. + String ResponseValue = PayflowConstants.PARAM_RESULT + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorCodes[PayflowConstants.E_UNKNOWN_STATE] + + PayflowConstants.DELIMITER_NVP + + PayflowConstants.PARAM_RESPMSG + + PayflowConstants.SEPARATOR_NVP + + (String)PayflowConstants.CommErrorMessages[PayflowConstants.E_UNKNOWN_STATE] + + ", " + mResponseString ; + this.SetParams(ResponseValue); + } + } + else + { + String AddlMessage = "Empty response"; + ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_EMPTY_PARAM_LIST, null, PayflowConstants.SEVERITY_WARN, false, AddlMessage); + mContext.AddError(Err); + Err = mContext.GetError(mContext.getErrorCount() - 1); + String ResponseValue = Err.ToString(); + this.SetParams(ResponseValue); + } + + } + catch (BaseException BaseEx) + { + //ErrorObject Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE,BaseEx,PayflowConstants.SEVERITY_ERROR,false, null); + ErrorObject Error = BaseEx.GetFirstErrorInExceptionContext(); + mContext.AddError(Error); + String ResponseValue = Error.ToString(); + this.SetParams(ResponseValue); + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + ErrorObject Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE,DEx,PayflowConstants.SEVERITY_ERROR,false,null); + mContext.AddError(Error); + String ResponseValue = Error.ToString(); + this.SetParams(ResponseValue); + } + //catch + //{ + // ErrorObject Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE,null,PayflowConstants.SEVERITY_ERROR,false,null); + // mContext.AddError(Error); + // String ResponseValue = Error.ToString(); + // this.SetParams(ResponseValue); + //} + } + + /// + /// Sets the transaction result params + /// + ///Response Hash table by ref + private void SetResultParams(ref Hashtable ResponseHashTable) + { + try + { + mTransactionResponse = new TransactionResponse(); + mTransactionResponse.SetParams(ref ResponseHashTable); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + /// + /// Sets fraud result params + /// + ///Response Hash table by ref + private void SetFraudResultParams(ref Hashtable ResponseHashTable) + { + try + { + mFraudResponse = new FraudResponse(); + mFraudResponse.SetParams(ref ResponseHashTable); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + /// + /// Sets recurring result params + /// + ///Response Hash table by ref + private void SetRecurringResultParams(ref Hashtable ResponseHashTable) + { + try + { + mRecurringResponse = new RecurringResponse(); + mRecurringResponse.SetParams(ref ResponseHashTable); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + /// + /// Sets the ExpressCheckout response for GET params + /// + ///Response Hash table by ref + private void SetExpressCheckoutGETResultParams(ref Hashtable ResponseHashTable) + { + try + { + mGetExpressCheckoutDetailsResponse = new ECGetResponse(); + mGetExpressCheckoutDetailsResponse.SetParams(ref ResponseHashTable); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + /// + /// Sets the ExpressCheckout response for DO params + /// + ///Response Hash table by ref + private void SetExpressCheckoutDOResultParams(ref Hashtable ResponseHashTable) + { + try + { + mDoExpressCheckoutPaymentResponse = new ECDoResponse(); + mDoExpressCheckoutPaymentResponse.SetParams(ref ResponseHashTable); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + /// + /// Sets the ExpressCheckout response for SET params + /// + ///Response Hash table by ref + private void SetExpressCheckoutSETResultParams(ref Hashtable ResponseHashTable) + { + try + { + mSetExpressCheckoutPaymentResponse = new ExpressCheckoutResponse(); + mSetExpressCheckoutPaymentResponse.SetParams(ref ResponseHashTable); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + /// + /// Sets the ExpressCheckout response for UPDATE params + /// + ///Response Hash table by ref + private void SetExpressCheckoutUPDATEResultParams(ref Hashtable ResponseHashTable) + { + try + { + mUpdateExpressCheckoutPaymentResponse = new ECUpdateResponse(); + mUpdateExpressCheckoutPaymentResponse.SetParams(ref ResponseHashTable); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + /// + /// Sets buyer auth results params + /// + ///Response Hash table by ref + private void SetBuyerAuthResultParams(ref Hashtable ResponseHashTable) + { + try + { + mBuyerAuthResponse = new BuyerAuthResponse(); + mBuyerAuthResponse.SetParams(ref ResponseHashTable); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + /// + /// Parses response + /// + /// Response string + private void ParseResponse(String Response) + { + //Pass a new context object to the validator. We do not mean to + //validate request here. We just need to parse it and populate + //the response hashtable. + Context RespContext = new Context(); + //Check newly created context for fatal error. If the newly created + //context has fatal error, it means that, there is a problem with the + //message file. So we'll have manually assign the result,respmsg value. + //Add following values in hashtable manually + //RESULT= + //RESPMSG=, + if(RespContext.HighestErrorLvl == PayflowConstants.SEVERITY_FATAL) + { + + String Result = PayflowUtility.LocateValueForName(Response,PayflowConstants.PARAM_RESULT,false); + String RespMsg = PayflowUtility.LocateValueForName(Response,PayflowConstants.PARAM_RESPMSG,false); + if (mResponseHashTable == null) + { + mResponseHashTable = new Hashtable(); + } + + mResponseHashTable.Add(PayflowConstants.INTL_PARAM_FULLRESPONSE, mResponseString); + mResponseHashTable.Add(PayflowConstants.PARAM_RESULT ,Result); + mResponseHashTable.Add(PayflowConstants.PARAM_RESPMSG,RespMsg); + + + } + else + { + mResponseHashTable = ParameterListValidator.ParseNVPList(Response, ref RespContext, true); + RespContext = null; + if (mResponseHashTable != null) + { + mResponseHashTable.Add(PayflowConstants.INTL_PARAM_FULLRESPONSE, Response); + } + } + + } + + /// + /// Populates extended response + /// array list + /// + private void SetExtDataList() + { + ExtendData ExtData = null; + String Name; + String Value; + if (mResponseHashTable == null || mResponseHashTable.Count == 0) + { + mExtDataList = null; + } + else + { + mExtDataList = new ArrayList(); + foreach (DictionaryEntry ExtDataPair in mResponseHashTable) + { + Name = (String) ExtDataPair.Key; + Value = (String) ExtDataPair.Value; + //Separate the recurring inquiry response here + int DuplicateKeyIndex = Name.IndexOf(PayflowConstants.TAG_DUPLICATE); + if (DuplicateKeyIndex > 0) + { + Name = Name.Substring(0, DuplicateKeyIndex - 1); + } + if (Name.StartsWith(PayflowConstants.PREFIX_RECURRING_INQUIRY_RESP)) + { + mRecurringResponse.InquiryParams.Add(Name, Value); + } + else + { + ExtData = new ExtendData(Name, Value); + mExtDataList.Add(ExtData); + } + Name = null; + Value = null; + ExtData = null; + } + } + } + internal void setRequestString(string RequestString) + { + mRequestString = RequestString; + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Rule.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Rule.cs new file mode 100644 index 0000000..f4a0216 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/Rule.cs @@ -0,0 +1,142 @@ +#region "Imports" + +using System; +using System.Collections; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for fraud rule information + /// + /// These are the fraud rules applied for the transaction. + public class Rule : BaseResponseDataObject + { + #region "Member Variables" + + /// + /// Number + /// + private int mNum; + + /// + /// Rule id + /// + private String mRuleId; + + /// + /// rule alias + /// + private String mRuleAlias; + + /// + /// Rule description + /// + private String mRuleDescription; + + /// + /// Action + /// + private String mAction; + + /// + /// triggered message + /// + private String mTriggeredMessage; + + /// + /// Rule Vendor params + /// + private ArrayList mRuleVendorParms; + + #endregion + + #region "Properties" + + /// + /// Gets, Sets Num + /// + /// This is the fraud rule number. + public int Num + { + get { return mNum; } + set { mNum = value; } + } + + /// + /// Gets, Sets RuleId + /// + /// This is the fraud rule id. + public String RuleId + { + get { return mRuleId; } + set { mRuleId = value; } + } + + /// + /// Gets, Sets RuleAlias + /// + /// This is the fraud rule alias. + public String RuleAlias + { + get { return mRuleAlias; } + set { mRuleAlias = value; } + } + + /// + /// Gets, Sets RuleDescription + /// + /// This is the fraud rule description. + public String RuleDescription + { + get { return mRuleDescription; } + set { mRuleDescription = value; } + } + + /// + /// Gets, Sets Action + /// + /// This is the fraud rule action. + public String Action + { + get { return mAction; } + set { mAction = value; } + } + + /// + /// Gets, Sets TriggeredMessage + /// + /// This is the fraud rule triggered message. + public String TriggeredMessage + { + get { return mTriggeredMessage; } + set { mTriggeredMessage = value; } + } + + /// + /// Gets, Sets RuleVendorParms + /// + /// This is the fraud rule vendor params arraylist + /// containing objects of RuleParameter. + public ArrayList RuleVendorParms + { + get { return mRuleVendorParms; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor for Rule + /// + internal Rule() + { + mRuleVendorParms = new ArrayList(); + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/RuleParameter.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/RuleParameter.cs new file mode 100644 index 0000000..862de83 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/RuleParameter.cs @@ -0,0 +1,95 @@ +#region "Imports" + +using System; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for fraud rule parameter + /// + /// Rule parameter are the parameters of each fraud rule. + public class RuleParameter : BaseResponseDataObject + { + #region "Member Variables" + + /// + /// Number + /// + private int mNum; + + /// + /// Name + /// + private String mName; + + /// + /// Value + /// + private String mValue; + + /// + /// Type + /// + private String mType; + + #endregion + + #region "Properties" + + /// + /// Gets Num + /// + /// This is the fraud rule parameter number. + public int Num + { + get { return mNum; } + set { mNum = value; } + } + + /// + /// Gets Name + /// + /// This is the fraud rule parameter name. + public String Name + { + get { return mName; } + set { mName = value; } + } + + /// + /// Gets Value + /// + /// This is the fraud rule parameter value. + public String Value + { + get { return mValue; } + set { mValue = value; } + } + + /// + /// Gets Type + /// + /// This is the fraud rule parameter type. + public String Type + { + get { return mType; } + set { mType = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor for RuleParameter + /// + internal RuleParameter() + { + } + + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ShipTo.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ShipTo.cs new file mode 100644 index 0000000..c88f2ed --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/ShipTo.cs @@ -0,0 +1,434 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for shipping address information + /// + /// Shipping address is destination address information. + /// + /// Following example shows how to use ShipTo. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// + /// //Set the Shipping Address details. + /// ShipTo Ship = new ShipTo(); + /// Ship.ShipToStreet = "685A E. Middlefield Rd."; + /// Ship.ShipToStree2 = "Apt. #2"; + /// Ship.ShipToZip = "94043"; + /// Inv.ShipTo = Ship; + /// ................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// + /// 'Set the Shipping Address details. + /// Dim Ship As ShipTo = New ShipTo + /// Ship.ShipToStreet = "685A E. Middlefield Rd." + /// Ship.ShipToStree2 = "Apt. #2"; + /// Ship.ShipToZip = "94043" + /// Inv.ShipTo = Ship + /// ................. + /// + /// + public sealed class ShipTo : Address + { + #region "Member Variables" + + /// + /// Shipping method. + /// + private String mShipMethod; + + /// + /// Shipping carrier + /// + private String mShipCarrier; + + /// + /// Ship from zip + /// + private String mShipFromZip; + + #endregion + + #region "Properties" + + /// + /// Gets, Sets shipping city + /// + /// + /// Shipping city + /// Maps to Payflow Parameter: + /// SHIPTOCITY + /// + public String ShipToCity + { + get { return base.AddressCity; } + set { base.AddressCity = value; } + } + + /// + /// Gets, Sets shipping country + /// + /// + /// Shipping country + /// Maps to Payflow Parameter: + /// SHIPTOCOUNTRY + /// + public String ShipToCountry + { + get { return base.AddressCountry; } + set { base.AddressCountry = value; } + } + + /// + /// Gets, Sets shipping email + /// + /// + /// Shipping email + /// Maps to Payflow Parameter: + /// SHIPTOEMAIL + /// + public String ShipToEmail + { + get { return base.AddressEmail; } + set { base.AddressEmail = value; } + } + + /// + /// Gets, Sets shipping first name + /// + /// + /// Shipping first name + /// Maps to Payflow Parameter: + /// SHIPTOFIRSTNAME + /// + public String ShipToFirstName + { + get { return base.AddressFirstName; } + set { base.AddressFirstName = value; } + } + + /// + /// Gets, Sets shipping last name + /// + /// + /// Shipping last name + /// Maps to Payflow Parameter: + /// SHIPTOLASTNAME + /// + public String ShipToLastName + { + get { return base.AddressLastName; } + set { base.AddressLastName = value; } + } + + /// + /// Gets, Sets shipping middle name + /// + /// + /// Shipping middle name + /// Maps to Payflow Parameter: + /// SHIPTOMIDDLENAME + /// + public String ShipToMiddleName + { + get { return base.AddressMiddleName; } + set { base.AddressMiddleName = value; } + } + + /// + /// Gets, Sets shipping phone2 + /// + /// + /// Shipping phone 2 + /// Maps to Payflow Parameter: + /// SHIPTOPHONE2 + /// + public String ShipToPhone2 + { + get { return base.AddressPhone2; } + set { base.AddressPhone2 = value; } + } + + /// + /// Gets, Sets shipping phone + /// + /// + /// Shipping phone + /// Maps to Payflow Parameter: + /// SHIPTOPHONE + /// + public String ShipToPhone + { + get { return base.AddressPhone; } + set { base.AddressPhone = value; } + } + + /// + /// Gets, Sets shipping state + /// + /// + /// Shipping state + /// Maps to Payflow Parameter: + /// SHIPTOSTATE + /// + public String ShipToState + { + get { return base.AddressState; } + set { base.AddressState = value; } + } + + /// + /// Gets, Sets shipping street + /// + /// + /// Shipping street + /// Maps to Payflow Parameter: + /// SHIPTOSTREET + /// + public String ShipToStreet + { + get { return base.AddressStreet; } + set { base.AddressStreet = value; } + } + + /// + /// Gets, Sets shipping street2 + /// + /// + /// Shipping street 2. + /// Maps to Payflow Parameter: + /// SHIPTOSTREET2 + /// + public String ShipToStreet2 + { + get { return base.AddressStreet2; } + set { base.AddressStreet2 = value; } + } + + /// + /// Gets, Sets shipping zip + /// + /// + /// Ship to postal code (called ZIP code in the USA). + /// Maps to Payflow Parameter: + /// SHIPTOZIP + /// + public String ShipToZip + { + get { return base.AddressZip; } + set { base.AddressZip = value; } + } + + /// + /// Gets, Sets shipping method + /// + /// + /// Shipping method + /// Maps to Payflow Parameter: + /// SHIPMETHOD + /// + public String ShipMethod + { + get { return mShipMethod; } + set { mShipMethod = value; } + } + + /// + /// Gets, Sets shipping carrier + /// + /// + /// Shipping carrier + /// Maps to Payflow Parameter: + /// SHIPCARRIER + /// + public String ShipCarrier + { + get { return mShipCarrier; } + set { mShipCarrier = value; } + } + + /// + /// Gets, Sets ship from zip + /// + /// + /// Ship from postal code (called ZIP code in the USA). + /// Maps to Payflow Parameter: + /// SHIPFROMZIP + /// + public String ShipFromZip + { + get { return mShipFromZip; } + set { mShipFromZip = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Constructor + /// + /// Shipping address is destination address information. + /// + /// Following example shows how to use ShipTo. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// + /// //Set the Shipping Address details. + /// ShipTo Ship = new ShipTo(); + /// Ship.ShipToStreet = "685A E. Middlefield Rd."; + /// Ship.ShipToStree2 = "Apt. #2"; + /// Ship.ShipToZip = "94043"; + /// Inv.ShipTo = Ship; + /// ................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// + /// 'Set the Shipping Address details. + /// Dim Ship As ShipTo = New ShipTo + /// Ship.ShipToStreet = "685A E. Middlefield Rd." + /// Ship.ShipToStree2 = "Apt. #2"; + /// Ship.ShipToZip = "94043" + /// Inv.ShipTo = Ship + /// ................. + /// + /// + public ShipTo() + { + } + + #endregion + + #region "Utility function" + + /// + /// This method copies the common contents + /// from shipping to billing address. + /// + /// Billing Address object + /// This method can be used to + /// populate the shipping addresses directly + /// from the billing addresses when + /// both are the same. + /// + /// + /// + /// ................ + /// //Ship is the object of + /// //ShipTo populated with + /// //the shipping addresses. + /// ................ + /// + /// + /// BillTo Bill; + /// + /// //Populate billing addresses + /// //from shipping addresses. + /// Bill = Ship.Copy(); + /// + /// ................ + /// + /// + /// + /// + /// ................ + /// 'Ship is the object of + /// 'ShipTo populated with + /// 'the shipping addresses. + /// ................ + /// + /// + /// BillTo Bill; + /// + /// 'Populate billing addresses + /// 'from shipping addresses. + /// Bill = Ship.Copy() + /// + /// ................ + /// + /// + /// + /// + public BillTo Copy() + { + BillTo CopyObject = new BillTo(); + CopyObject.AddressCity = AddressCity; + CopyObject.AddressCountry = AddressCountry; + CopyObject.AddressEmail = AddressEmail; + CopyObject.AddressFax = AddressFax; + CopyObject.AddressFirstName = AddressFirstName; + CopyObject.AddressLastName = AddressLastName; + CopyObject.AddressMiddleName = AddressMiddleName; + CopyObject.AddressPhone2 = AddressPhone2; + CopyObject.AddressPhone = AddressPhone; + CopyObject.AddressState = AddressState; + CopyObject.AddressStreet = AddressStreet; + CopyObject.AddressStreet2 = AddressStreet2; + CopyObject.AddressZip = AddressZip; + return CopyObject; + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOSTREET, this.ShipToStreet)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOSTREET2, this.ShipToStreet2)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOCITY, this.ShipToCity)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOSTATE, this.ShipToState)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOCOUNTRY, this.ShipToCountry)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOZIP, this.ShipToZip)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOPHONE, this.ShipToPhone)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOPHONE2, this.ShipToPhone2)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOEMAIL, this.ShipToEmail)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOFIRSTNAME, this.ShipToFirstName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOMIDDLENAME, this.ShipToMiddleName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPTOLASTNAME, this.ShipToLastName)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPCARRIER, mShipCarrier)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPMETHOD, mShipMethod)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPFROMZIP, mShipFromZip)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SHIPPEDFROMZIP, mShipFromZip)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/SwipeCard.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/SwipeCard.cs new file mode 100644 index 0000000..0f3e432 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/SwipeCard.cs @@ -0,0 +1,96 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for swipe card information + /// + /// + /// Used to pass the Track 1 or Track 2 data (the card’s + /// magnetic stripe information) for card-present + /// transactions. Include either Track 1 or Track 2 + /// data—not both. If Track 1 is physically damaged, the + /// POS application can send Track 2 data instead. + /// SwipeCard is associated with CardTender. + /// + /// + public sealed class SwipeCard : PaymentDevice + { + + #region "Constructors" + + /// + /// Constructor for SwipeCard + /// + /// Card Swipe value + /// This is used as Payment Device for the CardTender. + /// Maps to Payflow Parameter: + /// Swipe --> SWIPE + /// + /// + /// + /// ............. + /// + /// SwipeCard PayDevice = new SwipeCard("XXXXXXXXXXXXXXXXXXXXXXXXXXX"); + /// + /// .............. + /// + /// + /// ............. + /// + /// Dim PayDevice As SwipeCard = New SwipeCard("XXXXXXXXXXXXXXXXXXXXXXXXXXX") + /// + /// .............. + /// + /// + /// + public SwipeCard(String Swipe) : base(Swipe) + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + //Set the base acct field as swipe in the request. + if (base.Acct != "") + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SWIPE, base.Acct)); + } + if (mMagtekInfo != null) + { + mMagtekInfo.RequestBuffer = RequestBuffer; + mMagtekInfo.GenerateRequest(); + } + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/TransactionResponse.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/TransactionResponse.cs new file mode 100644 index 0000000..cf808ce --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/TransactionResponse.cs @@ -0,0 +1,1456 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using System.Collections; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for transaction response. + /// + /// + /// TransactionResponse object is contained in the main response + /// object Response of the transaction. + /// + /// + /// Following is the example of how to get the transaction response + /// after the transaction. + /// + /// ................... + /// //Trans is the transaction object. + /// ................... + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// } + /// ................ + /// + /// + /// ......................... + /// ' Trans is the transaction object. + /// ......................... + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// End If + /// + /// ......................... + /// + /// + public sealed class TransactionResponse : BaseResponseDataObject + { + #region "Member Variables" + + /// + /// Result + /// + private int mResult; + + /// + /// Pnref + /// + private String mPnref; + + /// + /// Resp msg + /// + private String mRespMsg; + + /// + /// Authcode + /// + private String mAuthCode; + + /// + /// Avs Addr + /// + private String mAvsAddr; + + /// + /// Avs zip + /// + private String mAvsZip; + + /// + /// Card Secure + /// + private String mCardSecure; + + /// + /// Cvv2 match + /// + private String mCVV2Match; + + /// + /// Iavs + /// + private String mIavs; + + /// + /// Inquiry OrigResult + /// + private String mOrigResult; + + //Expose OrigPnref param 28-12-2005 + /// + /// Inquiry OrigPnref + /// + private String mOrigPnref; + /// + /// Inquiry Trans state + /// + private String mTransState; + + /// + /// Inquiry cust ref + /// + private String mCustRef; + + /// + /// Inquiry start time + /// + private String mStartTime; + + /// + /// Inquiry end time + /// + private String mEndTime; + + /// + /// Duplicate + /// + private String mDuplicate; + + /// + /// Inquiry Date to settle + /// + private String mDateToSettle; + + /// + /// Inquiry Batch Id + /// + private String mBatchId; + + /// + /// Holds AddlMsgs + /// + private String mAddlMsgs; + + /// + /// Holds RespText + /// + private String mRespText; + + /// + /// Holds ProcAvs + /// + private String mProcAvs; + + /// + /// Holds ProcCardSecure + /// + private String mProcCardSecure; + + /// + /// Holds ProcCvv2 + /// + private String mProcCVV2; + + /// + /// Holds HostCode + /// + private String mHostCode; + //Added a SETTLE_DATE param is also available when VERBOSITY= MEDIUM + //2005-12-10 + /// + /// Inquiry SettleDate + /// + private String mSettleDate; + /// + /// PPref + /// + private String mPPRef; + /// + /// Holds the CorrelationId + /// + private String mCorrelationId; + /// + /// Holds FeeAmt + /// + private String mFeeAmt; + /// + /// Pending reason + /// + private String mPendingReason; + /// + /// Payment Type + /// + private String mPaymentType; + // Added STATUS param is also available when VERBOSITY = MEDIUM + /// + /// Inquiry Status + /// + private String mStatus; + // Added BALAMT param, AMEX CAPN 05/31/07 + /// + /// BalAmt + /// + private String mBalAmt; + // Added AMEXID param, AMEX CAPN 05/31/07 VERBOSITY = MEDIUM + /// + /// AmexID + /// + private String mAmexID; + // Added AMEXPOSDATA param, AMEX CAPN 11/07/07 VERBOSITY = MEDIUM + /// + /// AmexPosData + /// + private String mAmexPosData; + /// + /// TransTime + /// + private String mTransTime; + /// + /// CardType + /// + private String mCardType; + /// + /// OrigAmt + /// + private String mOrigAmt; + /// + /// Acct + /// + private String mAcct; + /// + /// LastName + /// + private String mLastName; + /// + /// FirstName + /// + private String mFirstName; + /// + /// Amt + /// + private String mAmt; + /// + /// EmailMatch + /// + private String mEmailMatch; + /// + /// PhoneMatch + /// + private String mPhoneMatch; + /// + /// ExpDate + /// + private String mExpDate; + /// + /// ExtRspMsg + /// + private String mExtRspMsg; + /// + /// SecureToken + /// + private String mSecureToken; + /// + /// SecureTokenId + /// + private String mSecureTokenId; + /// + /// MagTResponse + /// + private String mMagTResponse; + /// + /// TraceId + /// + private String mTraceId; + /// + /// AchStatus + /// + private String mAchStatus; + /// + /// TxId + /// + private String mTxId; + /// + /// PaymentAdviceCode + /// + private String mPaymentAdviceCode; + /// + /// AssociationResponseCode + /// + private String mAssociationResponseCode; + /// + /// Type + /// + private String mType; + /// + /// Affluent + /// + private String mAffluent; + /// + /// CCUpdated + /// + private String mCCUpdated; + /// + /// Rrn + /// + private String mRrn; + /// + /// Stan + /// + private String mStan; + /// + /// Aci + /// + private String mAci; + /// + /// ValidationCode + /// + private String mValidationCode; + /// + /// CCTransId + /// + private String mCCTransId; + /// + /// CCTrans_POSData + /// + private String mCCTrans_POSData; + + #endregion + + #region "Properties" + + /// + /// Gets Result + /// + /// + /// The outcome of the attempted transaction. A + /// result of 0 (zero) indicates the transaction was + /// approved. Any other number indicates a + /// decline or error. + /// Maps to Payflow Parameter: + /// RESULT + /// + public int Result + { + get { return mResult; } + } + + /// + /// Gets Pnref + /// + /// + /// PayPal Reference ID, a unique number that + /// identifies the transaction. + /// Maps to Payflow Parameter: + /// PNREF + /// + public String Pnref + { + get { return mPnref; } + } + + /// + /// Gets RespMsg + /// + /// + /// + /// The response message returned with the + /// transaction result. Exact wording varies. + /// Sometimes a colon appears after the initial + /// RESPMSG followed by more detailed + /// information. + /// + /// APPROVED + /// Maps to Payflow Parameter: + /// RESPMSG + /// + public String RespMsg + { + get { return mRespMsg; } + } + + /// + /// Gets AuthCode + /// + /// + /// Returned for Sale, Authorization, and Voice + /// Authorization transactions. AUTHCODE is the + /// approval code obtained over the phone from + /// the processing network. + /// Maps to Payflow Parameter: + /// AUTHCODE + /// + public String AuthCode + { + get { return mAuthCode; } + } + + /// + /// Gets AVSAddr + /// + /// + /// AVS address responses are for advice only. + /// This process does not affect the outcome of the + /// authorization. + /// Maps to Payflow Parameter: + /// AVSADDR + /// + public String AVSAddr + { + get { return mAvsAddr; } + } + + /// + /// Gets AVSZip + /// + /// + /// AVS ZIP code responses are for advice only. + /// This process does not affect the outcome of the + /// authorization. + /// Maps to Payflow Parameter: + /// AVSZIP + /// + public String AVSZip + { + get { return mAvsZip; } + } + + /// + /// Gets CardSecure + /// + /// + /// Obtained for Visa cards. + /// CAVV validity. + /// Y=valid, N=Not valid, X=cannot determine + /// Maps to Payflow Parameter: + /// CARDSECURE + /// + public String CardSecure + { + get { return mCardSecure; } + } + + /// + /// Gets CVV2Match + /// + /// + /// Result of the card security code (CVV2) check. + /// This value does not affect the outcome of the + /// transaction. + /// + /// + /// Value + /// Description + /// + /// + /// Y + /// The submitted value matches the data on file for the card. + /// + /// + /// N + /// The submitted value does not match the data on file for the card. + /// + /// + /// X + /// The cardholder’s bank does not support this service. + /// + /// + /// Maps to Payflow Parameter: + /// CVV2MATCH + /// + public String CVV2Match + { + get { return mCVV2Match; } + //set { mCVV2Match = value; } + } + + /// + /// Gets EMailMatch + /// + /// + /// Result of the e-mail check. + /// This value does not affect the outcome of the + /// transaction. + /// + /// + /// Value + /// Description + /// + /// + /// Y + /// The submitted value matches the data on file for the card holder. + /// + /// + /// N + /// The submitted value does not match the data on file for the card holder. + /// + /// + /// X + /// The cardholder’s bank does not support this service. + /// + /// + /// Maps to Payflow Parameter: + /// EMAILMATCH + /// + public String EmailMatch + { + get { return mEmailMatch; } + //set { mCVV2Match = value; } + } + + /// + /// Gets PhoneMatch + /// + /// + /// Result of the phone check. + /// This value does not affect the outcome of the + /// transaction. + /// + /// + /// Value + /// Description + /// + /// + /// Y + /// The submitted value matches the data on file for the card holder. + /// + /// + /// N + /// The submitted value does not match the data on file for the card holder. + /// + /// + /// X + /// The cardholder’s bank does not support this service. + /// + /// + /// Maps to Payflow Parameter: + /// PHONEMATCH + /// + public String PhoneMatch + { + get { return mPhoneMatch; } + //set { mCVV2Match = value; } + } + + /// + /// Gets IAVS + /// + /// + /// International AVS address responses are for + /// advice only. This value does not affect the + /// outcome of the transaction. + /// Indicates whether AVS response is + /// international (Y), US (N), or cannot be + /// determined (X). + /// Maps to Payflow Parameter: + /// IAVS + /// + public String IAVS + { + get { return mIavs; } + } + + + + /// + /// Gets inquiry OrigResult + /// + /// + /// Gets the Original transaction result for which + /// inquiry transaction is performed. + /// Maps to Payflow Parameter: + /// ORIGRESULT + /// + public String OrigResult + { + get { return mOrigResult; } + } + + //Expose OrigPnref param 28-12-2005 + /// + /// Gets inquiry OrigPnref + /// + /// + /// Gets the Original PNREF for which + /// inquiry transaction is performed. + /// Maps to Payflow Parameter: + /// ORIGPNREF + /// + public String OrigPnref + { + get { return mOrigPnref; } + } + + /// + /// Gets inquiry TransState + /// + /// + /// Gets the Transaction state of the transaction for + /// which inquiry transaction is performed. + /// Maps to Payflow Parameter: + /// TRANSSTATE + /// + public String TransState + { + get { return mTransState; } + } + + /// + /// Gets inquiry Custref + /// + /// + /// Merchant-defined identifier for reporting and + /// auditing purposes. For example, you can set + /// CUSTREF to the invoice number. + /// You can use CUSTREF when performing Inquiry + /// transactions. To ensure that you can always + /// access the correct transaction when performing + /// an Inquiry, you must provide a unique CUSTREF when submitting any transaction, including retries. + /// Maps to Payflow Parameter: + /// CUSTREF + /// + public String CustRef + { + get { return mCustRef; } + } + + /// + /// Gets inquiry StartTime + /// + /// + /// Gets the Start time of the transaction for + /// which inquiry transaction is performed. + /// Maps to Payflow Parameter: + /// STARTTIME + /// + public String StartTime + { + get { return mStartTime; } + } + + /// + /// Gets inquiry EndTime + /// + /// + /// Gets the End time of the transaction for + /// which inquiry transaction is performed. + /// Maps to Payflow Parameter: + /// ENDTIME + /// + public String EndTime + { + get { return mEndTime; } + } + + /// + /// Gets Duplicate + /// + /// + /// Indicates transactions sent with duplicate identifier. + /// If a transaction is performed with the request id that has + /// been previously used for another transaction, Duplicate is + /// returned as 1. + /// Maps to Payflow Parameter: + /// DUPLICATE + /// + public String Duplicate + { + get { return mDuplicate; } + } + + /// + /// Gets inquiry DateToSettle + /// + /// + /// Gets the settle date of the transaction for which + /// inquiry transaction is performed. + /// Value available only before settlement has started + /// Value obtained when Payflow Verbosity paramter = MEDIUM + /// Maps to Payflow Parameter: + /// DATE_TO_SETTLE + /// + public String DateToSettle + { + get { return mDateToSettle; } + } + + /// + /// Gets inquiry BatchId + /// + /// + /// Gets the batch id of the transaction for which the + /// inquiry transaction is performed. + /// Value available only after settlement has assigned a BatchId + /// Value obtained when Payflow Verbosity paramter = MEDIUM + /// Maps to Payflow Parameter: + /// BATCHID + /// + public String BatchId + { + get { return mBatchId; } + } + + /// + /// Gets, Sets AddlMsgs + /// + /// + /// Additional error message that indicates that the + /// merchant used a feature that is disabled. + /// Value obtained when Payflow Verbosity paramter = MEDIUM + /// Maps to Payflow Parameter: + /// ADDLMSGS + /// + public String AddlMsgs + { + get { return mAddlMsgs; } + } + + /// + /// Gets, Sets HostCode + /// + /// + /// Response code returned by the processor. This + /// value is not normalized by PayPal. + /// Maps to Payflow Parameter: + /// HOSTCODE + /// + public String HostCode + { + get { return mHostCode; } + + } + + /// + /// Gets, Sets ProcAVS + /// + /// + /// AVS (Address Verification Service) response + /// from the processor. + /// Value obtained when Payflow Verbosity paramter = MEDIUM + /// Maps to Payflow Parameter: + /// PROCAVS + /// + public String ProcAVS + { + get { return mProcAvs; } + } + + /// + /// Gets, Sets ProcCardSecure + /// + /// + /// VPAS/SPA response from the processor. + /// Value obtained when Payflow Verbosity paramter = MEDIUM + /// Maps to Payflow Parameter: + /// PROCCARDSECURE + /// + public String ProcCardSecure + { + get { return mProcCardSecure; } + } + + /// + /// Gets, Sets ProcCVV2 + /// + /// + /// CVV2 (buyer authentication) response from the processor. + /// Its a 3- or 4-digit code that is printed (not imprinted) on + /// the back of a credit card. Used as partial assurance + /// that the card is in the buyer’s possession. + /// Value obtained when Payflow Verbosity paramter = MEDIUM + /// Maps to Payflow Parameter: + /// PROCCVV2 + /// + public String ProcCVV2 + { + get { return mProcCVV2; } + } + + /// + /// Gets, Sets RespText + /// + /// + /// Text corresponding to the response code + /// returned by the processor. This text is not + /// normalized by Gateway server. + /// Maps to Payflow Parameter: + /// RESPTEXT + /// + public String RespText + { + get { return mRespText; } + } + + //Added as SETTLE_DATE parameter is also available when VERBOSITY= MEDIUM + //2005-12-10 + /// + /// Gets inquiry SettleDate + /// + /// + /// Date when the settlement is completed + /// Value obtained when Payflow Verbosity paramter = MEDIUM + /// Maps to Payflow Parameter: + /// SETTLE_DATE + /// + public String SettleDate + { + get { return mSettleDate; } + } + /// + /// Gets the PPref parameter + /// + /// + /// Maps to Payflow Parameter: + /// PPREF + /// + public String PPref + { + get {return mPPRef;} + } + /// + /// Gets the CorrelationId parameter + /// + /// + /// Maps to Payflow Parameter: + /// CORRELATIONID + /// + public String CorrelationId + { + get {return mCorrelationId;} + } + + /// + /// Gets the feeamt parameter + /// + /// + /// Maps to Payflow Parameter: + /// FEEAMT + /// + public String FeeAmt + { + get {return mFeeAmt;} + } + + /// + /// Gets the PendingReason parameter + /// + /// + /// Maps to Payflow Parameter: + /// PENDINGREASON + /// + public String PendingReason + { + get {return mPendingReason;} + } + /// + /// Gets the PaymentType parameter + /// + /// + /// Maps to Payflow Parameter: + /// PAYMENTTYPE + /// + public String PaymentType + { + get {return mPaymentType;} + } + + //Added as STATUS param is also available when VERBOSITY= MEDIUM + //2006-09-18 + /// + /// Gets inquiry Status + /// + /// + /// Status of transaction + /// Value obtained when Payflow Verbosity parameter = MEDIUM + /// Maps to Payflow Parameter: + /// STATUS + /// + public String Status + { + get { return mStatus; } + } + // Added BALAMT param 2007-05-31 + /// + /// Gets the BalAmt parameter + /// + /// + /// American Express CAPN transactions only: + /// Balance on a pre-paid store value card. The value includes a decimal and + /// the exact amount to the cent (42.00, not 42). + /// Maps to Payflow Parameter: + /// BALAMT + /// + public String BalAmt + { + get { return mBalAmt; } + } + // Added AMEXID param 2007-05-31 + /// + /// Gets the AmexID parameter + /// + /// + /// American Express CAPN transactions only: + /// Unique transaction ID returned when VERBOSITY = MEDIUM. + /// Used to track American Express CAPN transactions. + /// Maps to Payflow Parameter: + /// AMEXID + /// + public String AmexID + { + get { return mAmexID; } + } + // Added AMEXPOSDATA param 2007-11-05 + /// + /// Gets the AmexPosData parameter + /// + /// + /// American Express CAPN transactions only: + /// Unique field returned when VERBOSITY = MEDIUM. + /// Used by merchants who authorize transactions through + /// the payflow gateway but settle through a third-party solution. + /// Maps to Payflow Parameter: + /// AMEXPOSDATA + /// + public String AmexPosData + { + get { return mAmexPosData; } + } + /// + /// Gets the TransTime parameter + /// + /// + /// Returns the transaction time in the format of: + /// + /// Maps to Payflow Parameter: + /// TRANSTIME + /// + public String TransTime + { + get { return mTransTime; } + } + /// + /// Gets the CardType parameter + /// + /// + /// Returns a value which represents the card type used. + /// + /// Maps to Payflow Parameter: + /// CARDTYPE + /// + public String CardType + { + get { return mCardType; } + } + /// + /// Gets the OrigAmt parameter + /// + /// + /// Returns the original amount sent for processing. Used + /// with PARTIALAUTH parameter. + /// + /// Maps to Payflow Parameter: + /// ORIGAMT + /// + public String OrigAmt + { + get { return mOrigAmt; } + } + /// + /// Gets the Acct parameter + /// + /// + /// Returns the last 4-digits of the credit card number used. + /// + /// Maps to Payflow Parameter: + /// ACCT + /// + public String Acct + { + get { return mAcct; } + } + /// + /// Gets the LastName parameter + /// + /// + /// Returns the last name. + /// + /// Maps to Payflow Parameter: + /// LASTNAME + /// + public String LastName + { + get { return mLastName; } + } + /// + /// Gets the FirstName parameter + /// + /// + /// Returns the first name. + /// + /// Maps to Payflow Parameter: + /// FIRSTNAME + /// + public String FirstName + { + get { return mFirstName; } + } + /// + /// Gets the amt parameter + /// + /// + /// Returns the amount of the transaction that was + /// authorized. + /// + /// Maps to Payflow Parameter: + /// AMT + /// + public String Amt + { + get { return mAmt; } + } + /// + /// Gets the ExpDate parameter + /// + /// + /// Returns the expiration date of the credit card used. + /// + /// Maps to Payflow Parameter: + /// EXPDATE + /// + public String ExpDate + { + get { return mExpDate; } + } + /// + /// Gets the ExtRspMsg parameter + /// + /// + /// Returns additional (extra) response messages from processor. + /// Not supported by all processors. + /// + /// Maps to Payflow Parameter: + /// EXTRSPMSG + /// + public String ExtRspMsg + { + get { return mExtRspMsg; } + } + /// + /// Gets the SecureToken parameter + /// + /// + /// Returns the secure token that was sent in the original transaction. + /// Used with secure token id to call the hosted payment pages. + /// + /// Maps to Payflow Parameter: + /// SECURETOKEN + /// + public String SecureToken + { + get { return mSecureToken; } + } + /// + /// Gets the SecureTokenId parameter + /// + /// + /// Returns the secure token id that was sent in the original transaction. + /// Used with secure token to call the hosted payment pages. + /// + /// Maps to Payflow Parameter: + /// SECURETOKENID + /// + public String SecureTokenId + { + get { return mSecureTokenId; } + } + /// + /// Gets the MagTResponse parameter + /// + /// + /// This only appears in the response if a data validation error occurs or + /// if the MagTek service throws an error. + /// + /// Maps to Payflow Parameter: + /// MAGTRESPONSE + /// + public String MagTResponse + { + get { return mMagTResponse; } + } + /// + /// Gets the Trace Id parameter + /// + /// + /// Returns the Trace Id returned by TeleCheck. + /// + /// Maps to Payflow Parameter: + /// TRACEID + /// + public String TraceId + { + get { return mTraceId; } + } + /// + /// Gets the AchStatus parameter + /// + /// + /// Returns the ACH Status returned by TeleCheck. + /// + /// Maps to Payflow Parameter: + /// ACHSTATUS + /// + public String AchStatus + { + get { return mAchStatus; } + } + + /// + /// Gets the TXId parameter + /// + /// + /// Returns the Transaction Id for Card on File + /// + /// Maps to Payflow Parameter: + /// TXID + /// + public String TxId + { + get { return mTxId; } + } + /// + /// Gets the Payment Advice Code + /// + /// + /// Returns the Payment Advice Code for supported processors. + /// + /// Maps to Payflow Parameter: + /// PAYMENTADVICECODE + /// + public String PaymentAdviceCode + { + get { return mPaymentAdviceCode; } + } + /// + /// Gets the Association Response Code parameter + /// + /// + /// Returns the Association Response Code for supported processors. + /// + /// Maps to Payflow Parameter: + /// ASSOCIATIONRESPONSECODE + /// + public String AssociationResponseCode + { + get { return mAssociationResponseCode; } + } + /// + /// Gets the Type parameter + /// + /// + /// Returns the yype of account used in the transaction. + /// + /// Maps to Payflow Parameter: + /// TYPE + /// + public String Type + { + get { return Type; } + } + /// + /// Gets the Affluent parameter + /// + /// + /// Returns the status (affluent) of the card holder. + /// + /// Maps to Payflow Parameter: + /// AFFLUENT + /// + public String Affluent + { + get { return mAffluent; } + } + + /// + /// Gets the CC Updated parameter + /// + /// + /// Returns the status if the card was updated. + /// + /// Maps to Payflow Parameter: + /// CCUPDATED + /// + public String CCUpdated + { + get { return mCCUpdated; } + } + + /// + /// Gets the Retrieve Reference transaction. + /// + /// + /// Maps to Payflow Parameter: + /// RRN + /// + public String Rrn + { + get { return mRrn; } + } + /// + /// Gets the System Trace Audit number. + /// + /// + /// Maps to Payflow Parameter: + /// STAN + /// + public String Stan + { + get { return mStan; } + } + /// + /// Gets the Authorization Characteristics Indicator. + /// + /// + /// Maps to Payflow Parameter: + /// Aci + /// + public String Aci + { + get { return mAci; } + } + /// + /// Gets the Transaction Identifier. + /// + /// The transaction identifier associated with the transaction being settled. + /// + /// Maps to Payflow Parameter: + /// VALIDATIONCODE + /// + public String ValidationCode + { + get { return mValidationCode; } + } + + /// + /// Gets the Credit Card Transaction Id. + /// + /// Unique transaction ID returned by some processors for all credit card transactions. + /// + /// Maps to Payflow Parameter: + /// CCTRANSID + /// + public String CCTransId + { + get { return mCCTransId; } + } + /// + /// Gets the Credit Card Transaction POS Data + /// + /// Value returned by some processors for all credit card transactions. + /// + /// Maps to Payflow Parameter: + /// CCTRAN_POSDATA + /// + public String CCTrans_POSData + { + get { return mCCTrans_POSData; } + } + #endregion + + #region "Constructors" + + /// + /// Constructor for Transaction response. + /// + internal TransactionResponse () + { + + } + + + #endregion + + #region "Functions" + + /// + /// Sets response params + /// + ///Response Hash table by ref + internal void SetParams(ref Hashtable ResponseHashTable) + { + // mResponse = (String) ResponseHashTable[PayflowConstants.INTL_PARAM_FULLRESPONSE]; + mResult = int.Parse( (String)ResponseHashTable[PayflowConstants.PARAM_RESULT]); + mPnref = (String) ResponseHashTable[PayflowConstants.PARAM_PNREF]; + mRespMsg = (String) ResponseHashTable[PayflowConstants.PARAM_RESPMSG]; + mAuthCode = (String) ResponseHashTable[PayflowConstants.PARAM_AUTHCODE]; + mAvsAddr = (String) ResponseHashTable[PayflowConstants.PARAM_AVSADDR]; + mAvsZip = (String) ResponseHashTable[PayflowConstants.PARAM_AVSZIP]; + mCardSecure = (String) ResponseHashTable[PayflowConstants.PARAM_CARDSECURE]; + mCVV2Match = (String) ResponseHashTable[PayflowConstants.PARAM_CVV2MATCH]; + mIavs = (String) ResponseHashTable[PayflowConstants.PARAM_IAVS]; + mOrigResult = (String) ResponseHashTable[PayflowConstants.PARAM_ORIGRESULT]; + mTransState = (String) ResponseHashTable[PayflowConstants.PARAM_TRANSSTATE]; + mCustRef = (String) ResponseHashTable[PayflowConstants.PARAM_CUSTREF]; + mStartTime = (String) ResponseHashTable[PayflowConstants.PARAM_STARTTIME]; + mEndTime = (String) ResponseHashTable[PayflowConstants.PARAM_ENDTIME]; + mDuplicate = (String) ResponseHashTable[PayflowConstants.PARAM_DUPLICATE]; + mDateToSettle = (String) ResponseHashTable[PayflowConstants.PARAM_DATE_TO_SETTLE]; + mBatchId = (String) ResponseHashTable[PayflowConstants.PARAM_BATCHID]; + mAddlMsgs = (String) ResponseHashTable[PayflowConstants.PARAM_ADDLMSGS]; + mRespText = (String) ResponseHashTable[PayflowConstants.PARAM_RESPTEXT]; + mProcAvs = (String) ResponseHashTable[PayflowConstants.PARAM_PROCAVS]; + mProcCardSecure = (String) ResponseHashTable[PayflowConstants.PARAM_PROCCARDSECURE]; + mProcCVV2 = (String) ResponseHashTable[PayflowConstants.PARAM_PROCCVV2]; + mHostCode = (String) ResponseHashTable[PayflowConstants.PARAM_HOSTCODE]; + mSettleDate = (String) ResponseHashTable[PayflowConstants.PARAM_SETTLE_DATE]; + mOrigPnref = (String) ResponseHashTable[PayflowConstants.PARAM_ORIGPNREF]; + mPPRef = (String) ResponseHashTable[PayflowConstants.PARAM_PPREF]; + mCorrelationId = (String) ResponseHashTable[PayflowConstants.PARAM_CORRELATIONID]; + mFeeAmt = (String) ResponseHashTable[PayflowConstants.PARAM_FEEAMT]; + mPendingReason = (String) ResponseHashTable[PayflowConstants.PARAM_PENDINGREASON]; + mPaymentType = (String) ResponseHashTable[PayflowConstants.PARAM_PAYMENTTYPE]; + mStatus = (String)ResponseHashTable[PayflowConstants.PARAM_STATUS]; + mBalAmt = (String)ResponseHashTable[PayflowConstants.PARAM_BALAMT]; + mAmexID = (String)ResponseHashTable[PayflowConstants.PARAM_AMEXID]; + mAmexPosData = (String)ResponseHashTable[PayflowConstants.PARAM_AMEXPOSDATA]; + mAcct = (String)ResponseHashTable[PayflowConstants.PARAM_ACCT]; + mLastName = (String)ResponseHashTable[PayflowConstants.PARAM_LASTNAME]; + // due to issue where ACH doesn't support BILLTOFIRSTNAME we have to use legacy FIRSTNAME to get response value. + if (ResponseHashTable["FIRSTNAME"] == null) + mFirstName = (String)ResponseHashTable[PayflowConstants.PARAM_FIRSTNAME]; + else + mFirstName = (String)ResponseHashTable["FIRSTNAME"]; + mAmt = (String)ResponseHashTable[PayflowConstants.PARAM_AMT]; + mExpDate = (String)ResponseHashTable[PayflowConstants.PARAM_EXPDATE]; + mTransTime = (String)ResponseHashTable[PayflowConstants.PARAM_TRANSTIME]; + mCardType = (String)ResponseHashTable[PayflowConstants.PARAM_CARDTYPE]; + mOrigAmt = (String)ResponseHashTable[PayflowConstants.PARAM_ORIGAMT]; + mEmailMatch = (String)ResponseHashTable[PayflowConstants.PARAM_EMAILMATCH]; + mPhoneMatch = (String)ResponseHashTable[PayflowConstants.PARAM_PHONEMATCH]; + mExtRspMsg = (String)ResponseHashTable[PayflowConstants.PARAM_EXTRSPMSG]; + mSecureToken = (String)ResponseHashTable[PayflowConstants.PARAM_SECURETOKEN]; + mSecureTokenId = (String)ResponseHashTable[PayflowConstants.PARAM_SECURETOKENID]; + mMagTResponse = (String)ResponseHashTable[PayflowConstants.MAGTEK_PARAM_MAGTRESPONSE]; + mTraceId = (String)ResponseHashTable[PayflowConstants.PARAM_TRACEID]; + mAchStatus = (String)ResponseHashTable[PayflowConstants.PARAM_ACHSTATUS]; + mTxId = (String)ResponseHashTable[PayflowConstants.PARAM_TXID]; + mPaymentAdviceCode = (String)ResponseHashTable[PayflowConstants.PARAM_PAYMENTADVICECODE]; + mAssociationResponseCode = (String)ResponseHashTable[PayflowConstants.PARAM_ASSOCIATIONRESPCODE]; + mType = (String)ResponseHashTable[PayflowConstants.PARAM_TYPE]; + mCCUpdated = (String)ResponseHashTable[PayflowConstants.PARAM_CCUPDATED]; + mAffluent= (String)ResponseHashTable[PayflowConstants.PARAM_AFFLUENT]; + mRrn= (String)ResponseHashTable[PayflowConstants.PARAM_RRN]; + mStan = (String)ResponseHashTable[PayflowConstants.PARAM_STAN]; + mAci = (String)ResponseHashTable[PayflowConstants.PARAM_ACI]; + mValidationCode = (String)ResponseHashTable[PayflowConstants.PARAM_VALIDATIONCODE]; + mCCTransId = (String)ResponseHashTable[PayflowConstants.PARAM_CCTRANSID]; + mCCTrans_POSData = (String)ResponseHashTable[PayflowConstants.PARAM_CCTRANS_POSDATA]; + + // Remove the used response params from hash table. + // ResponseHashTable.Remove(PayflowConstants.INTL_PARAM_FULLRESPONSE); + ResponseHashTable.Remove(PayflowConstants.PARAM_RESULT); + ResponseHashTable.Remove(PayflowConstants.PARAM_PNREF); + ResponseHashTable.Remove(PayflowConstants.PARAM_RESPMSG); + ResponseHashTable.Remove(PayflowConstants.PARAM_AUTHCODE); + ResponseHashTable.Remove(PayflowConstants.PARAM_AVSADDR); + ResponseHashTable.Remove(PayflowConstants.PARAM_AVSZIP); + ResponseHashTable.Remove(PayflowConstants.PARAM_CARDSECURE); + ResponseHashTable.Remove(PayflowConstants.PARAM_CVV2MATCH); + ResponseHashTable.Remove(PayflowConstants.PARAM_IAVS); + ResponseHashTable.Remove(PayflowConstants.PARAM_ORIGRESULT); + ResponseHashTable.Remove(PayflowConstants.PARAM_TRANSSTATE); + ResponseHashTable.Remove(PayflowConstants.PARAM_CUSTREF); + ResponseHashTable.Remove(PayflowConstants.PARAM_STARTTIME); + ResponseHashTable.Remove(PayflowConstants.PARAM_ENDTIME); + ResponseHashTable.Remove(PayflowConstants.PARAM_DUPLICATE); + ResponseHashTable.Remove(PayflowConstants.PARAM_DATE_TO_SETTLE); + ResponseHashTable.Remove(PayflowConstants.PARAM_BATCHID); + ResponseHashTable.Remove(PayflowConstants.PARAM_ADDLMSGS); + ResponseHashTable.Remove(PayflowConstants.PARAM_RESPTEXT); + ResponseHashTable.Remove(PayflowConstants.PARAM_PROCAVS); + ResponseHashTable.Remove(PayflowConstants.PARAM_PROCCARDSECURE); + ResponseHashTable.Remove(PayflowConstants.PARAM_PROCCVV2); + ResponseHashTable.Remove(PayflowConstants.PARAM_HOSTCODE); + ResponseHashTable.Remove(PayflowConstants.PARAM_SETTLE_DATE); + ResponseHashTable.Remove(PayflowConstants.PARAM_ORIGPNREF); + ResponseHashTable.Remove(PayflowConstants.PARAM_PPREF); + ResponseHashTable.Remove(PayflowConstants.PARAM_CORRELATIONID); + ResponseHashTable.Remove(PayflowConstants.PARAM_FEEAMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_PENDINGREASON); + ResponseHashTable.Remove(PayflowConstants.PARAM_PAYMENTTYPE); + ResponseHashTable.Remove(PayflowConstants.PARAM_BALAMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_AMEXID); + ResponseHashTable.Remove(PayflowConstants.PARAM_AMEXPOSDATA); + ResponseHashTable.Remove(PayflowConstants.PARAM_ACCT); + ResponseHashTable.Remove(PayflowConstants.PARAM_LASTNAME); + ResponseHashTable.Remove(PayflowConstants.PARAM_FIRSTNAME); + // This is here to deal with FIRSTNAME returned in ACH, not BILLTOFIRSTNAME. + ResponseHashTable.Remove("FIRSTNAME"); + ResponseHashTable.Remove(PayflowConstants.PARAM_AMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_EXPDATE); + ResponseHashTable.Remove(PayflowConstants.PARAM_TRANSTIME); + ResponseHashTable.Remove(PayflowConstants.PARAM_CARDTYPE); + ResponseHashTable.Remove(PayflowConstants.PARAM_ORIGAMT); + ResponseHashTable.Remove(PayflowConstants.PARAM_EMAILMATCH); + ResponseHashTable.Remove(PayflowConstants.PARAM_PHONEMATCH); + ResponseHashTable.Remove(PayflowConstants.PARAM_EXTRSPMSG); + ResponseHashTable.Remove(PayflowConstants.PARAM_SECURETOKEN); + ResponseHashTable.Remove(PayflowConstants.PARAM_SECURETOKENID); + ResponseHashTable.Remove(PayflowConstants.MAGTEK_PARAM_MAGTRESPONSE); + ResponseHashTable.Remove(PayflowConstants.PARAM_TRACEID); + ResponseHashTable.Remove(PayflowConstants.PARAM_ACHSTATUS); + ResponseHashTable.Remove(PayflowConstants.PARAM_TXID); + ResponseHashTable.Remove(PayflowConstants.PARAM_PAYMENTADVICECODE); + ResponseHashTable.Remove(PayflowConstants.PARAM_ASSOCIATIONRESPCODE); + ResponseHashTable.Remove(PayflowConstants.PARAM_TYPE); + ResponseHashTable.Remove(PayflowConstants.PARAM_AFFLUENT); + ResponseHashTable.Remove(PayflowConstants.PARAM_CCUPDATED); + ResponseHashTable.Remove(PayflowConstants.PARAM_RRN); + ResponseHashTable.Remove(PayflowConstants.PARAM_STAN); + ResponseHashTable.Remove(PayflowConstants.PARAM_ACI); + ResponseHashTable.Remove(PayflowConstants.PARAM_VALIDATIONCODE); + ResponseHashTable.Remove(PayflowConstants.PARAM_CCTRANSID); + ResponseHashTable.Remove(PayflowConstants.PARAM_CCTRANS_POSDATA); + + // Commented Line below to reserve Status for Recurring Inquiry + // ResponseHashTable.Remove(PayflowConstants.PARAM_STATUS); + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/UserInfo.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/UserInfo.cs new file mode 100644 index 0000000..253733f --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/UserInfo.cs @@ -0,0 +1,184 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// Used for PayPal User account information + /// + /// + /// This is a required class for a strong assembly + /// transactions. This class is used to store the + /// user credential needed to authenticate the user + /// performing the transaction. + /// Every transaction takes UserInfo + /// mandatorily. + /// Following are the required user credentials: + /// + /// + /// Payflow Parameter + /// Description + /// + /// + /// USER + /// Login name. This value is case-sensitive. + /// The login name created while registering for the Payflow + /// account. + /// + /// + /// VENDOR + /// Login name. This value is case-sensitive. + /// The login name created while registering for the Payflow + /// account. + /// + /// + /// PARTNER + /// The authorized PayPal Reseller that + /// registered this account for the Payflow service + /// provided you with a Partner ID. + /// If you registered yourself, use PayPal. + /// Case-sensitive. + /// + /// + /// PWD + /// Case-sensitive 7 to 32-character password. + /// + /// + /// + public sealed class UserInfo : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// User id + /// + private String mUser; + + /// + /// Vendor id + /// + private String mVendor; + + /// + /// Partner id + /// + private String mPartner; + + /// + /// Password + /// + private String mPwd; + + #endregion + + #region "Constructors" + + /// + /// Constructor. + /// + /// User id + /// Vendor id + /// Partner id + /// Password + /// + /// This is a required class for a strong assembly + /// transactions. This class is used to store the + /// user credential needed to authenticate the user + /// performing the transaction. + /// Every transaction takes UserInfo + /// mandatorily. + /// Following are the required user credentials: + /// + /// + /// Payflow Parameter + /// Description + /// + /// + /// USER + /// Login name. This value is case-sensitive. + /// The login name created while registering for the Payflow + /// account. + /// + /// + /// VENDOR + /// Login name. This value is case-sensitive. + /// The login name created while registering for the Payflow + /// account. + /// + /// + /// PARTNER + /// The authorized PayPal Reseller that + /// registered this account for the Payflow service + /// provided you with a Partner ID. + /// If you registered yourself, use PayPal. + /// Case-sensitive. + /// + /// + /// PWD + /// Case-sensitive 6- to 32-character password. + /// + /// + /// + /// + /// + /// .............. + /// // Create the User data object with the required user details. + /// UserInfo User = new UserInfo("user", "vendor", "partner", "password"); + /// .............. + /// + /// + /// .............. + /// ' Create the User data object with the required user details. + /// Dim User As UserInfo = New UserInfo("user", "vendor", "partner", "password"); + /// .............. + /// + /// + public UserInfo(String User, String Vendor, String Partner, String Pwd) + { + mUser = User; + mVendor = Vendor; + mPartner = Partner; + mPwd = Pwd; + + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER, mUser)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_VENDOR, mVendor)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PARTNER, mPartner)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PWD, mPwd)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/UserItem.cs b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/UserItem.cs new file mode 100644 index 0000000..9ad97ef --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/DataObjects/UserItem.cs @@ -0,0 +1,302 @@ +#region "Imports" + +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.DataObjects +{ + /// + /// This class holds the User1 to User10 related information. + /// + /// + /// You are able to send up to 10 string type parameters that you can use to store temporary data (for example, variables, + /// session IDs, order numbers, and so on). These parameters enable you to echo back the data to your server either + /// via the Payflow API or as part of the Return or Silent Post if using the hosted checkout page. + /// + /// Note: UserItem1 through UserItem10 are not displayed to the customer and are not stored in + /// the PayPal transaction database. + /// + /// + /// Following example shows how to use user item. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// + /// //Create a user item. + /// UserItem nUser = new UserItem(); + /// + /// //Add information to user item. + /// nUser.UserItem1 = "tUSER1"; + /// nUser.UserItem2 = "TUSER2"; + /// + /// //Add line item to invoice. + /// Inv.UserItem = nUser; + /// + /// .................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// + /// //Create a user item. + /// Dim nUser As New UserItem + /// + /// 'Add info to line item. + /// nUser.UserItem1 = "TUSER1" + /// nUser.UserItem2 = "TUSER2" + /// + /// 'Add line item to invoice. + /// Inv.UserItem = nUser + /// + /// .................. + /// + /// + public sealed class UserItem : BaseRequestDataObject + { + #region "Member Variables" + + /// + /// User item 1 + /// + private String mUserItem1; + /// + /// User item 2 + /// + private String mUserItem2; + /// + /// User item 3 + /// + private String mUserItem3; + /// + /// User item 4 + /// + private String mUserItem4; + /// + /// User item 5 + /// + private String mUserItem5; + /// + /// User item 6 + /// + private String mUserItem6; + /// + /// User item 7 + /// + private String mUserItem7; + /// + /// User item 8 + /// + private String mUserItem8; + /// + /// User item 9 + /// + private String mUserItem9; + /// + /// User item 10 + /// + private String mUserItem10; + + #endregion + + #region "Constructors" + + /// + /// Constructor. + /// + /// + /// You are able to send up to 10 string type parameters that you can use to store temporary data (for example, variables, + /// session IDs, order numbers, and so on). These parameters enable you to echo back the data to your server either + /// via the Payflow API or as part of the Return or Silent Post if using the hosted checkout page. + /// + /// Note: UserItem1 through UserItem10 are not displayed to the customer and are not stored in + /// the PayPal transaction database. + /// + /// + /// Following example shows how to use user item. + /// + /// ................. + /// //Inv is the Invoice object. + /// ................. + /// + /// //Create a user item. + /// UserItem nUser = new UserItem(); + /// + /// //Add information to user item. + /// nUser.UserItem1 = "tUSER1"; + /// nUser.UserItem2 = "TUSER2"; + /// + /// //Add line item to invoice. + /// Inv.UserItem = nUser; + /// + /// .................. + /// + /// + /// ................. + /// 'Inv is the Invoice object. + /// ................. + /// + /// //Create a user item. + /// Dim nUser As New UserItem + /// + /// 'Add info to line item. + /// nUser.UserItem1 = "TUSER1" + /// nUser.UserItem2 = "TUSER2" + /// + /// 'Add line item to invoice. + /// Inv.UserItem = nUser + /// + /// .................. + /// + /// + public UserItem() + { + } + + #endregion + + #region "Properties" + + /// + /// Gets, Sets user item. + /// + /// + /// + /// These ten string type parameters are intended to store temporary data (for example, variables, + /// session IDs, order numbers, and so on). These parameters enable you to return the values + /// to your server by using the Post or Silent Post feature. + /// + /// Note: UserItem1 through UserItem10 are not displayed to the customer and are not stored in + /// the PayPal transaction database. + /// + /// Maps to Payflow Parameter: + /// USER1 + /// + public String UserItem1 + { + get { return mUserItem1; } + set { mUserItem1 = value; } + } + /// + /// Maps to Payflow Parameter: + /// USER2 + /// + public String UserItem2 + { + get { return mUserItem2; } + set { mUserItem2 = value; } + } + /// + /// Maps to Payflow Parameter: + /// USER3 + /// + public String UserItem3 + { + get { return mUserItem3; } + set { mUserItem3 = value; } + } + /// + /// Maps to Payflow Parameter: + /// USER4 + /// + public String UserItem4 + { + get { return mUserItem4; } + set { mUserItem4 = value; } + } + /// + /// Maps to Payflow Parameter: + /// USER5 + /// + public String UserItem5 + { + get { return mUserItem5; } + set { mUserItem5 = value; } + } + /// + /// Maps to Payflow Parameter: + /// USER6 + /// + public String UserItem6 + { + get { return mUserItem6; } + set { mUserItem6 = value; } + } + /// + /// Maps to Payflow Parameter: + /// USER7 + /// + public String UserItem7 + { + get { return mUserItem7; } + set { mUserItem7 = value; } + } + /// + /// Maps to Payflow Parameter: + /// USER8 + /// + public String UserItem8 + { + get { return mUserItem8; } + set { mUserItem8 = value; } + } + /// + /// Maps to Payflow Parameter: + /// USER9 + /// + public String UserItem9 + { + get { return mUserItem9; } + set { mUserItem9 = value; } + } + /// + /// Maps to Payflow Parameter: + /// USERn + /// + public String UserItem10 + { + get { return mUserItem10; } + set { mUserItem10 = value; } + } + + #endregion + + #region "Core functions" + + /// + /// Generates user item request + /// + internal override void GenerateRequest() + { + try + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER1, mUserItem1)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER2, mUserItem2)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER3, mUserItem3)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER4, mUserItem4)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER5, mUserItem5)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER6, mUserItem6)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER7, mUserItem7)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER8, mUserItem8)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER9, mUserItem9)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_USER10, mUserItem10)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + DataObjectException DEx = new DataObjectException(Ex); + throw DEx; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/AuthorizationTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/AuthorizationTransaction.cs new file mode 100644 index 0000000..23897c5 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/AuthorizationTransaction.cs @@ -0,0 +1,972 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; +using PayPal.Payments.Common; + + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to create and perform an + /// Authorization Transaction. + /// + /// A successful authorization needs to be captured using a capture transaction. + /// This example shows how to create and perform a authorization transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new Authorization Transaction. + /// AuthorizationTransaction Trans = new AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Authorization Transaction. + /// Dim Trans as New AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public class AuthorizationTransaction : BaseTransaction + { + #region "Member Variables" + + /// + /// Original transaction id. + /// The ORIGID is the PNREF no. from a previous transaction. + /// OrigId is used to create a new Authorization transaction using the details of a previous + /// transaction. + /// + private String mOrigId; + + /// + /// Partial authorization request. + /// Notifies processor that partial authorizations are supported. + /// + private String mPartialAuth; + + /// + /// Secure token request. + /// Used to store sensitive data prior to making a call to the hosted page. + /// + private String mCreateSecureToken; + + /// + /// Secure token id. + /// Id used to generate a secure token. Must be sent with the token when calling the hosted pages. + /// This can be any random GUID but must be unique. + /// + private String mSecureTokenId; + + + #endregion + + #region "Properties" + + /// + /// Gets, Sets OrigId. This property is used to perform a reference Authorization Transaction. + /// + /// A reference Authorization transaction is an authorization transaction which copies the transaction data, + /// except the Account Number, Expiration Date and Swipe data from a previous trasnaction. + /// PNRef of this previous trasnaction needs to be set in this OrigId property. + /// A successful authorization needs to be captured using a capture transaction. + /// This example shows how to create and perform a reference authorization transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new Authorization Transaction. + /// AuthorizationTransaction Trans = new AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// // Set the OrigId to refer to + /// // a previous trasncation. + /// Trans.OrigId = "V64A0A07BD24"; + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Authorization Transaction. + /// Dim Trans as New AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId) + /// ' Set the OrigId to refer to + /// ' a previous trasncation. + /// Trans.OrigId = "V64A0A07BD24" + /// + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public String OrigId + { + get { return mOrigId; } + set { mOrigId = value; } + } + #endregion + + #region "Properties" + + /// + /// Gets, Sets PartialAuth. This property is used to notify banks that a partial authorization can be performed for a pre-paid debit/gift card. + /// + /// Partial Approval is supported for Visa, MasterCard, American Express and Discover (JCB (US Domestic only), + /// and Diners) Prepaid card products such as gift, Flexible Spending Account (FSA) or Healthcare Reimbursement Account + /// (HRA) cards. In addition Discover (JCB (US Domestic only), and Diners) supports partial Approval on their consumer + /// credit card. It is often difficult for the consumer to spend the exact amount available on the prepaid account, as + /// the purchase can be for amounts greater than the value available. This can result in unnecessary declines. Visa, + /// MasterCard, American Express and Discover (JCB (US Domestic only), and Diners) recognize that the prepaid products + /// represent unique opportunities for both merchants and consumers. With Partial Approval issuers may approve a portion + /// of the amount requested. This will enable the residual transaction amount to be paid by other means. The introduction + /// of the partial approval capability will reduce decline frequency and enhance the consumer and merchant experience at + /// the point of sale. Merchants will now have the ability to accept partial approval rather than having the sale declined. + /// This example shows how to submit the Partial Authorization flag. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new Authorization Transaction. + /// AuthorizationTransaction Trans = new AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// // Set the flag to allow partial authorizations. + /// Trans.PartialAuth = "Y"; + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Authorization Transaction. + /// Dim Trans as New AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId) + /// 'Set the flag to allow partial authorizations. + /// Trans.PartialAuth = "Y" + /// + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public String PartialAuth + { + get { return mPartialAuth; } + set { mPartialAuth = value; } + } + + #endregion + + #region "Properties" + + /// Use a secure token to send non-credit card transaction data to the Payflow server for storage in + /// a way that can’t be intercepted and manipulated maliciously.The secure token must be used with the hosted + /// checkout pages. The token is good for a one-time transaction and is valid for 30 minutes. + /// + /// NOTE: Without using a secure token, Payflow Pro merchants can host their own payment page and Payflow Link merchants + /// can use a form post to send transaction data to the hosted checkout pages. However, by not using the secure token, + /// these Payflow gateway users are responsible for the secure handling of data. To obtain a secure token, pass a unique, + /// 36-character token ID and set CREATESECURETOKEN=Y in a request to the Payflow server. The Payflow server associates your + /// ID with a secure token and returns the token as a string of up to 32 alphanumeric characters. To pass the transaction + /// data to the hosted checkout page, you pass the secure token and token ID in an HTTP form post. The token and ID trigger + /// the Payflow server to retrieve your data and display it for buyer approval. + /// + /// See the DOSecureTokenAuth sample for more information. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// // Since we are using the hosted payment pages, you will not be sending the credit card data with the + /// // Secure Token Request. You just send all other 'sensitive' data within this request and when you + /// // call the hosted payment pages, you'll only need to pass the SECURETOKEN; which is generated and returned + /// // and the SECURETOKENID that was created and used in the request. + /// + /// // Create a new Secure Token Authorization Transaction. Even though this example is performing + /// // an authorization, you can create a secure token using SaleTransction too. Only Authorization and Sale + /// // type transactions are permitted. + /// //Create a new Authorization Transaction. + /// AuthorizationTransaction Trans = new AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// // Set the flag to create a Secure Token. + /// Trans.CreateSecureToken = "Y"; + /// // The Secure Token Id must be a unique id up to 36 characters. Using the RequestID object to generate + /// // a random id, but any means to create an id can be used. + /// Trans.SecureTokenId = PayflowUtility.RequestId; + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("SECURETOKEN = " + TrxnResponse.SecureToken); + /// Console.WriteLine("SECURETOKENID = " + TrxnResponse.SecureTokenId); + /// // If value is true, then the Request ID has not been changed and the original response + /// // of the original transaction is returned. + /// Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// ' Since we are using the hosted payment pages, you will not be sending the credit card data with the + /// ' Secure Token Request. You just send all other 'sensitive' data within this request and when you + /// ' call the hosted payment pages, you'll only need to pass the SECURETOKEN; which is generated and returned + /// ' and the SECURETOKENID that was created and used in the request. + /// + /// ' Create a new Secure Token Authorization Transaction. Even though this example is performing + /// ' an authorization, you can create a secure token using SaleTransction too. Only Authorization and Sale + /// ' type transactions are permitted. + /// 'Create a new Authorization Transaction. + /// Dim Trans as New AuthorizationTransaction(UserInfo, PayflowConnectionData, Invoice, Tender, RequestId) + /// ' See the CreateSecureToken parameter to yes "Y", to flag this transaction request to create a secure token. + /// Trans.CreateSecureToken = "Y" + /// + /// ' The Secure Token Id must be a unique id up to 36 characters. Using the RequestID object to + /// ' generate a random id, but any means to create an id can be used. + /// Trans.SecureTokenId = PayflowUtility.RequestId + /// + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("SECURETOKEN = " + TrxnResponse.SecureToken) + /// Console.WriteLine("SECURETOKENID = " + TrxnResponse.SecureTokenId) + /// ' If value is true, then the Request ID has not been changed and the original response + /// ' of the original transaction is returned. + /// Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + + /// + /// Gets, Sets CreateSecureToken. This property is used to create a SecureToken. + /// + public String CreateSecureToken + { + get { return mCreateSecureToken; } + set { mCreateSecureToken = value; } + } + + /// + /// Gets, Sets SecureTokenId. This property is used while calling the hosted page. + /// + public String SecureTokenId + { + get { return mSecureTokenId; } + set { mSecureTokenId = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Private Constructor. This prevents + /// creation of an empty Transaction object. + /// + private AuthorizationTransaction() + {} + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object + /// Request Id + /// This example shows how to create and perform a authorization transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new Authorization Transaction. + /// AuthorizationTransaction Trans = new AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Authorization Transaction. + /// Dim Trans as New AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public AuthorizationTransaction(UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, + Invoice Invoice, + BaseTender Tender, String RequestId) + : base(PayflowConstants.TRXTYPE_AUTH, UserInfo, PayflowConnectionData, + Invoice, + //PaymentDevice , + Tender, RequestId) + { + } + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Request Id + /// This example shows how to create and perform a authorization transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new Authorization Transaction. + /// AuthorizationTransaction Trans = new AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Authorization Transaction. + /// Dim Trans as New AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public AuthorizationTransaction(UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, + Invoice Invoice, String RequestId) + : base(PayflowConstants.TRXTYPE_AUTH, UserInfo, PayflowConnectionData, + Invoice, RequestId) + { + } + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender object + /// Request Id + /// This example shows how to create and perform + /// a authorization transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// // Create a new Authorization Transaction. + /// AuthorizationTransaction Trans = new AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Authorization Transaction. + /// Dim Trans as New AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public AuthorizationTransaction(UserInfo UserInfo, Invoice Invoice, + BaseTender Tender, String RequestId) + : this(UserInfo, null,Invoice,Tender, RequestId) + { + } + + //constructor to be used in case of basic and order auth + /// + /// + /// + /// + /// + /// + /// + /// + /// + internal AuthorizationTransaction(String TrxType , UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, + Invoice Invoice, + BaseTender Tender, String RequestId) + : base(TrxType, UserInfo, PayflowConnectionData, + Invoice, + //PaymentDevice , + Tender, RequestId) + { + } + /// + /// + /// + /// + /// + /// + /// + /// + internal AuthorizationTransaction(String TrxType ,UserInfo UserInfo, Invoice Invoice, + BaseTender Tender, String RequestId) + : this(TrxType ,UserInfo, null,Invoice,Tender, RequestId) + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORIGID, mOrigId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PARTIALAUTH, mPartialAuth)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CREATESECURETOKEN, mCreateSecureToken)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SECURETOKENID, mSecureTokenId)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TEx = new TransactionException(Ex); + throw TEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BaseTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BaseTransaction.cs new file mode 100644 index 0000000..4f673fe --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BaseTransaction.cs @@ -0,0 +1,1165 @@ +#region "Imports" + +using System; +using System.Collections; +using System.Text; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Logging; +using PayPal.Payments.Communication; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is the base class for all transaction objects. It has methods for generating the transaction request, + /// sending it to the server and obtaining the response. + /// For an usage of this class, please see the examples in SamplesCS + SamplesVB folders namely DOSale_Base.cs + /// and DOSale_Base.vb. + /// + /// This class can be extended to create a new transaction type. + /// This example shows how to create and perform an Sale transaction using a Basetransaction Object. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new Base Transaction. + /// BaseTransaction Trans = new BaseTransaction("S", + /// User, Connection, Inv, Card, PayflowUtility.RequestId); + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// // Get the Response + /// Response Resp = Trans.Response; + /// + /// + /// // Display the transaction response parameters. + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// + /// // Get the Transaction Context and check for any contained SDK specific errors (optional code). + /// Context TransCtx = Resp.TransactionContext; + /// if (TransCtx != null && TransCtx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + /// } + /// + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// ' Create a new Base Transaction. + /// Dim Trans As BaseTransaction = New BaseTransaction("S", User, Connection, Inv, Card, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// + /// + /// ' Display the response. + /// Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)) + /// + /// ' Get the Transaction Context and check for any contained SDK specific errors (optional code). + /// Dim TransCtx As Context = Resp.TransactionContext + /// If (Not TransCtx Is Nothing) And (TransCtx.getErrorCount() > 0) Then + /// Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()) + /// End If + /// + /// End If + /// + /// + + public class BaseTransaction + { + #region "Member Variables" + /// + /// Arraylist of Extend Data objects. The arraylist contains objects of type ExtendData. + /// ExtendData has a parameter name and value and is used for sending any additional parameter currently not + /// supported by the SDK. + /// + /// + private ArrayList mExtData; + + /// + /// Type of transaction to perform, indicated by a single character. + /// Credit payments require an ORIGID referring to an earlier Debit/Sale payment, + /// and the AMT must be empty or the exact amount of the original Debit/Sale payment. + /// + /// + /// Allowed TrxType values are: + /// + /// + /// Transaction Type + /// Transaction Name + /// + /// + /// S + /// Sale/Debit + /// + /// + /// A + /// Voice Authorization/Force + /// + /// + /// C + /// Credit + /// + /// + /// V + /// Void + /// + /// + /// D + /// Delayed Capture + /// + /// + /// F + /// Force/Voice Authorization + /// + /// + /// I + /// Inquiry + /// + /// + /// R + /// Recurring billing + /// + /// + /// Maps to Payflow Parameter: - TRXTYPE + /// + private String mTrxType; + + /// + /// Connection parameters to connect to the PayPal Payment Server. + /// + /// + private PayflowConnectionData mPayflowConnectionData; + + /// + /// Transaction request in Name-Value Pair format. + /// + /// TRXTYPE[1]=S&ACCT[16]=5105105105105100&EXPDATE[4]=0115&TENDER[1]=C&INVNUM[8]=INV12345&AMT[5]=25.12 + /// &PONUM[7]=PO12345&STREET[23]=123 Main St.&ZIP[5]=12345& + /// USER=user&VENDOR=vendor&PARTNER=partner&PWD=password + /// + /// + /// + private String mRequest; + + /// + /// Tender object for ACH, Credit Card, PINless Debit & eCheck. + /// + /// Allowed Tender Types are: + /// + /// + /// Tender Type + /// Tender Name + /// + /// + /// A + /// ACH ( Automatic Clearing House ) + /// + /// + /// C + /// Credit Card + /// + /// + /// D + /// PINLess Debit + /// + /// + /// K + /// e-Check ( TeleCheck ) + /// + /// + /// Each Tender type Maps to Payflow Parameter: - TENDER + /// + /// + /// + /// + /// + private BaseTender mTender; + + /// + /// Transaction invoice object. Has parameters like Amt, InvNum, BillTo, ShipTo etc. + /// + /// + private Invoice mInvoice; + + /// + /// Response object for the Transaction. Has objects like Transaction Response, Fraud Response, + /// Recurring Response etc. + /// + /// + private Response mResponse; + + /// + /// Payflow user credentials. Has parameters like User, Vendor, Partner, Password etc. + /// + /// + private UserInfo mUserInfo; + + /// + /// Holds USER1 to USER10 fields. + /// + /// + private UserInfo mUserItem; + + /// + /// Value (LOW, MEDIUM or HIGH) that controls the detail level and format of transaction results. + /// LOW (default) returns normalized values. MEDIUM or HIGH return the processor's raw response values. + /// + /// Maps to Payflow Parameter: - VERBOSITY + /// + /// + private String mVerbosity; + + /// + /// Context object containing the Error Objects. The context object is available to all the classes in the + /// SDK. The individual classes add their messages in form of Error Objects to the Context object. + /// + /// + private Context mContext; + + /// + /// Unique request id for the transaction. + /// Maps to Payflow Parameter: in header - PAYFLOW-REQUEST-ID + /// + public String mRequestId; + + /// + /// Request Buffer. This is used to build the request string in Name-Value pair format from Data Objects. + /// + private StringBuilder mRequestBuffer; + + /// + /// Client Header Information + /// + private ClientInfo mClientInfo; + /// + /// Transaction BuyerAuthStatus object. Has parameters like Authentication_ID, AuthenticatonStatus, CAVV,XID etc. + /// + /// + private BuyerAuthStatus mBuyerAuthStatus; + + #endregion + + #region "Properties" + + /// + /// Gets the StringBuilder object for RequestBuffer. + /// + internal virtual StringBuilder RequestBuffer + { + get { return mRequestBuffer; } + } + + + /// + /// Type of transaction to perform, indicated by a single character. + /// Credit payments require an ORIGID referring to an earlier Debit/Sale payment, + /// and the AMT must be empty or the exact amount of the original Debit/Sale payment. + /// Allowed TrxType values are: + /// + /// + /// Transaction Type + /// Transaction Name + /// + /// + /// S + /// Sale/Debit + /// + /// + /// A + /// Voice Authorization/Force + /// + /// + /// C + /// Credit + /// + /// + /// V + /// Void + /// + /// + /// D + /// Delayed Capture + /// + /// + /// F + /// Force/Voice Authorization + /// + /// + /// I + /// Inquiry + /// + /// + /// R + /// Recurring billing + /// + /// + /// Maps to Payflow Parameter: - TRXTYPE + /// + /// + /// + /// ............ + /// //Trans is the transaction object. + /// ............ + /// Console.WriteLine("Transaction Type = " + Trans.TrxType); + /// + /// + /// ............ + /// 'Trans is the transaction object. + /// ............ + /// Console.WriteLine("Transaction Type = " + Trans.TrxType); + /// + /// + public virtual String TrxType + { + get { return mTrxType; } + } + + /// + /// Value (LOW, MEDIUM or HIGH) that controls the detail level and format of transaction results. + /// LOW (default) returns normalized values. MEDIUM or HIGH return the processor's raw response values. + /// Maps to Payflow Parameter: - VERBOSITY + /// + /// + /// + /// ............ + /// //Trans is the transaction object. + /// ............ + /// Trans.Verbosity = "HIGH"; + /// Console.WriteLine("Transaction Type = " + Trans.TrxType); + /// + /// + /// ............ + /// 'Trans is the transaction object. + /// ............ + /// Trans.Verbosity = "HIGH" + /// Console.WriteLine("Transaction Type = " + Trans.TrxType) + /// + /// + public virtual String Verbosity + { + get { return mVerbosity; } + set { mVerbosity = value; } + } + + /// + /// Gets/sets the context object + /// of the current transaction. + /// + internal virtual Context Context + { + get { return mContext; } + set { mContext = value; } + } + + /// + /// Gets the transaction response object. + /// + /// + /// + /// ............ + /// //Trans is the transaction object. + /// ............ + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// ............ + /// 'Trans is the transaction object. + /// ............ + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public virtual Response Response + { + get { return mResponse; } + } + + /// + /// Gets the extend data list. + /// + /// + /// + /// ............ + /// //Trans is the transaction object. + /// ............ + /// + /// ArrayList ExtDataList = Trans.ExtendData; + /// + /// + /// ............ + /// 'Trans is the transaction object. + /// ............ + /// Dim ExtDataList as ArrayList = Trans.ExtendData + /// + /// + public virtual ArrayList ExtendData + { + get { return mExtData; } + } + + /// + /// Gets the transaction request. + /// + /// + /// + /// ............ + /// //Trans is the transaction object. + /// ............ + /// + /// Console.WriteLine("Transaction Request = " + Trans.Request); + /// + /// + /// ............ + /// 'Trans is the transaction object. + /// ............ + /// Console.WriteLine("Transaction Request = " + Trans.Request) + /// + /// + public virtual String Request + { + get { return mRequest; } + } + + /// + /// Gets the Tender Object. + /// + /// + /// + /// ............ + /// //Trans is the transaction object. + /// ............ + /// + /// BaseTender Tender = Trans.Tender; + /// + /// + /// ............ + /// 'Trans is the transaction object. + /// ............ + /// Dim Tender as BaseTender = Trans.Tender + /// + /// + public virtual BaseTender Tender + { + get { return mTender; } + } + + /// + /// Gets,Sets the RequestId for + /// the transaction. + /// + /// + /// + /// ............ + /// //Trans is the transaction object. + /// //A unique RequestId can be generated + /// //using the + /// PayflowUtility.RequestId + /// //property. + /// ............ + /// Trans.RequestId = PayflowUtility.RequestId; + /// Console.WriteLine("Transaction RequestId = " + Trans.RequestId); + /// + /// + /// ............ + /// 'Trans is the transaction object. + /// 'A unique RequestId can be generated + /// 'using the + /// PayflowUtility.RequestId + /// 'property. + /// ............ + /// Trans.RequestId = PayflowUtility.RequestId + /// Console.WriteLine("Transaction RequestId = " + Trans.RequestId) + /// + /// + public virtual String RequestId + { + get { return mRequestId; } + set { mRequestId = value; } + } + + /// + /// Gets , sets Client Information object. + /// + public ClientInfo ClientInfo + { + get { return mClientInfo; } + set { mClientInfo = value; } + } + + /// + /// Gets, sets BuyerAuthStatus object. + /// + public BuyerAuthStatus BuyerAuthStatus + { + get {return mBuyerAuthStatus;} + set {mBuyerAuthStatus = value;} + } + + #endregion + + #region "Constructors" + + /// + /// protected Constructor. This prevents + /// creation of an empty Transaction object. + /// + protected BaseTransaction() + { + mRequestBuffer = new StringBuilder(); + mContext = new Context(); + mContext.LoadLoggerErrs = true; + } + + /// + /// Constructor. + /// + /// Transaction type. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Request Id + public BaseTransaction(String TrxType, + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + String RequestId) : this() + { + mTrxType = TrxType; + mUserInfo = UserInfo; + mPayflowConnectionData = PayflowConnectionData; + mRequestId = RequestId; + if (mUserInfo != null) + { + mUserInfo.Context = mContext; + + } + if (mPayflowConnectionData != null) + { + if (mPayflowConnectionData.Context != null && mPayflowConnectionData.Context.IsErrorContained()) + { + mContext.AddErrors(mPayflowConnectionData.Context.GetErrors()); + } + } + } + /// + /// Constructor. + /// + /// Transaction type. + /// User Info object populated with user credentials. + /// Request Id + public BaseTransaction(String TrxType, + UserInfo UserInfo, + String RequestId) : this() + { + mTrxType = TrxType; + mUserInfo = UserInfo; + mRequestId = RequestId; + if (mUserInfo != null) + { + mUserInfo.Context = mContext; + + } + } + + /// + /// Constructor. + /// + /// Transaction type. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Request Id + public BaseTransaction(String TrxType, + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + Invoice Invoice, + String RequestId) : this(TrxType, UserInfo, PayflowConnectionData, RequestId) + { + mInvoice = Invoice; + if (mInvoice != null) + { + mInvoice.Context = mContext; + } + + } + /// + /// Constructor. + /// + /// Transaction type. + /// User Info object populated with user credentials. + /// Invoice object. + /// Request Id + public BaseTransaction(String TrxType, + UserInfo UserInfo, + Invoice Invoice, + String RequestId) : this(TrxType,UserInfo, null,Invoice,RequestId) + { + } + + /// + /// Constructor. + /// + /// Transaction type. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + public BaseTransaction(String TrxType, UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, Invoice Invoice, + BaseTender Tender, String RequestId) : this(TrxType, UserInfo, PayflowConnectionData, Invoice, RequestId) + { + mTender = Tender; + if (mTender != null) + { + mTender.Context = mContext; + mTender.RequestBuffer = mRequestBuffer; + } + } + /// + /// Constructor. + /// + /// Transaction type. + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + public BaseTransaction(String TrxType, UserInfo UserInfo, + Invoice Invoice, + BaseTender Tender, String RequestId) : this(TrxType, UserInfo, null, Invoice, Tender, RequestId) + { + } + + + #endregion + + #region "Core functions" + /// + /// This method submits the transaction + /// to the PayPal Payment Gateway. + /// The response is obtained from the gateway + /// and response object is populated with the + /// response values along with the sdk specific + /// errors in context, if any. + /// + /// Returns response object for Strong assembly transactions + /// + /// + /// ............ + /// //Trans is the transaction object. + /// ............ + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// ............ + /// 'Trans is the transaction object. + /// ............ + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public virtual Response SubmitTransaction() + { + PayflowNETAPI PfProNetApi=null; + String ResponseValue=null; + bool Fatal= false; + Logger.Instance.Log("##### BEGIN TRANSACTION ##### -- " + mRequestId, PayflowConstants.SEVERITY_INFO); + Logger.Instance.Log("PayPal.Payments.Transactions.BaseTransaction.SubmitTransaction(): Entered", PayflowConstants.SEVERITY_DEBUG); + try + { + if(mClientInfo == null) + { + mClientInfo = new ClientInfo(); + } + //Check for the errors in the context now. + ArrayList Errors = PayflowUtility.AlignContext(mContext,false); + mContext.LoadLoggerErrs = false; + mContext.ClearErrors(); + mContext.AddErrors(Errors); + + if (mContext.HighestErrorLvl + == PayflowConstants.SEVERITY_FATAL) + { + Logger.Instance.Log("PayPal.Payments.Transactions.BaseTransaction.SubmitTransaction(): Exiting", PayflowConstants.SEVERITY_DEBUG); + Fatal = true; + } + if (!Fatal) + { + GenerateRequest(); + + mRequest = RequestBuffer.ToString(); + + + //Remove the trailing PayflowConstants.DELIMITER_NVP; + int ParmListLen = mRequest.Length; + if( ParmListLen > 0 && mRequest[ParmListLen - 1] == '&') + { + mRequest = mRequest.Substring(0,ParmListLen -1); + } + + + //Call the api from here and submit transaction + + if (mPayflowConnectionData != null) + { + PfProNetApi = new PayflowNETAPI(mPayflowConnectionData.HostAddress, + mPayflowConnectionData.HostPort, + mPayflowConnectionData.TimeOut, + mPayflowConnectionData.ProxyAddress, + mPayflowConnectionData.ProxyPort, + mPayflowConnectionData.ProxyLogon, + mPayflowConnectionData.ProxyPassword); + } + else + { + PfProNetApi = new PayflowNETAPI(); + } + + PfProNetApi.IsStrongAssemblyTransaction = true; + PfProNetApi.ClientInfo = mClientInfo; + ResponseValue = PfProNetApi.SubmitTransaction(mRequest, mRequestId); + + Logger.Instance.Log("PayPal.Payments.Transactions.BaseTransaction.SubmitTransaction(): Exiting", PayflowConstants.SEVERITY_DEBUG); + Logger.Instance.Log("##### END TRANSACTION ##### -- " + mRequestId, PayflowConstants.SEVERITY_INFO); + } + } + catch (BaseException BaseEx) + { + ErrorObject Error = BaseEx.GetFirstErrorInExceptionContext(); + //ErrorObject Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE,BaseEx,PayflowConstants.SEVERITY_FATAL,false, null); + mContext.AddError(Error); + } + catch (Exception Ex) + { + TransactionException TransEx = new TransactionException(Ex); + ErrorObject Error = PayflowUtility.PopulateCommError(PayflowConstants.E_UNKNOWN_STATE,TransEx,PayflowConstants.SEVERITY_FATAL,false, null); + mContext.AddError(Error); + } + finally + { + if(PfProNetApi != null) + { + mRequest = PfProNetApi.TransactionRequest; + mContext.AddErrors(PfProNetApi.TransactionContext.GetErrors()); + mRequestId = PfProNetApi.RequestId; + mClientInfo = PfProNetApi.ClientInfo; + } + else + { + //There is some error due to which the return + //is called even before pfpronetapi object is + //created. + //Check the first fatal error in context and + //put its response value to string. + if(mRequest != null && mRequest.Length > 0 ) + { + mRequest = PayflowUtility.MaskSensitiveFields(mRequest); + } + ArrayList ErrorList = mContext.GetErrors(PayflowConstants.SEVERITY_FATAL); + ErrorObject FirstFatalError = (ErrorObject)ErrorList[0]; + ResponseValue = FirstFatalError.ToString(); + } + + mResponse = new Response(mRequestId ,mContext); + mResponse.setRequestString(mRequest); + mResponse.SetParams(ResponseValue); + + + //Log the context + if (mContext.IsErrorContained()) + { + mContext.LogErrors(); + } + PfProNetApi = null; + } + return mResponse; + } + + /// + /// Generates the transaction request. + /// + internal virtual void GenerateRequest() + { + Logger.Instance.Log("PayPal.Payments.Transactions.BaseTransaction.GenerateRequest(): Entered", PayflowConstants.SEVERITY_DEBUG); + try + { + mRequestBuffer = new StringBuilder(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_TRXTYPE, mTrxType)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_VERBOSITY, mVerbosity)); + if (mExtData != null && mExtData.Count > 0) + foreach (ExtendData Ed in mExtData) + { + if (Ed != null) + { + Ed.RequestBuffer = mRequestBuffer; + Ed.GenerateRequest(); + } + } + if (mTender != null) + { + mTender.RequestBuffer = mRequestBuffer; + mTender.GenerateRequest(); + } + if (mInvoice != null) + { + mInvoice.RequestBuffer = mRequestBuffer; + mInvoice.GenerateRequest(); + } + if (mUserInfo != null) + { + mUserInfo.RequestBuffer = mRequestBuffer; + mUserInfo.GenerateRequest(); + } + if (mUserItem != null) + { + mUserItem.RequestBuffer = mRequestBuffer; + mUserItem.GenerateRequest(); + } + if (mBuyerAuthStatus != null) + { + mBuyerAuthStatus.RequestBuffer = mRequestBuffer; + mBuyerAuthStatus.GenerateRequest(); + } + Logger.Instance.Log("PayPal.Payments.Transactions.BaseTransaction.GenerateRequest(): Exiting", PayflowConstants.SEVERITY_DEBUG); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TE = new TransactionException(Ex); + throw TE; + } + } + + #endregion + + #region "Extend Data Related Methods" + + /// + /// Adds an Extend Data object to + /// the extend data list held by transaction + /// object. + /// + /// Extend Data object to be added. + /// + /// + /// ............ + /// //Trans is the transaction object. + /// ............ + /// + /// //Create an object of ExtendData + /// ExtendData ExtData = new ExtendData("PFPRO_PARAM_NAME","Param Value"); + /// + /// //Add to Transaction Extend Data list. + /// Trans.AddToExtendData(ExtData); + /// + /// + /// + /// ............ + /// 'Trans is the transaction object. + /// ............ + /// + /// 'Create an object of ExtendData + /// Dim ExtData as ExtendData = new ExtendData("PFPRO_PARAM_NAME","Param Value") + /// + /// 'Add to Transaction Extend Data list. + /// Trans.AddToExtendData(ExtData) + /// + /// + /// + public virtual void AddToExtendData(ExtendData ExtData) + { + if (mExtData == null) + { + mExtData = new ArrayList(); + } + if (ExtData != null) + { + ExtData.Context = Context; + ExtData.RequestBuffer = mRequestBuffer; + mExtData.Add(ExtData); + } + } + + /// + /// Clears the Extend Data list held by + /// transaction object. + /// + /// + /// + /// ............ + /// //Trans is the transaction object. + /// ............ + /// + /// //Clear Transaction Extend Data list. + /// Trans.ClearExtendData(); + /// + /// + /// + /// ............ + /// 'Trans is the transaction object. + /// ............ + /// + /// 'Clear Transaction Extend Data list. + /// Trans.ClearExtendData() + /// + /// + /// + public virtual void ClearExtendData() + { + if (mExtData != null) + { + mExtData.Clear(); + } + } + + #endregion + + + #region "Client Header related methods" + /// + /// Adds a transaction header + /// + /// Header name + /// Header value + public void AddTransHeader(String HeaderName,String HeaderValue) + { + AddHeader(HeaderName,HeaderValue); + } + + /// + /// Adds a header + /// + /// Header name + /// Header value + private void AddHeader(String HeaderName,String HeaderValue) + { + if(mClientInfo == null) + { + mClientInfo = new ClientInfo(); + } + + mClientInfo.AddHeaderToHash(HeaderName,HeaderValue); + + } + + /// + /// Removes a Transaction header + /// + /// Header Name + public void RemoveTransHeader(String HeaderName) + { + RemoveHeader(HeaderName); + } + + + /// + /// Removes a header + /// + /// Header Name + private void RemoveHeader(String HeaderName) + { + if(mClientInfo != null) + { + if(mClientInfo.ClientInfoHash.ContainsKey(HeaderName)) + { + mClientInfo.ClientInfoHash.Remove(HeaderName); + } + + } + } + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BasicAuthorizationTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BasicAuthorizationTransaction.cs new file mode 100644 index 0000000..fca9142 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BasicAuthorizationTransaction.cs @@ -0,0 +1,42 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// Summary description for BasicAuthorizationTransaction. + /// + internal class BasicAuthorizationTransaction : AuthorizationTransaction + { + #region "Constructors" + /// + /// + /// + /// + /// + /// + /// + /// + public BasicAuthorizationTransaction (PayPalTender Tender, Invoice Invoice, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, String RequestId) + : base("B" ,UserInfo ,PayflowConnectionData ,Invoice ,Tender ,RequestId) + { + } + + /// + /// + /// + /// + /// + /// + /// + public BasicAuthorizationTransaction (PayPalTender Tender, Invoice Invoice, UserInfo UserInfo, String RequestId) + : base("B", UserInfo ,Invoice , Tender ,RequestId) + { + } + #endregion + + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BuyerAuthTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BuyerAuthTransaction.cs new file mode 100644 index 0000000..c8eefa0 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BuyerAuthTransaction.cs @@ -0,0 +1,81 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This abstract class serves as base class for + /// Buyer auth transactions. + /// + + public class BuyerAuthTransaction : BaseTransaction + { + #region "Constructors" + + /// + /// protected Constructor. This prevents + /// creation of an empty Transaction object. + /// + protected BuyerAuthTransaction() + { + } + + /// + /// Constructor. + /// + /// Transaction type + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Request Id + protected BuyerAuthTransaction(String TrxType, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, String RequestId) + : base(TrxType, UserInfo, PayflowConnectionData, RequestId) + { + } + /// + /// Constructor. + /// + /// Transaction type + /// User Info object populated with user credentials. + /// Request Id + protected BuyerAuthTransaction(String TrxType, UserInfo UserInfo, String RequestId) + : this(TrxType, UserInfo, null, RequestId) + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TE = new TransactionException(Ex); + throw TE; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BuyerAuthVATransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BuyerAuthVATransaction.cs new file mode 100644 index 0000000..9d82926 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BuyerAuthVATransaction.cs @@ -0,0 +1,386 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to create and perform + /// a Validate Authentication transaction. + /// Validate Authentication is the second step of Buyer authentication process. + /// + /// When the user authenticates on the secure authentication server, the server + /// returns back a Payer authentication Signature (PaRes). You must send this value of PaRes + /// to validate the authentication to the payment gateway during the Validate Authentication. + /// The gateway will then return the authentication status of the user in the response. + /// You should send this authntication information from the response into you main transaction. + /// For more information, please refer to the Payflow Developers' Guide. + /// + /// This example shows how to create and perform a Verify Eknrollment transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new validate Auhtentication Transaction. + /// BuyerAuthVATransaction Trans = new BuyerAuthVATransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Pares, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// + /// // Get the Buyer auth Response parameters. + /// BuyerAuthResponse BAResponse = Resp.BuyerAuthResponse; + /// if (BAResponse != null) + /// { + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status); + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Validate Authentication Transaction. + /// Dim Trans as New BuyerAuthVATransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Pares, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Buyer auth Response parameters. + /// Dim BAResponse As BuyerAuthResponse = Resp.BuyerAuthResponse; + /// If Not BAResponse Is Nothing Then + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status) + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public sealed class BuyerAuthVATransaction : BuyerAuthTransaction + { + #region "Member Variables" + + /// + /// Holds the PaRes value. + /// + private String mPaRes; + + #endregion + + #region "Constructors" + + /// + /// Private Constructor. This prevents + /// creation of an empty Transaction object. + /// + private BuyerAuthVATransaction() + { + } + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// PaRes Value + /// Request Id + /// When the user authenticates on the secure authentication server, the server + /// returns back a Payer authentication Signature (PaRes). You must send this value of PaRes + /// to validate the authentication to the payment gateway during the Validate Authentication. + /// The gateway will then return the authentication status of the user in the response. + /// You should send this authntication information from the response into you main transaction. + /// For more information, please refer to the Payflow Developers' Guide. + /// + /// This example shows how to create and perform a Verify Eknrollment transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new validate Auhtentication Transaction. + /// BuyerAuthVATransaction Trans = new BuyerAuthVATransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Pares, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// + /// // Get the Buyer auth Response parameters. + /// BuyerAuthResponse BAResponse = Resp.BuyerAuthResponse; + /// if (BAResponse != null) + /// { + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status); + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Validate Authentication Transaction. + /// Dim Trans as New BuyerAuthVATransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Pares, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Buyer auth Response parameters. + /// Dim BAResponse As BuyerAuthResponse = Resp.BuyerAuthResponse; + /// If Not BAResponse Is Nothing Then + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status) + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public BuyerAuthVATransaction(UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, String PaRes, String RequestId) : base(PayflowConstants.TRXTYPE_BUYERAUTH_VA, UserInfo, PayflowConnectionData, RequestId) + { + mPaRes = PaRes; + } + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// PaRes Value + /// Request Id + /// When the user authenticates on the secure authentication server, the server + /// returns back a Payer authentication Signature (PaRes). You must send this value of PaRes + /// to validate the authentication to the payment gateway during the Validate Authentication. + /// The gateway will then return the authentication status of the user in the response. + /// You should send this authntication information from the response into you main transaction. + /// For more information, please refer to the Payflow Developers' Guide. + /// + /// This example shows how to create and perform a Verify Eknrollment transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new validate Auhtentication Transaction. + /// BuyerAuthVATransaction Trans = new BuyerAuthVATransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Pares, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// + /// // Get the Buyer auth Response parameters. + /// BuyerAuthResponse BAResponse = Resp.BuyerAuthResponse; + /// if (BAResponse != null) + /// { + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status); + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Validate Authentication Transaction. + /// Dim Trans as New BuyerAuthVATransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Pares, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Buyer auth Response parameters. + /// Dim BAResponse As BuyerAuthResponse = Resp.BuyerAuthResponse; + /// If Not BAResponse Is Nothing Then + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status) + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public BuyerAuthVATransaction(UserInfo UserInfo, String PaRes, String RequestId) : this(UserInfo, null, PaRes,RequestId) + { + } + + #endregion + + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PARES, mPaRes)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TE = new TransactionException(Ex); + throw TE; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BuyerAuthVETransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BuyerAuthVETransaction.cs new file mode 100644 index 0000000..efa6f0f --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/BuyerAuthVETransaction.cs @@ -0,0 +1,474 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to create and perform + /// a Verify Enrollment transaction. + /// Verify Enrollment is the first step of Buyer authentication process. + /// + /// After a successful Verify Enrollment Transaction, + /// you should redirect the user's browser to his/her browser to the + /// secure authentication server which will authinticate the user. + /// While redirecting to this secure authentication server, + /// you must pass the parameter PaReq obtained in the response of this transaction. + /// For more information, please refer to the Payflow Developers' Guide. + /// + /// This example shows how to create and perform a Verify Eknrollment transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// + /// //Create the Card object. + /// CreditCard Card = new CreditCard("XXXXXXXXXXXXXXXX","XXXX"); + /// + /// //Create the currency object. + /// Currency Amt = new Currency(new decimal(1.00),"US"); + /// .......... + /// .......... + /// + /// //Create a new Verify Enrollment Transaction. + /// BuyerAuthVETransaction Trans = new BuyerAuthVETransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Card, + /// Amt, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// + /// // Get the Buyer auth Response parameters. + /// BuyerAuthResponse BAResponse = Resp.BuyerAuthResponse; + /// if (BAResponse != null) + /// { + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status); + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id); + /// Console.WriteLine("ACSURL = " + BAResponse.AcsUrl); + /// Console.WriteLine("PAREQ = " + BAResponse.PaReq); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// + /// //Create the Card object. + /// Dim Card As CreditCard = new CreditCard("XXXXXXXXXXXXXXXX","XXXX") + /// + /// //Create the currency object. + /// Dim Amt As Currency = new Currency(new decimal(1.00),"US") + /// .......... + /// .......... + /// + /// 'Create a new Authorization Transaction. + /// Dim Trans as New BuyerAuthVETransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Card, + /// Amt, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Buyer auth Response parameters. + /// Dim BAResponse As BuyerAuthResponse = Resp.BuyerAuthResponse; + /// If Not BAResponse Is Nothing Then + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status) + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id) + /// Console.WriteLine("ACSURL = " + BAResponse.AcsUrl) + /// Console.WriteLine("PAREQ = " + BAResponse.PaReq) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public sealed class BuyerAuthVETransaction : BuyerAuthTransaction + { + #region "Member Variables" + + /// + /// Holds the currency value, mandatory for VE. + /// + private Currency mCurrency; + + /// + /// Holds the Purchase Description. + /// + private String mPurDesc; + + private CreditCard mCreditcard; + + #endregion + + #region "Properties" + /// + /// Gets, Sets Purchase description. + /// Maps to Payflow Parameter: - PUR_DESC + /// + public String PurDesc + { + get { return mPurDesc; } + set { mPurDesc = value; } + } + #endregion + + #region "Constructors" + + /// + /// Private Constructor. This prevents + /// creation of an empty Transaction object. + /// + private BuyerAuthVETransaction() + { + } + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// Credit card information for the user. + /// Connection credentials object. + /// Currency value + /// Request Id + /// After a successful Verify Enrollment Transaction, + /// you should redirect the user's browser to his/her browser to the + /// secure authentication server which will authinticate the user. + /// While redirecting to this secure authentication server, + /// you must pass the parameter PaReq obtained in the response of this transaction. + /// + /// This example shows how to create and perform a Verify Eknrollment transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// + /// //Create the Card object. + /// CreditCard Card = new CreditCard("XXXXXXXXXXXXXXXX","XXXX"); + /// + /// //Create the currency object. + /// Currency Amt = new Currency(new decimal(1.00),"US"); + /// .......... + /// .......... + /// + /// //Create a new Verify Enrollment Transaction. + /// BuyerAuthVETransaction Trans = new BuyerAuthVETransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Card, + /// Amt, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// + /// // Get the Buyer auth Response parameters. + /// BuyerAuthResponse BAResponse = Resp.BuyerAuthResponse; + /// if (BAResponse != null) + /// { + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status); + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id); + /// Console.WriteLine("ACSURL = " + BAResponse.AcsUrl); + /// Console.WriteLine("PAREQ = " + BAResponse.PaReq); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// + /// //Create the Card object. + /// Dim Card As CreditCard = new CreditCard("XXXXXXXXXXXXXXXX","XXXX") + /// + /// //Create the currency object. + /// Dim Amt As Currency = new Currency(new decimal(1.00),"US") + /// .......... + /// .......... + /// + /// 'Create a new Authorization Transaction. + /// Dim Trans as New BuyerAuthVETransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Card, + /// Amt, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Buyer auth Response parameters. + /// Dim BAResponse As BuyerAuthResponse = Resp.BuyerAuthResponse; + /// If Not BAResponse Is Nothing Then + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status) + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id) + /// Console.WriteLine("ACSURL = " + BAResponse.AcsUrl) + /// Console.WriteLine("PAREQ = " + BAResponse.PaReq) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public BuyerAuthVETransaction(UserInfo UserInfo, CreditCard CreditCard, PayflowConnectionData PayflowConnectionData, Currency Currency, String RequestId) + : base(PayflowConstants.TRXTYPE_BUYERAUTH_VE, UserInfo, PayflowConnectionData, RequestId) + { + mCurrency = Currency; + mPurDesc = PurDesc; + mCreditcard = CreditCard; + + } + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// Credit card information for the user. + /// Currency value + /// Request Id + /// After a successful Verify Enrollment Transaction, + /// you should redirect the user's browser to his/her browser to the + /// secure authentication server which will authinticate the user. + /// While redirecting to this secure authentication server, + /// you must pass the parameter PaReq obtained in the response of this transaction. + /// + /// This example shows how to create and perform a Verify Eknrollment transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// + /// //Create the Card object. + /// CreditCard Card = new CreditCard("XXXXXXXXXXXXXXXX","XXXX"); + /// + /// //Create the currency object. + /// Currency Amt = new Currency(new decimal(1.00),"US"); + /// .......... + /// .......... + /// + /// //Create a new Verify Enrollment Transaction. + /// BuyerAuthVETransaction Trans = new BuyerAuthVETransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Card, + /// Amt, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// + /// // Get the Buyer auth Response parameters. + /// BuyerAuthResponse BAResponse = Resp.BuyerAuthResponse; + /// if (BAResponse != null) + /// { + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status); + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id); + /// Console.WriteLine("ACSURL = " + BAResponse.AcsUrl); + /// Console.WriteLine("PAREQ = " + BAResponse.PaReq); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// + /// //Create the Card object. + /// Dim Card As CreditCard = new CreditCard("XXXXXXXXXXXXXXXX","XXXX") + /// + /// //Create the currency object. + /// Dim Amt As Currency = new Currency(new decimal(1.00),"US") + /// .......... + /// .......... + /// + /// 'Create a new Verify Enrollment Transaction. + /// Dim Trans as New BuyerAuthVETransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Card, + /// Amt, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Buyer auth Response parameters. + /// Dim BAResponse As BuyerAuthResponse = Resp.BuyerAuthResponse; + /// If Not BAResponse Is Nothing Then + /// Console.WriteLine("AUTHENTICATION_STATUS = " + BAResponse.Authentication_Status) + /// Console.WriteLine("AUTHENTICATION_ID = " + BAResponse.Authentication_Id) + /// Console.WriteLine("ACSURL = " + BAResponse.AcsUrl) + /// Console.WriteLine("PAREQ = " + BAResponse.PaReq) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public BuyerAuthVETransaction(UserInfo UserInfo, CreditCard CreditCard, Currency Currency,String RequestId) + : this(UserInfo, CreditCard ,null, Currency, RequestId) + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + if (mCreditcard != null) + { + mCreditcard.RequestBuffer = RequestBuffer ; + mCreditcard.GenerateRequest (); + } + + if (mCurrency != null) + { + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CURRENCY, mCurrency.CurrencyCode )); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_AMT, mCurrency)); + } + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_PUR_DESC, mPurDesc)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TEx = new TransactionException(Ex); + throw TEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/CaptureTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/CaptureTransaction.cs new file mode 100644 index 0000000..bfdce4a --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/CaptureTransaction.cs @@ -0,0 +1,637 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform a capture transaction. + /// + /// Capture transaction needs to be performed on a successful + /// authorization transaction in order to capture the amount. Therefore, a + /// capture transaction always takes the PNRef of a authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Capture Transaction. + /// CaptureTransaction Trans = new CaptureTransaction("PNRef of Authorization transaction", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ' Create a new Capture Transaction. + /// Dim Trans As CaptureTransaction = New CaptureTransaction("PNRef of Authorization transaction", User, + /// Connection, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public sealed class CaptureTransaction : ReferenceTransaction + { + #region "Member variables" + /// + /// Capture Complete. Y or N. + /// + private String mCaptureComplete; + #endregion + + #region "Properties" + /// + /// Gets, Sets CaptureComplete. + /// + /// + /// UK Only: Used with Delay Capture transaction + /// to indicate this is the last capture you intend + /// to make. + /// Values are : Y (default) N + /// If CaptureComplete is Y, any remaining amount of the + /// original reauthorized transaction is voided. + /// Maps to Payflow Parameter: + /// CAPTURECOMPLETE + /// + public String CaptureComplete + { + get { return mCaptureComplete; } + set { mCaptureComplete = value; } + } + #endregion + + #region "Constructors" + + /// + /// Private Constructor. This prevents + /// creation of an empty Transaction object. + /// + private CaptureTransaction() + { + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Request Id + /// Capture transaction needs to be performed on a successful + /// authorization transaction in order to capture the amount. Therefore, a + /// capture transaction always takes the PNRef of a authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Capture Transaction. + /// CaptureTransaction Trans = new CaptureTransaction("PNRef of Authorization transaction", + /// User, Connection, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Capture Transaction. + /// Dim Trans As CaptureTransaction = New CaptureTransaction("PNRef of Authorization transaction", + /// User, Connection, Inv, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CaptureTransaction(String OrigId, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, Invoice Invoice, String RequestId) : base(PayflowConstants.TRXTYPE_CAPTURE, OrigId, UserInfo, PayflowConnectionData, Invoice, RequestId) + { + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Invoice object. + /// Request Id + /// Capture transaction needs to be performed on a successful + /// authorization transaction in order to capture the amount. Therefore, a + /// capture transaction always takes the PNRef of a authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Capture Transaction. + /// CaptureTransaction Trans = new CaptureTransaction("PNRef of Authorization transaction", + /// User, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Capture Transaction. + /// Dim Trans As CaptureTransaction = New CaptureTransaction("PNRef of Authorization transaction", + /// User, Inv, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CaptureTransaction(String OrigId, UserInfo UserInfo, Invoice Invoice, String RequestId) : this(OrigId, UserInfo, null, Invoice, RequestId) + { + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object. + /// Request Id + /// Capture transaction needs to be performed on a successful + /// authorization transaction in order to capture the amount. Therefore, a + /// capture transaction always takes the PNRef of a authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Capture Transaction. + /// CaptureTransaction Trans = new CaptureTransaction("PNRef of Authorization transaction", + /// User, Connection, Inv, Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Capture Transaction. + /// Dim Trans As CaptureTransaction = New CaptureTransaction("PNRef of Authorization transaction", User, Connection, + /// Inv, Tender, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CaptureTransaction(String OrigId, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, Invoice Invoice, BaseTender Tender, String RequestId) : base(PayflowConstants.TRXTYPE_CAPTURE, OrigId, UserInfo, PayflowConnectionData, Invoice, Tender, RequestId) + { + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender object. + /// Request Id + /// Capture transaction needs to be performed on a successful + /// authorization transaction in order to capture the amount. Therefore, a + /// capture transaction always takes the PNRef of a authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Capture Transaction. + /// CaptureTransaction Trans = new CaptureTransaction("PNRef of Authorization transaction", + /// User, Inv, Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Capture Transaction. + /// Dim Trans As CaptureTransaction = New CaptureTransaction("PNRef of Authorization transaction", User, + /// Inv, Tender, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CaptureTransaction(String OrigId, UserInfo UserInfo, Invoice Invoice, BaseTender Tender, String RequestId) : this(OrigId, UserInfo, null, Invoice, Tender, RequestId) + { + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Request Id + /// Capture transaction needs to be performed on a successful + /// authorization transaction in order to capture the amount. Therefore, a + /// capture transaction always takes the PNRef of a authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Capture Transaction. + /// CaptureTransaction Trans = new CaptureTransaction("PNRef of Authorization transaction", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Capture Transaction. + /// Dim Trans As CaptureTransaction = New CaptureTransaction("PNRef of Authorization transaction", User, + /// Connection, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CaptureTransaction(String OrigId, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, String RequestId) : base(PayflowConstants.TRXTYPE_CAPTURE, OrigId, UserInfo, PayflowConnectionData, RequestId) + { + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Request Id + /// Capture transaction needs to be performed on a successful + /// authorization transaction in order to capture the amount. Therefore, a + /// capture transaction always takes the PNRef of a authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Capture Transaction. + /// CaptureTransaction Trans = new CaptureTransaction("PNRef of Authorization transaction", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Capture Transaction. + /// Dim Trans As CaptureTransaction = New CaptureTransaction("PNRef of Authorization transaction", User, + /// Connection, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CaptureTransaction(String OrigId, + UserInfo UserInfo, + String RequestId) : base(PayflowConstants.TRXTYPE_CAPTURE, OrigId, UserInfo, RequestId) + { + } + #endregion + + #region "Core functions" + internal override void GenerateRequest() + { + try + { + base.GenerateRequest (); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CAPTURECOMPLETE,mCaptureComplete)); + + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TEx = new TransactionException(Ex); + throw TEx; + } + } + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/CreditTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/CreditTransaction.cs new file mode 100644 index 0000000..7d69521 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/CreditTransaction.cs @@ -0,0 +1,792 @@ +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to create and perform an + /// Credit Transaction. + /// + /// Reference credit transaction can be performed on successful + /// transactions in order to credit the amount. Therefore, a + /// reference credit transaction takes the PNRef of a previous transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Credit Transaction. + /// // Following is an example of a reference credit type of transaction. + /// CreditTransaction Trans = new CreditTransaction("PNRef of a previous transaction.", + /// User, Connection, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Credit Transaction. + /// ' Following is an example of a reference credit type of transaction. + /// Dim Trans As CreditTransaction = New CreditTransaction("PNRef of a previous transaction.", User, + /// Connection, Inv, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + + + public sealed class CreditTransaction : BaseTransaction + { + #region "Member Variables" + + /// + /// Original transaction id. + /// + private String mOrigId; + + #endregion + + #region "Constructors" + + /// + /// Private Constructor. This prevents + /// creation of an empty Transaction object. + /// + private CreditTransaction() + { + } + + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Request Id + /// Reference credit transaction can be performed on successful + /// transactions in order to credit the amount. Therefore, a + /// reference credit transaction takes the PNRef of a previous transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Credit Transaction. + /// // Following is an example of a reference credit type of transaction. + /// CreditTransaction Trans = new CreditTransaction("PNRef of a previous transaction.", + /// User, Connection, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Credit Transaction. + /// ' Following is an example of a reference credit type of transaction. + /// Dim Trans As CreditTransaction = New CreditTransaction("PNRef of a previous transaction.", User, + /// Connection, Inv, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CreditTransaction(String OrigId, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, Invoice Invoice, String RequestId) : base(PayflowConstants.TRXTYPE_CREDIT, UserInfo, PayflowConnectionData, Invoice, RequestId) + { + mOrigId = OrigId; + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Invoice object. + /// Request Id + /// Reference credit transaction can be performed on successful + /// transactions in order to credit the amount. Therefore, a + /// reference credit transaction takes the PNRef of a previous transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Credit Transaction. + /// // Following is an example of a reference credit type of transaction. + /// CreditTransaction Trans = new CreditTransaction("PNRef of a previous transaction.", + /// User, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Credit Transaction. + /// ' Following is an example of a reference credit type of transaction. + /// Dim Trans As CreditTransaction = New CreditTransaction("PNRef of a previous transaction.", User, + /// Inv, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CreditTransaction(String OrigId, UserInfo UserInfo, Invoice Invoice, String RequestId) : this(OrigId, UserInfo, null,Invoice, RequestId) + { + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object. + /// Request Id + /// Reference credit transaction can be performed on successful + /// transactions in order to credit the amount. Therefore, a + /// reference credit transaction takes the PNRef of a previous transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Credit Transaction. + /// // Following is an example of a reference credit type of transaction. + /// CreditTransaction Trans = new CreditTransaction("PNRef of a previous transaction.", + /// User, Connection, Inv, Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Credit Transaction. + /// ' Following is an example of a reference credit type of transaction. + /// Dim Trans As CreditTransaction = New CreditTransaction("PNRef of a previous transaction.", User, + /// Connection, Inv, Tender, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CreditTransaction(String OrigId, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, Invoice Invoice, BaseTender Tender, String RequestId) : base(PayflowConstants.TRXTYPE_CREDIT, UserInfo, PayflowConnectionData, Invoice, Tender, RequestId) + { + mOrigId = OrigId; + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender object. + /// Request Id + /// Reference credit transaction can be performed on successful + /// transactions in order to credit the amount. Therefore, a + /// reference credit transaction takes the PNRef of a previous transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Credit Transaction. + /// // Following is an example of a reference credit type of transaction. + /// CreditTransaction Trans = new CreditTransaction("PNRef of a previous transaction.", + /// User, Inv, Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Credit Transaction. + /// ' Following is an example of a reference credit type of transaction. + /// Dim Trans As CreditTransaction = New CreditTransaction("PNRef of a previous transaction.", User, + /// Inv, Tender, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CreditTransaction(String OrigId, UserInfo UserInfo, Invoice Invoice, BaseTender Tender, String RequestId) : this(OrigId, UserInfo, null,Invoice, Tender, RequestId) + { + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Request Id + /// Reference credit transaction can be performed on successful + /// transactions in order to credit the amount. Therefore, a + /// reference credit transaction takes the PNRef of a previous transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Credit Transaction. + /// // Following is an example of a reference credit type of transaction. + /// CreditTransaction Trans = new CreditTransaction("PNRef of a previous transaction.", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Credit Transaction. + /// ' Following is an example of a reference credit type of transaction. + /// Dim Trans As CreditTransaction = New CreditTransaction("PNRef of a previous transaction.", User, + /// Connection, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CreditTransaction(String OrigId, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData,String RequestId) : base(PayflowConstants.TRXTYPE_CREDIT, UserInfo, PayflowConnectionData, null, RequestId) + { + mOrigId = OrigId; + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// User Info object populated with user credentials. + /// Request Id + /// Reference credit transaction can be performed on successful + /// transactions in order to credit the amount. Therefore, a + /// reference credit transaction takes the PNRef of a previous transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Credit Transaction. + /// // Following is an example of a reference credit type of transaction. + /// CreditTransaction Trans = new CreditTransaction("PNRef of a previous transaction.", PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Credit Transaction. + /// ' Following is an example of a reference credit type of transaction. + /// Dim Trans As CreditTransaction = New CreditTransaction("PNRef of a previous transaction.", User, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CreditTransaction(String OrigId, UserInfo UserInfo, String RequestId) : base(PayflowConstants.TRXTYPE_CREDIT,UserInfo, RequestId) + { + mOrigId = OrigId; + } + + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + /// This class is used for a stand alone credit transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Credit Transaction. + /// // Following is an example of a stand alone credit type of transaction. + /// CreditTransaction Trans = new CreditTransaction(User, Inv, Connection, + /// Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Credit Transaction. + /// ' Following is an example of a stand alone credit type of transaction. + /// Dim Trans As CreditTransaction = New CreditTransaction(User, Connection, + /// Inv, Tender, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CreditTransaction(UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + Invoice Invoice, + BaseTender Tender, + String RequestId) + : base(PayflowConstants.TRXTYPE_CREDIT, UserInfo, + PayflowConnectionData, + Invoice, + Tender, + RequestId) + { + } + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + /// This class is used for a stand alone credit transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Credit Transaction. + /// // Following is an example of a stand alone type of transaction. + /// CreditTransaction Trans = new CreditTransaction(User, Inv, + /// Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Credit Transaction. + /// ' Following is an example of a stand alone credit type of transaction. + /// Dim Trans As CreditTransaction = New CreditTransaction(User, + /// Inv, Tender, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public CreditTransaction(UserInfo UserInfo, + Invoice Invoice, + BaseTender Tender, + String RequestId) + : this(UserInfo, + null, + Invoice, + Tender, + RequestId) + { + } + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORIGID, mOrigId)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TEx = new TransactionException(Ex); + throw TEx; + } + //catch + //{ + // throw new Exception(); + //} + + } + + + #endregion + + + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/FraudReviewTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/FraudReviewTransaction.cs new file mode 100644 index 0000000..35ad356 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/FraudReviewTransaction.cs @@ -0,0 +1,297 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform a fraud review transaction. + /// + /// Fraud Review can be used as alternative to manually + /// approving transactions under fraud on PayPal manager. + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Ensure that Purchase price ceiling filter is set to $50. + /// // Create a new Sale Transaction with purchase price ceiling amount filter set to $50. + /// // Submit the sale transaction and get the PNRef number from this. + /// FraudReviewTransaction Trans = new FraudReviewTransaction("PNRef of Fraud Sale", "RMS_APPROVE", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors (optional code). + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Ensure that Purchase price ceiling filter is set to $50. + /// ' Create a new Sale Transaction with purchase price ceiling amount filter set to $50. + /// ' Submit the sale transaction and get the PNRef number from this. + /// Dim Trans As FraudReviewTransaction = New FraudReviewTransaction("PNRef of Fraud Sale", "RMS_APPROVE", + /// User, Connection, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors (optional code). + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public sealed class FraudReviewTransaction : ReferenceTransaction + { + #region "Member Variables" + + /// + /// Holds the update action. Mandatory for this transaction. + /// + String mUpdateAction; + + #endregion + + #region "Constructors" + + /// + /// Private Constructor. This prevents + /// creation of an empty Transaction object. + /// + private FraudReviewTransaction() + { + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// Update Action RMS_APPROVE or RMS_MERCHANT_DECLINE + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Request Id + /// Fraud Review can be used as alternative to manually + /// approving transactions under fraud on PayPal manager. + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Ensure that Purchase price ceiling filter is set to $50. + /// // Create a new Sale Transaction with purchase price ceiling amount filter set to $50. + /// // Submit the sale transaction and get the PNRef number from this. + /// FraudReviewTransaction Trans = new FraudReviewTransaction("PNRef of Fraud Sale", "RMS_APPROVE", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors (optional code). + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Ensure that Purchase price ceiling filter is set to $50. + /// ' Create a new Sale Transaction with purchase price ceiling amount filter set to $50. + /// ' Submit the sale transaction and get the PNRef number from this. + /// Dim Trans As FraudReviewTransaction = New FraudReviewTransaction("PNRef of Fraud Sale", "RMS_APPROVE", + /// User, Connection, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors (optional code). + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public FraudReviewTransaction( + String OrigId, + String UpdateAction, + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + String RequestId) + : base(PayflowConstants.TRXTYPE_FRAUDAPPROVE, OrigId, UserInfo, PayflowConnectionData, RequestId) + { + mUpdateAction = UpdateAction; + } + + /// + /// Constructor. + /// + /// Original Transaction Id + /// Update Action RMS_APPROVE or RMS_MERCHANT_DECLINE + /// User Info object populated with user credentials. + /// Request Id + /// Fraud Review can be used as alternative to manually + /// approving transactions under fraud on PayPal manager. + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Ensure that Purchase price ceiling filter is set to $50. + /// // Create a new Sale Transaction with purchase price ceiling amount filter set to $50. + /// // Submit the sale transaction and get the PNRef number from this. + /// FraudReviewTransaction Trans = new FraudReviewTransaction("PNRef of Fraud Sale", "RMS_APPROVE", + /// User, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors (optional code). + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Ensure that Purchase price ceiling filter is set to $50. + /// ' Create a new Sale Transaction with purchase price ceiling amount filter set to $50. + /// ' Submit the sale transaction and get the PNRef number from this. + /// Dim Trans As FraudReviewTransaction = New FraudReviewTransaction("PNRef of Fraud Sale", "RMS_APPROVE", + /// User, PayflowUtility.RequestId) + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors (optional code). + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public FraudReviewTransaction( + String OrigId, + String UpdateAction, + UserInfo UserInfo, + String RequestId) + : this(OrigId, UpdateAction, UserInfo, null, RequestId) + { + } + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + //Add UPDATEACTION + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_UPDATEACTION, mUpdateAction)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TEx = new TransactionException(Ex); + throw TEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + + #endregion + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/ITransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/ITransaction.cs new file mode 100644 index 0000000..06b63dc --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/ITransaction.cs @@ -0,0 +1,32 @@ +#region "Imports" + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// Base Interface for all the transaction objects. + /// + /// This interface cane be implemented to create a new + /// transaction type. + public interface ITransaction + { + /// + /// Submits the transaction to the Payflow server + /// and populates the response object. + /// + /// When implemented in the derived class, this method + /// should be preferred to be made as an internal method. + /// true if successful, false otherwise. + bool SubmitTransaction(); + + /// + /// generates the request. + /// + /// When implemented in the derived class, this method + /// should be preferred to be made as an internal method. + void GenerateRequest(); + + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/InquiryTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/InquiryTransaction.cs new file mode 100644 index 0000000..44c5f6b --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/InquiryTransaction.cs @@ -0,0 +1,582 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform an inquiry transaction. + /// + /// Inquiry transaction gets the status of a previously performed + /// transaction. Therefore, inquiry transaction always takes the PNRef of a + /// previous transaction. + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Inquiry Transaction. + /// InquiryTransaction Trans = new InquiryTransaction("PNRef of a previous transaction", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult); + /// Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState); + /// Console.WriteLine("CUSTREF = " + TrxnResponse.CustRef); + /// } + /// + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Inquiry Transaction. + /// Dim Trans As InquiryTransaction = New InquiryTransaction("PNRef of a previous transaction", + /// User, Connection, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult) + /// Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState) + /// Console.WriteLine("CUSTREF = " + TrxnResponse.CustRef) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public sealed class InquiryTransaction : ReferenceTransaction + { + #region "Constructors" + + /// + /// Private Constructor. This prevents + /// creation of an empty Transaction object. + /// + private InquiryTransaction() + { + } + + /// + /// Constructor + /// + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Request Id + /// Inquiry transaction gets the status of a previously performed + /// transaction. Therefore, inquiry transaction always takes the PNRef of a + /// previous transaction. + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Inquiry Transaction. + /// InquiryTransaction Trans = new InquiryTransaction("PNRef of a previous transaction", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult); + /// Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState); + /// Console.WriteLine("CUSTREF = " + TrxnResponse.CustRef); + /// } + /// + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Inquiry Transaction. + /// Dim Trans As InquiryTransaction = New InquiryTransaction("PNRef of a previous transaction", + /// User, Connection, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult) + /// Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState) + /// Console.WriteLine("CUSTREF = " + TrxnResponse.CustRef) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public InquiryTransaction(String OrigId, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, String RequestId) : base(PayflowConstants.TRXTYPE_INQUIRY, OrigId, UserInfo, PayflowConnectionData, RequestId) + { + } + + /// + /// Constructor + /// + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Request Id + /// Inquiry transaction gets the status of a previously performed + /// transaction. Therefore, inquiry transaction always takes the PNRef of a + /// previous transaction. + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Inquiry Transaction. + /// InquiryTransaction Trans = new InquiryTransaction("PNRef of a previous transaction", + /// User, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult); + /// Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState); + /// Console.WriteLine("CUSTREF = " + TrxnResponse.CustRef); + /// } + /// + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Inquiry Transaction. + /// Dim Trans As InquiryTransaction = New InquiryTransaction("PNRef of a previous transaction", + /// User, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult) + /// Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState) + /// Console.WriteLine("CUSTREF = " + TrxnResponse.CustRef) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public InquiryTransaction(String OrigId, UserInfo UserInfo,String RequestId) : base(PayflowConstants.TRXTYPE_INQUIRY, OrigId, UserInfo, RequestId) + { + } + + /// + /// Constructor + /// + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Request Id + /// Inquiry transaction gets the status of a previously performed + /// transaction. Therefore, inquiry transaction always takes the PNRef or CustRef of a + /// previous transaction. + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Inquiry Transaction. + /// InquiryTransaction Trans = new InquiryTransaction("PNRef of a previous transaction", + /// User, Connection, Inv, PayflowUtility.RequestId); + /// + /// // To use CUSTREF instead of PNREF you need to set the CustRef and include the INVOICE object in your + /// // request. Since you will be using CUSTREF instead of PNREF, PNREF will be "" (null). + /// // Create a new Invoice data object with the Amount, Billing Address etc. details. + /// //Invoice Inv = new Invoice(); + /// //Inv.CustRef = "TEST1"; + /// //InquiryTransaction Trans = new InquiryTransaction("", User, Connection, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult); + /// Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState); + /// Console.WriteLine("CUSTREF = " + TrxnResponse.CustRef); + /// } + /// + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Inquiry Transaction. + /// Dim Trans As InquiryTransaction = New InquiryTransaction("PNRef of a previous transaction", + /// User, Connection, Inv, PayflowUtility.RequestId) + /// + /// ' To use CUSTREF instead of PNREF you need to set the CustRef and include the INVOICE object in your + /// ' request. Since you will be using CUSTREF instead of PNREF, PNREF will be "" (null). + /// ' Create a new Invoice data object with the Amount, Billing Address etc. details. + /// 'Dim Inv As Invoice = New Invoice + /// 'Inv.CustRef = "TEST1" + /// 'Dim Trans As InquiryTransaction = New InquiryTransaction("", User, Connection, Inv, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult) + /// Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState) + /// Console.WriteLine("CUSTREF = " + TrxnResponse.CustRef) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public InquiryTransaction(String OrigId, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, Invoice Invoice, String RequestId) : base(PayflowConstants.TRXTYPE_INQUIRY, OrigId, UserInfo, PayflowConnectionData, Invoice, RequestId) + { + } + + /// + /// Constructor + /// + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Invoice object. + /// Request Id + /// Inquiry transaction gets the status of a previously performed + /// transaction. Therefore, inquiry transaction always takes the PNRef or CustRef of a + /// previous transaction. + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Inquiry Transaction. + /// InquiryTransaction Trans = new InquiryTransaction("PNRef of a previous transaction", + /// User, Inv, PayflowUtility.RequestId); + /// + /// // To use CUSTREF instead of PNREF you need to set the CustRef and include the INVOICE object in your + /// // request. Since you will be using CUSTREF instead of PNREF, PNREF will be "" (null). + /// // Create a new Invoice data object with the Amount, Billing Address etc. details. + /// //Invoice Inv = new Invoice(); + /// //Inv.CustRef = "TEST1"; + /// //InquiryTransaction Trans = new InquiryTransaction("", User, Connection, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult); + /// Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState); + /// Console.WriteLine("CUSTREF = " + TrxnResponse.CustRef); + /// } + /// + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Inquiry Transaction. + /// Dim Trans As InquiryTransaction = New InquiryTransaction("PNRef of a previous transaction", + /// User, Inv, PayflowUtility.RequestId) + /// + /// ' To use CUSTREF instead of PNREF you need to set the CustRef and include the INVOICE object in your + /// ' request. Since you will be using CUSTREF instead of PNREF, PNREF will be "" (null). + /// ' Create a new Invoice data object with the Amount, Billing Address etc. details. + /// 'Dim Inv As Invoice = New Invoice + /// 'Inv.CustRef = "TEST1" + /// 'Dim Trans As InquiryTransaction = New InquiryTransaction("", User, Connection, Inv, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult) + /// Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState) + /// Console.WriteLine("CUSTREF = " + TrxnResponse.CustRef) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public InquiryTransaction(String OrigId, UserInfo UserInfo, Invoice Invoice, String RequestId) : this(OrigId, UserInfo, null, Invoice, RequestId) + { + } + + + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/NamespaceDoc.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/NamespaceDoc.cs new file mode 100644 index 0000000..37bd1b4 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/NamespaceDoc.cs @@ -0,0 +1,10 @@ + +namespace PayPal.Payments.Transactions +{ + /// + ///NameSpace doc for Transactions namespace + /// + internal class NamespaceDoc + { + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/OrderTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/OrderTransaction.cs new file mode 100644 index 0000000..e59a851 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/OrderTransaction.cs @@ -0,0 +1,308 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects ; +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to create and perform an Order Transaction for Express Checkout. + /// + /// An Order transaction represents an agreement to pay one or more authorized amounts up to + /// the specified total over a maximum of 29 days. + /// + /// This example shows how to create and perform a order transaction as part of Express Checkout. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// // Create the Tender object. + /// PayPalTender Tender = new PayPalTender(SetRequest); + /// + /// // Create an Order Transaction. An Order transaction represents an agreement to pay one or more + /// // authorized amounts up to the specified total over a maximum of 29 days. + /// OrderTransaction Trans = new OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString()); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); + /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// ' Create the Tender object. + /// Dim Tender As New PayPalTender(SetRequest) + /// + /// ' Create an Order Transaction. An Order transaction represents an agreement to pay one or more + /// ' authorized amounts up to the specified total over a maximum of 29 days. + /// Dim Trans As New OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token) + /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public class OrderTransaction : AuthorizationTransaction + { + #region "Constructors" + + /// + /// This class is used to create and perform an Order Transaction for Express Checkout. + /// + /// An Order transaction represents an agreement to pay one or more authorized amounts up to + /// the specified total over a maximum of 29 days. + /// + /// This example shows how to create and perform a order transaction as part of Express Checkout. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// // Create the Tender object. + /// PayPalTender Tender = new PayPalTender(SetRequest); + /// + /// // Create an Order Transaction. An Order transaction represents an agreement to pay one or more + /// // authorized amounts up to the specified total over a maximum of 29 days. + /// OrderTransaction Trans = new OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString()); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); + /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// ' Create the Tender object. + /// Dim Tender As New PayPalTender(SetRequest) + /// + /// ' Create an Order Transaction. An Order transaction represents an agreement to pay one or more + /// ' authorized amounts up to the specified total over a maximum of 29 days. + /// Dim Trans As New OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token) + /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object + /// Request Id + public OrderTransaction (UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, Invoice Invoice, PayPalTender Tender, String RequestId) + : base("O", UserInfo ,PayflowConnectionData ,Invoice ,Tender ,RequestId) + {} + /// + /// This class is used to create and perform an Order Transaction for Express Checkout. + /// + /// An Order transaction represents an agreement to pay one or more authorized amounts up to + /// the specified total over a maximum of 29 days. + /// + /// This example shows how to create and perform a order transaction as part of Express Checkout. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// // Create the Tender object. + /// PayPalTender Tender = new PayPalTender(SetRequest); + /// + /// // Create an Order Transaction. An Order transaction represents an agreement to pay one or more + /// // authorized amounts up to the specified total over a maximum of 29 days. + /// OrderTransaction Trans = new OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString()); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); + /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// ' Create the Tender object. + /// Dim Tender As New PayPalTender(SetRequest) + /// + /// ' Create an Order Transaction. An Order transaction represents an agreement to pay one or more + /// ' authorized amounts up to the specified total over a maximum of 29 days. + /// Dim Trans As New OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token) + /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender object + /// Request Id + public OrderTransaction ( UserInfo UserInfo, Invoice Invoice, PayPalTender Tender, String RequestId) + : base("0", UserInfo,Invoice ,Tender ,RequestId) + {} + #endregion + + + } +} diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringAddTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringAddTransaction.cs new file mode 100644 index 0000000..bd154e6 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringAddTransaction.cs @@ -0,0 +1,436 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform a recurring transaction with + /// add action. + /// + /// RecurringAddTransaction is used to add a new recurring profile + /// either by submitting the data that defines the profile or by converting an + /// existing transaction into a profile. Upon successful creation of a profile, + /// PayPal activates the profile, performs the Optional Transaction if specified, + /// initiates the payment cycle, and returns a Profile ID (a 12-character string that + /// uniquely identifies the profile for searching and reporting). Upon failure, PayPal + /// does not generate the profile and returns an error message. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Add Transaction. + /// RecurringAddTransaction Trans = new RecurringAddTransaction( + /// User, Connection, Inv, Card, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Add Transaction. + /// Dim Trans As RecurringAddTransaction = New RecurringAddTransaction(User, Connection, Inv, + /// Card, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public class RecurringAddTransaction : RecurringTransaction + { + /// + /// Used for original transaction id. + /// + private String mOrigId; + + #region "Properties" + + /// + /// Gets, Sets OrigId + /// + public virtual String OrigId + { + get { return mOrigId; } + set { mOrigId = value; } + } + + #endregion + + #region "Constructor" + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object such as Card Tender. + /// RecurringInfo object . + /// Request Id + /// RecurringAddTransaction is used to add a new recurring profile + /// either by submitting the data that defines the profile or by converting an + /// existing transaction into a profile. Upon successful creation of a profile, + /// PayPal activates the profile, performs the Optional Transaction if specified, + /// initiates the payment cycle, and returns a Profile ID (a 12-character string that + /// uniquely identifies the profile for searching and reporting). Upon failure, PayPal + /// does not generate the profile and returns an error message. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Add Transaction. + /// RecurringAddTransaction Trans = new RecurringAddTransaction( + /// User, Connection, Inv, Card, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Add Transaction. + /// Dim Trans As RecurringAddTransaction = New RecurringAddTransaction(User, Connection, Inv, + /// Card, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringAddTransaction( + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + Invoice Invoice, + BaseTender Tender, + RecurringInfo RecurringInfo, + String RequestId) + : base(PayflowConstants.RECURRING_ACTION_ADD, + RecurringInfo, + UserInfo, PayflowConnectionData, Invoice, Tender, RequestId) + { + } + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender object such as Card Tender. + /// RecurringInfo object . + /// Request Id + /// RecurringAddTransaction is used to add a new recurring profile + /// either by submitting the data that defines the profile or by converting an + /// existing transaction into a profile. Upon successful creation of a profile, + /// PayPal activates the profile, performs the Optional Transaction if specified, + /// initiates the payment cycle, and returns a Profile ID (a 12-character string that + /// uniquely identifies the profile for searching and reporting). Upon failure, PayPal + /// does not generate the profile and returns an error message. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Add Transaction. + /// RecurringAddTransaction Trans = new RecurringAddTransaction( + /// User, Inv, Card, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Add Transaction. + /// Dim Trans As RecurringAddTransaction = New RecurringAddTransaction(User, Inv, + /// Card, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringAddTransaction( + UserInfo UserInfo, + Invoice Invoice, + BaseTender Tender, + RecurringInfo RecurringInfo, + String RequestId) + : this(UserInfo, null, Invoice, Tender, RecurringInfo, RequestId) + { + } + + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORIGID, mOrigId)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TEx = new TransactionException(Ex); + throw TEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringCancelTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringCancelTransaction.cs new file mode 100644 index 0000000..ad1c911 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringCancelTransaction.cs @@ -0,0 +1,323 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform a recurring transaction with + /// cancel action. + /// + /// RecurringCancelTransaction is used to cancel the recurring profile + /// to deactivate the profile from performing further transactions. The profile is + /// marked as cancelled and the customer is no longer billed. PayPal records the + /// cancellation date. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Cancel Transaction. + /// RecurringCancelTransaction Trans = new RecurringCancelTransaction( + /// User, Connection, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Cancel Transaction. + /// Dim Trans As RecurringCancelTransaction = New RecurringCancelTransaction(User, + /// Connection, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public class RecurringCancelTransaction : RecurringTransaction + { + #region "Constructor" + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// RecurringInfo object. + /// Request Id + /// RecurringCancelTransaction is used to cancel the recurring profile + /// to deactivate the profile from performing further transactions. The profile is + /// marked as cancelled and the customer is no longer billed. PayPal records the + /// cancellation date. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Cancel Transaction. + /// RecurringCancelTransaction Trans = new RecurringCancelTransaction( + /// User, Connection, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Cancel Transaction. + /// Dim Trans As RecurringCancelTransaction = New RecurringCancelTransaction(User, + /// Connection, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public RecurringCancelTransaction( + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + RecurringInfo RecurringInfo, String RequestId) + : base(PayflowConstants.RECURRING_ACTION_CANCEL, + RecurringInfo, + UserInfo, PayflowConnectionData, RequestId) + { + } + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// RecurringInfo object. + /// Request Id + /// RecurringCancelTransaction is used to cancel the recurring profile + /// to deactivate the profile from performing further transactions. The profile is + /// marked as cancelled and the customer is no longer billed. PayPal records the + /// cancellation date. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Cancel Transaction. + /// RecurringCancelTransaction Trans = new RecurringCancelTransaction( + /// User, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Cancel Transaction. + /// Dim Trans As RecurringCancelTransaction = New RecurringCancelTransaction(User, + /// RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public RecurringCancelTransaction( + UserInfo UserInfo, + RecurringInfo RecurringInfo, String RequestId) + : this(UserInfo, null, RecurringInfo,RequestId) + { + } + #endregion + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringInquiryTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringInquiryTransaction.cs new file mode 100644 index 0000000..10059e5 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringInquiryTransaction.cs @@ -0,0 +1,446 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform a recurring transaction with + /// inquiry action. + /// + /// + /// RecurringInquiryTransaction is used to request two different sets of information: + /// To view the full set of payment information for a profile, include the + /// PAYMENTHISTORY=Y name/value pair with the Inquiry action. + /// To view the status of a customer’s profile, submit an Inquiry action that does + /// not include the PAYMENTHISTORY parameter (alternatively, submit + /// PAYMENTHISTORY=N). + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Inquiry Transaction. + /// RecurringInquiryTransaction Trans = new RecurringInquiryTransaction( + /// User, Connection, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// Console.WriteLine("STATUS = " + RecurResponse.Status); + /// Console.WriteLine("PROFILENAME = " + RecurResponse.ProfileName); + /// Console.WriteLine("START = " + RecurResponse.Start); + /// Console.WriteLine("TERM = " + RecurResponse.Term); + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment); + /// Console.WriteLine("PAYPERIOD = " + RecurResponse.PayPeriod); + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment); + /// Console.WriteLine("TENDER = " + RecurResponse.Tender); + /// Console.WriteLine("AMT = " + RecurResponse.Amt); + /// Console.WriteLine("ACCT = " + RecurResponse.Acct); + /// Console.WriteLine("EXPDATE = " + RecurResponse.ExpDate); + /// Console.WriteLine("AGGREGATEAMT = " + RecurResponse.AggregateAmt); + /// Console.WriteLine("AGGREGATEOPTIONALAMT = " + RecurResponse.AggregateOptionalAmt); + /// Console.WriteLine("MAXFAILPAYMENTS = " + RecurResponse.MaxFailPayments); + /// Console.WriteLine("NUMFAILPAYMENTS = " + RecurResponse.NumFailPayments); + /// Console.WriteLine("RETRYNUMDAYS = " + RecurResponse.RetryNumDays); + /// Console.WriteLine("STREET = " + RecurResponse.Street); + /// Console.WriteLine("ZIP = " + RecurResponse.Zip); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Inquiry Transaction. + /// Dim Trans As RecurringInquiryTransaction = New RecurringInquiryTransaction(User, + /// Connection, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// Console.WriteLine("STATUS = " + RecurResponse.Status) + /// Console.WriteLine("PROFILENAME = " + RecurResponse.ProfileName) + /// Console.WriteLine("START = " + RecurResponse.Start) + /// Console.WriteLine("TERM = " + RecurResponse.Term) + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment) + /// Console.WriteLine("PAYPERIOD = " + RecurResponse.PayPeriod) + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment) + /// Console.WriteLine("TENDER = " + RecurResponse.Tender) + /// Console.WriteLine("AMT = " + RecurResponse.Amt) + /// Console.WriteLine("ACCT = " + RecurResponse.Acct) + /// Console.WriteLine("EXPDATE = " + RecurResponse.ExpDate) + /// Console.WriteLine("AGGREGATEAMT = " + RecurResponse.AggregateAmt) + /// Console.WriteLine("AGGREGATEOPTIONALAMT = " + RecurResponse.AggregateOptionalAmt) + /// Console.WriteLine("MAXFAILPAYMENTS = " + RecurResponse.MaxFailPayments) + /// Console.WriteLine("NUMFAILPAYMENTS = " + RecurResponse.NumFailPayments) + /// Console.WriteLine("RETRYNUMDAYS = " + RecurResponse.RetryNumDays) + /// Console.WriteLine("STREET = " + RecurResponse.Street) + /// Console.WriteLine("ZIP = " + RecurResponse.Zip) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public class RecurringInquiryTransaction : RecurringTransaction + { + #region "Constructor" + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// RecurringInfo object. + /// Request Id + /// + /// RecurringInquiryTransaction is used to request two different sets of information: + /// To view the full set of payment information for a profile, include the + /// PAYMENTHISTORY=Y name/value pair with the Inquiry action. + /// To view the status of a customer’s profile, submit an Inquiry action that does + /// not include the PAYMENTHISTORY parameter (alternatively, submit + /// PAYMENTHISTORY=N). + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Inquiry Transaction. + /// RecurringInquiryTransaction Trans = new RecurringInquiryTransaction( + /// User, Connection, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// Console.WriteLine("STATUS = " + RecurResponse.Status); + /// Console.WriteLine("PROFILENAME = " + RecurResponse.ProfileName); + /// Console.WriteLine("START = " + RecurResponse.Start); + /// Console.WriteLine("TERM = " + RecurResponse.Term); + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment); + /// Console.WriteLine("PAYPERIOD = " + RecurResponse.PayPeriod); + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment); + /// Console.WriteLine("TENDER = " + RecurResponse.Tender); + /// Console.WriteLine("AMT = " + RecurResponse.Amt); + /// Console.WriteLine("ACCT = " + RecurResponse.Acct); + /// Console.WriteLine("EXPDATE = " + RecurResponse.ExpDate); + /// Console.WriteLine("AGGREGATEAMT = " + RecurResponse.AggregateAmt); + /// Console.WriteLine("AGGREGATEOPTIONALAMT = " + RecurResponse.AggregateOptionalAmt); + /// Console.WriteLine("MAXFAILPAYMENTS = " + RecurResponse.MaxFailPayments); + /// Console.WriteLine("NUMFAILPAYMENTS = " + RecurResponse.NumFailPayments); + /// Console.WriteLine("RETRYNUMDAYS = " + RecurResponse.RetryNumDays); + /// Console.WriteLine("STREET = " + RecurResponse.Street); + /// Console.WriteLine("ZIP = " + RecurResponse.Zip); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Inquiry Transaction. + /// Dim Trans As RecurringInquiryTransaction = New RecurringInquiryTransaction(User, + /// Connection, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// Console.WriteLine("STATUS = " + RecurResponse.Status) + /// Console.WriteLine("PROFILENAME = " + RecurResponse.ProfileName) + /// Console.WriteLine("START = " + RecurResponse.Start) + /// Console.WriteLine("TERM = " + RecurResponse.Term) + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment) + /// Console.WriteLine("PAYPERIOD = " + RecurResponse.PayPeriod) + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment) + /// Console.WriteLine("TENDER = " + RecurResponse.Tender) + /// Console.WriteLine("AMT = " + RecurResponse.Amt) + /// Console.WriteLine("ACCT = " + RecurResponse.Acct) + /// Console.WriteLine("EXPDATE = " + RecurResponse.ExpDate) + /// Console.WriteLine("AGGREGATEAMT = " + RecurResponse.AggregateAmt) + /// Console.WriteLine("AGGREGATEOPTIONALAMT = " + RecurResponse.AggregateOptionalAmt) + /// Console.WriteLine("MAXFAILPAYMENTS = " + RecurResponse.MaxFailPayments) + /// Console.WriteLine("NUMFAILPAYMENTS = " + RecurResponse.NumFailPayments) + /// Console.WriteLine("RETRYNUMDAYS = " + RecurResponse.RetryNumDays) + /// Console.WriteLine("STREET = " + RecurResponse.Street) + /// Console.WriteLine("ZIP = " + RecurResponse.Zip) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringInquiryTransaction( + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + RecurringInfo RecurringInfo, String RequestId) + : base(PayflowConstants.RECURRING_ACTION_INQUIRY, + RecurringInfo, + UserInfo, PayflowConnectionData, RequestId) + { + } + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// RecurringInfo object. + /// Request Id + /// + /// RecurringInquiryTransaction is used to request two different sets of information: + /// To view the full set of payment information for a profile, include the + /// PAYMENTHISTORY=Y name/value pair with the Inquiry action. + /// To view the status of a customer’s profile, submit an Inquiry action that does + /// not include the PAYMENTHISTORY parameter (alternatively, submit + /// PAYMENTHISTORY=N). + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Inquiry Transaction. + /// RecurringInquiryTransaction Trans = new RecurringInquiryTransaction( + /// User, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// Console.WriteLine("STATUS = " + RecurResponse.Status); + /// Console.WriteLine("PROFILENAME = " + RecurResponse.ProfileName); + /// Console.WriteLine("START = " + RecurResponse.Start); + /// Console.WriteLine("TERM = " + RecurResponse.Term); + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment); + /// Console.WriteLine("PAYPERIOD = " + RecurResponse.PayPeriod); + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment); + /// Console.WriteLine("TENDER = " + RecurResponse.Tender); + /// Console.WriteLine("AMT = " + RecurResponse.Amt); + /// Console.WriteLine("ACCT = " + RecurResponse.Acct); + /// Console.WriteLine("EXPDATE = " + RecurResponse.ExpDate); + /// Console.WriteLine("AGGREGATEAMT = " + RecurResponse.AggregateAmt); + /// Console.WriteLine("AGGREGATEOPTIONALAMT = " + RecurResponse.AggregateOptionalAmt); + /// Console.WriteLine("MAXFAILPAYMENTS = " + RecurResponse.MaxFailPayments); + /// Console.WriteLine("NUMFAILPAYMENTS = " + RecurResponse.NumFailPayments); + /// Console.WriteLine("RETRYNUMDAYS = " + RecurResponse.RetryNumDays); + /// Console.WriteLine("STREET = " + RecurResponse.Street); + /// Console.WriteLine("ZIP = " + RecurResponse.Zip); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Inquiry Transaction. + /// Dim Trans As RecurringInquiryTransaction = New RecurringInquiryTransaction(User, + /// RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// Console.WriteLine("STATUS = " + RecurResponse.Status) + /// Console.WriteLine("PROFILENAME = " + RecurResponse.ProfileName) + /// Console.WriteLine("START = " + RecurResponse.Start) + /// Console.WriteLine("TERM = " + RecurResponse.Term) + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment) + /// Console.WriteLine("PAYPERIOD = " + RecurResponse.PayPeriod) + /// Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment) + /// Console.WriteLine("TENDER = " + RecurResponse.Tender) + /// Console.WriteLine("AMT = " + RecurResponse.Amt) + /// Console.WriteLine("ACCT = " + RecurResponse.Acct) + /// Console.WriteLine("EXPDATE = " + RecurResponse.ExpDate) + /// Console.WriteLine("AGGREGATEAMT = " + RecurResponse.AggregateAmt) + /// Console.WriteLine("AGGREGATEOPTIONALAMT = " + RecurResponse.AggregateOptionalAmt) + /// Console.WriteLine("MAXFAILPAYMENTS = " + RecurResponse.MaxFailPayments) + /// Console.WriteLine("NUMFAILPAYMENTS = " + RecurResponse.NumFailPayments) + /// Console.WriteLine("RETRYNUMDAYS = " + RecurResponse.RetryNumDays) + /// Console.WriteLine("STREET = " + RecurResponse.Street) + /// Console.WriteLine("ZIP = " + RecurResponse.Zip) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringInquiryTransaction( + UserInfo UserInfo, + RecurringInfo RecurringInfo, String RequestId) + : this(UserInfo, null,RecurringInfo, RequestId) + { + } + + #endregion + + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringModifyTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringModifyTransaction.cs new file mode 100644 index 0000000..b7f4d32 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringModifyTransaction.cs @@ -0,0 +1,575 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform a recurring transaction with + /// modify action. + /// + /// + /// RecurringModifyTransaction is used to modify any profile value by + /// sending any subset of the profile parameters, including an Optional Transaction. + /// The Modify action is useful, for example, when an inactive customer wishes to + /// restart payments using a new valid credit card. The Modify action changes a + /// profile’s STATUS to active but does not change the START date. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// RecurInfo.ProfileName = "PayPal Inc."; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Modify Transaction. + /// RecurringModifyTransaction Trans = new RecurringModifyTransaction( + /// User, Connection, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// RecurInfo.ProfileName = "PayPal Inc." + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Modify Transaction. + /// Dim Trans As RecurringModifyTransaction = New RecurringModifyTransaction(User, + /// Connection, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public class RecurringModifyTransaction : RecurringTransaction + { + #region "Constructor" + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// RecurringInfo object. + /// Request Id + /// + /// RecurringModifyTransaction is used to modify any profile value by + /// sending any subset of the profile parameters, including an Optional Transaction. + /// The Modify action is useful, for example, when an inactive customer wishes to + /// restart payments using a new valid credit card. The Modify action changes a + /// profile’s STATUS to active but does not change the START date. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// RecurInfo.ProfileName = "PayPal Inc."; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Modify Transaction. + /// RecurringModifyTransaction Trans = new RecurringModifyTransaction( + /// User, Connection, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// RecurInfo.ProfileName = "PayPal Inc." + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Modify Transaction. + /// Dim Trans As RecurringModifyTransaction = New RecurringModifyTransaction(User, + /// Connection, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringModifyTransaction( + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + RecurringInfo RecurringInfo, String RequestId) + : base(PayflowConstants.RECURRING_ACTION_MODIFY, + RecurringInfo, + UserInfo, PayflowConnectionData, RequestId) + { + } + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// RecurringInfo object. + /// Request Id + /// + /// RecurringModifyTransaction is used to modify any profile value by + /// sending any subset of the profile parameters, including an Optional Transaction. + /// The Modify action is useful, for example, when an inactive customer wishes to + /// restart payments using a new valid credit card. The Modify action changes a + /// profile’s STATUS to active but does not change the START date. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// RecurInfo.ProfileName = "PayPal Inc."; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Modify Transaction. + /// RecurringModifyTransaction Trans = new RecurringModifyTransaction( + /// User, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// RecurInfo.ProfileName = "PayPal Inc." + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Modify Transaction. + /// Dim Trans As RecurringModifyTransaction = New RecurringModifyTransaction(User, + /// RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringModifyTransaction( + UserInfo UserInfo, + RecurringInfo RecurringInfo, String RequestId) + : this(UserInfo, null, RecurringInfo, RequestId) + { + } + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// RecurringInfo object. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + /// + /// RecurringModifyTransaction is used to modify any profile value by + /// sending any subset of the profile parameters, including an Optional Transaction. + /// The Modify action is useful, for example, when an inactive customer wishes to + /// restart payments using a new valid credit card. The Modify action changes a + /// profile’s STATUS to active but does not change the START date. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// RecurInfo.ProfileName = "PayPal Inc."; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Modify Transaction. + /// RecurringModifyTransaction Trans = new RecurringModifyTransaction( + /// User, Connection, RecurInfo, Inv, Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// RecurInfo.ProfileName = "PayPal Inc." + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Modify Transaction. + /// Dim Trans As RecurringModifyTransaction = New RecurringModifyTransaction(User, + /// Connection, RecurInfo, Inv, Tender, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringModifyTransaction( + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + RecurringInfo RecurringInfo, + Invoice Invoice, + BaseTender Tender, String RequestId) + : base(PayflowConstants.RECURRING_ACTION_MODIFY, + RecurringInfo, + UserInfo, PayflowConnectionData, + Invoice, + Tender, RequestId) + { + } + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// RecurringInfo object. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + /// + /// RecurringModifyTransaction is used to modify any profile value by + /// sending any subset of the profile parameters, including an Optional Transaction. + /// The Modify action is useful, for example, when an inactive customer wishes to + /// restart payments using a new valid credit card. The Modify action changes a + /// profile’s STATUS to active but does not change the START date. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// RecurInfo.ProfileName = "PayPal Inc."; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Modify Transaction. + /// RecurringModifyTransaction Trans = new RecurringModifyTransaction( + /// User, RecurInfo, Inv, Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// RecurInfo.ProfileName = "PayPal Inc." + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Modify Transaction. + /// Dim Trans As RecurringModifyTransaction = New RecurringModifyTransaction(User, + /// RecurInfo, Inv, Tender, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringModifyTransaction( + UserInfo UserInfo, + RecurringInfo RecurringInfo, + Invoice Invoice, + BaseTender Tender, String RequestId) + : this(UserInfo, null,RecurringInfo, + Invoice, + Tender, RequestId) + { + } + + #endregion + + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringPaymentTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringPaymentTransaction.cs new file mode 100644 index 0000000..eeeca66 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringPaymentTransaction.cs @@ -0,0 +1,411 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform a recurring transaction with + /// payment action. + /// + /// + /// RecurringPaymentTransaction action performs a real-time retry on + /// a transaction that is in the retry state. The response string is similar + /// to the string for Optional transactions, except that, upon approval, + /// the profile is updated to reflect the successful retry. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// RecurInfo.PaymentNum = "01012009"; + /// + /// // Create a new Invoice data object with the Amount, Billing Address etc. details. + /// Invoice Inv = new Invoice(); + /// + /// // Set Amount. + /// Currency Amt = new Currency(new decimal(25.12)); + /// Inv.Amt = Amt; + /// Inv.PoNum = "PO12345"; + /// Inv.InvNum = "INV12345"; + /// + /// // Set the Billing Address details. + /// BillTo Bill = new BillTo(); + /// Bill.BillToStreet = "123 Main St."; + /// Bill.BillToZip = "12345"; + /// Inv.BillTo = Bill; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Payment Transaction. + /// RecurringPaymentTransaction Trans = new RecurringPaymentTransaction( + /// User, Connection, RecurInfo, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// RecurInfo.PaymentNum = "01012009" + /// + /// ' Create a new Invoice data object with the Amount, Billing Address etc. details. + /// Dim Inv As Invoice = New Invoice + /// + /// ' Set Amount. + /// Dim Amt As Currency = New Currency(New Decimal(25.12)) + /// Inv.Amt = Amt + /// Inv.PoNum = "PO12345" + /// Inv.InvNum = "INV12345" + /// + /// ' Set the Billing Address details. + /// Dim Bill As BillTo = New BillTo + /// Bill.BillToStreet = "123 Main St." + /// Bill.BillToZip = "12345" + /// Inv.BillTo = Bill + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Payment Transaction. + /// Dim Trans As RecurringPaymentTransaction = New RecurringPaymentTransaction(User, + /// Connection, RecurInfo, Inv, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public class RecurringPaymentTransaction : RecurringTransaction + { + #region "Constructor" + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// RecurringInfo object. + /// Invoice object. + /// Request Id + /// + /// RecurringPaymentTransaction action performs a real-time retry on + /// a transaction that is in the retry state. The response string is similar + /// to the string for Optional transactions, except that, upon approval, + /// the profile is updated to reflect the successful retry. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// RecurInfo.PaymentNum = "01012009"; + /// + /// // Create a new Invoice data object with the Amount, Billing Address etc. details. + /// Invoice Inv = new Invoice(); + /// + /// // Set Amount. + /// Currency Amt = new Currency(new decimal(25.12)); + /// Inv.Amt = Amt; + /// Inv.PoNum = "PO12345"; + /// Inv.InvNum = "INV12345"; + /// + /// // Set the Billing Address details. + /// BillTo Bill = new BillTo(); + /// Bill.BillToStreet = "123 Main St."; + /// Bill.BillToZip = "12345"; + /// Inv.BillTo = Bill; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Payment Transaction. + /// RecurringPaymentTransaction Trans = new RecurringPaymentTransaction( + /// User, Connection, RecurInfo, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// RecurInfo.PaymentNum = "01012009" + /// + /// ' Create a new Invoice data object with the Amount, Billing Address etc. details. + /// Dim Inv As Invoice = New Invoice + /// + /// ' Set Amount. + /// Dim Amt As Currency = New Currency(New Decimal(25.12)) + /// Inv.Amt = Amt + /// Inv.PoNum = "PO12345" + /// Inv.InvNum = "INV12345" + /// + /// ' Set the Billing Address details. + /// Dim Bill As BillTo = New BillTo + /// Bill.BillToStreet = "123 Main St." + /// Bill.BillToZip = "12345" + /// Inv.BillTo = Bill + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Payment Transaction. + /// Dim Trans As RecurringPaymentTransaction = New RecurringPaymentTransaction(User, + /// Connection, RecurInfo, Inv, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringPaymentTransaction( + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + RecurringInfo RecurringInfo, + Invoice Invoice, String RequestId) + : base(PayflowConstants.RECURRING_ACTION_PAYMENT, + RecurringInfo, + UserInfo, PayflowConnectionData, Invoice, RequestId) + { + } + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// RecurringInfo object. + /// Invoice object. + /// Request Id + /// + /// RecurringPaymentTransaction action performs a real-time retry on + /// a transaction that is in the retry state. The response string is similar + /// to the string for Optional transactions, except that, upon approval, + /// the profile is updated to reflect the successful retry. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// RecurInfo.PaymentNum = "01012009"; + /// + /// // Create a new Invoice data object with the Amount, Billing Address etc. details. + /// Invoice Inv = new Invoice(); + /// + /// // Set Amount. + /// Currency Amt = new Currency(new decimal(25.12)); + /// Inv.Amt = Amt; + /// Inv.PoNum = "PO12345"; + /// Inv.InvNum = "INV12345"; + /// + /// // Set the Billing Address details. + /// BillTo Bill = new BillTo(); + /// Bill.BillToStreet = "123 Main St."; + /// Bill.BillToZip = "12345"; + /// Inv.BillTo = Bill; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Payment Transaction. + /// RecurringPaymentTransaction Trans = new RecurringPaymentTransaction( + /// User, RecurInfo, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// RecurInfo.PaymentNum = "01012009" + /// + /// ' Create a new Invoice data object with the Amount, Billing Address etc. details. + /// Dim Inv As Invoice = New Invoice + /// + /// ' Set Amount. + /// Dim Amt As Currency = New Currency(New Decimal(25.12)) + /// Inv.Amt = Amt + /// Inv.PoNum = "PO12345" + /// Inv.InvNum = "INV12345" + /// + /// ' Set the Billing Address details. + /// Dim Bill As BillTo = New BillTo + /// Bill.BillToStreet = "123 Main St." + /// Bill.BillToZip = "12345" + /// Inv.BillTo = Bill + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Payment Transaction. + /// Dim Trans As RecurringPaymentTransaction = New RecurringPaymentTransaction(User, + /// RecurInfo, Inv, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringPaymentTransaction( + UserInfo UserInfo, + RecurringInfo RecurringInfo, + Invoice Invoice, String RequestId) + : this(UserInfo, null, RecurringInfo,Invoice, RequestId) + { + } + + #endregion + + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringReActivateTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringReActivateTransaction.cs new file mode 100644 index 0000000..0a11366 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringReActivateTransaction.cs @@ -0,0 +1,588 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform a recurring transaction with + /// reactivate action. + /// + /// + /// RecurringReactivatetransaction reactivates a profile with inactive STATUS. + /// (Profiles can be deactivated for the following reasons: the term has completed, + /// the profile reached maximum allowable payment failures, or the profile is canceled.) + /// Reactivation gives the option to alter any profile parameter, including an + /// Optional Transaction and a new start date must be specified . + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring ReActivate Transaction. + /// RecurringReActivateTransaction Trans = new RecurringReActivateTransaction( + /// User, Connection, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring ReActivate Transaction. + /// Dim Trans As RecurringReActivateTransaction = New RecurringReActivateTransaction(User, + /// Connection, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public class RecurringReActivateTransaction : RecurringTransaction + { + #region "Constructor" + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// RecurringInfo object. + /// Request Id + /// + /// RecurringReactivatetransaction reactivates a profile with inactive STATUS. + /// (Profiles can be deactivated for the following reasons: the term has completed, + /// the profile reached maximum allowable payment failures, or the profile is canceled.) + /// Reactivation gives the option to alter any profile parameter, including an + /// Optional Transaction and a new start date must be specified . + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring ReActivate Transaction. + /// RecurringReActivateTransaction Trans = new RecurringReActivateTransaction( + /// User, Connection, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring ReActivate Transaction. + /// Dim Trans As RecurringReActivateTransaction = New RecurringReActivateTransaction(User, + /// Connection, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringReActivateTransaction( + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + RecurringInfo RecurringInfo, String RequestId) + : base(PayflowConstants.RECURRING_ACTION_REACTIVATE, + RecurringInfo, + UserInfo, PayflowConnectionData, RequestId) + { + } + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// RecurringInfo object. + /// Request Id + /// + /// RecurringReactivatetransaction reactivates a profile with inactive STATUS. + /// (Profiles can be deactivated for the following reasons: the term has completed, + /// the profile reached maximum allowable payment failures, or the profile is canceled.) + /// Reactivation gives the option to alter any profile parameter, including an + /// Optional Transaction and a new start date must be specified . + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring ReActivate Transaction. + /// RecurringReActivateTransaction Trans = new RecurringReActivateTransaction( + /// User, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring ReActivate Transaction. + /// Dim Trans As RecurringReActivateTransaction = New RecurringReActivateTransaction(User, + /// RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringReActivateTransaction( + UserInfo UserInfo, + RecurringInfo RecurringInfo, String RequestId) + : this(UserInfo, null, RecurringInfo, RequestId) + { + } + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// RecurringInfo object. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + /// + /// RecurringReactivatetransaction reactivates a profile with inactive STATUS. + /// (Profiles can be deactivated for the following reasons: the term has completed, + /// the profile reached maximum allowable payment failures, or the profile is canceled.) + /// Reactivation gives the option to alter any profile parameter, including an + /// Optional Transaction and a new start date must be specified . + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring ReActivate Transaction. + /// RecurringReActivateTransaction Trans = new RecurringReActivateTransaction( + /// User, Connection, Inv, Tender, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring ReActivate Transaction. + /// Dim Trans As RecurringReActivateTransaction = New RecurringReActivateTransaction(User, + /// Connection, Inv, Tender, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringReActivateTransaction( + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + RecurringInfo RecurringInfo, + Invoice Invoice, + BaseTender Tender, String RequestId) + : base(PayflowConstants.RECURRING_ACTION_REACTIVATE, + RecurringInfo, + UserInfo, PayflowConnectionData, + Invoice, + Tender, RequestId) + { + } + + /// + /// Constructor + /// + /// User Info object populated with user credentials. + /// RecurringInfo object. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + /// + /// RecurringReactivatetransaction reactivates a profile with inactive STATUS. + /// (Profiles can be deactivated for the following reasons: the term has completed, + /// the profile reached maximum allowable payment failures, or the profile is canceled.) + /// Reactivation gives the option to alter any profile parameter, including an + /// Optional Transaction and a new start date must be specified . + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// RecurInfo.OrigProfileId = "RT0000001350"; + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring ReActivate Transaction. + /// RecurringReActivateTransaction Trans = new RecurringReActivateTransaction( + /// User, Inv, Tender, RecurInfo, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// RecurInfo.OrigProfileId = "RT0000001350" + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring ReActivate Transaction. + /// Dim Trans As RecurringReActivateTransaction = New RecurringReActivateTransaction(User, + /// Inv, Tender, RecurInfo, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringReActivateTransaction( + UserInfo UserInfo, + RecurringInfo RecurringInfo, + Invoice Invoice, + BaseTender Tender, String RequestId) + : this(UserInfo, null,RecurringInfo, + Invoice, + Tender, RequestId) + { + } + + #endregion + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringTransaction.cs new file mode 100644 index 0000000..74ddf89 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/RecurringTransaction.cs @@ -0,0 +1,975 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; +using PayPal.Payments.Common; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This is the base class of all different recurring action transactions. + /// + /// + /// Each derived class of RecurringTransaction specifies a unique action + /// transaction. This class can also be directly used to perform a recurring + /// transaction. Alternatively, a new class can be extended from this to + /// create a specific recurring action transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Transaction. + /// RecurringTransaction Trans = new RecurringTransaction("A", RecurInfo, + /// User, Connection, Inv, Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Transaction. + /// Dim Trans As RecurringTransaction = New RecurringTransaction("A", RecurInfo, + /// User, Connection, Inv, Tender, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public class RecurringTransaction : PayPal.Payments.Transactions.BaseTransaction + { + #region "Member Variables" + + private String mAction; + + /// + /// Holds the Recurring Info object + /// + private RecurringInfo mRecurringInfo; + + #endregion + + #region "Constructors" + + /// + /// private Constructor. This prevents + /// creation of an empty Transaction object. + /// + private RecurringTransaction() + { + } + + /// + /// Constructor + /// + /// Action, type of recurring transaction + /// Recurring Info object. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Request Id + /// + /// Each derived class of RecurringTransaction specifies a unique action + /// transaction. This class can also be directly used to perform a recurring + /// transaction. Alternatively, a new class can be extended from this to + /// create a specific recurring action transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Transaction. + /// RecurringTransaction Trans = new RecurringTransaction("A", RecurInfo, + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Transaction. + /// Dim Trans As RecurringTransaction = New RecurringTransaction("A", RecurInfo, + /// User, Connection, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringTransaction( + String Action, + RecurringInfo RecurringInfo, + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, String RequestId) + : base(PayflowConstants.TRXTYPE_RECURRING, + UserInfo, PayflowConnectionData, RequestId) + { + if (RecurringInfo != null) + { + mRecurringInfo = RecurringInfo; + mRecurringInfo.Context = base.Context; + } + mAction = Action; + } + + /// + /// Constructor + /// + /// Action, type of recurring transaction + /// Recurring Info object. + /// User Info object populated with user credentials. + /// Request Id + /// + /// Each derived class of RecurringTransaction specifies a unique action + /// transaction. This class can also be directly used to perform a recurring + /// transaction. Alternatively, a new class can be extended from this to + /// create a specific recurring action transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Transaction. + /// RecurringTransaction Trans = new RecurringTransaction("A", RecurInfo, + /// User, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Transaction. + /// Dim Trans As RecurringTransaction = New RecurringTransaction("A", RecurInfo, + /// User, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringTransaction( + String Action, + RecurringInfo RecurringInfo, + UserInfo UserInfo, + String RequestId) + : base(PayflowConstants.TRXTYPE_RECURRING, + UserInfo, RequestId) + { + if (RecurringInfo != null) + { + mRecurringInfo = RecurringInfo; + mRecurringInfo.Context = base.Context; + } + mAction = Action; + } + + + /// + /// Constructor + /// + /// Action, type of recurring transaction + /// Recurring Info object. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice Object + /// Request Id + /// + /// Each derived class of RecurringTransaction specifies a unique action + /// transaction. This class can also be directly used to perform a recurring + /// transaction. Alternatively, a new class can be extended from this to + /// create a specific recurring action transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Transaction. + /// RecurringTransaction Trans = new RecurringTransaction("A", RecurInfo, + /// User, Connection, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Transaction. + /// Dim Trans As RecurringTransaction = New RecurringTransaction("A", RecurInfo, + /// User, Connection, Inv, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringTransaction( + String Action, + RecurringInfo RecurringInfo, + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + Invoice Invoice, String RequestId) + : base(PayflowConstants.TRXTYPE_RECURRING, + UserInfo, PayflowConnectionData, Invoice, RequestId) + { + if (RecurringInfo != null) + { + mRecurringInfo = RecurringInfo; + mRecurringInfo.Context = base.Context; + } + mAction = Action; + } + + /// + /// Constructor + /// + /// Action, type of recurring transaction + /// Recurring Info object. + /// User Info object populated with user credentials. + /// Invoice Object + /// Request Id + /// + /// Each derived class of RecurringTransaction specifies a unique action + /// transaction. This class can also be directly used to perform a recurring + /// transaction. Alternatively, a new class can be extended from this to + /// create a specific recurring action transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Transaction. + /// RecurringTransaction Trans = new RecurringTransaction("A", RecurInfo, + /// User, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Transaction. + /// Dim Trans As RecurringTransaction = New RecurringTransaction("A", RecurInfo, + /// User, Inv, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringTransaction( + String Action, + RecurringInfo RecurringInfo, + UserInfo UserInfo, + Invoice Invoice, String RequestId) + : this(Action, RecurringInfo,UserInfo, null, Invoice, RequestId) + { + } + + /// + /// Constructor + /// + /// Action, type of recurring transaction + /// Recurring Info object. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender + /// Request Id + /// + /// Each derived class of RecurringTransaction specifies a unique action + /// transaction. This class can also be directly used to perform a recurring + /// transaction. Alternatively, a new class can be extended from this to + /// create a specific recurring action transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Transaction. + /// RecurringTransaction Trans = new RecurringTransaction("A", RecurInfo, + /// User, Connection, Inv, Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Transaction. + /// Dim Trans As RecurringTransaction = New RecurringTransaction("A", RecurInfo, + /// User, Connection, Inv, Tender, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringTransaction( + String Action, + RecurringInfo RecurringInfo, + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + Invoice Invoice, + BaseTender Tender, String RequestId) + : base(PayflowConstants.TRXTYPE_RECURRING, + UserInfo, PayflowConnectionData, Invoice, + Tender, RequestId) + { + if (RecurringInfo != null) + { + mRecurringInfo = RecurringInfo; + mRecurringInfo.Context = base.Context; + } + mAction = Action; + } + + /// + /// Constructor + /// + /// Action, type of recurring transaction + /// Recurring Info object. + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender + /// Request Id + /// + /// Each derived class of RecurringTransaction specifies a unique action + /// transaction. This class can also be directly used to perform a recurring + /// transaction. Alternatively, a new class can be extended from this to + /// create a specific recurring action transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// //Set the Recurring related information. + /// RecurringInfo RecurInfo = new RecurringInfo(); + /// // The date that the first payment will be processed. + /// // This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009"; + /// RecurInfo.ProfileName = "PayPal"; + /// // Specifies how often the payment occurs. All PAYPERIOD values must use + /// // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// // QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK"; + /// /////////////////////////////////////////////////////////////////// + /// + /// // Create a new Recurring Transaction. + /// RecurringTransaction Trans = new RecurringTransaction("A", RecurInfo, + /// User, Inv, Tender, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// + /// // Get the Recurring Response parameters. + /// RecurringResponse RecurResponse = Resp.RecurringResponse; + /// if (RecurResponse != null) + /// { + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef); + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// 'Set the Recurring related information. + /// Dim RecurInfo As RecurringInfo = New RecurringInfo + /// ' The date that the first payment will be processed. + /// ' This will be of the format mmddyyyy. + /// RecurInfo.Start = "01012009" + /// RecurInfo.ProfileName = "PayPal" + /// ' Specifies how often the payment occurs. All PAYPERIOD values must use + /// ' capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + /// ' QTER / SMYR / YEAR + /// RecurInfo.PayPeriod = "WEEK" + /// '///////////////////////////////////////////////////////////////// + /// + /// ' Create a new Recurring Transaction. + /// Dim Trans As RecurringTransaction = New RecurringTransaction("A", RecurInfo, + /// User, Inv, Tender, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// + /// ' Get the Recurring Response parameters. + /// Dim RecurResponse As RecurringResponse = Resp.RecurringResponse + /// If Not RecurResponse Is Nothing Then + /// Console.WriteLine("RPREF = " + RecurResponse.RPRef) + /// Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + /// + public RecurringTransaction( + String Action, + RecurringInfo RecurringInfo, + UserInfo UserInfo, + Invoice Invoice, + BaseTender Tender, String RequestId) + : this(Action,RecurringInfo, + UserInfo, null, Invoice, + Tender, RequestId) + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ACTION, mAction)); + if (mRecurringInfo != null) + { + mRecurringInfo.RequestBuffer = RequestBuffer; + mRecurringInfo.GenerateRequest(); + } + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TEx = new TransactionException(Ex); + throw TEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + + #endregion + + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/ReferenceTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/ReferenceTransaction.cs new file mode 100644 index 0000000..a37a71a --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/ReferenceTransaction.cs @@ -0,0 +1,222 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used as base class for all reference transactions. + /// + /// This class can be derived to create a new reference transaction + /// or can be used as is to submit a new type of reference transaction. + /// A reference transaction is a transaction which always takes + /// the PNRef of a previously submitted transaction. + /// + public class ReferenceTransaction : BaseTransaction + { + #region "Member Variables" + + /// + /// Original Transaction Id. Mandatory for any reference transaction. + /// + private String mOrigId; + /// + /// Original PayPal Transaction Id. + /// + private String mOrigPpref; + + #endregion + + #region "Properties" + /// + /// Gets, Sets OrigPpref + /// + /// + /// Maps to Payflow Parameter: + /// ORIGPPREF + /// + public String OrigPpref + { + get { return mOrigPpref;} + set { mOrigPpref = value;} + } + #endregion + + #region "Constructors" + + /// + /// protected Constructor. This prevents + /// creation of an empty Transaction object. + /// + protected ReferenceTransaction() + { + } + + /// + /// Constructor + /// + /// Transaction Type + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Request Id + /// This class can be derived to create a new reference transaction + /// or can be used as is to submit a new type of reference transaction. + /// A reference transaction is a transaction which always takes + /// the PNRef of a previously submitted transaction. + /// + public ReferenceTransaction(String TrxType, + String OrigId, + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + String RequestId) : base(TrxType, UserInfo, PayflowConnectionData, RequestId) + { + mOrigId = OrigId; + } + + /// + /// Constructor + /// + /// Transaction Type + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Request Id + /// This class can be derived to create a new reference transaction + /// or can be used as is to submit a new type of reference transaction. + /// A reference transaction is a transaction which always takes + /// the PNRef of a previously submitted transaction. + /// + public ReferenceTransaction( + String TrxType, + String OrigId, + UserInfo UserInfo, + String RequestId) : base(TrxType, UserInfo, RequestId) + { + mOrigId = OrigId; + } + + + /// + /// Constructor + /// + /// Transaction Type + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Request Id + /// This class can be derived to create a new reference transaction + /// or can be used as is to submit a new type of reference transaction. + /// A reference transaction is a transaction which always takes + /// the PNRef of a previously submitted transaction. + /// + public ReferenceTransaction(String TrxType, + String OrigId, + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + Invoice Invoice, String RequestId) : base(TrxType, UserInfo, PayflowConnectionData, Invoice, RequestId) + { + mOrigId = OrigId; + } + + /// + /// Constructor + /// + /// Transaction Type + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Invoice object. + /// Request Id + /// This class can be derived to create a new reference transaction + /// or can be used as is to submit a new type of reference transaction. + /// A reference transaction is a transaction which always takes + /// the PNRef of a previously submitted transaction. + /// + public ReferenceTransaction(String TrxType, String OrigId, UserInfo UserInfo, Invoice Invoice, String RequestId) : this(TrxType, OrigId, UserInfo, null, Invoice, RequestId) + { + } + + /// + /// Constructor + /// + /// Transaction Type + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object. + /// Request Id + /// This class can be derived to create a new reference transaction + /// or can be used as is to submit a new type of reference transaction. + /// A reference transaction is a transaction which always takes + /// the PNRef of a previously submitted transaction. + /// + public ReferenceTransaction(String TrxType, + String OrigId, + UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, + Invoice Invoice, + BaseTender Tender, String RequestId) : base(TrxType, UserInfo, PayflowConnectionData, Invoice, Tender, RequestId) + { + mOrigId = OrigId; + } + + /// + /// Constructor + /// + /// Transaction Type + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender object. + /// Request Id + /// This class can be derived to create a new reference transaction + /// or can be used as is to submit a new type of reference transaction. + /// A reference transaction is a transaction which always takes + /// the PNRef of a previously submitted transaction. + /// + public ReferenceTransaction(String TrxType, String OrigId, UserInfo UserInfo, Invoice Invoice, BaseTender Tender, String RequestId) : this(TrxType, OrigId, UserInfo, null, Invoice, Tender, RequestId) + { + } + + #endregion + + + + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORIGID, mOrigId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORIGPPREF, mOrigPpref)); + + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TEx = new TransactionException(Ex); + throw TEx; + } + } + + #endregion + + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/SaleTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/SaleTransaction.cs new file mode 100644 index 0000000..451ac89 --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/SaleTransaction.cs @@ -0,0 +1,698 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common.Exceptions; +using PayPal.Payments.Common; + + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to create and perform a + /// Sale Transaction. + /// + /// This example shows how to create and perform a sale transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new Sale Transaction + /// SaleTransaction Trans = new SaleTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Sale Transaction + /// Dim Trans as New SaleTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public sealed class SaleTransaction : BaseTransaction + { + #region "Member Variables" + + /// + /// Original transaction id. + /// The ORIGID is the PNREF no. for a previous transaction. + /// OrigId is used in case Authorization transaction is a Follow-On transaction. + /// + private String mOrigId; + + /// + /// Secure token request. + /// Used to store sensitive data prior to making a call to the hosted page. + /// + private String mCreateSecureToken; + + /// + /// Secure token id. + /// Id used to generate a secure token. Must be sent with the token when calling the hosted pages. + /// This can be any random GUID but must be unique. + /// + private String mSecureTokenId; + + #endregion + + #region "Properties" + + /// + /// Gets, Sets OrigId. This property is used to perform a + /// reference Sale Transaction. + /// + /// A reference Sale transaction is a sale transaction which copies the transaction data, + /// except the Account Number, Expiration Date and Swipe data from a previous transaction. + /// PNRef of this previous transaction needs to be set in this OrigId property. + /// A successful Sale needs to be captured using a capture transaction. + /// This example shows how to create and perform a reference sale transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new Sale Transaction + /// SaleTransaction Trans = new SaleTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// + /// // Set the OrigId to refer to a previous transaction. + /// Trans.OrigId = "V64A0A07BD24"; + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Sale Transaction + /// Dim Trans as New SaleTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId) + /// + /// + /// ' Set the OrigId to refer to a previous transaction. + /// Trans.OrigId = "V64A0A07BD24" + /// + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public String OrigId + { + get { return mOrigId; } + set { mOrigId = value; } + } + + #endregion + + #region "Properties" + + /// Use a secure token to send non-credit card transaction data to the Payflow server for storage in + /// a way that can’t be intercepted and manipulated maliciously.The secure token must be used with the hosted + /// checkout pages. The token is good for a one-time transaction and is valid for 30 minutes. + /// + /// NOTE: Without using a secure token, Payflow Pro merchants can host their own payment page and Payflow Link merchants + /// can use a form post to send transaction data to the hosted checkout pages. However, by not using the secure token, + /// these Payflow gateway users are responsible for the secure handling of data. To obtain a secure token, pass a unique, + /// 36-character token ID and set CREATESECURETOKEN=Y in a request to the Payflow server. The Payflow server associates your + /// ID with a secure token and returns the token as a string of up to 32 alphanumeric characters. To pass the transaction + /// data to the hosted checkout page, you pass the secure token and token ID in an HTTP form post. The token and ID trigger + /// the Payflow server to retrieve your data and display it for buyer approval. + /// + /// See the DOSecureTokenAuth sample for more information. + /// This example shows how to create a SecureToken and SecureTokenId. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// // Since we are using the hosted payment pages, you will not be sending the credit card data with the + /// // Secure Token Request. You just send all other 'sensitive' data within this request and when you + /// // call the hosted payment pages, you'll only need to pass the SECURETOKEN; which is generated and returned + /// // and the SECURETOKENID that was created and used in the request. + /// + /// // Create a new Secure Token Authorization Transaction. Even though this example is performing + /// // an authorization, you can create a secure token using SaleTransction too. Only Authorization and Sale + /// // type transactions are permitted. + /// //Create a new Authorization Transaction. + /// AuthorizationTransaction Trans = new AuthorizationTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// // Set the flag to create a Secure Token. + /// Trans.CreateSecureToken = "Y"; + /// // The Secure Token Id must be a unique id up to 36 characters. Using the RequestID object to generate + /// // a random id, but any means to create an id can be used. + /// Trans.SecureTokenId = PayflowUtility.RequestId; + /// + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("SECURETOKEN = " + TrxnResponse.SecureToken); + /// Console.WriteLine("SECURETOKENID = " + TrxnResponse.SecureTokenId); + /// // If value is true, then the Request ID has not been changed and the original response + /// // of the original transaction is returned. + /// Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null ++ Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// ' Since we are using the hosted payment pages, you will not be sending the credit card data with the + /// ' Secure Token Request. You just send all other 'sensitive' data within this request and when you + /// ' call the hosted payment pages, you'll only need to pass the SECURETOKEN; which is generated and returned + /// ' and the SECURETOKENID that was created and used in the request. + /// + /// ' Create a new Secure Token Authorization Transaction. Even though this example is performing + /// ' an authorization, you can create a secure token using SaleTransction too. Only Authorization and Sale + /// ' type transactions are permitted. + /// 'Create a new Authorization Transaction. + /// Dim Trans as New AuthorizationTransaction(UserInfo, PayflowConnectionData, Invoice, Tender, RequestId) + /// ' See the CreateSecureToken parameter to yes "Y", to flag this transaction request to create a secure token. + /// Trans.CreateSecureToken = "Y" + /// + /// ' The Secure Token Id must be a unique id up to 36 characters. Using the RequestID object to + /// ' generate a random id, but any means to create an id can be used. + /// Trans.SecureTokenId = PayflowUtility.RequestId + /// + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("SECURETOKEN = " + TrxnResponse.SecureToken) + /// Console.WriteLine("SECURETOKENID = " + TrxnResponse.SecureTokenId) + /// ' If value is true, then the Request ID has not been changed and the original response + /// ' of the original transaction is returned. + /// Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + + + /// + /// Gets, Sets CreateSecureToken. This property is used to create a Secure Token. + /// + public String CreateSecureToken + { + get { return mCreateSecureToken; } + set { mCreateSecureToken = value; } + } + + /// + /// Gets, Sets SecureTokenId. This property is used when calling the hosted page. + /// + public String SecureTokenId + { + get { return mSecureTokenId; } + set { mSecureTokenId = value; } + } + + #endregion + + #region "Constructors" + + /// + /// Private Constructor. This prevents + /// creation of an empty Transaction object. + /// + private SaleTransaction() + { + } + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object + /// Request Id + /// This example shows how to create and perform a sale transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// //Create a new Sale Transaction + /// SaleTransaction Trans = new SaleTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Sale Transaction + /// Dim Trans as New SaleTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public SaleTransaction(UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, Invoice Invoice, + //PaymentDevice PaymentDevice , + BaseTender Tender, String RequestId) + : base(PayflowConstants.TRXTYPE_SALE, UserInfo, + PayflowConnectionData, Invoice, + //PaymentDevice , + Tender, RequestId) + { + } + + /// + /// Constructor. + /// + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender object + /// Request Id + /// This example shows how to create and perform a sale transaction. + /// + /// .......... + /// .......... + /// //Populate required data objects. + /// .......... + /// .......... + /// + /// // Create a new Sale Transaction. + /// SaleTransaction Trans = new SaleTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId); + /// //Submit the transaction. + /// Trans.SubmitTransaction(); + /// + /// // Get the Response. + /// Response Resp = Trans.Response; + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + /// } + /// // Get the Fraud Response parameters. + /// FraudResponse FraudResp = Resp.FraudResponse; + /// if (FraudResp != null) + /// { + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + /// } + /// } + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// .......... + /// .......... + /// 'Populate required data objects. + /// .......... + /// .......... + /// + /// 'Create a new Sale Transaction. + /// Dim Trans as New SaleTransaction( + /// UserInfo, + /// PayflowConnectionData, + /// Invoice, + /// Tender, + /// RequestId) + /// ' Submit the transaction. + /// Trans.SubmitTransaction() + /// + /// ' Get the Response. + /// Dim Resp As Response = Trans.Response + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr) + /// Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip) + /// Console.WriteLine("IAVS = " + TrxnResponse.IAVS) + /// End If + /// + /// ' Get the Fraud Response parameters. + /// Dim FraudResp As FraudResponse = Resp.FraudResponse + /// If Not FraudResp Is Nothing Then + /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg) + /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + public SaleTransaction(UserInfo UserInfo, + Invoice Invoice, + BaseTender Tender, String RequestId) + : this(UserInfo, + null, Invoice, + Tender, RequestId) + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_ORIGID, mOrigId)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_CREATESECURETOKEN, mCreateSecureToken)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_SECURETOKENID, mSecureTokenId)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TEx = new TransactionException(Ex); + throw TEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + + } +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/VoiceAuthTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/VoiceAuthTransaction.cs new file mode 100644 index 0000000..746cb9e --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/VoiceAuthTransaction.cs @@ -0,0 +1,428 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Exceptions; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform a voice authorization transaction. + /// + /// + /// Some transactions cannot be authorized over the Internet (for example, high dollar + /// amounts)—processing networks generate Referral (Result Code 13) transactions. + /// In these situations, contact the customer service department of the + /// merchant bank and provide the payment information as requested. + /// If the transaction is approved, the bank provides a voice authorization + /// code (AUTHCODE) for the transaction. This must be included as AUTHCODE + /// as part of a Voice Authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Voice Auth Transaction. + /// VoiceAuthTransaction Trans = new VoiceAuthTransaction("123PNI", + /// User, Connection, Inv, Card, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Voice Auth Transaction. + /// Dim Trans As VoiceAuthTransaction = New VoiceAuthTransaction("123PNI", User, + /// Connection, Inv, Card, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public sealed class VoiceAuthTransaction : BaseTransaction + { + #region "Member variables" + + /// + /// Holds AuthCode, Authorization code obtain via another means; i.e. phone. + /// + private String mAuthCode; + /// + /// Holds AuthDate, Date the AuthCode was obtained. + /// + private String mAuthDate; + + #endregion + + #region "Constructors" + + /// + /// Private Constructor. This prevents creation of an empty Transaction object. + /// + private VoiceAuthTransaction() + { + } + + /// + /// Constructor + /// + /// Authorization code obtain via another means; i.e. phone. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + /// + /// Some transactions cannot be authorized over the Internet (for example, high dollar + /// amounts)—processing networks generate Referral (Result Code 13) transactions. + /// In these situations, contact the customer service department of the + /// merchant bank and provide the payment information as requested. + /// If the transaction is approved, the bank provides a voice authorization + /// code (AUTHCODE) for the transaction. This must be included as AUTHCODE + /// as part of a Voice Authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Voice Authorization Transaction. + /// VoiceAuthTransaction Trans = new VoiceAuthTransaction("123PNI", + /// User, Connection, Inv, Card, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Voice Authorization Transaction. + /// Dim Trans As VoiceAuthTransaction = New VoiceAuthTransaction("123PNI", User, + /// Connection, Inv, Card, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public VoiceAuthTransaction(String AuthCode, UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, Invoice Invoice, + BaseTender Tender, String RequestId) + : base(PayflowConstants.TRXTYPE_VOICEAUTH, UserInfo, + PayflowConnectionData, Invoice, + Tender, RequestId) + { + mAuthCode = AuthCode; + } + + /// + /// Constructor + /// + /// Authorization code obtain via another means; i.e. phone. + /// Date the AuthCode was obtained. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + /// + /// Some transactions cannot be authorized over the Internet (for example, high dollar + /// amounts)—processing networks generate Referral (Result Code 13) transactions. + /// In these situations, contact the customer service department of the + /// merchant bank and provide the payment information as requested. + /// If the transaction is approved, the bank provides a voice authorization + /// code (AUTHCODE) for the transaction. This must be included as AUTHCODE + /// as part of a Voice Authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Voice Authorization Transaction. + /// VoiceAuthTransaction Trans = new VoiceAuthTransaction("123PNI", "08102020", + /// User, Connection, Inv, Card, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Voice Authorization Transaction. + /// Dim Trans As VoiceAuthTransaction = New VoiceAuthTransaction("123PNI", "08102020", + /// User, Connection, Inv, Card, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public VoiceAuthTransaction(String AuthCode, String AuthDate, UserInfo UserInfo, + PayflowConnectionData PayflowConnectionData, Invoice Invoice, + BaseTender Tender, String RequestId) + : base(PayflowConstants.TRXTYPE_VOICEAUTH, UserInfo, + PayflowConnectionData, Invoice, + Tender, RequestId) + { + mAuthCode = AuthCode; + mAuthDate = AuthDate; + } + + /// + /// Constructor + /// + /// Authorization code obtain via another means; i.e. phone. + /// User Info object populated with user credentials. + /// Invoice object. + /// Tender object such as Card Tender. + /// Request Id + /// + /// Some transactions cannot be authorized over the Internet (for example, high dollar + /// amounts)—processing networks generate Referral (Result Code 13) transactions. + /// In these situations, contact the customer service department of the + /// merchant bank and provide the payment information as requested. + /// If the transaction is approved, the bank provides a voice authorization + /// code (AUTHCODE) for the transaction. This must be included as AUTHCODE + /// as part of a Voice Authorization transaction. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Voice Authorization Transaction. + /// VoiceAuthTransaction Trans = new VoiceAuthTransaction("123PNI", + /// User, Inv, Card, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null && Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Voice Auth Transaction. + /// Dim Trans As VoiceAuthTransaction = New VoiceAuthTransaction("123PNI", User, + /// Inv, Card, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public VoiceAuthTransaction(String AuthCode, UserInfo UserInfo, + Invoice Invoice, + BaseTender Tender, String RequestId) + : this(AuthCode,UserInfo, + null, Invoice, + Tender, RequestId) + { + } + + #endregion + + #region "Core functions" + + /// + /// Generates the transaction request. + /// + internal override void GenerateRequest() + { + try + { + base.GenerateRequest(); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_AUTHCODE, mAuthCode)); + RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_AUTHDATE, mAuthDate)); + } + catch (BaseException) + { + throw; + } + catch (Exception Ex) + { + TransactionException TEx = new TransactionException(Ex); + throw TEx; + } + //catch + //{ + // throw new Exception(); + //} + } + + #endregion + + + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayPal/Payments/Transactions/VoidTransaction.cs b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/VoidTransaction.cs new file mode 100644 index 0000000..9300b4c --- /dev/null +++ b/dotNET/PayflowProSDK/PayPal/Payments/Transactions/VoidTransaction.cs @@ -0,0 +1,432 @@ +#region "Imports" + +using System; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Common.Utility; + +#endregion + +namespace PayPal.Payments.Transactions +{ + /// + /// This class is used to perform a void transaction. + /// + /// + /// The Void transaction prevents a transaction from being settled, but does + /// not release the authorization (hold on funds) on the cardholder’s account. + /// Delayed Capture, Sale, Credit, Authorization, and Voice + /// Authorization transactions can be voided. A Void transaction cannot be voided. + /// The Void must occur prior to settlement. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Void Transaction. + /// // The ORIGID is the PNREF no. for a previous transaction. + /// VoidTransaction Trans = new VoidTransaction("V63A0A07BE5A", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null & & Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Void Transaction. + /// ' The ORIGID is the PNREF no. for a previous transaction. + /// Dim Trans As VoidTransaction = New VoidTransaction("V63A0A07BE5A", + /// User, Connection, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public class VoidTransaction : ReferenceTransaction + { + #region "Constructors" + + /// + /// Private Constructor. This prevents + /// creation of an empty Transaction object. + /// + private VoidTransaction() + { + } + + /// + /// Constructor + /// + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Request Id + /// + /// The Void transaction prevents a transaction from being settled, but does + /// not release the authorization (hold on funds) on the cardholder’s account. + /// Delayed Capture, Sale, Credit, Authorization, and Voice + /// Authorization transactions can be voided. A Void transaction cannot be voided. + /// The Void must occur prior to settlement. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Void Transaction. + /// // The ORIGID is the PNREF no. for a previous transaction. + /// VoidTransaction Trans = new VoidTransaction("V63A0A07BE5A", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null & & Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Void Transaction. + /// ' The ORIGID is the PNREF no. for a previous transaction. + /// Dim Trans As VoidTransaction = New VoidTransaction("V63A0A07BE5A", + /// User, Connection, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public VoidTransaction(String OrigId, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, String RequestId) : base(PayflowConstants.TRXTYPE_VOID, OrigId, UserInfo, PayflowConnectionData, RequestId) + { + } + + /// + /// Constructor + /// + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Request Id + /// + /// The Void transaction prevents a transaction from being settled, but does + /// not release the authorization (hold on funds) on the cardholder’s account. + /// Delayed Capture, Sale, Credit, Authorization, and Voice + /// Authorization transactions can be voided. A Void transaction cannot be voided. + /// The Void must occur prior to settlement. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Void Transaction. + /// // The ORIGID is the PNREF no. for a previous transaction. + /// VoidTransaction Trans = new VoidTransaction("V63A0A07BE5A", + /// User, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null & & Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Void Transaction. + /// ' The ORIGID is the PNREF no. for a previous transaction. + /// Dim Trans As VoidTransaction = New VoidTransaction("V63A0A07BE5A", + /// User, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public VoidTransaction(String OrigId, UserInfo UserInfo, String RequestId) : base(PayflowConstants.TRXTYPE_VOID, OrigId, UserInfo, RequestId) + { + } + + /// + /// Constructor + /// + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Connection credentials object. + /// Invoice object. + /// Request Id + /// + /// The Void transaction prevents a transaction from being settled, but does + /// not release the authorization (hold on funds) on the cardholder’s account. + /// Delayed Capture, Sale, Credit, Authorization, and Voice + /// Authorization transactions can be voided. A Void transaction cannot be voided. + /// The Void must occur prior to settlement. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Void Transaction. + /// // The ORIGID is the PNREF no. for a previous transaction. + /// VoidTransaction Trans = new VoidTransaction("V63A0A07BE5A", + /// User, Connection, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null & & Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Void Transaction. + /// ' The ORIGID is the PNREF no. for a previous transaction. + /// Dim Trans As VoidTransaction = New VoidTransaction("V63A0A07BE5A", + /// User, Connection, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public VoidTransaction(String OrigId, UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, Invoice Invoice, String RequestId) : base(PayflowConstants.TRXTYPE_VOID, OrigId, UserInfo, PayflowConnectionData, Invoice, RequestId) + { + } + + /// + /// Constructor + /// + /// Original Transaction Id. + /// User Info object populated with user credentials. + /// Invoice object. + /// Request Id + /// + /// The Void transaction prevents a transaction from being settled, but does + /// not release the authorization (hold on funds) on the cardholder’s account. + /// Delayed Capture, Sale, Credit, Authorization, and Voice + /// Authorization transactions can be voided. A Void transaction cannot be voided. + /// The Void must occur prior to settlement. + /// + /// + /// + /// ............... + /// // Populate data objects + /// ............... + /// + /// // Create a new Void Transaction. + /// // The ORIGID is the PNREF no. for a previous transaction. + /// VoidTransaction Trans = new VoidTransaction("V63A0A07BE5A", + /// User, Connection, Inv, PayflowUtility.RequestId); + /// + /// // Submit the transaction. + /// Response Resp = Trans.SubmitTransaction(); + /// + /// if (Resp != null) + /// { + /// // Get the Transaction Response parameters. + /// TransactionResponse TrxnResponse = Resp.TransactionResponse; + /// if (TrxnResponse != null) + /// { + /// Console.WriteLine("RESULT = " + TrxnResponse.Result); + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + /// } + /// } + /// + /// // Get the Context and check for any contained SDK specific errors. + /// Context Ctx = Resp.TransactionContext; + /// if (Ctx != null & & Ctx.getErrorCount() > 0) + /// { + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); + /// } + /// + /// + /// + /// + /// ............... + /// ' Populate data objects + /// ............... + /// ' Create a new Void Transaction. + /// ' The ORIGID is the PNREF no. for a previous transaction. + /// Dim Trans As VoidTransaction = New VoidTransaction("V63A0A07BE5A", + /// User, Connection, Inv, PayflowUtility.RequestId) + /// + /// ' Submit the transaction. + /// Dim Resp As Response = Trans.SubmitTransaction() + /// + /// If Not Resp Is Nothing Then + /// ' Get the Transaction Response parameters. + /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse + /// If Not TrxnResponse Is Nothing Then + /// Console.WriteLine("RESULT = " + TrxnResponse.Result) + /// Console.WriteLine("PNREF = " + TrxnResponse.Pnref) + /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) + /// End If + /// End If + /// + /// ' Get the Context and check for any contained SDK specific errors. + /// Dim Ctx As Context = Resp.TransactionContext + /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then + /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()) + /// End If + /// + /// + /// + public VoidTransaction(String OrigId, UserInfo UserInfo, Invoice Invoice, String RequestId) : this(OrigId, UserInfo, null, Invoice, RequestId) + { + } + #endregion + } + +} \ No newline at end of file diff --git a/dotNET/PayflowProSDK/PayflowProSDK.csproj b/dotNET/PayflowProSDK/PayflowProSDK.csproj new file mode 100644 index 0000000..5723c83 --- /dev/null +++ b/dotNET/PayflowProSDK/PayflowProSDK.csproj @@ -0,0 +1,11 @@ + + + + netstandard2.0 + + + + + + + diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOAuth.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOAuth.cs new file mode 100644 index 0000000..4bc7c32 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOAuth.cs @@ -0,0 +1,119 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Authorize transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DOAuth + { + public DOAuth() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOAuth.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(10.00)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV123415"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToFirstName = "Sam"; + Bill.BillToLastName = "Smith"; + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0125"); + CC.Cvv2 = "123"; + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + + // Create a new Auth Transaction. + AuthorizationTransaction Trans = new AuthorizationTransaction(User, Connection, Inv, Card, PayflowUtility.RequestId); + // Set the transaction verbosity to HIGH to display most details. + Trans.Verbosity = "HIGH"; + Trans.AddTransHeader("PAYPAL-NVP", "Y"); + + // Set the extended data value. + ExtendData ExtData = new ExtendData("VERSION", "214.0"); + // Add extended data to transaction. + Trans.AddToExtendData(ExtData); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + Console.WriteLine("CVV2MATCH = " + TrxnResponse.CVV2Match); + // If value is true, then the Request ID has not been changed and the original response + // of the original transaction is returned. + Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOCapture.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOCapture.cs new file mode 100644 index 0000000..b4607a7 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOCapture.cs @@ -0,0 +1,104 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Capture transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DOCapture + { + public DOCapture() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOCapture.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + /////////////////////////////////////////////////////////////////// + + // If you want to change the amount being captured, you'll need to set the Amount object. + // Invoice Inv = new Invoice(); + // Set the amount object if you want to change the amount from the original authorization. + // Currency Code USD is US ISO currency code. If no code passed, USD is default. + // See the Developer//s Guide for the list of three-character currency codes available. + // Currency Amt = new Currency(new decimal(25.12)); + // Inv.Amt = Amt; + // CaptureTransaction Trans = new CaptureTransaction("", User, Connection, Inv, PayflowUtility.RequestId); + + // Create a new Capture Transaction for the original amount of the authorization. See above if you + // need to change the amount. + CaptureTransaction Trans = new CaptureTransaction("", User, Connection, PayflowUtility.RequestId); + + // Indicates if this Delayed Capture transaction is the last capture you intend to make. + // The values are: Y (default) / N + // NOTE: If CAPTURECOMPLETE is Y, any remaining amount of the original reauthorized transaction + // is automatically voided. Also, this is only used for UK and US accounts where PayPal is acting + // as your bank. + // Trans.CaptureComplete = "N"; + + // Set the transaction verbosity to HIGH to display most details. + Trans.Verbosity = "HIGH"; + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + // If value is true, then the Request ID has not been changed and the original response + // of the original transction is returned. + Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOCredit.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOCredit.cs new file mode 100644 index 0000000..bbce76d --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOCredit.cs @@ -0,0 +1,108 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple independent Credit transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DOCredit + { + public DOCredit() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOCredit.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0115"); + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + /////////////////////////////////////////////////////////////////// + + // Create a new Credit Transaction. + // Following is an example of a independent credit type of transaction. + CreditTransaction Trans = new CreditTransaction(User, Connection, Inv, Card, + PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + Console.WriteLine("CVV2MATCH = " + TrxnResponse.CVV2Match); + // If value is true, then the Request ID has not been changed and the original response + // of the original transction is returned. + Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOEncryptedSwipe.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOEncryptedSwipe.cs new file mode 100644 index 0000000..90a5e46 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOEncryptedSwipe.cs @@ -0,0 +1,135 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Authorize transaction using Encrypted Swipe Data + /// from card readers by Magtek, http://www.magtek.com. + /// + /// The request is sent as a Data Object and the response received is also a Data Object. + /// Payflow Pro supports card-present transactions (face-to-face purchases). + /// + /// Follow these guidelines to take advantage of the lower card-present transaction rate: + /// + /// * Contact your merchant account provider to ensure that they support card-present transactions. + /// * Contact PayPal Customer Service to request having your account set up properly for accepting and passing + /// swipe data. + /// * If you plan to process card-present as well as card-not-present transactions, set up two separate Payflow + /// Pro accounts. Request that one account be set up for card-present transactions, and use it solely for that + /// purpose. Use the other for card-not-present transactions. Using the wrong account may result in downgrades. + /// * A Sale is the preferred method to use for card-present transactions. Consult with your acquiring bank for + /// recommendations on other methods. + /// + /// NOTE: The SWIPE parameter is not supported on accounts where PayPal is the Processor. This would include Website + /// Payments Pro UK accounts. + /// + /// See the Payflow Gateway Developer Guide and Reference at https://developer.paypal.com/docs/classic/payflow/integration-guide for more information. + /// + public class DOEncryptedSwipe + { + public DOEncryptedSwipe() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOEncryptedSwipe.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(1.00)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + Inv.Comment1 = "Magtek Encrypted Swipe Example"; + + // Create a new Payment Device - Swipe data object. The input parameter is Swipe Data. + // The data passed in this example will be extracted from a Magtek Encrypted Card reader. Please refer + // to the Magtek SDK and documentation on how to obtain the data from the reader. + // The parameter data for the SwipeCard object is usually obtained with a card reader and this shows + // how to send data obtained from a Magtek Encrypted reader. + // NOTE: The SWIPE parameter is not supported on accounts where PayPal is the Processor. + + // Create a new Magtek data object with the device serial number, track data, etc. + MagtekInfo MT = new MagtekInfo(); + + // The data below CANNOT be used for Testing. It is only here to show what the data fields look like once you + // obtain them from the reader itself. Refer to the Payflow Pro Developers Guide and the Appendix related to processing + // with Magtek card readers for more information. + // The Payflow Gateway Developer Guide and Reference found at https://developer.paypal.com/docs/classic/payflow/integration-guide/ + MT.DeviceSN = "B32XXXXXXXXXXAA"; + MT.EncMP = "34F29380E6AFED395472A63063B6XXXXXXXXXXXXXXXXXXXXXXXXXC987D2A1F7A50554DFC4A0D215A8AA0591D82B6DB13516F220C4CB93899"; + MT.EncryptionBlockType = "1"; + MT.EncTrack1 = "80BC13515EF76421FCXXXXXXXXXXXXXXXXXXXXXXXXX02E53C0ECCC83B1787DE05BB5D8C7FA679D0C40CC989F7FAF307FE7FD0B588261DDA0"; + MT.EncTrack2 = "4CDD6BC521B397CD2DB1324199XXXXXXXXXXXXXXXXXXXXXXXXX83A9044B397C1D14AFEE2C0BA1002"; + MT.EncTrack3 = ""; + MT.KSN = "901188XXXXXXXXXX00F4"; + MT.MagtekCardType = "1"; + MT.MPStatus = "61403000"; + MT.RegisteredBy = "PayPal"; + MT.SwipedECRHost = "MAGT"; + + // When using Encrypted Card Readers you do not populate the SwipeCard object as the data from the Magtek object + // will be used instead. + SwipeCard Swipe = new SwipeCard(""); + Swipe.MagtekInfo = MT; + + // Create a new Tender - Swipe Tender data object. + CardTender Card = new CardTender(Swipe); + + // Create a new Sale Transaction using Swipe data. + SaleTransaction Trans = new SaleTransaction(User, Connection, Inv, Card, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + // Magtek Response will only be available if a failure or error in the request. + Console.WriteLine("MAGTRESPONSE = " + TrxnResponse.MagTResponse); + // If value is true, then the Request ID has not been changed and the original response + // of the original transaction is returned. + Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOInquiry.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOInquiry.cs new file mode 100644 index 0000000..867eec4 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOInquiry.cs @@ -0,0 +1,115 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + // + // This class uses the Payflow SDK Data Objects to do an Inquiry transaction. + // + // You perform an inquiry using a reference to an original transaction—either the PNREF + // value returned for the original transaction or the CUSTREF value that you specified for the original + // transaction. + // + // While the amount of information returned in an Inquiry transaction depends upon the VERBOSITY setting, + // Inquiry responses mimic the verbosity level of the original transaction as much as possible. + // + // Transaction results (especially values for declines and error conditions) returned by each PayPal-supported + // processor vary in detail level and in format. The Payflow Pro Verbosity parameter enables you to control + // the kind and level of information you want returned. By default, Verbosity is set to LOW. + // A LOW setting causes PayPal to normalize the transaction result values. Normalizing the values limits + // them to a standardized set of values and simplifies the process of integrating Payflow Pro. + // By setting Verbosity to MEDIUM, you can view the processor?s raw response values. This setting is more + // "verbose" than the LOW setting in that it returns more detailed, processor-specific information. + // + // The request is sent as a Data Object and the response received is also a Data Object. + // + public class DOInquiry + { + public DOInquiry() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOInquiry.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Inquiry Transaction. + //Replace with a previous transaction ID that you processed on your account. + InquiryTransaction Trans = new InquiryTransaction("", User, Connection, PayflowUtility.RequestId); + + // To use CUSTREF or SECURETOKEN instead of PNREF you need to set the CustRef or SecureToken and include the INVOICE object in your + // request. Since you will be using CUSTREF or SECURETOKEN instead of PNREF, PNREF will be "" (null). + // Create a new Invoice data object with the Amount, Billing Address etc. details. + //Invoice Inv = new Invoice(); + //Inv.CustRef = "CUSTREF"; // Can also use Inv.SecureToken + //InquiryTransaction Trans = new InquiryTransaction("", User, Connection, Inv, PayflowUtility.RequestId); + + // Refer to the Payflow Pro Developer's Guide for more information regarding the parameters returned + // when VERBOSITY is set. + Trans.Verbosity = "HIGH"; // Set to HIGH to see all available data available. + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + // Display the transaction response parameters. Refer to the Payflow Pro Developer's Guide for explanations. + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("--------------------------------------------"); + Console.WriteLine("Original Response Data"); + Console.WriteLine("--------------------------------------------"); + Console.WriteLine("RESULT = " + TrxnResponse.OrigResult); + Console.WriteLine("PNREF = " + TrxnResponse.OrigPnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("CVV2MATCH = " + TrxnResponse.CVV2Match); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + Console.WriteLine("HOSTCODE = " + TrxnResponse.HostCode); + Console.WriteLine("RESPTEXT = " + TrxnResponse.RespText); + Console.WriteLine("PROCAVS = " + TrxnResponse.ProcAVS); + Console.WriteLine("PROCCVV2 = " + TrxnResponse.ProcCVV2); + Console.WriteLine("PROCCARDSECURE = " + TrxnResponse.ProcCardSecure); + Console.WriteLine("ADDLMSGS = " + TrxnResponse.AddlMsgs); + Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState); + Console.WriteLine("DATE_TO_SETTLE = " + TrxnResponse.DateToSettle); + Console.WriteLine("BATCHID = " + TrxnResponse.BatchId); + Console.WriteLine("SETTLE_DATE = " + TrxnResponse.SettleDate); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOPartialAuth.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOPartialAuth.cs new file mode 100644 index 0000000..0c857d1 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOPartialAuth.cs @@ -0,0 +1,207 @@ +using System; +using System.Globalization; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Partial Authorize transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + /// Partial Approval is supported for Visa, MasterCard, American Express and Discover (JCB + /// (US Domestic only), and Diners) Prepaid card products such as gift, Flexible Spending Account + /// (FSA) or Healthcare Reimbursement Account (HRA) cards. In addition Discover (JCB (US Domestic only), + /// and Diners) supports partial Approval on their consumer credit card. It is often difficult for the + /// consumer to spend the exact amount available on the prepaid account, as the purchase can be for + /// amounts greater than the value available. This can result in unnecessary declines. Visa, MasterCard, + /// American Express and Discover (JCB (US Domestic only), and Diners) recognize that the prepaid products + /// represent unique opportunities for both merchants and consumers. With Partial Approval issuers may + /// approve a portion of the amount requested. This will enable the residual transaction amount to be + /// paid by other means. The introduction of the partial approval capability will reduce decline frequency + /// and enhance the consumer and merchant experience at the point of sale. Merchants will now have the + /// ability to accept partial approval rather than having the sale declined. + /// + public class DOPartialAuth + { + public DOPartialAuth() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOPartialAuth.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Refer to the DOSaleComplete.cs sample for a more detailed explaination of fields. + // + //Create the Data Objects. + // Creates a CultureInfo for English in the U.S. + // Not necessary, just here for example of using currency formatting. + CultureInfo us = new CultureInfo("en-US"); + String usCurrency = "USD"; + + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set the amount and currency being used. + // See the Developer's Guide for the list of the three-digit currency codes. + // Refer to the Payflow Pro Developer's Guide on testing parameters for Partial Authorization. + // In this example, sending $120.00 will generate a partial approval of only $100.00. + + Currency Amt = new Currency(new decimal(120.00), usCurrency); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToFirstName = "Sam"; + Bill.BillToLastName = "Smith"; + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0115"); + CC.Cvv2 = "123"; + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + + // Create a new Auth Transaction. + AuthorizationTransaction Trans = new AuthorizationTransaction(User, Connection, Inv, Card, PayflowUtility.RequestId); + + // Set the flag to request that Partial Authorizations be accepted. + Trans.PartialAuth = "Y"; + + // You must set the transaction verbosity to HIGH to display the appropriate response. + Trans.Verbosity = "HIGH"; + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + // Refer to the Payflow Pro .NET API Reference Guide and the Payflow Pro Developer's Guide + // for explanation of the items returned and for additional information and parameters available. + if (TrxnResponse != null) + { + Console.WriteLine("Transaction Response:"); + Console.WriteLine("Result Code (RESULT) = " + TrxnResponse.Result); + Console.WriteLine("Transaction ID (PNREF) = " + TrxnResponse.Pnref); + // If the amount is partially authorized the RESPMSG will be "Partial Approval". + // If the amount is fully authorized the RESPMSG will be "Approved". + Console.WriteLine("Response Message (RESPMSG) = " + TrxnResponse.RespMsg); + Console.WriteLine("Authorization (AUTHCODE) = " + TrxnResponse.AuthCode); + Console.WriteLine("Street Address Match (AVSADDR) = " + TrxnResponse.AVSAddr); + Console.WriteLine("Streep Zip Match (AVSZIP) = " + TrxnResponse.AVSZip); + Console.WriteLine("International Card (IAVS) = " + TrxnResponse.IAVS); + Console.WriteLine("CVV2 Match (CVV2MATCH) = " + TrxnResponse.CVV2Match); + Console.WriteLine("------------------------------------------------------"); + // These are all new items returned when VERBOSITY=HIGH. + Console.WriteLine("Credit Card Information:"); + Console.WriteLine("Last 4-digits Credit Card Number (ACCT) = " + TrxnResponse.Acct); + if (TrxnResponse.CardType != null) + { + Console.Write("Card Type (CARDTYPE) = "); + switch (TrxnResponse.CardType) + { + case "0": + Console.WriteLine("Visa"); + break; + case "1": + Console.WriteLine("MasterCard"); + break; + case "2": + Console.WriteLine("Discover"); + break; + case "3": + Console.WriteLine("American Express"); + break; + case "4": + Console.WriteLine("Diner's Club"); + break; + case "5": + Console.WriteLine("JCB"); + break; + case "6": + Console.WriteLine("Maestro"); + break; + default: + Console.WriteLine("Unknown: " + TrxnResponse.CardType); // new or unknown card type + break; + } + } + Console.WriteLine("Expiration Date (EXPDATE) = " + TrxnResponse.ExpDate); + Console.WriteLine("Billing Name (FIRSTNAME, LASTNAME) = " + TrxnResponse.FirstName + " " + TrxnResponse.LastName); + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Verbosity Response:"); + Console.WriteLine("Processor AVS (PROCAVS) = " + TrxnResponse.ProcAVS); + Console.WriteLine("Processor CSC (PROCCVV2) = " + TrxnResponse.ProcCVV2); + Console.WriteLine("Processor Result (HOSTCODE) = " + TrxnResponse.HostCode); + Console.WriteLine("Transaction Date/Time (TRANSTIME) = " + TrxnResponse.TransTime); + + // For Partial Authorization you will need to check the following 3 items to see if the card was + // fully authorized or partially authorized. + // + // For example, if you send in a request of $120.00 (AMT=120.00) and the card only has $100.00 of available credit on it, + // the card will be authorized for $100.00, the AMT field will be changed from 120 to 100 (AMT=100.00 to reflect this. + // The balance of $20.00 which is still due will be returned in the BALAMT (BALAMT=-20.00) field and the ORIGAMT field + // will contain the original requested amount (ORIGAMT=120.00). + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Partial Payment Response:"); + Console.WriteLine("Original Amount (ORIGAMT) = " + TrxnResponse.OrigAmt); + Console.WriteLine("Amount of Transaction (AMT) = " + TrxnResponse.Amt); + if (Convert.ToDecimal(TrxnResponse.BalAmt)== 0 & (Convert.ToDecimal(TrxnResponse.OrigAmt) > Convert.ToDecimal(TrxnResponse.Amt))) + { + decimal BalDue = Convert.ToDecimal(TrxnResponse.OrigAmt) - Convert.ToDecimal(TrxnResponse.Amt); + if (BalDue > 0) + { + // Seems a balance is still due, collect the difference. + Console.WriteLine("Please provide additional payment of: " + BalDue.ToString("c", us)); + } + else if (BalDue == 0) + { + Console.WriteLine("Transaction is Paid in Full."); + } + else + { + // Card still has available balance on it. + Console.WriteLine("Balance Amount (BALAMT) = " + TrxnResponse.BalAmt); + } + } + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOReferenceCredit.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOReferenceCredit.cs new file mode 100644 index 0000000..765bf27 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOReferenceCredit.cs @@ -0,0 +1,100 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple reference Credit transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DOReferenceCredit + { + public DOReferenceCredit() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOReferenceCredit.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + /////////////////////////////////////////////////////////////////// + + // If you want to change the amount being credited, you'll need to set the Amount object. + //Invoice Inv = new Invoice(); + // Set the amount object if you want to change the amount from the original transaction. + // Currency Code USD is US ISO currency code. If no code passed, USD is default. + // See the Developer's Guide for the list of three-character currency codes available. + //Currency Amt = new Currency(new decimal(10.00)); + //Inv.Amt = Amt; + //CreditTransaction trans = new CreditTransaction("", User, Connection, Inv, PayflowUtility.getRequestId()); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Create a new Credit Transaction from the original transaction. See above if you + // need to change the amount. + CreditTransaction Trans = new CreditTransaction("", User, Connection, Inv, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSale.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSale.cs new file mode 100644 index 0000000..fe89c45 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSale.cs @@ -0,0 +1,109 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Sale transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DOSale + { + public DOSale() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOSale.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the app.config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0125"); + CC.Cvv2 = "023"; + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + /////////////////////////////////////////////////////////////////// + + // Create a new Sale Transaction. + SaleTransaction Trans = new SaleTransaction( + User, Connection, Inv, Card, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + Console.WriteLine("CVV2MATCH = " + TrxnResponse.CVV2Match); + // If value is true, then the Request ID has not been changed and the original response + // of the original transaction is returned. + Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSaleComplete.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSaleComplete.cs new file mode 100644 index 0000000..2ea439c --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSaleComplete.cs @@ -0,0 +1,715 @@ +using System; +using System.Globalization; +using System.Net; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; +using System.Threading; + + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow .NET SDK Data Objects to do a Sale transaction including some business rules. + /// This class depicts the use of the Data Objects which would normally be used in a transaction. + /// + public class DOSaleCompleteCS + { + public DOSaleCompleteCS() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOSaleComplete.cs"); + Console.WriteLine("------------------------------------------------------"); + + // + // PLEASE READ ALL COMMENTS BELOW: + // All information regarding the available objects within payflow_dotNET.dll can be found in the API doc + // found under the "Docs" directory of the installed SDK. You will also need to refer to the + // Payflow Gateway Developer Guide and Reference found at + // https://developer.paypal.com/docs/classic/payflow/integration-guide/ + // + // Regarding the Request ID: + // + // The request Id is a unique id that you send with your transaction data. This Id if not changed + // will help prevent duplicate transactions. The idea is to set this Id outside the loop or if on a page, + // prior to the final confirmation page. + // + // Once the transaction is sent and if you don't receive a response you can resend the transaction and the + // server will respond with the response data of the original submission. Also, the object, + // Trans.Response.TransactionResponse.Duplicate will be set to "1" if the transaction is a duplicate. + // + // This allows you to resend transaction requests should there be a network or user issue without re-charging + // a customers credit card. + // + // COMMON ISSUES: + // + // Result Code 1: + // Is usually caused by one of the following: + // ** Invalid login information, see result code 26 below. + // ** IP Restrictions on the account. Verify there are no IP restrictions in Manager under Service Settings. + // + // Result Code 26: + // Verify USER, VENDOR, PARTNER and PASSWORD. Remember, USER and VENDOR are both the merchant login + // ID unless a Payflow Pro USER was created. All fields are case-sensitive. + // + // Receiving Communication Exceptions or No Response: + // Since this service is based on HTTPS it is possible that due to network issues either on PayPal's side or + // yours that you can not process a transaction. If this is the case, what is suggested is that you put some + // type of loop in your code to try up to X times before "giving up". This example will try to get a response + // up to 3 times before it fails and by using the Request ID as described above, you can do these attempts without + // the chance of causing duplicate charges on your customer's credit card. + // + // END COMMENTS + + // Begin Application + // + // Set the Request ID + // Uncomment the line below and run two concurrent transactions to show how duplicate works. You will notice on + // the second transaction that the response returned is identical to the first, but the duplicate object will be set. + // String strRequestID = "123456"; + // Comment out this line if testing duplicate response. + String RequestID = PayflowUtility.RequestId; + + // *** Create the Data Objects. *** + // + // *** Create the User data object with the required user details. *** + // + // Should you choose to store the login information (Vendor, User, Partner and Password) in + // app.config, you can retrieve the data using PayflowUtility.AppSettings. + // + // For Example: + // + // App.Config Entry: + // + // String mUser = PayflowUtility.AppSettings("PayflowUser"); + // String mVendor = PayflowUtility.AppSettings("PayflowVendor"); + // String mPartner = PayflowUtility.AppSettings("PayflowPartner"); + // String mPassword = PayflowUtility.AppSettings("PayflowPassword"); + // + // UserInfo User = new UserInfo (mUser, mVendor, mPartner, mPassword); + + // Remember: = your merchant (login id), = unless you created a separate for Payflow Pro. + // Result code 26 will be issued if you do not provide both the and fields. + + // The other most common error with authentication is result code 1, user authentication failed. This is usually + // due to invalid account information or IP restriction on the account. You can verify IP restriction by logging + // into Manager. + UserInfo User = new UserInfo("", "", "", ""); + + // *** Create the Payflow Connection data object with the required connection details. *** + // + // To allow the ability to change easily between the live and test servers, the PFPRO_HOST + // property is defined in the App.config (or web.config for a web site) file. However, + // you can also pass these fields and others directly from the PayflowConnectionData constructor. + // This will override the values passed in the App.config file. + // + // For Example: + // + // Example values passed below are as follows: + // Payflow Pro Host address : pilot-payflowpro.paypal.com + // Payflow Pro Host Port : 443 + // Timeout : 45 ( in seconds ) + // + // PayflowConnectionData Connection = new PayflowConnectionData("pilot-payflowpro.paypal.com", 443, 45, "",0,"",""); + // + // Obtain Host address from the app.config file and use default values for + // timeout and proxy settings. + + PayflowConnectionData Connection = new PayflowConnectionData(); + + // *** Create a new Invoice data object *** + // Set Invoice object with the Amount, Billing & Shipping Address, etc. *** + + Invoice Inv = new Invoice(); + + // Creates a CultureInfo for English in the U.S. + // Not necessary, just here for example of using currency formatting. + //CultureInfo us = new CultureInfo("en-US"); + //String usCurrency = "USD"; + + // Set the amount object. For Partial Authorizations, refer to the DoPartialAuth example. + // Currency Code 840 (USD) is US ISO currency code. If no code passed, 840 is default. + // See the Developer's Guide for the list of the three-digit currency codes. + //Currency Amt = new Currency(new decimal(0.00), usCurrency); + Currency Amt = new Currency(new decimal(25.00), "USD"); + + // A valid amount has either no decimal value or only a two decimal value. + // An invalid amount will generate a result code 4. + // + // For values which have more than two decimal places such as: + // Currency Amt = new Currency(new Decimal(25.1214)); + // You will either need to truncate or round as needed using the following property: Amt.NoOfDecimalDigits + // + // If the NoOfDecimalDigits property is used then it is mandatory to set one of the following + // properties to true. + // + //Amt.Round = true; + //Amt.Truncate = true; + // + // For Currencies without a decimal, you'll need to set the NoOfDecimalDigits = 0. + //Amt.NoOfDecimalDigits = 0; + Inv.Amt = Amt; + + Currency TaxAmt = new Currency(new decimal(0.00), "USD"); + Inv.TaxAmt = TaxAmt; + + // PONum, InvNum and CustRef are sent to the processors and could show up on a customers + // or your bank statement. These fields are reportable but not searchable in PayPal Manager. + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + Inv.CustRef = "CustRef1"; + + // Merchant information is detailed data about a merchant such as the merchant's name, business address, business location identifier, + // and contact information and is used to change the merchant's information on a customer's credit card. + // See the section, "Submitting Soft Merchant Information" in the Payflow Pro Developer's Guide for more information. + //MerchantInfo Merchant = new MerchantInfo(); + //Merchant.MerchantName = "MerchantXXXXX"; + //Merchant.MerchantCity = "Somewhere"; + //Inv.MerchantInfo = Merchant; + Inv.VatTaxAmt = new Currency(new decimal(25.00), "USD"); + + // Comment1 and Comment2 fields are search-able within PayPal Manager . + // You may want to populate these fields with any of the above three fields or any other data. + // However, the search is a case-sensitive and is a non-wild card search, so plan accordingly. + + Inv.Comment1 = "Comment1"; + Inv.Comment2 = "Comment2"; + + // There are additional Invoice parameters that could assist you in obtaining a better rate + // from your merchant bank. Refer to the Payflow Pro Developer’s Guide1 + // and consult your Internet Merchant Bank on what parameters (if any) you can use. + // Some of the parameters could include: + // Inv.Recurring = "Y"; + // Inv.TaxExempt = "Y"; + + + // *** Create Level 2/3 Data for Purchase Card *** + // PayPal Payment Services supports passing Purchasing Card Level 2 information (such as + // purchase order number, tax amount, and charge description) in the settlement file. + // If additional required invoice information and line item details are included in the transaction, + // PayPal formats Purchasing Card Level 3 information in an appropriate format, for example, + // EDI (Electronic Data Interchange) 810 format as required by American Express during + // settlement processing. + // + // Discuss with your merchant acquiring bank to determine if you should be passing this data and + // refer to the Payflow Gateway Developer's Guide under your processor for all valid and required + // parameters. + // + //Create a line item. + //LineItem Item = new LineItem(); + //Add info to line item. + //Item.Amt = new Currency(new Decimal(100.00)); + //Item.Cost = new Currency(new Decimal(49.99)); + //Add line item to invoice. + //Inv.AddLineItem(Item); + // To add additional line items, just repeat the same statements above changing the values. + + // *** Set the Billing Address details. *** + // + // The billing details below except for Street and Zip are for reporting purposes only. + // It is suggested that you pass all the billing details for enhanced reporting and as data backup. + + // Create the BillTo object. + BillTo Bill = new BillTo(); + // Set the customer name. + Bill.BillToFirstName = "Joe"; + Bill.BillToMiddleName = "M"; + Bill.BillToLastName = "Smith"; + Bill.BillToCompanyName = "Joe's Hardware"; + // It is highly suggested that you pass at minimum Street and Zip for AVS response. + // However, AVS is only supported by US banks and some foreign banks. See the Payflow + // Developer's Guide for more information. Sending these fields could help in obtaining + // a lower discount rate from your Internet merchant Bank. Consult your bank for more information. + Bill.BillToStreet = "123 Main St."; + Bill.BillToStreet2 = "Suite A"; + Bill.BillToCity = "San Jose"; + Bill.BillToState = "CA"; + Bill.BillToZip = "12345"; + // BillToCountry code is based on numeric ISO country codes. (e.g. 840 = USA) + // For more information, refer to the Payflow Developer's Guide. + Bill.BillToCountry = "840"; + Bill.BillToPhone = "555-243-7689"; + // Secondary phone numbers (could be mobile number etc). + Bill.BillToPhone2 = "222-222-2222"; + Bill.BillToHomePhone = "555-123-9867"; + Bill.BillToFax = "555-343-5444"; + Bill.BillToEmail = "Joe.Smith@anyemail.com"; + + // Set the BillTo object into invoice. + Inv.BillTo = Bill; + + // Shipping details may not be necessary if providing a service or downloadable product such as software etc. + // + // Set the Shipping Address details. + // The shipping details are for reporting purposes only. + // It is suggested that you pass all the shipping details for enhanced reporting. + // + // Create the ShipTo object. + ShipTo Ship = new ShipTo(); + + // To prevent an 'Address Mismatch' fraud trigger, we are shipping to the billing address. However, + // shipping parameters are listed. + // Comment line below if you want a separate Ship To address. + //Ship = Bill.Copy(); + + // Uncomment statements below to send to separate Ship To address. + // Set the recipient's name. + // Ship.ShipToFirstName = "Sam"; + // Ship.ShipToMiddleName = "J"; + // Ship.ShipToLastName = "Spade"; + // Ship.ShipToStreet = "456 Shipping St."; + // Ship.ShipToStreet2 = "Apt A"; + // Ship.ShipToCity = "Las Vegas"; + // Ship.ShipToState = "NV"; + // Ship.ShipToZip = "99999"; + // ShipToCountry code is based on numeric ISO country codes. (e.g. 840 = USA) + // For more information, refer to the Payflow Pro Developer's Guide. + // Ship.ShipToCountry = "840"; + // Ship.ShipToPhone = "555-123-1233"; + // Secondary phone numbers (could be mobile number etc). + // Ship.ShipToPhone2 = "555-333-1222"; + // Ship.ShipToEmail = "Sam.Spade@email.com"; + // Ship.ShipFromZip = Bill.BillToZip; + // Following 2 items are just for reporting purposes and are not required. + // Ship.ShipCarrier = "UPS"; + // Ship.ShipMethod = "Ground"; + //Inv.ShipTo = Ship; + + // ECHODATA allows you to trigger data sent in the request to be returned in the request. + // "ADDRESS" will return both shipping and billing address data, if sent. + // "USER" will return User Information, set below. + // "CUSTDATA" returns miscellaneous fields. Refer to the developer guide. + //Inv.EchoData = "USER"; + + // *** Create Customer Data *** + // There are additional CustomerInfo parameters that are used for Level 2 Purchase Cards. + // Refer to the Payflow Pro Developer’s Guide and consult with your Internet + // Merchant Bank regarding what parameters to send. + // Some of the parameters could include: + // + //CustomerInfo CustInfo = new CustomerInfo(); + //CustInfo.CustCode = "CustCode123"; // Customer Code + //CustInfo.CustId = "CustId123"; + //CustInfo.CustIP = "255.255.255.255"; // Customer's IP Address + //Inv.CustomerInfo = CustInfo; + + // *** Send User fields *** + // You can send up to ten string type parameters to store temporary data (for example, variables, + // session IDs, order numbers, and so on). These fields will be echoed back either via API response + // or as part of the Silent / Return post if using the hosted checkout page. + // + // Note: UserItem1 through UserItem10 are not displayed to the customer and are not stored in + // the PayPal transaction database. + // + // For these fields to echoed back in the response, you need to set the ECHODATA object. + //UserItem nUser = new UserItem(); + //nUser.UserItem1 = "TUSER1"; + //nUser.UserItem2 = "TUSER2"; + //Inv.UserItem = nUser; + + // *** Create Soft Descriptor Data *** + // There are additional MerchantInfo parameters that are used for Level 2 Purchase Cards + // to change the Merchant Name and other information that is shown on a card holders statement. + // Refer to the Payflow Gateway Developer's Guide for more information. + // + //MerchantInfo MerchInfo = new MerchantInfo(); + //MerchInfo.MerchantName = "My Company Name"; + //MerchInfo.MerchantCity = "My Company City"; + //Inv.MerchantInfo = MerchInfo; + + // *** Create a new Payment Device - Credit Card data object. *** + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + // Note: Expiration date is in the format MMYY. + CreditCard CC = new CreditCard("4111111111111111", "0125"); + + // Example of Swipe Transaction. + // See DOSwipe.cs example for more information. + //SwipeCard Swipe = new SwipeCard(";5105105105105100=15121011000012345678?"); + + // *** Card Security Code *** + // This is the 3 or 4 digit code on either side of the Credit Card. + // It is highly suggested that you obtain and pass this information to help prevent fraud. + // Sending this fields could help in obtaining a lower discount rate from your Internet merchant Bank. + // CVV2 is not required when performing a Swipe transaction as the card is present. + CC.Cvv2 = "123"; + // Name on Credit Card is optional and not used as part of the authorization. + // Also, this field populates the NAME field which is the same as FIRSTNAME, so if you + // are already populating first name, do not use this field. + //CC.Name = "Joe Smith"; + + // Card on File: Stored Credential + // A stored credential is information, including, but not limited to, an account number or a payment token. + // It is stored by a merchant, its agent, a payment facilitator or a staged digital wallet operator to process future transactions for a cardholder. + // Refer to the Payflow Gateway Developer Guide for more information. + // + // Example: + // CITI (CIT Initial) - Signifies that the merchant is storing the cardholder credentials for the first time in anticipation of future + // stored credential transactions. Example: A cardholder sets up a customer profile for future purchases. + //CC.CardonFile = "CITI"; + + // *** Create a new Tender - Card Tender data object. *** + CardTender Card = new CardTender(CC); // credit card + // If you are doing card-present (retail)type transactions you will want to use the swipe object. Before doing so, verify with + // your merchant bank that you are setup to process card-present transactions and contact Payflow support to request your account + // be setup to process these types of transactions. You will need to request your market seqment be changed from e-commerce (default) + // to retail. + //CardTender Card = new CardTender(Swipe); + + // *** Create a new Sale Transaction. *** + // The Request Id is the unique id necessary for each transaction. If you are performing an authorization + // - delayed capture transaction, make sure that you pass two different unique request ids for each of the + // transaction. + // If you pass a non-unique request id, you will receive the transaction details from the original request. + // The only difference is you will also receive a parameter DUPLICATE indicating this request id has been used + // before. + // The Request Id can be any unique number such order id, invoice number from your implementation or a random + // id can be generated using the PayflowUtility.RequestId. + SaleTransaction Trans = new SaleTransaction(User, Connection, Inv, Card, RequestID); + + // Used to store client information; such as your cart name, version, etc. Only informational. + //ClientInfo cInfo = new ClientInfo(); + //cInfo.IntegrationProduct = "Shopping Cart"; + //cInfo.IntegrationVersion = "1.0"; + //Trans.ClientInfo = cInfo; + + // Transaction results (especially values for declines and error conditions) returned by each PayPal-supported + // processor vary in detail level and in format. The Payflow Verbosity parameter enables you to control the kind + // and level of information you want returned. + // + // By default, Verbosity is set to LOW. A LOW setting causes PayPal to normalize the transaction result values. + // Normalizing the values limits them to a standardized set of values and simplifies the process of integrating + // the Payflow SDK. + // + // By setting Verbosity to HIGH, you can view the processor's raw response values along with card information. This + // setting is more verbose than the LOW or MEDIUM setting in that it returns more detailed, processor and card specific + // information. + // + // Review the chapter in the Payflow Pro Developer's Guide regarding VERBOSITY and the INQUIRY function for more details. + + // Set the transaction verbosity to HIGH to display most details. + Trans.Verbosity = "HIGH"; + + // Try to submit the transaction up to 3 times with 5 second delay. This can be used + // in case of network issues. The idea here is since you are posting via HTTPS behind the scenes there + // could be general network issues, so try a few times before you tell customer there is an issue. + int trxCount = 1; + bool RespRecd = false; + while (trxCount <= 3 && !RespRecd) + { + // Notice we set the request id earlier in the application and outside our loop. This way if a response was not received + // but PayPal processed the original request, you'll receive the original response with DUPLICATE set. + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Uncomment line below to simulate "No Response" + //Resp = null; + + // Display the transaction response parameters. + if (Resp != null) + { + RespRecd = true; // Got a response. + + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + // Refer to the Payflow Pro .NET API Reference Guide and the Payflow Pro Developer's Guide + // for explanation of the items returned and for additional information and parameters available. + if (TrxnResponse != null) + { + Console.WriteLine("Transaction Response:"); + Console.WriteLine("Result Code (RESULT) = " + TrxnResponse.Result); + Console.WriteLine("Transaction ID (PNREF) = " + TrxnResponse.Pnref); + Console.WriteLine("Response Message (RESPMSG) = " + TrxnResponse.RespMsg); + Console.WriteLine("Authorization (AUTHCODE) = " + TrxnResponse.AuthCode); + Console.WriteLine("Street Address Match (AVSADDR) = " + TrxnResponse.AVSAddr); + Console.WriteLine("Street Zip Match (AVSZIP) = " + TrxnResponse.AVSZip); + Console.WriteLine("International Card (IAVS) = " + TrxnResponse.IAVS); + Console.WriteLine("CVV2 Match (CVV2MATCH) = " + TrxnResponse.CVV2Match); + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Credit Card Information:"); + Console.WriteLine("Last 4-digits Credit Card Number (ACCT) = " + TrxnResponse.Acct); + if (TrxnResponse.CardType != null) + { + Console.Write("Card Type (CARDTYPE) = "); + switch (TrxnResponse.CardType) + { + case "0": + Console.WriteLine("Visa"); + break; + case "1": + Console.WriteLine("MasterCard"); + break; + case "2": + Console.WriteLine("Discover"); + break; + case "3": + Console.WriteLine("American Express"); + break; + case "4": + Console.WriteLine("Diner's Club"); + break; + case "5": + Console.WriteLine("JCB"); + break; + case "6": + Console.WriteLine("Maestro"); + break; + case "S": + Console.WriteLine("Solo"); + break; + } + } + Console.WriteLine("Billing Name (FIRSTNAME, LASTNAME) = " + TrxnResponse.FirstName + " " + TrxnResponse.LastName); + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Verbosity Response:"); + // Displays amount formatted as currency for the CurrentCulture. + // Due to operating system differences, you cannot be sure what currency + // symbol will be used. + //Console.WriteLine("Amount of Transaction (AMT) = " + Convert.ToDecimal(TrxnResponse.Amt).ToString("c", us)); + Console.WriteLine("Amount of Transaction (AMT) = " + TrxnResponse.Amt); + Console.WriteLine("Processor AVS (PROCAVS) = " + TrxnResponse.ProcAVS); + Console.WriteLine("Processor CSC (PROCCVV2) = " + TrxnResponse.ProcCVV2); + Console.WriteLine("Processor Result (HOSTCODE) = " + TrxnResponse.HostCode); + Console.WriteLine("Transaction Date/Time (TRANSTIME) = " + TrxnResponse.TransTime); + Console.WriteLine("Expiration Date (EXPDATE) = " + TrxnResponse.ExpDate); + if (TrxnResponse.TxId != null) + { + // If card is flagged as Card on file (Stored Credential) a transaction ID will be returned that is used on future reference/recurring transactions. + Console.WriteLine("Transaction ID (TXID) = " + TrxnResponse.TxId); + } + } + + // Get the Fraud Response parameters. + // All trial accounts come with basic Fraud Protection Services enabled. + // Review the PayPal Manager guide to set up your Fraud Filters prior to + // running this sample code. + // If Fraud Filters are not set, you will receive a RESULT code 126. + FraudResponse FraudResp = Resp.FraudResponse; + if (FraudResp != null) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Fraud Response:"); + Console.WriteLine("Pre-Filters (PREFPSMSG) = " + FraudResp.PreFpsMsg); + Console.WriteLine("Post-Filters (POSTFPSMSG) = " + FraudResp.PostFpsMsg); + } + + // The details below describe what you'd see in the raw response which can be seen in the log file. + // + // Was this a duplicate transaction, i.e. the request ID was NOT changed. + // Remember, a duplicate response will return the results of the original transaction which + // could be misleading if you are debugging your software. + // For Example, let's say you got a result code 4, Invalid Amount from the original request because + // you were sending an amount like: 1,050.98. Since the comma is invalid, you'd receive result code 4. + // RESULT=4&PNREF=V18A0C24920E&RESPMSG=Invalid amount&PREFPSMSG=No Rules Triggered + // Now, let's say you modified your code to fix this issue and ran another transaction but did not change + // the request ID. Notice the PNREF below is the same as above, but DUPLICATE=1 is now appended. + // RESULT=4&PNREF=V18A0C24920E&RESPMSG=Invalid amount&DUPLICATE=1 + // This would tell you that you are receiving the results from a previous transaction. This goes for + // all transactions even a Sale transaction. In this example, let's say a customer ordered something and got + // a valid response and now a different customer with different credit card information orders something, but again + // the request ID is NOT changed, notice the results of these two sales. In this case, you would have not received + // funds for the second order. + // First order: RESULT=0&PNREF=V79A0BC5E9CC&RESPMSG=Approved&AUTHCODE=166PNI&AVSADDR=X&AVSZIP=X&CVV2MATCH=Y&IAVS=X + // Second order: RESULT=0&PNREF=V79A0BC5E9CC&RESPMSG=Approved&AUTHCODE=166PNI&AVSADDR=X&AVSZIP=X&CVV2MATCH=Y&IAVS=X&DUPLICATE=1 + // Again, notice the PNREF is from the first transaction, this goes for all the other fields as well. + // It is suggested that your use this to your benefit to prevent duplicate transaction from the same customer, but you want + // to check for DUPLICATE=1 to ensure it is not the same results as a previous one. + // + // Since we are using objects instead of the raw name-value-pairs, you'd check the Duplicate parameter of the TrxnResponse object. + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Duplicate Response:"); + string DupMsg; + if (TrxnResponse.Duplicate == "1") + { + DupMsg = "Duplicate Transaction"; + } + else + { + DupMsg = "Not a Duplicate Transaction"; + } + Console.WriteLine(("Duplicate Transaction (DUPLICATE) = " + DupMsg)); + + // Part of accepting credit cards or PayPal is to determine what your business rules are. Basically, what risk are you + // willing to take, especially with credit cards. The code below gives you an idea of how to check the results returned + // so you can determine how to handle the transaction. + // + // This is not an exhaustive list of failures or issues that could arise. Review the list of Result Code's in the + // Developer Guide and add logic as you deem necessary. + // These responses are just an example of what you can do and how you handle the response received + // from the bank/PayPal is dependent on your own business rules and needs. + + string RespMsg; + // Evaluate Result Code + if (TrxnResponse.Result < 0) + { + // Transaction failed. + RespMsg = "There was an error processing your transaction. Please contact Customer Service." + + Environment.NewLine + "Error: " + TrxnResponse.Result.ToString(); + } + else if (TrxnResponse.Result == 1 || TrxnResponse.Result == 26) + { + // This is just checking for invalid login credentials. You normally would not display this type of message. + // Result code 26 will be issued if you do not provide both the and fields. + // Remember: = your merchant (login id), = unless you created a seperate for Payflow Pro. + // + // The other most common error with authentication is result code 1, user authentication failed. This is usually + // due to invalid account information or ip restriction on the account. You can verify ip restriction by logging + // into Manager. See Service Settings >> Allowed IP Addresses. Lastly it could be you forgot the path "/transaction" + // on the URL. + RespMsg = "Account configuration issue. Please verify your login credentials."; + } + else if (TrxnResponse.Result == 0) + { + // Example of a message you might want to display with an approved transaction. + RespMsg = "Your transaction was approved. Will ship in 24 hours."; + + // Even though the transaction was approved, you still might want to check for AVS or CVV2(CSC) prior to + // accepting the order. Do realize that credit cards are approved (charged) regardless of the AVS/CVV2 results. + // Should you decline (void) the transaction, the card will still have a temporary charge (approval) on it. + // + // Check AVS - Street/Zip + // In the message below it shows what failed, ie street, zip or cvv2. To prevent fraud, it is suggested + // you only give a generic billing error message and not tell the card-holder what is actually wrong. However, + // that decision is yours. + // + // Also, it is totally up to you on if you accept only "Y" or allow "N" or "X". You need to decide what + // business logic and liability you want to accept with cards that either don't pass the check or where + // the bank does not participate or return a result. Remember, AVS is mostly used in the US but some foreign + // banks do participate. + // + // Remember, this just an example of what you might want to do. + if (TrxnResponse.AVSAddr != "Y") + { + // Display message that transaction was not accepted. At this time, you + // could display message that information is incorrect and redirect user + // to re-enter STREET and ZIP information. However, there should be some sort of + // 3 strikes your out check. + RespMsg = "Your billing (street) information does not match. Please re-enter."; + // Here you might want to put in code to flag or void the transaction depending on your needs. + } + if (TrxnResponse.AVSZip != "Y") + { + // Display message that transaction was not accepted. At this time, you + // could display message that information is incorrect and redirect user + // to re-enter STREET and ZIP information. However, there should be some sort of + // 3 strikes your out check. + RespMsg = "Your billing (zip) information does not match. Please re-enter."; + // Here you might want to put in code to flag or void the transaction depending on your needs. + } + if (TrxnResponse.CVV2Match != "Y") + { + // Display message that transaction was not accepted. At this time, you + // could display message that information is incorrect. Normally, to prevent + // fraud you would not want to tell a customer that the 3/4 digit number on + // the credit card was invalid. + RespMsg = "Your billing (cvv2) information does not match. Please re-enter."; + // Here you might want to put in code to flag or void the transaction depending on your needs. + } + } + else if (TrxnResponse.Result == 12) + { + // Hard decline from bank. Customer will need to use another card or payment type. + RespMsg = "Your transaction was declined."; + } + else if (TrxnResponse.Result == 13) + { + // Voice authorization required. You would need to contact your merchant bank to obtain a voice authorization. If authorization is + // given, you can manually enter it via Virtual Terminal in PayPal Manager or via the VoiceAuthTransaction object. + RespMsg = "Your Transaction is pending. Contact Customer Service to complete your order."; + } + else if (TrxnResponse.Result == 23 || TrxnResponse.Result == 24) + { + // Issue with credit card number or expiration date. + RespMsg = "Invalid credit card information. Please re-enter."; + } + else if (TrxnResponse.Result == 125) + { + // Using the Fraud Protection Service. + // This portion of code would be is you are using the Fraud Protection Service, this is for US merchants only. + // 125, 126 and 127 are Fraud Responses. + // Refer to the Payflow Pro Fraud Protection Services User's Guide or Website Payments Pro Payflow Edition - Fraud Protection Services User's Guide. + RespMsg = "Your Transactions has been declined. Contact Customer Service."; + } + else if (TrxnResponse.Result == 126) + { + // One of more filters were triggered. Here you would check the fraud message returned if you + // want to validate data. For example, you might have 3 filters set, but you'll allow 2 out of the + // 3 to consider this a valid transaction. You would then send the request to the server to modify the + // status of the transaction. Performing this function is outside the scope of this sample, refer + // to the Fraud Developer's Guide. + // + // Decline transaction if AVS fails. + if (TrxnResponse.AVSAddr != "Y" || TrxnResponse.AVSZip != "Y") + { + // Display message that transaction was not accepted. At this time, you + // could display message that information is incorrect and redirect user + // to re-enter STREET and ZIP information. However, there should be some sort of + // strikes your out check. + RespMsg = "Your billing information does not match. Please re-enter."; + } + else + { + RespMsg = "Your Transaction is Under Review. We will notify you via e-mail if accepted."; + } + RespMsg = "Your Transaction is Under Review. We will notify you via e-mail if accepted."; + } + else if (TrxnResponse.Result == 127) + { + // There is an issue with checking this transaction through the fraud service. + // You will need to manually approve. + RespMsg = "Your Transaction is Under Review. We will notify you via e-mail if accepted."; + } + else + { + // Error occurred, display normalized message returned. + RespMsg = TrxnResponse.RespMsg; + } + + // Display Message + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("User/System Response:"); + Console.WriteLine("User Message (RESPMSG) = " + RespMsg); + Console.WriteLine("System Message (TRXNRESPONSE.RESPMSG) = " + TrxnResponse.RespMsg); + + // Display the status response of the transaction. + // This is just additional information and normally would not be used in production. + // Your business logic should be built around the result code returned as shown above. + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Overall Transaction Status: " + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + // This is not normally used in production. + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Transaction Context Errors: " + TransCtx.ToString()); + } + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + else + { + Thread.Sleep(5000); // let's wait 5 seconds to see if this is a temporary network issue. + Console.WriteLine("Retry #: " + trxCount.ToString()); + trxCount++; + } + } + if (!RespRecd) + { + Console.WriteLine("There is a problem obtaining an authorization for your order."); + Console.WriteLine("Please contact Customer Support."); + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSecureTokenAuth.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSecureTokenAuth.cs new file mode 100644 index 0000000..2a4a6fb --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSecureTokenAuth.cs @@ -0,0 +1,104 @@ +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do create a Secure Token used with the + /// hosted checkout page. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DOSecureTokenAuth + { + public DOSecureTokenAuth() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOSecureTokenAuth.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. The amount cannot be changed once submitted. + Currency Amt = new Currency(new decimal(10.00), "USD"); + Inv.Amt = Amt; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. You can also send the shipping information. Both the Billing + // and Shipping information can be changed if the functionality is allowed in the Configuration section + // of Manager. No other information submitted using a secure token call can be changed. + BillTo Bill = new BillTo(); + Bill.BillToFirstName = "Sam"; + Bill.BillToLastName = "Smith"; + Bill.BillToStreet = "123 Main St."; + Bill.BillToCity = "Any Town"; + Bill.BillToState = "CA"; + Bill.BillToZip = "12345"; + Bill.BillToPhone = "408-123-1234"; + Bill.BillToEmail = "test@myemail.com"; + Bill.BillToCountry = "840"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + //CreditCard CC = new CreditCard("5105105105105100", "0110"); + //CC.Cvv2 = "023"; + + // Create a new Tender - Card Tender data object. + //CardTender Card = new CardTender(CC); + /////////////////////////////////////////////////////////////////// + + // Since we are using the hosted payment pages, you will not be sending the credit card data with the + // Secure Token Request. You just send all other 'sensitive' data within this request and when you + // call the hosted payment pages, you'll only need to pass the SECURETOKEN; which is generated and returned + // and the SECURETOKENID that was created and used in the request. + // + // Create a new Secure Token Authorization Transaction. Even though this example is performing + // an authorization, you can create a secure token using SaleTransaction too. Only Authorization and Sale + // type transactions are permitted. + // + // Remember, all data submitted as part of the Secure Token call cannot be modified at a later time. The only exception + // is the billing and shipping information if these items are selection in the Setup section in PayPal Manager. + AuthorizationTransaction Trans = new AuthorizationTransaction(User, Connection, Inv, null, PayflowUtility.RequestId); + + // Set VERBOSITY to High + Trans.Verbosity = "High"; + + // Set the flag to create a Secure Token. + Trans.CreateSecureToken = "Y"; + + // The Secure Token Id must be a unique id up to 36 characters. Using the RequestID object to + // generate a random id, but any means to create an id can be used. + Trans.SecureTokenId = PayflowUtility.RequestId; + + // Set the extended data value. + //ExtendData ExtData = new ExtendData("SILENTTRAN", "True"); + // Add extended data to transaction. + //Trans.AddToExtendData(ExtData); + + // IMPORTANT NOTE: + // + // Remember, the Secure Token can only be used once. Once it is redeemed by a valid transaction it cannot be used again and you will + // need to generate a new token. Also, the token has a life time of 30 minutes. + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + Console.WriteLine(DateTime.Now.ToString("hh:mm:ss tt") + " : " + Trans.Response.ResponseString); + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSwipe.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSwipe.cs new file mode 100644 index 0000000..a3ce8de --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOSwipe.cs @@ -0,0 +1,108 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Authorize transaction using Swipe Data. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// Payflow Pro supports card-present transactions (face-to-face purchases). + /// + /// Follow these guidelines to take advantage of the lower card-present transaction rate: + /// + /// * Contact your merchant account provider to ensure that they support card-present transactions. + /// * Contact PayPal Customer Service to request having your account set up properly for accepting and passing + /// swipe data. + /// * If you plan to process card-present as well as card-not-present transactions, set up two separate Payflow + /// Pro accounts. Request that one account be set up for card-present transactions, and use it solely for that + /// purpose. Use the other for card-not-present transactions. Using the wrong account may result in downgrades. + /// * A Sale is the preferred method to use for card-present transactions. Consult with your acquiring bank for + /// recommendations on other methods. + /// + /// NOTE: The SWIPE parameter is not supported on accounts where PayPal is the Processor. This would include Website + /// Payments Pro UK accounts. + /// + /// See the Payflow Pro Developer's Guide or Websites Payments Pro Payflow Edition Guide for more information. + /// + public class DOSwipe + { + public DOSwipe() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOSwipe.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.25)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + Inv.Comment1 = "Swipe Example"; + + // Create a new Payment Device - Swipe data object. The input parameter is Swipe Data. + // Used to pass the Track 1 or Track 2 data (the card’s magnetic stripe information) for card-present + // transactions. Include either Track 1 or Track 2 data—not both. If Track 1 is physically damaged, + // the POS application can send Track 2 data instead. + + // The parameter data for the SwipeCard object is usually obtained with a card reader. + // NOTE: The SWIPE parameter is not supported on accounts where PayPal is the Processor. + SwipeCard Swipe = new SwipeCard(";5105105105105100=20121011000012345678?"); + // Create a new Tender - Swipe Tender data object. + CardTender Card = new CardTender(Swipe); + + // Create a new Sale Transaction using Swipe data. + SaleTransaction Trans = new SaleTransaction(User, Connection, Inv, Card, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + // If value is true, then the Request ID has not been changed and the original response + // of the original transction is returned. + Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOVoiceAuth.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOVoiceAuth.cs new file mode 100644 index 0000000..2eb10b4 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOVoiceAuth.cs @@ -0,0 +1,99 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Voice Authorization transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DOVoiceAuth + { + public DOVoiceAuth() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOVoiceAuth.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0115"); + CC.Cvv2 = "123"; + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + /////////////////////////////////////////////////////////////////// + + // Create a new Voice Authorization Transaction. + // Some processors also require an authorization date to be sent. + VoiceAuthTransaction Trans = new VoiceAuthTransaction("", + User, Connection, Inv, Card, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + Console.WriteLine("CVV2MATCH = " + TrxnResponse.CVV2Match); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOVoid.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOVoid.cs new file mode 100644 index 0000000..f0ecc50 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/DOVoid.cs @@ -0,0 +1,83 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Void transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DOVoid + { + public DOVoid() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOVoid.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + /////////////////////////////////////////////////////////////////// + + // Create a new Void Transaction. + // The ORIGID is the PNREF no. for a previous transaction. + VoidTransaction Trans = new VoidTransaction("", + User, Connection, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/Reporting.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/Reporting.cs new file mode 100644 index 0000000..870aa55 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/BasicTransactions/Reporting.cs @@ -0,0 +1,72 @@ +using System; +using System.Net; +using System.Xml; +using System.Text; +using System.Collections; +using System.IO; + +namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions +{ + /// + /// The Reporting Service is an XML based service that you can use to automate your report queries. + /// It allows you to programmatically query in XML the Reporting database to generate a varity of + /// reports for your business. + /// + /// PayPal Manager is also a client of the Reporting Service. Everything that Manager can do with + /// reports is available to you. You can, for example, request a particular report be run within a + /// specified date range. The response returns all the data that the report generates. + /// + /// The reporting service encapsulates the information in all the Payflow services reports. You can + /// store this information in your local database and use it as needed. + /// + /// To use this service you will be + /// + public class Reporting + { + //public Reporting() + //{ + //} + + //public static void Main(string[] Args) + //{ + // string requestURL = "https://payments-reports.paypal.com/reportingengine"; + // HttpWebRequest request = HttpWebRequest.Create(requestURL) as HttpWebRequest; + // XmlDocument xml = new XmlDocument(); + // xml.LoadXml("report.xml"); // returns xml as string as shown in earlier post + // byte[] reqBytes = UTF8Encoding.UTF8.GetBytes(xml.InnerXml); + // request.ContentLength = reqBytes.Length; + // request.Method = "POST"; + // request.ContentType = "text/plain"; // changing this to text/xml returns "Bad content-type: text/xml" + + // Stream requestStream = request.GetRequestStream(); + // requestStream.Write(reqBytes, 0, reqBytes.Length); + + // try + // { + // HttpWebResponse response = request.GetResponse() as HttpWebResponse; + + // Console.WriteLine("########## Response ####################"); + + // byte[] respBytes = readServiceResponse(response); + // String strResp = UTF8Encoding.UTF8.GetString(respBytes); + // XmlDocument responseXML = new System.Xml.XmlDocument(); + // responseXML.LoadXml(strResp); + // Console.WriteLine(responseXML.InnerXml); + // Console.In.Read(); + // } + // catch (Exception ex) + // { + // Console.WriteLine("Error: SubmitRequest"); + // Console.WriteLine(ex.Message); + + // if (null != ex.InnerException) + // { + // Console.WriteLine(ex.InnerException.Message); + // } + + // Console.In.Read(); + // } + + //} + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DODoEC.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DODoEC.cs new file mode 100644 index 0000000..bc89741 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DODoEC.cs @@ -0,0 +1,157 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.ExpressCheckout +{ + /// + /// This class uses the Payflow SDK Data Objects to do a normal DO Express Checkout transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + /// This sample is for reference and for testing purposes only. See the eStoreFront sample for + /// one way to perform an Express Checkout transaction from your web site. + /// + /// Refer to the "PayPal Express Checkout Transaction Processing" chapter of the Payflow Pro Developer's + /// Guide (US, AU) or the Websites Payments Pro Payflow Edition Developer's Guide (UK). + /// + /// Besides doing a standard Express Checkout transactions, you can also do a Express Checkout Reference + /// Transaction. + /// + /// A reference transaction takes existing billing information already gathered from a previously + /// authorized transaction and reuses it to charge the customer in a subsequent transaction. + /// Reference transactions, typically used for repeat billing to a merchants PayPal account when + /// customers are not present to log in, are now supported through Express Checkout. + /// + /// NOTE: You must be enabled by PayPal to use reference transactions. Contact your account manager + /// or the sales department for more details. + /// + /// See the DOSetEC Sample for more details on Reference Transations using Express Checkout. + /// + public class DODoEC + { + public DODoEC() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DODoEC.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Once the customer has reviewed the shipping details and decides to continue + // checkout by clicking on "Continue Checkout" button, it's time to actually + // authorize the transaction. + // This is the third step in PayPal Express Checkout, in which you need to perform a + // DO operation to authorize the purchase amount. + // + // For more information on Reference Transactions, see the DOSetEC Sample for more details. + + // For Regular Express Checkout or Express Checkout Reference Transaction with Purchase. + ECDoRequest DoRequest = new ECDoRequest("", ""); + + // For Express Checkout Reference Transaction without Purchase. + //ECDoBARequest DoRequest = new ECDoBARequest("", ""); + + // Performing a Reference Transaction, Credit Transaction, Do Authorization or a Reauthorization + // These transactions do not require a token or payerid. Additional fields + // are set using the ExtendData, ECDoRequest or AuthorizationTransaction objects, see below. + //ECDoRequest DoRequest = new ECDoRequest("", ""); + + // Perform a Do Reauthorization + // To reauthorize an Authorization for an additional three-day honor period, you can use a Do + // Reauthorization transaction. A Do Reauthorization can be used at most once during the 29-day + // authorization period. + // To set up a Do Reauthorization, you must pass ORIGID in the AuthorizationTransaction object + // and set DoReauthorization to 1. + //DoRequest.DoReauthorization("1"); + + // Populate Invoice object. + Invoice Inv = new Invoice(); + Inv.Amt = new Currency(new decimal(21.98), "USD"); + Inv.Comment1 = "Testing Express Checkout"; + + // **** PayPal Pay Later Service **** + // See DoSetEC.vb for information on PayPal's Pay Later Service. + + // Create the Tender object. + PayPalTender Tender = new PayPalTender(DoRequest); + + // Create the transaction object. + AuthorizationTransaction Trans = new AuthorizationTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); + + // Doing a credit? + //CreditTransaction Trans = new CreditTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); + + // Using a Reference Transaction + // To be able to "charge" a customer using their Billing Agreement you will need to pass the BAID + // and other parameters via the ExtendData Object. + //ExtendData BAId = new ExtendData("BAID", ""); + //Trans.AddToExtendData(BAId); + //ExtendData CaptureComplete = new ExtendData("CAPTURECOMPLETE", "NO"); + //Trans.AddToExtendData(CaptureComplete); + //ExtendData MaxAmt = new ExtendData("MAXAMT", "15.00"); + //Trans.AddToExtendData(MaxAmt); + + // Perform a Do Authorization or Do Reauthorization + // You must pass ORIGID using the PNREF of the original order transaction. + //Trans.OrigId(""); + + // Submit the transaction. + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("PPREF = " + TrxnResponse.PPref); + Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); + Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); + Console.WriteLine("PAYERID = " + Trans.Response.ExpressCheckoutGetResponse.PayerId); + Console.WriteLine("PAYMENTTYPE = " + Trans.Response.TransactionResponse.PaymentType); + Console.WriteLine("PENDINGREASON = " + Trans.Response.TransactionResponse.PendingReason); + + // BAID is returned with Express Checkout Reference Transaction with and without Purchase. + // See the notes in DOSetEC regarding this feature. + if (Trans.Response.ExpressCheckoutDoResponse.BAId != null) + { + Console.WriteLine(Environment.NewLine + "BAID = " + Trans.Response.ExpressCheckoutDoResponse.BAId); + } + + // If value is true, then the Request ID has not been changed and the original response + // of the original transction is returned. + Console.WriteLine(Environment.NewLine + "DUPLICATE = " + TrxnResponse.Duplicate); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DOGetEC.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DOGetEC.cs new file mode 100644 index 0000000..a2d053a --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DOGetEC.cs @@ -0,0 +1,145 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.ExpressCheckout +{ + /// + /// This class uses the Payflow SDK Data Objects to do a normal GET Express Checkout transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + /// This sample is for reference and for testing purposes only. See the eStoreFront sample for + /// one way to perform an Express Checkout transaction from your web site. + /// + /// Refer to the "PayPal Express Checkout Transaction Processing" chapter of the Payflow Pro Developer's + /// Guide (US, AU) or the Websites Payments Pro Payflow Edition Developer's Guide (UK). + /// + /// Besides doing a standard Express Checkout transactions, you can also do a Express Checkout Reference + /// Transaction. + /// + /// A reference transaction takes existing billing information already gathered from a previously + /// authorized transaction and reuses it to charge the customer in a subsequent transaction. + /// Reference transactions, typically used for repeat billing to a merchants PayPal account when + /// customers are not present to log in, are now supported through Express Checkout. + /// + /// NOTE: You must be enabled by PayPal to use reference transactions. Contact your account manager + /// or the sales department for more details. + /// + /// See the DOSetEC Sample for more details on Reference Transations using Express Checkout. + /// + public class DOGetEC + { + public DOGetEC() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOGetEC.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Calling a GET operation is second step in PayPal Express checkout process. Once the + // customner has logged into his/her paypal account, selected shipping address and clicked on + // "Continue checkout", the PayPal server will redirect the page to the ReturnUrl you have + // specified in the previous SET request. To obtain the shipping details chosen by the + // Customer, you will then need to do a GET operation. + // + // For more information on Reference Transactions, see the DOSetEC Sample for more details. + + // For Regular Express Checkout or Express Checkout Reference Transaction with Purchase. + ECGetRequest GetRequest = new ECGetRequest(""); + + // For Express Checkout Reference Transaction without Purchase. + //ECGetBARequest GetRequest = new ECGetBARequest(""); + + // Create the Tender. + PayPalTender Tender = new PayPalTender(GetRequest); + + // Create a transaction. + AuthorizationTransaction Trans = new AuthorizationTransaction + (User, Connection, null, Tender, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString()); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + // The TOKEN is needed for the DODoEC Sample. + Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); + Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); + Console.WriteLine("EMAIL = " + Trans.Response.ExpressCheckoutGetResponse.EMail); + // The PAYERID is needed for the DODoEC Sample. + Console.WriteLine("PAYERID = " + Trans.Response.ExpressCheckoutGetResponse.PayerId); + Console.WriteLine("PAYERSTATUS = " + Trans.Response.ExpressCheckoutGetResponse.PayerStatus); + // Express Checkout Transactions and Express Checkout Reference Transactions with Purchase + // begin with EC, while Express Checkout Reference Transactions without Purchase begin with BA. + // Reference Transactions without Purchase do not return shipping information. + if (Trans.Response.ExpressCheckoutSetResponse.Token != null) + { + if (Trans.Response.ExpressCheckoutSetResponse.Token.StartsWith("EC")) + { + Console.WriteLine(Environment.NewLine + "Shipping Information:"); + Console.WriteLine("FIRST = " + Trans.Response.ExpressCheckoutGetResponse.FirstName); + Console.WriteLine("LAST = " + Trans.Response.ExpressCheckoutGetResponse.LastName); + Console.WriteLine("SHIPTOSREET = " + Trans.Response.ExpressCheckoutGetResponse.ShipToStreet); + Console.WriteLine("SHIPTOSTREET2 = " + Trans.Response.ExpressCheckoutGetResponse.ShipToStreet2); + Console.WriteLine("SHIPTOCITY = " + Trans.Response.ExpressCheckoutGetResponse.ShipToCity); + Console.WriteLine("SHIPTOSTATE = " + Trans.Response.ExpressCheckoutGetResponse.ShipToState); + Console.WriteLine("SHIPTOZIP = " + Trans.Response.ExpressCheckoutGetResponse.ShipToZip); + Console.WriteLine("SHIPTOCOUNTRY = " + Trans.Response.ExpressCheckoutGetResponse.ShipToCountry); + Console.WriteLine("AVSADDR = " + Trans.Response.TransactionResponse.AVSAddr); + } + // BA_Flag is returned with Express Checkout Reference Transaction with Purchase. + // See the notes in DOSetEC regarding this feature. + if (Trans.Response.ExpressCheckoutGetResponse.BA_Flag != null) + { + Console.WriteLine(Environment.NewLine + "BA_FLAG = " + Trans.Response.ExpressCheckoutGetResponse.BA_Flag); + if (Trans.Response.ExpressCheckoutGetResponse.BA_Flag == "1") + { + Console.WriteLine("Buyer Agreement was created."); + } + else + { + Console.WriteLine("Buyer Agreement not was accepted."); + } + } + } + + // If value is true, then the Request ID has not been changed and the original response + // of the original transction is returned. + Console.WriteLine(Environment.NewLine + "DUPLICATE = " + TrxnResponse.Duplicate); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DOSetEC.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DOSetEC.cs new file mode 100644 index 0000000..6773ac1 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DOSetEC.cs @@ -0,0 +1,250 @@ +using System; +using System.Diagnostics; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.ExpressCheckout +{ + /// + /// This class uses the Payflow SDK Data Objects to do a normal SET Express Checkout transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + /// Express Checkout offers your customers an easy, convenient checkout experience. It lets them + /// use shipping and billing information stored securely at PayPal to check out, so they don’t have + /// to re-enter it on your site. + /// + /// From the perspective of website development, Express Checkout works like other Payflow Pro + /// features. You submit transaction information to the server as name-value pair parameter + /// strings or using Data Objects as this example. + /// + /// Refer to the "PayPal Express Checkout Transaction Processing" chapter of the Payflow Pro Developer's + /// Guide (US, AU) or the Websites Payments Pro Payflow Edition Developer's Guide (UK). + /// + /// This sample is for reference and for testing purposes only. See the eStoreFront sample for + /// one way to perform an Express Checkout transaction from your web site. The eStoreFront sample does + /// not include reference transactions. + /// + /// Besides doing a standard Express Checkout transactions, you can also do a Express Checkout Reference + /// Transaction. + /// + /// A reference transaction takes existing billing information already gathered from a previously + /// authorized transaction and reuses it to charge the customer in a subsequent transaction. + /// Reference transactions, typically used for repeat billing to a merchants PayPal account when + /// customers are not present to log in, are now supported through Express Checkout. + /// + /// NOTE: You must be enabled by PayPal to use reference transactions. Contact your account manager + /// or the sales department for more details. + /// + /// To implement a reference transaction, you must first obtain a billing agreement from the + /// customer. The customer logs into PayPal once to consent to the billing agreement, after which + /// customer login is not required. The customer’s consent allows PayPal to withdraw funds from + /// the customer’s PayPal account. + /// + /// The billing agreement is good until canceled by you or the customer. A customer may have + /// more than one billing agreement for your website. This can occur if the customer establishes + /// separate agreements for different kinds of service. If you use reference transactions, be sure + /// that they are associated with the correct billing agreement. + /// + /// When you implement reference transactions on your website, the customer can choose to + /// accept or reject the billing agreement with or without making a purchase. + /// + public class DOSetEC + { + public DOSetEC() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOSetEC.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // See the DoSaleComplete sample for more information on setting the Connection object. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create the invoice object and set the amount value. + Invoice Inv = new Invoice(); + Inv.Amt = new Currency(new decimal(21.98), "USD"); + Inv.OrderDesc = "This is my Order Description"; + + // **** PayPal Pay Later Service **** + // PayPal Pay Later is a new, convenient, and secure service that allows you to offer your + // customers promotional financing. Buyers that choose the promotional offer can defer + // payments for purchases on participating merchant web sites, allowing them to shop now and + // pay later. + // The PayPal Pay Later service allows online merchants to offer promotional financing to + // buyers at checkout - even if a buyer doesn't have a PayPal account. Promotional offers, such as + // no payments for 90 days, give merchants new and powerful ways to market to online + // shoppers. + // The PayPal Pay Later service is issued by GE Money Bank, one of the world's leading + // providers of consumer credit. + // **** Signing Up for PayPal Pay Later **** + // PayPal's new promotional financing is currently available to consumers and select merchants + // in the U.S. If you are a merchant and would like to add this service, please contact your sales + // representative for information and additional documentation. + // + //PayLater setPayLater = new PayLater(); + //setPayLater.ShippingMethod = "UPSGround"; + //setPayLater.ProductCategory = "E"; // Camera and Photos + //setPayLater.PayPalCheckoutBtnType = "P"; + // You can combine up to 10 promotions for PayPal Promotional Financing. + // L_PROMOCODE0 + //PayLaterLineItem setPayLaterLineItem = new PayLaterLineItem(); + //setPayLaterLineItem.PromoCode = "101"; + //setPayLater.PayLaterAddLineItem(setPayLaterLineItem); + // L_PROMOCODE1 + //PayLaterLineItem setPayLaterLineItem1 = new PayLaterLineItem(); + //setPayLaterLineItem1.PromoCode = "102"; + //setPayLater.PayLaterAddLineItem(setPayLaterLineItem1); + + // **** Performing a Standard Transaction using Express Checkout **** + // + // Express Checkout offers your customers an easy, convenient checkout experience. It lets them + // use shipping and billing information stored securely at PayPal to check out, so they don’t have + // to re-enter it on your site. + // + // From the perspective of website development, Express Checkout works like other Payflow Pro + // features. You submit transaction information to the server as name-value pair parameter + // strings. + // + // Create the data object for Express Checkout SET operation using ECSetRequest Data Object. + ECSetRequest SetRequest = new ECSetRequest("http://www.myreturnurl.com", "http://www.mycancelurl.com"); + + // If using Pay Later, you would create the data object as below. + //ECSetRequest setRequest = new ECSetRequest("http://www.myreturnurl.com", "http://www.mycancelurl.com", setPayLater); + + // **** Performing a Reference Transaction using Express Checkout **** + // + // NOTE: You must be enabled by PayPal to use reference transactions. Contact your account manager + // or the sales department for more details. + // + // See the "Using Reference Transactions with Express Checkout" guide that is supplied to you + // once your account is active with the feature. + + // *** With Making a Purchase *** + // Say that you have implemented Express Checkout on your website. The customer logs in to + // purchase an item of merchandise and chooses PayPal to pay for it. In the normal Express + // Checkout flow, the customer is then redirected to PayPal to log in to verify their billing + // information. If the customer approves payment on the Confirmation page when you are using + // a reference transaction, you receive the billing agreement as part of the transaction.You can + // use that billing agreement later to bill the customer a set amount on a recurring basis, such as + // once-a-month, for future purchases. The customer doesn’t need to log into PayPal each time to + // make a payment. + // + // Create the data object for Express Checkout Reference Transaction SET operation + // with Purchase using ECSetRequest Data Object. + //ECSetRequest SetRequest = new ECSetRequest("http://www.myreturnurl.com", "http://www.mycancelurl.com", + // "MerchantInitiatedBilling", "Test Description", "any", "BACustom"); + + // *** Without Making a Purchase *** + // Typically, the customer chooses a billing agreement without making a purchase when they + // subscribe for merchandise they will pay for on a recurring schedule. If, for example, the + // customer logs in to your website to order a magazine subscription, you set up an agreement to + // bill the customer on a scheduled basis, say, once a month. In the billing agreement flow + // without purchase, the customer is redirected to PayPal to log in. On the PayPal site, they + // consent to the billing agreement. Next month, when you send the customer the first magazine + // issue, the billing agreement authorizes you to start charging the customer’s PayPal account on + // the agreed upon recurring basis without having the customer log in to PayPal. + // + // Create the data object for Express Checkout Reference Transaction SET operation + // without Purchase using ECSetBARequest Data Object. + //ECSetBARequest SetRequest = new ECSetBARequest("http://www.myreturnurl.com", "http://www.mycancelurl.com", + // "MerchantInitiatedBilling", "Test Description", "any", "BACustom"); + + // Create the Tender object. + PayPalTender Tender = new PayPalTender(SetRequest); + + // Create the transaction object. + AuthorizationTransaction Trans = new AuthorizationTransaction + (User, Connection, Inv, Tender, PayflowUtility.RequestId); + + // Create an Order Transaction. An Order transaction represents an agreement to pay one or more + // authorized amounts up to the specified total over a maximum of 29 days. + // Refer to the Express Checkout for Payflow Pro Developer's Guide regarding Orders. + //OrderTransaction Trans = new OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString()); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); + Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); + // If value is true, then the Request ID has not been changed and the original response + // of the original transction is returned. + Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); + } + + if (TrxnResponse.Result == 0) + { + Console.WriteLine(Environment.NewLine + "Transaction was Approved."); + Console.WriteLine(Environment.NewLine + "The next step would be to redirect to PayPal to allow customer to log"); + Console.WriteLine("into their account to select payment. For this demo, DO NOT CLOSE the browser"); + Console.WriteLine("as you will need the TOKEN and/or PAYER ID from the URL for the GET and DO"); + Console.WriteLine("samples."); + Console.WriteLine(Environment.NewLine + "Make sure you are logged into Developer Central (https://developer.paypal.com) before continuing."); + Console.WriteLine(Environment.NewLine + "Press to redirect to PayPal."); + Console.ReadLine(); + + // Using the PayPal SandBox for Express Checkout: + // Before you can use the PayPal Sandbox with a Gateway account you'll need to do the following: + // To setup a PayPal Sandbox account to work with a Payflow Pro account you will need to go to + // https://developer.paypal.com and create an account. Once you have access to the Sandbox then + // you will be able to set up test business accounts, premier accounts and personal accounts. Please + // set up a test business account and personal account so you can test Express Checkout. + // + // Once you have a test business account created, create a ticket at http://www.paypal.com/mts + // under Contact Support and request to have your Payflow Pro (US, AU) or Websites Payments Pro + // Payflow Edition (UK) account modified to use the PayPal Sandbox. Provide the e-mail ID you + // used when you created your account on the Sandbox. + // + // Once you are notified that your account has been updated you will then need to modify the host + // URLs of the Payflow Pro Express Checkout test servers to the URLs used by the Sandbox. + // For example, https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=. + + // If the SET operation succeeds, you will get a secure session token id in the response of this + // operation. Using this token, redirect the user's browser as follows: + + // For Regular Express Checkout or Express Checkout (Reference) with Purchase. + String PayPalUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; + + // For Express Checkout (Reference) without Purchase. + //String PayPalUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_customer-billing-agreement&token="; + + PayPalUrl += Trans.Response.ExpressCheckoutSetResponse.Token; + //Process.Start(PayPalUrl); // Open default browser. + //Process.Start("iexplore.exe", PayPalUrl); + Process.Start("C:\\Program Files\\Mozilla Firefox\\firefox.exe", PayPalUrl); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DOUpdateEC.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DOUpdateEC.cs new file mode 100644 index 0000000..3a7fca8 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/ExpressCheckout/DOUpdateEC.cs @@ -0,0 +1,116 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.ExpressCheckout +{ + /// + /// This class uses the Payflow SDK Data Objects to do an Update Express Checkout transaction. Used + /// for reference transaction only, see below. + /// + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + /// This sample is for reference and for testing purposes only. See the eStoreFront sample for + /// one way to perform an Express Checkout transaction from your web site. + /// + /// Refer to the "PayPal Express Checkout Transaction Processing" chapter of the Payflow Pro Developer's + /// Guide (US, AU) or the Websites Payments Pro Payflow Edition Developer's Guide (UK). + /// + /// Besides doing a standard Express Checkout transactions, you can also do a Express Checkout Reference + /// Transaction. + /// + /// A reference transaction takes existing billing information already gathered from a previously + /// authorized transaction and reuses it to charge the customer in a subsequent transaction. + /// Reference transactions, typically used for repeat billing to a merchants PayPal account when + /// customers are not present to log in, are now supported through Express Checkout. + /// + /// NOTE: You must be enabled by PayPal to use reference transactions. Contact your account manager + /// or the sales department for more details. + /// + /// See the DOSetEC Sample for more details on Reference Transations using Express Checkout. + /// + public class DOUpdateEC + { + public DOUpdateEC() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOUpdateEC.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // You can use the Update Billing Agreement request to cancel the billing agreement or update + // the billing agreement description. + // + // For more information on Reference Transactions, see the DOSetEC Sample for more details. + + // For Express Checkout Reference Transaction without Purchase. + ECUpdateBARequest UpdateRequest = new ECUpdateBARequest("", "", ""); + + // Create the Tender object. + PayPalTender Tender = new PayPalTender(UpdateRequest); + + // Create the transaction object. We do not pass a Transaction Type for an update call. + BaseTransaction Trans = new BaseTransaction( + null, User, Connection, null, Tender, PayflowUtility.RequestId); + + // Submit the transaction. + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + // PNREF is not returned with an Update call. + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + if (TrxnResponse.Result == 0) + { + Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); + Console.WriteLine("PAYERID = " + Trans.Response.ExpressCheckoutGetResponse.PayerId); + Console.WriteLine("PAYERSTATUS = " + Trans.Response.ExpressCheckoutGetResponse.PayerStatus); + Console.WriteLine("FIRST = " + Trans.Response.ExpressCheckoutGetResponse.FirstName); + Console.WriteLine("LAST = " + Trans.Response.ExpressCheckoutGetResponse.LastName); + Console.WriteLine("EMAIL = " + Trans.Response.ExpressCheckoutGetResponse.EMail); + Console.WriteLine("BAID = " + Trans.Response.ExpressCheckoutDoResponse.BAId); + Console.WriteLine("BA_STATUS = " + Trans.Response.ExpressCheckoutUpdateResponse.BA_Status); + Console.WriteLine("BA_DESC = " + Trans.Response.ExpressCheckoutUpdateResponse.BA_Desc); + } + } + + // If value is true, then the Request ID has not been changed and the original response + // of the original transction is returned. + Console.WriteLine(Environment.NewLine + "DUPLICATE = " + TrxnResponse.Duplicate); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Fraud/DOFraudFilters.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Fraud/DOFraudFilters.cs new file mode 100644 index 0000000..2977225 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Fraud/DOFraudFilters.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Fraud +{ + /// + /// This class uses the Payflow SDK Data Objects to do a Fraudulent Sale transaction. A pre-requisite + /// to this transaction is to set a value of $50 for the "Purchase Price Ceiling Filter". + /// An amount of $51 is passed to trigger the filter. + /// + public class DOFraudFilters + { + public DOFraudFilters() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOFraudFilters.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(51.00)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "677 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + CustomerInfo CustInfo = new CustomerInfo(); + CustInfo.CustIP = "10.1.1.1"; // IP Velocity Filter + Inv.CustomerInfo = CustInfo; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0115"); + CC.Cvv2 = "444"; + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + /////////////////////////////////////////////////////////////////// + + // Create a new Sale Transaction with purchase price ceiling amount filter set to $50. + SaleTransaction Trans = new SaleTransaction( + User, Connection, Inv, Card, PayflowUtility.RequestId); + + // Set the Verbosity of the transaction to HIGH to get maximum information in the response. + Trans.Verbosity = "HIGH"; + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + Console.WriteLine("HOSTCODE = " + TrxnResponse.HostCode); + Console.WriteLine("PROCAVS = " + TrxnResponse.ProcAVS); + Console.WriteLine("CVV2MATCH = " + TrxnResponse.CVV2Match); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + + // The following lines of code dealing with PreXmlData and PostXmlData will return all th rules + // that were triggered by the Fraud Service. For Example, let's assume the both AVS and CSC (CVV2) + // failed, the FraudResp.PostFpsMsg would something similar to: + // "Review: More than one rule was triggered for Review". + // + // The Fps_PreXmlData is returned as an Xml string. This is converted into Data Objects + // with the object hierarchy as shown below: + // FpsXmlData + // >>>>>>>>> List of Rule objects + // >>>>>>>>>>>>>>>>>> List of RuleVendorParm objects. + FpsXmlData PreXmlData = FraudResp.Fps_PreXmlData; + if (PreXmlData != null) + { + // Get the list of Rules. + ArrayList RulesList = PreXmlData.Rules; + if (RulesList != null && RulesList.Count > 0) + { + IEnumerator RulesEnum = RulesList.GetEnumerator(); + Rule DORule = null; + // Loop through the list of Rules. + while (RulesEnum.MoveNext()) + { + DORule = (Rule)RulesEnum.Current; + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("PRE-XML DATA"); + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Rule Number = " + DORule.Num.ToString()); + Console.WriteLine("Rule Id = " + DORule.RuleId); + Console.WriteLine("Rule Alias = " + DORule.RuleAlias); + Console.WriteLine("Rule Description = " + DORule.RuleDescription); + Console.WriteLine("Action = " + DORule.Action); + Console.WriteLine("Triggered Message = " + DORule.TriggeredMessage); + + // Get the list of Rule Vendor Parameters. + ArrayList RuleVendorParmsList = DORule.RuleVendorParms; + + if (RuleVendorParmsList != null && RuleVendorParmsList.Count > 0) + { + IEnumerator RuleParametersEnum = RuleVendorParmsList.GetEnumerator(); + // Loop through the list of Rule Parameters. + while (RuleParametersEnum.MoveNext()) + { + RuleParameter DORuleParam = (RuleParameter)RuleParametersEnum.Current; + Console.WriteLine("Number = " + DORuleParam.Num.ToString()); + Console.WriteLine("Name = " + DORuleParam.Name); + Console.WriteLine("Type = " + DORuleParam.Type); + Console.WriteLine("Value = " + DORuleParam.Value); + } + } + } + } + // The Fps_PostXmlData is returned as an Xml string. This is converted into Data Objects + // with the object hierarchy as shown below: + // FpsXmlData + // >>>>>>>>> List of Rule objects + // >>>>>>>>>>>>>>>>>> List of RuleVendorParm objects. + FpsXmlData PostXmlData = FraudResp.Fps_PostXmlData; + if (PostXmlData != null) + { + // Get the list of Rules. + ArrayList PostRulesList = PostXmlData.Rules; + if (PostRulesList != null && PostRulesList.Count > 0) + { + IEnumerator RulesEnum = PostRulesList.GetEnumerator(); + Rule DORule = null; + // Loop through the list of Rules. + while (RulesEnum.MoveNext()) + { + DORule = (Rule)RulesEnum.Current; + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("POST-XML DATA"); + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Rule Number = " + DORule.Num.ToString()); + Console.WriteLine("Rule Id = " + DORule.RuleId); + Console.WriteLine("Rule Alias = " + DORule.RuleAlias); + Console.WriteLine("Rule Description = " + DORule.RuleDescription); + Console.WriteLine("Action = " + DORule.Action); + Console.WriteLine("Triggered Message = " + DORule.TriggeredMessage); + + // Get the list of Rule Vendor Parameters. + ArrayList RuleVendorParmsList = DORule.RuleVendorParms; + + if (RuleVendorParmsList != null && RuleVendorParmsList.Count > 0) + { + IEnumerator RuleParametersEnum = RuleVendorParmsList.GetEnumerator(); + // Loop through the list of Rule Parameters. + while (RuleParametersEnum.MoveNext()) + { + RuleParameter DORuleParam = (RuleParameter)RuleParametersEnum.Current; + Console.WriteLine("Number = " + DORuleParam.Num.ToString()); + Console.WriteLine("Name = " + DORuleParam.Name); + Console.WriteLine("Type = " + DORuleParam.Type); + Console.WriteLine("Value = " + DORuleParam.Value); + } + } + } + } + } + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } + } + } +} diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Fraud/DOFraudReview.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Fraud/DOFraudReview.cs new file mode 100644 index 0000000..cc87451 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Fraud/DOFraudReview.cs @@ -0,0 +1,66 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Fraud +{ + /// + /// This class uses the Payflow SDK Data Objects to Approve a Fraudulent transaction. + /// + public class DOFraudReview + { + public DOFraudReview() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOFraudReview.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + /////////////////////////////////////////////////////////////////// + + // Create a new Sale Transaction with purchase price ceiling amount filter set to $50. + FraudReviewTransaction Trans = new FraudReviewTransaction("V64A0A15ECF3", "RMS_APPROVE", + User, Connection, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } + +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOAdditionalHeaders.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOAdditionalHeaders.cs new file mode 100644 index 0000000..33d79b4 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOAdditionalHeaders.cs @@ -0,0 +1,112 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Misc +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Sale transaction. + /// This class also shows how to add/remove custom client information header in a transaction + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DOAdditionalHeaders + { + public DOAdditionalHeaders() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOAdditionalHeaders.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0115"); + CC.Cvv2 = "123"; + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + /////////////////////////////////////////////////////////////////// + + // Create a new Sale Transaction. + SaleTransaction Trans = new SaleTransaction( + User, Connection, Inv, Card, PayflowUtility.RequestId); + + // Add a new custom client information header + // to the transaction. + Trans.AddTransHeader("X-VPS-VIT-WRAPPER-TYPE","VRSN-CS-SAMPLE"); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + Console.WriteLine("CVV2MATCH = " + TrxnResponse.CVV2Match); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DODataUpload.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DODataUpload.cs new file mode 100644 index 0000000..113f1d3 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DODataUpload.cs @@ -0,0 +1,117 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Samples.CS.DataObjects.Recurring; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Misc +{ + /// + /// To assist is providing a PCI compliant solution, PayPal now allows a you to upload your + /// existing credit card data using a new transaction type. As the data is uploaded, a + /// transaction id (PNREF) will be generated that can be stored locally to perform a Reference + /// Transaction (tokenization). This allows you to remove all credit card data from your + /// local servers. For more information regarding Reference Transactions review the section in + /// the Payflow Developer's Guide. + /// + /// The transaction type value is "L" which allows the credit card data to be sent and stored + /// without being sent to the banks for processing. You must send at miminum the following + /// items: TRXTYPE, TENDER, ACCT and EXPDATE. + /// + /// As you can see, you can send in Billing and Shipping information to be stored, but you must + /// not include the AMT field. If AMT is passed you will receive a RESULT=4, RESPMSG=Invalid Amount error. + /// + /// IMPORTANT: The credit card data sent for storage is not verified in any way as it is not + /// sent to the banks for processing. To validate a transaction, you would do an account + /// verification; also known as a, zero dollar authorization, type transaction. + /// + /// NOTE: This is processor dependent and not all processors support this feature. + /// + /// For Reference transactions, please use ReferenceTransaction class and for Recurring use + /// RecurringTransaction base class. + /// + /// + /// + public class DODataUpload + { + public DODataUpload() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DODataUpload.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // Values of connection details can also be passed in the constructor of + // PayflowConnectionData. This will override the values passed in the App config file. + // Example values passed below are as follows: + // Payflow Pro Host address : pilot-payflowpro.paypal.com + // Payflow Pro Host Port : 443 + // Timeout : 45 ( in seconds ) + PayflowConnectionData Connection = new PayflowConnectionData("pilot-payflowpro.paypal.com", 443, 45); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Remember, we do not send in an amount. + + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0115"); + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + + // Create a new Base Transaction. + BaseTransaction Trans = new BaseTransaction("L", User, Connection, Inv, Card, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("TRANSTIME = " + TrxnResponse.TransTime); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOInquiry_ACH.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOInquiry_ACH.cs new file mode 100644 index 0000000..d7b52eb --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOInquiry_ACH.cs @@ -0,0 +1,84 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Misc +{ + // + // This class uses the Payflow SDK Data Objects to do an ACH Inquiry transaction. + // + // You perform an inquiry using a reference to an original transaction that you specified for the original + // transaction. + // + // While the amount of information returned in an Inquiry transaction depends upon the VERBOSITY setting, + // Inquiry responses mimic the verbosity level of the original transaction as much as possible. + // + // Transaction results (especially values for declines and error conditions) returned by each PayPal-supported + // processor vary in detail level and in format. The Payflow Pro Verbosity parameter enables you to control + // the kind and level of information you want returned. + // + public class DOInquiry + { + public DOInquiry() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOInquiry.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + /////////////////////////////////////////////////////////////////// + + // Create a new Inquiry Transaction. + //Replace with a previous transaction ID that you processed on your account. + InquiryTransaction Trans = new InquiryTransaction("",User, Connection, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + // Display the transaction response parameters. Refer to the Payflow Pro Developer's Guide for explanations. + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("--------------------------------------------"); + Console.WriteLine("Original Response Data"); + Console.WriteLine("--------------------------------------------"); + Console.WriteLine("ORIGRESULT = " + TrxnResponse.OrigResult); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("STATUS = " + TrxnResponse.Status); + Console.WriteLine("TRANSSTATE = " + TrxnResponse.TransState); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOReference.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOReference.cs new file mode 100644 index 0000000..d63e7fc --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOReference.cs @@ -0,0 +1,112 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Samples.CS.DataObjects.Recurring; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Misc +{ + /// + /// This class uses the Payflow SDK Reference Transaction object to do a Sale transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// The Reference Transaction object should be used be used only in a remote scenario when the user + /// needs to do a reference transaction type which is not directly supported by the transaction objects + /// provided by the SDK. Doing a transaction in this fashion enables the user to have flexibility in + /// terms of specifying the transaction type (TRXTYPE). + /// For normal transactions, please use BaseTransaction class and for Recurring use RecurringTransaction + /// base class. + /// + /// + /// + public class DOReference + { + public DOReference() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOReference.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + + // Create a new Tender - Base Tender data object and set the Tender Type to "C". + // We do not pass any payment device + BaseTender Tender = new BaseTender("C",null); + // To modify the expiration date, we wil also need to create a CreditCard object + // without passing the credit card number. + //CreditCard CC = new CreditCard(null, "1215"); + //CardTender Card = new CardTender(CC); + + // Create a new Reference Transaction. + ReferenceTransaction Trans = new ReferenceTransaction("S", "", User, Connection, Inv, PayflowUtility.RequestId); + // If expiration date is changed too. + //ReferenceTransaction Trans = new ReferenceTransaction("S", "", User, Connection, Inv, Card, PayflowUtility.RequestId); + + // You can also change the expiration date of the new reference transaction, by passing the EXPDATE via the ExtendData object. + //ExtendData ExpDate = new ExtendData("EXPDATE", "1215"); + //Trans.AddToExtendData(ExpDate); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + + } + + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOSale_ACH.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOSale_ACH.cs new file mode 100644 index 0000000..7149ba5 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOSale_ACH.cs @@ -0,0 +1,103 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Misc +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple ACH - Sale transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + /// Refer to the Payflow ACH Payment Service Guide for more information. + /// + /// + public class DOSale_ACH + { + public DOSale_ACH() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOSale_ACH.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Bank Account data object. + // The input parameters are Account No. and ABA. + BankAcct BA = new BankAcct("1111111111", "111111118"); + // The Account Type can be "C" for Checking and "S" for Saving. + BA.AcctType = "C"; + BA.Name = "John Doe"; + + // Create a new Tender - ACH Tender data object. + ACHTender ACH = new ACHTender(BA); + ACH.AuthType = "WEB"; // Sending as a Web transaction. + ACH.ChkNum = "1234"; + + // Create a new ACH - Sale Transaction. + SaleTransaction Trans = new SaleTransaction(User, Connection, Inv, ACH, PayflowUtility.RequestId); + + // Setting verbosity to HIGH to get full response. + Trans.Verbosity = "HIGH"; + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("HOSTCODE = " + TrxnResponse.HostCode); + Console.WriteLine("TRANSTIME = " + TrxnResponse.TransTime); + Console.WriteLine("CHECK NAME (FIRSTNAME) = " + TrxnResponse.FirstName); + Console.WriteLine("AMOUNT = " + TrxnResponse.Amt); + Console.WriteLine("ACCT = " + TrxnResponse.Acct); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOSale_Base.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOSale_Base.cs new file mode 100644 index 0000000..c7b162b --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOSale_Base.cs @@ -0,0 +1,131 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Samples.CS.DataObjects.Recurring; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Misc +{ + /// + /// This class uses the Payflow SDK Base Transaction object to do a simple Sale transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// The Base Transaction object should be used be used only in a remote scenario when the user + /// needs to do a transaction type which is not directly supported by the transaction objects + /// provided by the SDK. Doing a transaction in this fashion enables the user to have flexibility in + /// terms of specifying the transaction type (TRXTYPE). + /// For Reference transactions, please use ReferenceTransaction class and for Recurring use + /// RecurringTransaction base class. + /// + /// + /// + public class DOSale_Base + { + public DOSale_Base() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOSale_Base.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // Values of connection details can also be passed in the constructor of + // PayflowConnectionData. This will override the values passed in the App config file. + // Example values passed below are as follows: + // Payflow Pro Host address : pilot-payflowpro.paypal.com + // Payflow Pro Host Port : 443 + // Timeout : 45 ( in seconds ) + PayflowConnectionData Connection = new PayflowConnectionData("pilot-payflowpro.paypal.com",443,45); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.1256)); + Inv.Amt = Amt; + // Truncate the Amount value using the truncate feature of + // the Currency Data Object. + // Note: Currency Data Object also has the Round feature + // which will round the amount value to desired number of decimal + // digits ( default 2 ). However, round and truncate cannot be used + // at the same time. You can set one of round or truncate true. + Inv.Amt.Truncate = true; + // Set the truncation decimal digit to 2. + Inv.Amt.NoOfDecimalDigits = 2; + + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0115"); + CC.Cvv2 = "123"; + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + /////////////////////////////////////////////////////////////////// + + // Create a new Base Transaction. + BaseTransaction Trans = new BaseTransaction("S", + User, Connection, Inv, Card, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + Console.WriteLine("CVV2MATCH = " + TrxnResponse.CVV2Match); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOTeleCheck.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOTeleCheck.cs new file mode 100644 index 0000000..b694f2c --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOTeleCheck.cs @@ -0,0 +1,160 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Misc +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Telecheck - Authorization transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DOTeleCheck + { + public DOTeleCheck() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("---------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DO_TeleCheck.cs"); + Console.WriteLine("---------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Bill.BillToCity = "New York"; + Bill.BillToState = "PA"; + Bill.BillToZip = "12345"; + Bill.BillToPhone = "123-4546-7890"; + Bill.BillToEmail = "ivan@test.com"; + Bill.BillToCountry = "US"; + Inv.BillTo = Bill; + + // Set the IP address of the customer + CustomerInfo custInfo = new CustomerInfo(); + custInfo.CustIP = "111.111.11.111"; + Inv.CustomerInfo = custInfo; + + // Create a new Payment Device - Check Payment data object. + // The input parameters is MICR. Magnetic Ink Check Reader. This is the entire line + // of numbers at the bottom of all checks. It includes the transit number, account + // number, and check number. + CheckPayment ChkPayment = new CheckPayment("1234567804390850001234"); + + // Name property needs to be set for the Check Payment. + ChkPayment.Name = "Ivan Smith"; + // Create a new Tender - Check Tender data object. + CheckTender ChkTender = new CheckTender(ChkPayment); + // Account holder’s next unused (available) check number. Up to 7 characters. + ChkTender.ChkNum = "1234"; + // DL or SS is required for a TeleCheck transaction. + // If CHKTYPE=P, a value for either DL or SS must be passed as an identifier. + // If CHKTYPE=C, the Federal Tax ID must be passed as the SS value. + ChkTender.ChkType = "P"; + // Driver’s License number. If CHKTYPE=P, a value for either DL or SS must be passed as an identifier. + // Format: XXnnnnnnnn + // XX = State Code, nnnnnnnn = DL Number - up to 31 characters. + ChkTender.DL = "CAN85452345"; + // Social Security number. Needed if ChkType = P + ChkTender.SS = "456765833"; + // AuthType = I-Internet Check, P-Checks by Phone, D-Prearranged Deposit + ChkTender.AuthType = "I"; + + // Create a new TeleCheck - Authorization Transaction. + AuthorizationTransaction Trans = new AuthorizationTransaction( + User, Connection, Inv, ChkTender, PayflowUtility.RequestId); + + //Want VERBOSITY=HIGH to get all the response values back. + Trans.Verbosity = "HIGH"; + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("HOSTCODE = " + TrxnResponse.HostCode); + Console.WriteLine("TRACEID = " + TrxnResponse.TraceId); + Console.WriteLine("ACHSTATUS = " + TrxnResponse.AchStatus); + } + // Display the response. + Console.WriteLine(PayflowUtility.GetStatus(Resp) + Environment.NewLine); + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine("Transaction Errors = " + TransCtx.ToString() + Environment.NewLine); + } + if (TrxnResponse.Result == 0) + { + // Transaction approved, display acceptance verbiage, after consumer accepts, capture the + // transaction to finalize it. + CaptureTransaction capTrans = new CaptureTransaction(TrxnResponse.Pnref, User, Connection, null, ChkTender, PayflowUtility.RequestId); + // Set the transaction verbosity to HIGH to display most details. + capTrans.Verbosity = "HIGH"; + + // Submit the Transaction + Response capResp = capTrans.SubmitTransaction(); + + // Display the transaction response parameters. + if (capResp != null) + { + // Get the Transaction Response parameters. + TransactionResponse capTrxnResponse = capResp.TransactionResponse; + if (capTrxnResponse != null) + { + Console.WriteLine("RESULT = " + capTrxnResponse.Result); + Console.WriteLine("PNREF = " + capTrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + capTrxnResponse.RespMsg); + Console.WriteLine("HOSTCODE = " + capTrxnResponse.HostCode); + Console.WriteLine("TRACEID = " + capTrxnResponse.TraceId); + } + // Display the response. + Console.WriteLine(PayflowUtility.GetStatus(capResp) + Environment.NewLine); + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context capTransCtx = capResp.TransactionContext; + if (capTransCtx != null && capTransCtx.getErrorCount() > 0) + { + Console.WriteLine("Transaction Errors = " + capTransCtx.ToString() + Environment.NewLine); + } + } + else + { + Console.WriteLine("Unable to capture transaction as it declined or failed." + Environment.NewLine); + } + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOVerbosity.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOVerbosity.cs new file mode 100644 index 0000000..70202cd --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Misc/DOVerbosity.cs @@ -0,0 +1,122 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Misc +{ + /// + /// This class uses the Payflow SDK Data Objects to do a simple Sale transaction with MEDIUM Verbosity. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + /// Transaction results (especially values for declines and error conditions) returned by each PayPal-supported + /// processor vary in detail level and in format. The Payflow Verbosity parameter enables you to control the kind + /// and level of information you want returned. + /// + /// By default, Verbosity is set to LOW. A LOW setting causes PayPal to normalize the transaction result values. + /// Normalizing the values limits them to a standardized set of values and simplifies the process of integrating + /// the Payflow SDK. + /// + /// By setting Verbosity to MEDIUM, you can view the processor’s raw response values. This setting is more “verbose” + /// than the LOW setting in that it returns more detailed, processor-specific information. + /// + /// Review the chapter in the Payflow Pro Developer's Guide regarding VERBOSITY and the INQUIRY function for more details. + /// + public class DOVerbosity + { + public DOVerbosity() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DOVerbosity.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0115"); + CC.Cvv2 = "123"; + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + /////////////////////////////////////////////////////////////////// + + // Create a new Sale Transaction. + SaleTransaction Trans = new SaleTransaction( + User, Inv, Card, PayflowUtility.RequestId); + + // Set the transaction verbosity to MEDIUM. + Trans.Verbosity = "MEDIUM"; + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("PNREF = " + TrxnResponse.Pnref); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode); + Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr); + Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); + Console.WriteLine("IAVS = " + TrxnResponse.IAVS); + Console.WriteLine("HOSTCODE = " + TrxnResponse.HostCode); + Console.WriteLine("PROCAVS = " + TrxnResponse.ProcAVS); + Console.WriteLine("CVV2MATCH = " + TrxnResponse.CVV2Match); + Console.WriteLine("PROCCVV2 = " + TrxnResponse.ProcCVV2); + Console.WriteLine("RESPTEXT = " + TrxnResponse.RespText); + Console.WriteLine("ADDLMSGS = " + TrxnResponse.AddlMsgs); + } + + // Get the Fraud Response parameters. + FraudResponse FraudResp = Resp.FraudResponse; + // Display Fraud Response parameter + if (FraudResp != null) + { + Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); + Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurring.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurring.cs new file mode 100644 index 0000000..9d4f307 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurring.cs @@ -0,0 +1,116 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Samples.CS.DataObjects.Misc; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Recurring +{ + /// + /// This class uses the Payflow SDK Recurring Transaction object to do a simple Recurring Add transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// The Recurring Transaction object should be used be used only in a remote scenario when the user + /// needs to do a recurring transaction type which is not directly supported by the transaction objects + /// provided by the SDK. Doing a transaction in this fashion enables the user to have flexibility in + /// terms of specifying the transaction type (TRXTYPE). + /// For normal transactions, please use BaseTransaction class and for Recurring use RecurringTransaction + /// base class. + /// + /// + /// + public class DORecurring + { + public DORecurring() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DORecurring.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Create a new Invoice data object details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0125"); + CC.Cvv2 = "123"; + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + + RecurringInfo RecurInfo = new RecurringInfo(); + // The date that the first payment will be processed. + // This will be of the format mmddyyyy. + RecurInfo.Start = ""; + RecurInfo.ProfileName = ""; + // Specifies how often the payment occurs. All PAYPERIOD values must use + // capital letters and can be any of DAY / WEEK / BIWK / SMMO / FRWK / ] + // MONT / QTER / SMYR / YEAR + RecurInfo.PayPeriod = "MONT"; + + // Create a new Recurring Transaction. + RecurringTransaction Trans = new RecurringTransaction("A", RecurInfo, + User, Connection, Inv, Card, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + } + + // Get the Recurring Response parameters. + RecurringResponse RecurResponse = Resp.RecurringResponse; + if (RecurResponse != null) + { + Console.WriteLine("RPREF = " + RecurResponse.RPRef); + Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + } + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + Console.WriteLine(Environment.NewLine + "Press Enter to Continue ..."); + Console.ReadLine(); + } + + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringAdd.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringAdd.cs new file mode 100644 index 0000000..5eaf750 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringAdd.cs @@ -0,0 +1,171 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Recurring +{ + /// + /// This class uses the Payflow SDK Data Objects to do a Recurring Add transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DORecurringAdd + { + public DORecurringAdd() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DORecurringAdd.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + // Creating a profile where our customer is paying three installments of $25.75 with a shipping + // charge of $9.95. So, our first payment will be $25.75 + 9.95 with two more payments of $25.75 due. + // + // This is just one example of how you might create a new profile. + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.75), "USD"); + Inv.Amt = Amt; + //Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + // Only Street and Zip are set below for AVS check; however, you would probably want + // to include full name and address information. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Bill.BillToCountry = "US"; + Inv.BillTo = Bill; + + // Create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0115"); + // CVV2 is used for Optional Transaction (Sale or Authorization) Only. It is not stored as + // part of the profile, nor is it sent when payments are made. + CC.Cvv2 = "123"; + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + + RecurringInfo RecurInfo = new RecurringInfo(); + // The date that the first payment will be processed. + // This will be of the format mmddyyyy. + RecurInfo.Start = "07152008"; + RecurInfo.ProfileName = "Test_Profile"; // User provided Profile Name. + + // Specifies how often the payment occurs. All PAYPERIOD values must use + // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / + // QTER / SMYR / YEAR + RecurInfo.PayPeriod = "WEEK"; + RecurInfo.Term = 2; // Number of payments + + // Peform an Optional Transaction. + RecurInfo.OptionalTrx = "S"; // S = Sale, A = Authorization + // Set the amount if doing a "Sale" for the Optional Transaction. + Currency oTrxAmt = new Currency(new decimal(25.75 + 9.95), "USD"); + RecurInfo.OptionalTrxAmt = oTrxAmt; + + // Create a new Recurring Add Transaction. + RecurringAddTransaction Trans = new RecurringAddTransaction( + User, Connection, Inv, Card, RecurInfo, PayflowUtility.RequestId); + + // Use ORIGID to create a profile based on the details of another transaction. See Reference Transaction. + //Trans.OrigId = ""; + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + } + + // Get the Recurring Response parameters. + RecurringResponse RecurResponse = Resp.RecurringResponse; + if (RecurResponse != null) + { + String ProfileMsg; + if (TrxnResponse.Result == 0) + { + ProfileMsg = "Profile Created."; + } + else + { + ProfileMsg = "Error, Profile Not Created."; + } + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine(("Profile Status: " + ProfileMsg)); + Console.WriteLine("Recurring Profile Reference (RPREF) = " + RecurResponse.RPRef); + Console.WriteLine("Recurring Profile ID (PROFILEID) = " + RecurResponse.ProfileId); + + // Was an Optional Transaction processed? + if (RecurResponse.TrxResult != null) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Optional Transaction Details:"); + Console.WriteLine("Transaction PNREF (TRXPNREF) = " + RecurResponse.TrxPNRef); + Console.WriteLine("Transaction Result (TRXRESULT) = " + RecurResponse.TrxResult); + Console.WriteLine("Transaction Message (TRXRESPMSG) = " + RecurResponse.TrxRespMsg); + Console.WriteLine(("Authorization (AUTHCODE) = " + TrxnResponse.AuthCode)); + Console.WriteLine(("Security Code Match (CVV2MATCH) = " + TrxnResponse.CVV2Match)); + Console.WriteLine(("Street Address Match (AVSADDR) = " + TrxnResponse.AVSAddr)); + Console.WriteLine(("Streep Zip Match (AVSZIP) = " + TrxnResponse.AVSZip)); + Console.WriteLine(("International Card (IAVS) = " + TrxnResponse.IAVS)); + + // Was this a duplicate transaction? + // If this value is true, you will probably receive a result code 19, Original transaction ID not found. + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Duplicate Response:"); + String DupMsg; + if (TrxnResponse.Duplicate == "1") + { + + DupMsg = "Duplicate Transaction"; + } + else + { + DupMsg = "Not a Duplicate Transaction"; + } + Console.WriteLine("Duplicate Transaction (DUPLICATE) = " + DupMsg); + } + } + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + + + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringCancel.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringCancel.cs new file mode 100644 index 0000000..4481caf --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringCancel.cs @@ -0,0 +1,79 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Recurring +{ + /// + /// This class uses the Payflow SDK Data Objects to do a Recurring Cancel transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DORecurringCancel + { + public DORecurringCancel() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DORecurringCancel.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + RecurringInfo RecurInfo = new RecurringInfo(); + RecurInfo.OrigProfileId = ""; // RT0000001350 + + // Create a new Recurring Cancel Transaction. + RecurringCancelTransaction Trans = new RecurringCancelTransaction( + User, Connection, RecurInfo, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + } + + // Get the Recurring Response parameters. + RecurringResponse RecurResponse = Resp.RecurringResponse; + if (RecurResponse != null) + { + Console.WriteLine("RPREF = " + RecurResponse.RPRef); + Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + + } + + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringInquiry.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringInquiry.cs new file mode 100644 index 0000000..b84fcf2 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringInquiry.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Recurring +{ + /// + /// This class uses the Payflow SDK Data Objects to do a Recurring Inquiry transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DORecurringInquiry + { + public DORecurringInquiry() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DORecurringInquiry.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + RecurringInfo RecurInfo = new RecurringInfo(); + RecurInfo.OrigProfileId = ""; // RT0000001350 + // To show payment history instead of Profile details, change to "Y". + // To view "Optional Transactions", use 'O'. + RecurInfo.PaymentHistory = "N"; + + /////////////////////////////////////////////////////////////////// + + // Create a new Recurring Inquiry Transaction. + RecurringInquiryTransaction Trans = new RecurringInquiryTransaction( + User, Connection, RecurInfo, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + } + + // Get the Recurring Response parameters. + RecurringResponse RecurResponse = Resp.RecurringResponse; + if (RecurResponse != null) + { + Console.WriteLine("RPREF = " + RecurResponse.RPRef); + Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + // Show Profile Details. + if (RecurResponse.InquiryParams.Count == 0) + { + Console.WriteLine("STATUS = " + RecurResponse.Status); + Console.WriteLine("PROFILENAME = " + RecurResponse.ProfileName); + Console.WriteLine("START = " + RecurResponse.Start); + Console.WriteLine("TERM = " + RecurResponse.Term); + Console.WriteLine("PAYMENTSLEFT = " + RecurResponse.PaymentsLeft); + Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment); + Console.WriteLine("PAYPERIOD = " + RecurResponse.PayPeriod); + Console.WriteLine("TENDER = " + RecurResponse.Tender); + Console.WriteLine("AMT = " + RecurResponse.Amt); + Console.WriteLine("ACCT = " + RecurResponse.Acct); + Console.WriteLine("EXPDATE = " + RecurResponse.ExpDate); + Console.WriteLine("AGGREGATEAMT = " + RecurResponse.AggregateAmt); + Console.WriteLine("AGGREGATEOPTIONALAMT = " + RecurResponse.AggregateOptionalAmt); + Console.WriteLine("MAXFAILPAYMENTS = " + RecurResponse.MaxFailPayments); + Console.WriteLine("NUMFAILPAYMENTS = " + RecurResponse.NumFailPayments); + Console.WriteLine("RETRYNUMDAYS = " + RecurResponse.RetryNumDays); + Console.WriteLine("END = " + RecurResponse.End); + Console.WriteLine("FIRSTNAME = " + RecurResponse.Name); + Console.WriteLine("LASTNAME = " + RecurResponse.LastName); + Console.WriteLine("STREET = " + RecurResponse.Street); + Console.WriteLine("ZIP = " + RecurResponse.Zip); + } + else + { + // Display the Payment History instead of Profile data. + // Payment History is stored in the HASHTABLE RecurResponse.InquiryParams. + // PAYMENTHISTORY = Y or O + Console.WriteLine("INQUIRY PARAMS"); + int x = 0; + char Tab = (char)9; + while (true) + { + x++; + if(RecurResponse.InquiryParams["P_PNREF" + x.ToString()] == null) + { + break; + } + Console.WriteLine("PAYMENT: {0}" + Tab + + "RESULT: {1}" + Tab + + "PNREF: " + "{2}" + Tab + + "AMOUNT: " + "{3}" + Tab + + "TRANSTIME: " + "{4}" + Tab + + "TRANSTATE: " + "{5}" + Tab + + "TENDER: " + "{6}" + Tab, + x, + RecurResponse.InquiryParams["P_RESULT" + x.ToString()], + RecurResponse.InquiryParams["P_PNREF" + x.ToString()], + RecurResponse.InquiryParams["P_AMT" + x.ToString()], + RecurResponse.InquiryParams["P_TRANSTIME" + x.ToString()], + RecurResponse.InquiryParams["P_TRANSTATE" + x.ToString()], + RecurResponse.InquiryParams["P_TENDER" + x.ToString()]); + } + } + } + + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringModify.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringModify.cs new file mode 100644 index 0000000..7b458cc --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringModify.cs @@ -0,0 +1,109 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Recurring +{ + /// + /// This class uses the Payflow SDK Data Objects to do a Recurring Modify transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DORecurringModify + { + public DORecurringModify() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DORecurringModify.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + RecurringInfo RecurInfo = new RecurringInfo(); + RecurInfo.OrigProfileId = ""; // RT0000001350 + RecurInfo.ProfileName = ""; // Test_Profile + + // Create a new Invoice data object with the Amount, Billing Address etc. details for the data you + // want to change. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Bill.BillToEmail = "abc@abc.com"; + Bill.BillToPhone = "123-123-1234"; + Inv.BillTo = Bill; + + // If you want to modify the credit card information, create a new Payment Device - Credit Card data object. + // The input parameters are Credit Card Number and Expiration Date of the Credit Card. + CreditCard CC = new CreditCard("5105105105105100", "0115"); + + // Create a new Tender - Card Tender data object. + CardTender Card = new CardTender(CC); + + // If NO card details available and want to modify only information like E-Mail or Phone Number, use following: + //RecurringModifyTransaction Trans = new RecurringModifyTransaction(User, Connection, RecurInfo, Inv, null, PayflowUtility.RequestId); + + // If you want to modify the RecurringInfo information only, use the following: + //RecurringModifyTransaction Trans = new RecurringModifyTransaction(User, Connection, RecurInfo, PayflowUtility.RequestId); + + // Create a new Recurring Modify Transaction. + RecurringModifyTransaction Trans = new RecurringModifyTransaction(User, Connection, RecurInfo, Inv, Card, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + } + + // Get the Recurring Response parameters. + RecurringResponse RecurResponse = Resp.RecurringResponse; + if (RecurResponse != null) + { + Console.WriteLine("RPREF = " + RecurResponse.RPRef); + Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringPayment.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringPayment.cs new file mode 100644 index 0000000..b4c092e --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringPayment.cs @@ -0,0 +1,94 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Recurring +{ + /// + /// This class uses the Payflow SDK Data Objects to do a Recurring Payment transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DORecurringPayment + { + public DORecurringPayment() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DORecurringPayment.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + RecurringInfo RecurInfo = new RecurringInfo(); + RecurInfo.OrigProfileId = ""; // RT0000001350 + RecurInfo.PaymentNum = "2"; // The failed payment to be retried. + + // Create a new Invoice data object with the Amount, Billing Address etc. details. + Invoice Inv = new Invoice(); + + // Set Amount. + Currency Amt = new Currency(new decimal(25.12)); + Inv.Amt = Amt; + Inv.PoNum = "PO12345"; + Inv.InvNum = "INV12345"; + + // Set the Billing Address details. + BillTo Bill = new BillTo(); + Bill.BillToStreet = "123 Main St."; + Bill.BillToZip = "12345"; + Inv.BillTo = Bill; + /////////////////////////////////////////////////////////////////// + + // Create a new Recurring Payment Transaction. + RecurringPaymentTransaction Trans = new RecurringPaymentTransaction( + User, Connection, RecurInfo, Inv, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + } + + // Get the Recurring Response parameters. + RecurringResponse RecurResponse = Resp.RecurringResponse; + if (RecurResponse != null) + { + Console.WriteLine("RPREF = " + RecurResponse.RPRef); + Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringReActivate.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringReActivate.cs new file mode 100644 index 0000000..d027f61 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/DataObjects/Recurring/DORecurringReActivate.cs @@ -0,0 +1,78 @@ +using System; +using PayPal.Payments.Common; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.DataObjects; +using PayPal.Payments.Transactions; + +namespace PayPal.Payments.Samples.CS.DataObjects.Recurring +{ + /// + /// This class uses the Payflow SDK Data Objects to do a Recurring ReActivate transaction. + /// The request is sent as a Data Object and the response received is also a Data Object. + /// + public class DORecurringReActivate + { + public DORecurringReActivate() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: DORecurringReActivate.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Create the Data Objects. + // Create the User data object with the required user details. + UserInfo User = new UserInfo("", "", "", ""); + + // Create the Payflow Connection data object with the required connection details. + // The PAYFLOW_HOST property is defined in the App config file. + PayflowConnectionData Connection = new PayflowConnectionData(); + + RecurringInfo RecurInfo = new RecurringInfo(); + RecurInfo.OrigProfileId = ""; // RT0000001350 + // The date that the first payment will be processed. + // This will be of the format mmddyyyy. + RecurInfo.Start = "01012009"; + + // Create a new Recurring ReActivate Transaction. + RecurringReActivateTransaction Trans = new RecurringReActivateTransaction( + User, Connection, RecurInfo, PayflowUtility.RequestId); + + // Submit the Transaction + Response Resp = Trans.SubmitTransaction(); + // Display the transaction response parameters. + if (Resp != null) + { + // Get the Transaction Response parameters. + TransactionResponse TrxnResponse = Resp.TransactionResponse; + if (TrxnResponse != null) + { + Console.WriteLine("RESULT = " + TrxnResponse.Result); + Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); + } + + // Get the Recurring Response parameters. + RecurringResponse RecurResponse = Resp.RecurringResponse; + if (RecurResponse != null) + { + Console.WriteLine("RPREF = " + RecurResponse.RPRef); + Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); + } + + // Display the response. + Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); + + // Get the Transaction Context and check for any contained SDK specific errors (optional code). + Context TransCtx = Resp.TransactionContext; + if (TransCtx != null && TransCtx.getErrorCount() > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); + } + } + Console.WriteLine("Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/NameValuePairs/NVPCommandLine.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/NameValuePairs/NVPCommandLine.cs new file mode 100644 index 0000000..03abc16 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/NameValuePairs/NVPCommandLine.cs @@ -0,0 +1,74 @@ +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Communication; +using PayPal.Payments.DataObjects; + +namespace PayPal.Payments.Samples.CS.NameValuePairs +{ + /// + /// This class uses the Payflow SDK API to do a simple Sale transaction from the Command Line. + /// The request is sent as a Name-Value pair string & the response received is also + /// Name-Value Pair string. + /// + public class NVPCommandLine + { + public NVPCommandLine() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: NVPCommandLine.cs"); + Console.WriteLine("------------------------------------------------------"); + + String ResponseStr = null; + if (Args.Length < 4) + { + Console.WriteLine(Environment.NewLine + "Incorrect number of arguments. Usage:" + Environment.NewLine + + "SamplesCS "); + Console.WriteLine(Environment.NewLine + "Example transaction:" + Environment.NewLine + "SamplesCS pilot-payflowpro.paypal.com 443 \"USER=&TRXTYPE[1]=A&VENDOR=&AMT[5]=25.00&PWD=&PARTNER=&TENDER[1]=C&ACCT[16]=5100000000000008&EXPDATE[4]=0125\" 45"); + Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + Console.ReadLine(); + System.Environment.Exit(-1); + } + + PayflowNETAPI PayflowNETAPI; + if (Args.Length == 4) + { + PayflowNETAPI = new PayflowNETAPI(Args[0], + System.Convert.ToInt32(Args[1]), + System.Convert.ToInt32(Args[3])); + } + else + { + PayflowNETAPI = new PayflowNETAPI(Args[0], + System.Convert.ToInt32(Args[1]), + System.Convert.ToInt32(Args[3]), Args[4], + System.Convert.ToInt32(Args[5]), + Args[6], Args[7]); + } + + ResponseStr = PayflowNETAPI.SubmitTransaction(Args[2], + PayflowUtility.RequestId); + + // To write the Response on to the console. + Console.WriteLine(Environment.NewLine + "Request = " + PayflowNETAPI.TransactionRequest); + Console.WriteLine(Environment.NewLine + "Response = " + ResponseStr); + + // Following lines of code are optional. + // Begin optional code for displaying SDK errors ... + // It is used to read any errors that might have occurred in the SDK. + // Get the transaction errors. + String TransErrors = PayflowNETAPI.TransactionContext.ToString(); + if (TransErrors != null && TransErrors.Length > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + } + + Console.WriteLine(Environment.NewLine + "Status: " + PayflowUtility.GetStatus(ResponseStr)); + Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/NameValuePairs/NVPSale.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/NameValuePairs/NVPSale.cs new file mode 100644 index 0000000..dea76e9 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/NameValuePairs/NVPSale.cs @@ -0,0 +1,60 @@ +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Communication; +using PayPal.Payments.DataObjects; + +namespace PayPal.Payments.Samples.CS.NameValuePairs +{ + /// + /// This class uses the Payflow SDK API to do a simple Sale transaction. + /// The request is sent as a Name-Value pair string & the response received + /// is also Name-Value Pair string. + /// + public class NVPSale + { + public NVPSale() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: NVPSale.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Sample Request. + // Please replace , , & with your merchant information. + //String Request = "USER=&VENDOR=&PARTNER=&PWD=&TRXTYPE=S&ACCT=5105105105105100&EXPDATE=0125&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345"; + String Request = "USER=toddprov4&VENDOR=toddprov4&PARTNER=VeriSign&PWD=password1&TRXTYPE=S&ORIGID=A50O0BE63815&EXPDATE=0125&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345"; + + // Create an instance of PayflowNETAPI. + PayflowNETAPI PayflowNETAPI = new PayflowNETAPI(); + // Can also pass the values in the constructor itself instead of using .config file. + PayflowNETAPI.SetParameters("pilot-payflowpro.paypal.com", 443, 45, "", 0, "", "", "enabled", "1", "payflow.log", "10240000", false); + + // RequestId is a unique string that is required for each & every transaction. + // The merchant can use her/his own algorithm to generate this unique request id or + // use the SDK provided API to generate this as shown below (PayflowUtility.RequestId). + // + // NOTE: Review the comments in the DoSaleComplete example under BasicTransactions for + // more information on the Request ID. + String Response = PayflowNETAPI.SubmitTransaction(Request, PayflowUtility.RequestId); + + // To write the Response on to the console. + Console.WriteLine(Environment.NewLine + "Request = " + PayflowNETAPI.TransactionRequest); + Console.WriteLine(Environment.NewLine + "Response = " + Response); + // Following lines of code are optional. + // Begin optional code for displaying SDK errors ... + // It is used to read any errors that might have occurred in the SDK. + // Get the transaction errors. + String TransErrors = PayflowNETAPI. TransactionContext.ToString(); + if (TransErrors != null && TransErrors.Length > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + } + Console.WriteLine(Environment.NewLine + "Status: " + PayflowUtility.GetStatus(Response)); + Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/XMLPay/XMLPayCommandLine.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/XMLPay/XMLPayCommandLine.cs new file mode 100644 index 0000000..f980fc6 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/XMLPay/XMLPayCommandLine.cs @@ -0,0 +1,73 @@ +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Communication; +using PayPal.Payments.DataObjects; + +namespace PayPal.Payments.Samples.CS.XMLPay +{ + /// + /// This class uses the Payflow SDK API to do a simple Sale transaction + /// from the Command Line using XML Pay parameter list. + /// The request is sent as a XML Pay string & the response received + /// is also XML Pay string. + /// + public class XMLPayCommandLine + { + public XMLPayCommandLine() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: XMLPayCommandLine.cs"); + Console.WriteLine("------------------------------------------------------"); + + if (Args.Length < 4) + { + Console.WriteLine(Environment.NewLine + "Incorrect number of arguments. Usage:" + Environment.NewLine + + "SamplesCS "); + Console.WriteLine(Environment.NewLine + "Example transaction:" + Environment.NewLine + + "SamplesCS pilot-payflowpro.paypal.com 443 \"[partner][vendor]25.12INV12345PO12345
123 Main St.12345
5105105105105100201501
[user][password]
\" 45"); + Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + Console.ReadLine(); + System.Environment.Exit(-1); + } + + PayflowNETAPI PayflowNETAPI; + if (Args.Length == 3) + { + PayflowNETAPI = new PayflowNETAPI(Args[0], + System.Convert.ToInt32(Args[1]), + System.Convert.ToInt32(Args[3])); + } + else + { + PayflowNETAPI = new PayflowNETAPI(Args[0], + System.Convert.ToInt32(Args[1]), + System.Convert.ToInt32(Args[3]), Args[4], + System.Convert.ToInt32(Args[5]), + Args[6], Args[7]); + } + + String ResponseStr = PayflowNETAPI.SubmitTransaction(Args[2], PayflowUtility.RequestId); + + // To write the Response on to the console. + Console.WriteLine(Environment.NewLine + "Request = " + PayflowNETAPI.TransactionRequest); + Console.WriteLine(Environment.NewLine + "Response = " + ResponseStr); + + // Following lines of code are optional. + // Begin optional code for displaying SDK errors ... + // It is used to read any errors that might have occurred in the SDK. + // Get the transaction errors. + String TransErrors = PayflowNETAPI. TransactionContext.ToString(); + if (TransErrors != null && TransErrors.Length > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + } + Console.WriteLine(Environment.NewLine + "Status: " + PayflowUtility.GetStatus(ResponseStr)); + Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/XMLPay/XMLPayCommandLine_File.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/XMLPay/XMLPayCommandLine_File.cs new file mode 100644 index 0000000..b43f713 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/XMLPay/XMLPayCommandLine_File.cs @@ -0,0 +1,102 @@ +using System; +using System.IO; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Communication; +using PayPal.Payments.DataObjects; + +namespace PayPal.Payments.Samples.CS.XMLPay +{ + /// + /// This class uses the Payflow SDK API to run XML Pay transactions by reading the files. + /// The request is sent as a XMLPay string & the response received + /// is also XMLPay string. + /// + public class XMLPayCommandLine_File + { + public XMLPayCommandLine_File() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: XMLPayCommandLine_File.cs"); + Console.WriteLine("------------------------------------------------------"); + + if (Args.Length < 4) + { + Console.WriteLine(Environment.NewLine + "Incorrect number of arguments. Usage:" + Environment.NewLine + "SamplesCS "); + Console.WriteLine(Environment.NewLine + "Example transaction:" + Environment.NewLine + "SamplesCS pilot-payflowpro.paypal.com 443 \"C:" + + System.IO.Path.DirectorySeparatorChar + "Sale.xml\" 45"); + Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + Console.ReadLine(); + System.Environment.Exit(-1); + } + + PayflowNETAPI PayflowNETAPI; + if (Args.Length == 4) + { + PayflowNETAPI = new PayflowNETAPI(Args[0], + System.Convert.ToInt32(Args[1]), + System.Convert.ToInt32(Args[3])); + } + else + { + PayflowNETAPI = new PayflowNETAPI(Args[0], + System.Convert.ToInt32(Args[1]), + System.Convert.ToInt32(Args[3]), Args[4], + System.Convert.ToInt32(Args[5]), + Args[6], Args[7]); + } + + String XmlFile = ReadFile(Args[2]); + if (XmlFile != null) + { + String ResponseStr = PayflowNETAPI.SubmitTransaction(XmlFile, PayflowUtility.RequestId); + + // To write the Response on to the console. + Console.WriteLine(Environment.NewLine + "Request = " + PayflowNETAPI.TransactionRequest); + Console.WriteLine(Environment.NewLine + "Response = " + ResponseStr); + + // Following lines of code are optional. + // Begin optional code for displaying SDK errors ... + // It is used to read any errors that might have occurred in the SDK. + // Get the transaction errors. + String TransErrors = PayflowNETAPI. TransactionContext.ToString(); + if (TransErrors != null && TransErrors.Length > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + } + Console.WriteLine(Environment.NewLine + "Status: " + PayflowUtility.GetStatus(ResponseStr)); + Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + Console.ReadLine(); + } + else + { + Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + Console.ReadLine(); + } + } + + // Read the xml file into a string. + private static String ReadFile(String FilePath) + { + String FileString = null; + if (File.Exists(FilePath)) + { + StreamReader sr = new StreamReader(new FileStream(FilePath, + FileMode.Open, FileAccess.Read)); + FileString = sr.ReadToEnd(); + + sr.Close(); + } + else + { + Console.WriteLine("-100" + + "Failed to open XML file at location " + FilePath + "V00000000000" + + "0000000"); + } + return FileString; + } + } +} \ No newline at end of file diff --git a/dotNET/Samples/PayPal/Payments/Samples/CS/XMLPay/XMLPaySale.cs b/dotNET/Samples/PayPal/Payments/Samples/CS/XMLPay/XMLPaySale.cs new file mode 100644 index 0000000..e3c0b14 --- /dev/null +++ b/dotNET/Samples/PayPal/Payments/Samples/CS/XMLPay/XMLPaySale.cs @@ -0,0 +1,61 @@ +using System; +using PayPal.Payments.Common.Utility; +using PayPal.Payments.Communication; +using PayPal.Payments.DataObjects; + +namespace PayPal.Payments.Samples.CS.XMLPay +{ + /// + /// This class uses the Payflow SDK API to do a simple Sale transaction. + /// The request is sent as a XML Pay string & the response received + /// is also XML Pay string. + /// + public class XMLPaySale + { + public XMLPaySale() + { + } + + public static void Main(string[] Args) + { + Console.WriteLine("------------------------------------------------------"); + Console.WriteLine("Executing Sample from File: XMLPaySale.cs"); + Console.WriteLine("------------------------------------------------------"); + + // Sample Request. + // Please replace [user], [vendor], [password] & [partner] with your merchant information. + String Request = "[partner][vendor]25.12INV12345PO12345
123 Main St.12345
5105105105105100202501
[user][password]
"; + + // Create an instance of PayflowNETAPI. + PayflowNETAPI PayflowNETAPI = new PayflowNETAPI(); + // Can also pass the values in the constructor itself instead of using .config file. + //PayflowNETAPI.SetParameters("pilot-payflowpro.paypal.com", 443, 45, "", 0, "", "", "enabled", "1", "payflow.log", "10240000", false); + + // RequestId is a unique string that is required for each & every transaction. + // The merchant can use her/his own algorithm to generate this unique request id or + // use the SDK provided API to generate this as shown below (PayflowUtility.RequestId). + // + // NOTE: Review the comments in the DoSaleComplete example under BasicTransactions for + // more information on the Request ID. + String Response = PayflowNETAPI.SubmitTransaction(Request, PayflowUtility.RequestId); + + // To write the Response on to the console. + Console.WriteLine(Environment.NewLine + "Request = " + PayflowNETAPI.TransactionRequest); + Console.WriteLine(Environment.NewLine + "Response = " + Response); + + // Following lines of code are optional. + // Begin optional code for displaying SDK errors ... + // It is used to read any errors that might have occurred in the SDK. + // Get the transaction errors. + String TransErrors = PayflowNETAPI.TransactionContext.ToString(); + if (TransErrors != null && TransErrors.Length > 0) + { + Console.WriteLine(Environment.NewLine + "Transaction Errors from SDK = " + TransErrors); + } + + Console.WriteLine(Environment.NewLine + "Status: " + PayflowUtility.GetStatus(Response)); + Console.WriteLine(Environment.NewLine + "Press Enter to Exit ..."); + Console.ReadLine(); + } + } +} diff --git a/dotNET/Samples/Samples.csproj b/dotNET/Samples/Samples.csproj new file mode 100644 index 0000000..55b8da4 --- /dev/null +++ b/dotNET/Samples/Samples.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp3.1 + PayPal.Payments.Samples.CS.DataObjects.ExpressCheckout.DODoEC + + + + + + + diff --git a/dotNET/SamplesCS/App.config b/dotNET/SamplesCS/App.config index 8198101..9982cb3 100644 --- a/dotNET/SamplesCS/App.config +++ b/dotNET/SamplesCS/App.config @@ -32,7 +32,7 @@ - + diff --git a/dotNET/SamplesCS/SamplesCS.csproj b/dotNET/SamplesCS/SamplesCS.csproj index f4e87c8..350e154 100644 --- a/dotNET/SamplesCS/SamplesCS.csproj +++ b/dotNET/SamplesCS/SamplesCS.csproj @@ -19,14 +19,15 @@ Exe SamplesCS OnBuildSuccess - PayPal.Payments.Samples.CS.DataObjects.BasicTransactions.DOInquiry + PayPal.Payments.Samples.CS.DataObjects.ExpressCheckout.DODoEC - v4.6.1 + v4.8 0.0 false + publish\ true Disk @@ -41,7 +42,6 @@ 1.0.0.%2a false true - bin\Debug\ @@ -230,9 +230,9 @@ - - {ce010258-e90b-4349-9bda-c717768c9442} - PFProSDK + + {8009b18a-efbc-467d-9e86-afbc1c7ab031} + PayflowProSDK