Exemplo n.º 1
0
        public void CompletedOrder_BuyNow_BAPoints_30()
        {
            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("receiver_email", "*****@*****.**");
            requestData.Add("txn_id", "6AY89642EM656753M");
            requestData.Add("payment_status", "Completed");
            requestData.Add("txn_type", "web_accept");
            requestData.Add("quantity", "1");
            requestData.Add("item_number", "BAPoints_30");
            requestData.Add("custom", profile.GlobalId.ToString());

            TestablePayPalHandler handler = new TestablePayPalHandler(manager, "*****@*****.**");

            handler.PayPalResponse = "VERIFIED";
            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                handler.ProcessOrderRequest(serviceSession, requestData, null);
            }
            Session.Clear();
            var dbProfile = Session.Get <Profile>(profile.GlobalId);

            Assert.AreEqual(30, dbProfile.Licence.BAPoints);
            Assert.AreEqual(DateTime.MinValue, dbProfile.Licence.LastPointOperationDate);

            var baPoints = Session.QueryOver <BAPoints>().SingleOrDefault();

            Assert.AreEqual(30, baPoints.Points);
            Assert.AreEqual(dbProfile.GlobalId, baPoints.Profile.GlobalId);
            Assert.AreEqual(requestData["txn_id"], baPoints.Identifier);
            Assert.AreEqual(BAPointsType.PayPal, baPoints.Type);
        }
Exemplo n.º 2
0
        public void DuplicatedOrder_BuyNow()
        {
            BAPoints point = new BAPoints();

            point.Identifier   = "6AY89642EM656753M";
            point.Profile      = profile;
            point.ImportedDate = DateTime.UtcNow;
            insertToDatabase(point);

            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("receiver_email", "*****@*****.**");
            requestData.Add("txn_id", "6AY89642EM656753M");
            requestData.Add("payment_status", "Completed");
            requestData.Add("txn_type", "web_accept");
            requestData.Add("quantity", "1");
            requestData.Add("item_number", "BAPoints_30");
            requestData.Add("custom", profile.GlobalId.ToString());

            TestablePayPalHandler handler = new TestablePayPalHandler(manager, "*****@*****.**");

            handler.PayPalResponse = "VERIFIED";
            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                try
                {
                    handler.ProcessOrderRequest(serviceSession, requestData, null);
                    Assert.Fail();
                }
                catch (UniqueException)
                {
                }
            }
            Session.Clear();
            var baPoints = Session.QueryOver <BAPoints>().RowCount();

            Assert.AreEqual(1, baPoints);
        }
Exemplo n.º 3
0
        public void WrongReceiverMail_BuyNow()
        {
            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("receiver_email", "*****@*****.**");
            requestData.Add("txn_id", "6AY89642EM656753M");
            requestData.Add("payment_status", "Pending");
            requestData.Add("txn_type", "web_accept");
            requestData.Add("quantity", "1");
            requestData.Add("item_number", "BAPoints_30");
            requestData.Add("custom", profile.GlobalId.ToString());

            TestablePayPalHandler handler = new TestablePayPalHandler(manager, "*****@*****.**");

            handler.PayPalResponse = "VERIFIED";
            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                try
                {
                    handler.ProcessOrderRequest(serviceSession, requestData, null);
                    Assert.Fail();
                }
                catch (ValidationException)
                {
                }
            }
            Session.Clear();
            var dbProfile = Session.Get <Profile>(profile.GlobalId);

            Assert.AreEqual(0, dbProfile.Licence.BAPoints);
            Assert.AreEqual(DateTime.MinValue, dbProfile.Licence.LastPointOperationDate);

            var baPoints = Session.QueryOver <BAPoints>().RowCount();

            Assert.AreEqual(0, baPoints);
        }