Example #1
0
    /// <summary>
    /// Process credit card
    /// </summary>
    /// <param name="payment"></param>
    /// <returns></returns>
    public static string ProcessCreditCard(PaymentInformation payment)
    {
        string response        = "";
        string mRequestId      = "";
        string transactionReqt = "";

        transactionReqt += "NAME=" + payment.NameOnCard + "&";
        transactionReqt += "ACCT=" + payment.CreditCardNumber + "&";
        transactionReqt += "EXPDATE=" + payment.CardExpirationMonth + payment.CardExpirationYear + "&";
        transactionReqt += "AMT=" + payment.TransactionAmount + "&";
        transactionReqt += "STREET=" + payment.Street + "&";
        transactionReqt += "CITY=" + payment.City + "&";
        transactionReqt += "STATE=" + payment.State + "&";
        transactionReqt += "ZIP=" + payment.Zip + "&";
        transactionReqt += "CVV2=" + payment.CreditCardVerificationCode + "&";

        transactionReqt += "TRXTYPE=S&TENDER=C&";
        transactionReqt += "USER="******"&";
        transactionReqt += "VENDOR=" + PayflowUtility.AppSettings(LACESConstant.PaymentInfo.VENDOR) + "&";
        transactionReqt += "PARTNER=" + PayflowUtility.AppSettings(LACESConstant.PaymentInfo.PARTNER) + "&";
        transactionReqt += "PWD=" + PayflowUtility.AppSettings(LACESConstant.PaymentInfo.PWD);


        mRequestId = PayflowUtility.RequestId;

        PayflowNETAPI PayflowNETAPI = new PayflowNETAPI();

        //TransactionReqt = "TRXTYPE=S&ACCT=5105105105105101&EXPDATE=0109&TENDER=C&INVNUM=INV12345&AMT=25.12&PONUM=PO12345&STREET=123 Main St.&ZIP=12345&CVV2=123&USER=zmiller636&VENDOR=zmiller636&PARTNER=paypal&PWD=luvspurple1";

        response = PayflowNETAPI.SubmitTransaction(transactionReqt, mRequestId);

        return(response);
    }
Example #2
0
        private void InitializeInstance()
        {
            //FileSizeLimit="";
            var keyName = "";
            var isLogLevelKeyPresent = false;
            var isLogFilenameKeyPresent = false;
            var 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.ConfigLogLevel);
                }
                catch
                {
                    keyName = PayflowConstants.ConfigLogLevel;
                    _mLogLevel = PayflowConstants.LoggingOff;
                    isLogLevelKeyPresent = false;
                }

            if (_mStrLogLevel == null || _mStrLogLevel.Length == 0)
            {
                keyName = PayflowConstants.ConfigLogLevel;
                _mLogLevel = PayflowConstants.LoggingOff;
                isLogLevelKeyPresent = false;
            }
            else
            {
                switch (_mStrLogLevel.Trim().ToUpper())
                {
                    case "OFF":
                        _mLogLevel = PayflowConstants.LoggingOff;
                        break;
                    case "DEBUG":
                        _mLogLevel = PayflowConstants.SeverityDebug;
                        break;
                    case "INFO":
                        _mLogLevel = PayflowConstants.SeverityInfo;
                        break;
                    case "WARN":
                        _mLogLevel = PayflowConstants.SeverityWarn;
                        break;
                    case "ERROR":
                        _mLogLevel = PayflowConstants.SeverityError;
                        break;
                    case "FATAL":
                        _mLogLevel = PayflowConstants.SeverityFatal;
                        break;
                    default:
                        _mLogLevel = PayflowConstants.LoggingOff;
                        break;
                }
            }

            isLogLevelKeyPresent =
                _mLogLevel > PayflowConstants.LoggingOff && _mLogLevel <= PayflowConstants.SeverityFatal;


            // Do not need to do any further processing if Logging is set to OFF.
            if (_mLogLevel != PayflowConstants.LoggingOff)
            {
                if (!_mIsCom)
                    try
                    {
                        _mLogFileName = PayflowUtility.AppSettings(PayflowConstants.ConfigLogfileName);
                    }
                    catch
                    {
                        if (string.Empty.Equals(keyName))
                            keyName = PayflowConstants.ConfigLogfileName;
                        else
                            keyName = keyName + ", " + PayflowConstants.ConfigLogfileName;
                    }

                //				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.LogfileName;
                else
                    isLogFilenameKeyPresent = true;


                if (!_mIsCom)
                    try
                    {
                        _mFileSizeLimit = PayflowUtility.AppSettings(PayflowConstants.ConfigLogfileSize);
                    }
                    catch
                    {
                        //mFileSize = PayflowConstants.LOGFILE_SIZE; 
                        if (string.Empty.Equals(keyName))
                            keyName = PayflowConstants.ConfigLogfileSize;
                        else
                            keyName = keyName + ", " + PayflowConstants.ConfigLogfileSize;
                    }

                if (_mFileSizeLimit == null || _mFileSizeLimit.Length == 0)
                {
                    _mFileSize = PayflowConstants.LogfileSize;
                }
                else
                {
                    try
                    {
                        _mFileSize = int.Parse(_mFileSizeLimit);
                    }
                    catch
                    {
                        _mFileSize = PayflowConstants.LogfileSize;
                        if (string.Empty.Equals(keyName))
                            keyName = PayflowConstants.ConfigLogfileSize;
                        else
                            keyName = keyName + ", " + PayflowConstants.ConfigLogfileSize;
                    }

                    if (_mFileSize < 1)
                        _mFileSize = PayflowConstants.LogfileSize;
                    isLogFileSizeKeyPresent = true;
                }
            }

            if (!(isLogLevelKeyPresent && isLogFilenameKeyPresent && isLogFileSizeKeyPresent))
                if (!(isLogLevelKeyPresent == false && isLogFilenameKeyPresent == false &&
                      isLogFileSizeKeyPresent == false))
                {
                    ErrorObject error;
                    var respMessage = PayflowConstants.ParamResult
                                      + PayflowConstants.SeparatorNvp
                                      + (string) PayflowConstants.CommErrorCodes[PayflowConstants.EConfigError]
                                      + PayflowConstants.DelimiterNvp
                                      + PayflowConstants.ParamRespmsg
                                      + PayflowConstants.SeparatorNvp
                                      + (string) PayflowConstants.CommErrorMessages[PayflowConstants.EConfigError]
                                      + "Tags "
                                      + keyName
                                      + " are not present in the config file or config file is missing.";
                    if (isLogLevelKeyPresent == false)
                        error = new ErrorObject(PayflowConstants.SeverityError, "", respMessage);
                    else
                        error = new ErrorObject(PayflowConstants.SeverityWarn, "", respMessage);
                    _mLoggerErrs.Add(error);
                    //if(IsLogLevelKeyPresent )
                    //{
                    //	InitializeStream();
                    //}
                }
        }
