Example #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///     This function overrides the object.toString method.
        ///     This function formats the error message by filling the place holders with the
        ///     context parameters
        /// </summary>
        /// <returns>Formatted error String </returns>
        /// <remarks>
        /// </remarks>
        /// -----------------------------------------------------------------------------
        public override string ToString()
        {
            //This needs to get the message bode using the message code
            string formattedMessage;

            if (MessageParams != null)
            {
                var msgParams = MessageParams.ToArray();
                MessageParams.CopyTo(msgParams);
                try
                {
                    formattedMessage = string.Format(MessageBody, msgParams);
                }
                catch (Exception ex)
                {
                    var stackTrace = PayflowConstants.EmptyString;
                    PayflowUtility.InitStackTraceOn();

                    if (PayflowConstants.TraceOn.Equals(PayflowConstants.Trace))
                    {
                        stackTrace = " " + ex;
                    }

                    formattedMessage = PayflowConstants.MessageFormattingError + stackTrace;
                }
            }
            else
            {
                formattedMessage = MessageBody;
            }

            return(formattedMessage);
        }
Example #2
0
 /// <summary>
 /// Generates the transaction request.
 /// </summary>
 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();
     //}
 }
 /// <summary>
 /// Generates the transaction request.
 /// </summary>
 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();
     //}
 }
Example #4
0
        /// <summary>
        ///     Generates the transaction request.
        /// </summary>
        internal override void GenerateRequest()
        {
            try
            {
                base.GenerateRequest();
                if (_mCreditcard != null)
                {
                    _mCreditcard.RequestBuffer = RequestBuffer;
                    _mCreditcard.GenerateRequest();
                }

                if (_mCurrency != null)
                {
                    RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamCurrency,
                                                                        _mCurrency.CurrencyCode));
                    RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamAmt, _mCurrency));
                }

                RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamPurDesc, PurDesc));
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception ex)
            {
                ex = new TransactionException(ex);
                throw ex;
            }

            //catch
            //{
            //    throw new Exception();
            //}
        }
Example #5
0
        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("<user>", "<vendor>", "<partner>", "<password>");

            // 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 = "<PROFILE_ID>";              // 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();
        }
Example #6
0
 /// <summary>
 /// Generates the transaction request.
 /// </summary>
 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));
 }
        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 <hostAddress> <hostPort> <parmList> <timeOut> <proxyAddress> <proxyPort> <proxyLogon> <proxyPassword>");
                Console.WriteLine(Environment.NewLine + "Example transaction:" + Environment.NewLine + "SamplesCS pilot-payflowpro.paypal.com 443 \"USER=<user>&TRXTYPE[1]=A&VENDOR=<vendor>&AMT[5]=25.00&PWD=<password>&PARTNER=<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();
        }
Example #8
0
        /// <summary>
        /// Sets the appropriate server file path for the connection
        /// and initializes the connection uri.
        /// </summary>
        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);
        }
        /// <summary>
        ///     Receives the transaction response from
        ///     the server.
        /// </summary>
        /// <returns>String Value of Response.</returns>
        public async Task <string> ReceiveResponseAsync()
        {
            Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ReceiveResponse(): Entered.",
                                PayflowConstants.SeverityDebug);
            var response = PayflowConstants.EmptyString;

            try
            {
                var serverResponse = await _mServerConnection.GetResponseAsync();

                var responseStream = serverResponse.GetResponseStream();
                RequestId = serverResponse.Headers.Get(PayflowConstants.PayflowheaderRequestId);
                Logger.Instance.Log(
                    "PayPal.Payments.Communication.PaymentConnection.ReceiveResponse(): Obtained RequestId = " +
                    RequestId,
                    PayflowConstants.SeverityInfo);

                // 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 = await new StreamReader(serverResponse.GetResponseStream()).ReadToEndAsync();

                Logger.Instance.Log(
                    "PayPal.Payments.Communication.PaymentConnection.ReceiveResponse(): Obtained Response.",
                    PayflowConstants.SeverityInfo);
                responseStream.Close();
                _mServerConnection = null;
            }
            catch (Exception ex)
            {
                var addlMessage = "Input Server Uri = " + _mServerUri.AbsoluteUri;
                if (IsProxy)
                {
                    addlMessage += " Input Proxy info = " + _mProxyInfo.Address;
                }
                var initError = PayflowUtility.PopulateCommError(PayflowConstants.ETimeoutWaitResp, ex,
                                                                 PayflowConstants.SeverityError, IsXmlPayRequest,
                                                                 addlMessage);
                if (!ConnContext.IsCommunicationErrorContained(initError))
                {
                    ConnContext.AddError(initError);
                }
            }
            finally
            {
                Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.ReceiveResponse(): Exiting.",
                                    PayflowConstants.SeverityDebug);
            }

            return(response);
        }
Example #10
0
 /// <summary>
 /// Generates the transaction request.
 /// </summary>
 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;
     }
 }
 /// <summary>
 ///     Generates the transaction request.
 /// </summary>
 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.ParamBaStatus, BaStatus));
     RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamBaDesc, BaDesc));
     RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamBaid, BaId));
 }
Example #12
0
        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("<user>", "<vendor>", "<partner>", "<password>");

            // 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 <PNREF> with a previous transaction ID that you processed on your account.
            InquiryTransaction Trans = new InquiryTransaction("<PNREF>", 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();
        }
