Exemplo n.º 1
0
        public void SendTest_Capture_Approved()
        {
            //check login / password
            string sError = CheckLoginPassword();

            Assert.IsTrue(sError == "", sError);

            //setup
            decimal amount   = (decimal)30.12;
            string  authCode = SendAuthOnly(amount + 1, false);

            Assert.IsTrue(authCode.Trim().Length > 0);

            //start testing
            string responseString = "1.0|1|1|This transaction has been approved.||P||2207702802|9FE994E47A8F0F44552C5CA59D09BE79||||||||||||XXXX1111|Visa";

            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new CardPresentResponse(responseString.Split('|'));

            CardPresentGateway target = new CardPresentGateway(ApiLoginCP, TransactionKeyCP, true);

            IGatewayRequest request     = new CardPresentCaptureOnly(authCode, "4111111111111111", "0224", amount);
            string          description = "CP Capture transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
Exemplo n.º 2
0
        public void SendTest_Auth_Approved()
        {
            //check login / password
            string sError = CheckLoginPassword();

            Assert.IsTrue(sError == "", sError);

            string responseString = "1.0|1|1|This transaction has been approved.|N8IV1Z|Y||2207395117|4BA6F435F8046E347710457856F3BAD1||||||||||||XXXX1111|Visa";

            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new CardPresentResponse(responseString.Split('|'));

            CardPresentGateway target = new CardPresentGateway(ApiLoginCP, TransactionKeyCP, true);

            IGatewayRequest request     = new CardPresentAuthorizationRequest((decimal)30.11, "4111111111111111", "02", "16");
            string          description = "CP Auth transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.AuthorizationCode.Trim().Length > 0);
            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
Exemplo n.º 3
0
        private string SendAuthOnly(decimal amount, bool returnTransID)
        {
            string responseString = "1.0|1|1|This transaction has been approved.|N8IV1Z|Y||2207395117|4BA6F435F8046E347710457856F3BAD1||||||||||||XXXX1111|Visa";

            LocalRequestObject.ResponseString = responseString;

            CardPresentGateway target = new CardPresentGateway(ApiLoginCP, TransactionKeyCP, true);

            IGatewayRequest request     = new CardPresentAuthorizationRequest(amount, "4111111111111111", "02", "16");
            string          description = "CP Auth transaction approved testing";

            IGatewayResponse response = target.Send(request, description);

            if (response.Approved)
            {
                if (returnTransID)
                {
                    return(response.TransactionID);
                }
                else
                {
                    return(response.AuthorizationCode);
                }
            }
            else
            {
                return("");
            }
        }
Exemplo n.º 4
0
        public void SendTest_PriorAuthCap_Approved()
        {
            //check login / password
            string sError = CheckLoginPassword();

            Assert.IsTrue(sError == "", sError);

            //setup
            decimal amount  = (decimal)30.13;
            string  transID = SendAuthOnly(amount + 1, true);

            Assert.IsTrue(transID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(transID) > 0);

            //start testing
            string responseString = "1.0|1|1|This transaction has been approved.||P||2207397444|37887CB02372C5074386923E7E33BB3C||||||||||||XXXX1111|Visa";

            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new CardPresentResponse(responseString.Split('|'));

            CardPresentGateway target = new CardPresentGateway(ApiLoginCP, TransactionKeyCP, true);

            IGatewayRequest request     = new CardPresentPriorAuthCapture(transID, amount);
            string          description = "CP PriorAuthCap transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
Exemplo n.º 5
0
        public void SendTest_PriorAuthCap_LessAmount_Failed()
        {
            //check login / password
            string sError = CheckLoginPassword();

            Assert.IsTrue(sError == "", sError);

            //setup
            decimal amount  = (decimal)30.13;
            string  transID = SendAuthOnly(amount - 1, true);

            Assert.IsTrue(transID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(transID) > 0);

            //start testing
            string responseString = "1.0|3|47|The amount requested for settlement cannot be greater than the original amount authorized.||P||0|723B86547E0A4F9D9A2293081DA46A70|||||||||||||Visa";

            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new CardPresentResponse(responseString.Split('|'));

            CardPresentGateway target = new CardPresentGateway(ApiLoginCP, TransactionKeyCP, true);

            IGatewayRequest request     = new CardPresentPriorAuthCapture(transID, amount);
            string          description = "CP PriorAuthCap transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) == 0);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Processes the CC.
        /// </summary>
        /// <param name="ccNumber">The cc number.</param>
        /// <param name="ccExpDate">The cc exp date.</param>
        /// <param name="chargeAmount">The charge amount.</param>
        /// <param name="orderNumber">The order number.</param>
        /// <param name="zipCode">The zip code.</param>
        /// <returns></returns>
        private static string ProcessCC(string ccNumber, string ccExpDate, decimal chargeAmount, string orderNumber, string zipCode, string name)
        {
            try
            {
                if (chargeAmount > 0)
                {
                    var request = new AuthorizationRequest(ccNumber, ccExpDate, chargeAmount, "Bettery Charge");
                    request.Zip = zipCode;

                    //  Store the Swap Station ID in the CustID field
                    request.CustId = ConfigurationManager.AppSettings[Constants.SettingKeys.StationId];

                    //  Add customer info if user is logged in.
                    //if (BaseController.CurrentTransaction.Email != null || BaseController.CurrentTransaction.Email != String.Empty)
                    //    request.Email = BaseController.CurrentTransaction.Email;

                    if (BaseController.LoggedOnUser != null)
                    {
                        request.AddCustomer(BaseController.LoggedOnUser.MemberId.ToString(), BaseController.LoggedOnUser.MemberFirstName, BaseController.LoggedOnUser.MemberLastName, "", "", BaseController.CurrentTransaction.ZipCode);
                    }
                    else
                    {
                        request.FirstName = name;
                        request.Zip       = BaseController.CurrentTransaction.ZipCode;
                    }


                    // Get Test Request setting from config file
                    request.TestRequest = ConfigurationManager.AppSettings["TestTransaction"].ToString();


                    // Set Test Request true for admins
                    if (BaseController.LoggedOnUser != null && (BaseController.LoggedOnUser.GroupID == Constants.Group.SuperUser || BaseController.LoggedOnUser.GroupID == Constants.Group.SwapStationAdmin || BaseController.LoggedOnUser.GroupID == Constants.Group.CompanyAccount))
                    {
                        request.TestRequest = "TRUE";
                    }

                    //order number
                    request.AddInvoice(orderNumber);

                    var gate = new CardPresentGateway(BaseController.ApiLogin, BaseController.TransactionKey, false);

                    //step 3 - make some money
                    var response = gate.Send(request);
                    if (!response.Approved)
                    {
                        BaseController.CurrentTransaction.ZipCode = null;
                        throw new KioskException(Constants.Messages.NonApprovedRequest);
                    }
                    BaseController.CurrentTransaction.TransactionID = response.TransactionID;
                    return(response.AuthorizationCode);
                }
                else
                {
                    return("");
                }
            }
            catch (KioskException kioskException)
            {
                AlertController.AuthorizeDotNetAlert(kioskException);
                throw kioskException;
            }
            catch (Exception ex)
            {
                KioskException kioskException = new KioskException(Constants.Messages.CouldNotConnectToAuthorize);
                kioskException.OriginalException = ex;

                AlertController.AuthorizeDotNetAlert(ex);
                Logger.Log(EventLogEntryType.Error, "Could Not Connect to Authorize.NET or other Authorize.NET failure", BaseController.StationId);
                throw kioskException;
            }
        }