Example #3
0
		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();
					//}
				}
			}
			
		}
Example #4
0
        /// <summary>
        /// Initializes the default values
        /// </summary>
        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);
            }
        }
Example #5
0
        /// <summary>
        ///     Initializes the default values
        /// </summary>
        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
            //intialize them to appropriate
            //default values.

            //set the timeout to default timeout.
            if (TimeOut == 0)
            {
                TimeOut = PayflowConstants.DefaultTimeout;
            }

            /**
             * // ToInt32 can throw FormatException or OverflowException.
             * try
             * {
             *    mTimeOut = Convert.ToInt32(PayflowUtility.AppSettings(PayflowConstants.INTL_PARAM_PAYFLOW_TIMEOUT));
             * }
             * catch (FormatException 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_TIMEOUT +
             +        " is not valid, using default value."
             + StackTrace;
             +    ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, "", RespMessage);
             +    Context.AddError(Error);
             + }
             + catch (OverflowException 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_TIMEOUT +
             +        " is not valid, using default value."
             + StackTrace;
             +    ErrorObject Error = new ErrorObject(PayflowConstants.SEVERITY_FATAL, "", RespMessage);
             +    Context.AddError(Error);
             + }
             +
             + }
             +  mHostPort = PayflowConstants.DEFAULT_HOSTPORT;
             + }*/

            try
            {
                if (HostAddress == null || HostAddress.Length == 0)
                {
                    var hostAddress = PayflowUtility.AppSettings(PayflowConstants.IntlParamPayflowHost);
                    if (hostAddress != null && hostAddress.Length > 0)
                    {
                        hostAddress = hostAddress.TrimStart().TrimEnd();
                        if (hostAddress.Length == 0)
                        {
                            var respMessage = PayflowConstants.ParamResult
                                              + PayflowConstants.SeparatorNvp
                                              + (string)PayflowConstants.CommErrorCodes[PayflowConstants.EConfigError]
                                              + PayflowConstants.DelimiterNvp
                                              + PayflowConstants.ParamRespmsg
                                              + PayflowConstants.SeparatorNvp
                                              + (string)PayflowConstants.CommErrorMessages[
                                PayflowConstants.EConfigError]
                                              + "Tag "
                                              + PayflowConstants.IntlParamPayflowHost +
                                              " is not present in the config file or config file is missing.";
                            var error = new ErrorObject(PayflowConstants.SeverityFatal, "", respMessage);
                            Context.AddError(error);
                        }
                        else
                        {
                            HostAddress = hostAddress;
                        }
                    }
                    else
                    {
                        var respMessage = PayflowConstants.ParamResult
                                          + PayflowConstants.SeparatorNvp
                                          + (string)PayflowConstants.CommErrorCodes[PayflowConstants.EConfigError]
                                          + PayflowConstants.DelimiterNvp
                                          + PayflowConstants.ParamRespmsg
                                          + PayflowConstants.SeparatorNvp
                                          + (string)PayflowConstants.CommErrorMessages[PayflowConstants.EConfigError]
                                          + "Tag "
                                          + PayflowConstants.IntlParamPayflowHost +
                                          " is not present in the config file or config file is missing.";
                        var error = new ErrorObject(PayflowConstants.SeverityFatal, "", respMessage);
                        Context.AddError(error);
                    }
                }
            }
            catch (Exception ex)
            {
                var stackTrace = PayflowConstants.EmptyString;
                PayflowUtility.InitStackTraceOn();
                if (PayflowConstants.TraceOn.Equals(PayflowConstants.Trace))
                {
                    stackTrace = ": " + ex.Message + ex.StackTrace;
                }
                var respMessage = PayflowConstants.ParamResult
                                  + PayflowConstants.SeparatorNvp
                                  + (string)PayflowConstants.CommErrorCodes[PayflowConstants.EConfigError]
                                  + PayflowConstants.DelimiterNvp
                                  + PayflowConstants.ParamRespmsg
                                  + PayflowConstants.SeparatorNvp
                                  + (string)PayflowConstants.CommErrorMessages[PayflowConstants.EConfigError]
                                  + "Tag "
                                  + PayflowConstants.IntlParamPayflowHost +
                                  " is not present in the config file or config file is missing."
                                  + stackTrace;
                var error = new ErrorObject(PayflowConstants.SeverityFatal, "", respMessage);
                Context.AddError(error);
            }
        }