Example #13
0
        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 <hostAddress> <hostPort> <xml-parmList> <timeout> <proxyAddress> <proxyPort> <proxyLogon> <proxyPassword>");
                Console.WriteLine(Environment.NewLine + "Example transaction:" + Environment.NewLine
                                  + "SamplesCS pilot-payflowpro.paypal.com 443 \"<?xml version='1.0'?><XMLPayRequest Timeout='45' version='2.0'><RequestData><Partner>[partner]</Partner><Vendor>[vendor]</Vendor><Transactions><Transaction><Sale><PayData><Invoice><TotalAmt Currency='USD'>25.12</TotalAmt><InvNum>INV12345</InvNum><BillTo><PONum>PO12345</PONum><Address><Street>123 Main St.</Street><Zip>12345</Zip></Address></BillTo></Invoice><Tender><Card><CardNum>5105105105105100</CardNum><ExpDate>201501</ExpDate></Card></Tender></PayData></Sale></Transaction></Transactions></RequestData><RequestAuth><UserPass><User>[user]</User><Password>[password]</Password></UserPass></RequestAuth></XMLPayRequest>\" 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();
        }
Example #14
0
        /// <summary>
        /// Generates line item request
        /// </summary>
        /// <param name="Index">index number of line item</param>
        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;
            }
        }
        /// <summary>
        /// Generates the transaction request.
        /// </summary>
        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));
        }
Example #16
0
        /// <summary>
        /// Gets the request to be sent.
        /// </summary>
        /// <returns>Request to be sent.</returns>
        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);
        }
        /// <summary>
        /// Receives the transaction response from
        /// the server.
        /// </summary>
        /// <returns>String Value of Response.</returns>
        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);
        }
        /// <summary>
        ///     Generates the transaction request.
        /// </summary>
        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.ParamToken, Token));
            RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamCountrycode, CountryCode));
            RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamPostalcode, PostalCode));
            RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamAction, _mAction));
            RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamDoreauthorization,
                                                                DoReauthorization));
        }
Example #19
0
		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;
			}

		}
        /// <summary>
        /// Executes the transaction.
        /// </summary>
        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);
            }
        }
Example #21
0
 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;
     }
 }
Example #22
0
        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("<user>", "<vendor>", "<partner>", "<password>");

            // 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();
        }
        /// <summary>
        ///     Gets the request to be sent.
        /// </summary>
        /// <returns>Request to be sent.</returns>
        public override string GetSendRequest()
        {
            Logger.Instance.Log("PayPal.Payments.Communication.TransactionSendState.GetSendRequest(): Entered.",
                                PayflowConstants.SeverityDebug);

            var logRequest = TransactionRequest;

            logRequest = PayflowUtility.MaskSensitiveFields(logRequest);


            Logger.Instance.Log(
                "PayPal.Payments.Communication.TransactionSendState.GetSendRequest(): Request = " + logRequest,
                PayflowConstants.SeverityInfo);
            Logger.Instance.Log("PayPal.Payments.Communication.TransactionSendState.GetSendRequest(): Exiting.",
                                PayflowConstants.SeverityDebug);
            return(TransactionRequest);
        }
 /// <summary>
 /// Generates line item request
 /// </summary>
 /// <param name="Index">index number of line item</param>
 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;
     }
 }
Example #25
0
 /// <summary>
 /// Generates the transaction request.
 /// </summary>
 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;
     }
 }
        /// <summary>
        ///     Generates the transaction request.
        /// </summary>
        internal override void GenerateRequest()
        {
            try
            {
                RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamProfilename, ProfileName));
                RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamStart, Start));

                if (Term != PayflowConstants.InvalidNumber)
                {
                    RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamTerm, Term));
                }

                RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamPayperiod, _mPayPeriod));
                RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamOptionaltrx, OptionalTrx));
                RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamOptionaltrxamt,
                                                                    OptionalTrxAmt));
                RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamRetrynumdays,
                                                                    RetryNumDays));
                if (MaxFailPayments != PayflowConstants.InvalidNumber)
                {
                    RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamMaxfailpayments,
                                                                        MaxFailPayments));
                }
                RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamOrigprofileid,
                                                                    OrigProfileId));
                RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamPaymenthistory,
                                                                    PaymentHistory));
                RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamPaymentnum, PaymentNum));
                //RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_RECURRING, mRecurring));
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception ex)
            {
                var dEx = new DataObjectException(ex);
                throw dEx;
            }

            //catch
            //{
            //    throw new Exception();
            //}
        }
 /// <summary>
 ///     Generates line item request
 /// </summary>
 /// <param name="index">index number of line item</param>
 internal void GenerateRequest(int index)
 {
     try
     {
         var indexVal = index.ToString();
         RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamPromocode + indexVal,
                                                             PromoCode));
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception ex)
     {
         var dEx = new DataObjectException(ex);
         throw dEx;
     }
 }
 /// <summary>
 ///     Generates the transaction request.
 /// </summary>
 internal override void GenerateRequest()
 {
     try
     {
         base.GenerateRequest();
         RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamOrigid, _mOrigId));
         RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamOrigppref, OrigPpref));
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception ex)
     {
         ex = new TransactionException(ex);
         throw ex;
     }
 }
 /// <summary>
 /// Generates the transaction request.
 /// </summary>
 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;
     }
 }
 internal override void GenerateRequest()
 {
     try
     {
         base.GenerateRequest();
         RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.ParamCapturecomplete,
                                                             CaptureComplete));
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception ex)
     {
         ex = new TransactionException(ex);
         throw ex;
     }
 }