public void ListCreditCardsShouldSucceed()
        {
            string expectedRequestUrl = "https://sandbox.thelevelup.com/v15/credit_cards";

            RestResponse expectedResponse = new RestResponse
            {
                StatusCode = HttpStatusCode.OK,
                Content    =
                    "[" +
                    "{" +
                    "\"credit_card\": {" +
                    "\"bin\": \"123456\"," +
                    "\"description\": \"JCB ending in 1234\"," +
                    "\"expiration_month\": 7," +
                    "\"expiration_year\": 2015," +
                    "\"id\": 305999," +
                    "\"last_4\": \"1234\"," +
                    "\"promoted\": true," +
                    "\"state\": \"active\"," +
                    "\"type\": \"JCB\"" +
                    "}" +
                    "}," +
                    "{" +
                    "\"credit_card\": {" +
                    "\"bin\": \"654321\"," +
                    "\"description\": \"JCB ending in 4321\"," +
                    "\"expiration_month\": 3," +
                    "\"expiration_year\": 2015," +
                    "\"id\": 999503," +
                    "\"last_4\": \"4321\"," +
                    "\"promoted\": false," +
                    "\"state\": \"active\"," +
                    "\"type\": \"JCB\"" +
                    "}" +
                    "}" +
                    "]"
            };

            IQueryCreditCards client = ClientModuleUnitTestingUtilities.GetMockedLevelUpModule <IQueryCreditCards>(
                expectedResponse, expectedAccessToken: "access_token", expectedRequestUrl: expectedRequestUrl);
            var cards = client.ListCreditCards("access_token");

            Assert.AreEqual(cards.Count, 2);
            Assert.AreEqual(cards[0].Bin, "123456");
            Assert.AreEqual(cards[1].Bin, "654321");
        }
Exemplo n.º 2
0
        // Braintree enforces a 50-cards-per-user restriction, so we can't keep adding/removing cards for the test user.
        public void CreateCreditCards()
        {
            ICreateCreditCards  createInterface  = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateCreditCards>();
            IDestroyCreditCards destroyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyCreditCards>();
            IQueryCreditCards   queryInterface   = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryCreditCards>();

            CreditCard created = createInterface.CreateCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                  ClientModuleIntegrationTestingUtilities.SandboxIntegrationTestCreditCard);

            List <CreditCard> creditCards = new List <CreditCard>(queryInterface.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken));

            Assert.AreEqual(creditCards.FindAll(x => x.Id == created.Id).Count, 1);

            destroyInterface.DeleteCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, created.Id);

            creditCards = new List <CreditCard> (queryInterface.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken));
            Assert.AreEqual(creditCards.FindAll(x => x.Id == created.Id).Count, 0);

            // Note: The card won't actually be deleted in the cleanup for this test, just deactivated.  AFAIK cards cannot be deleted via
            // the api, and they just languish in a deactivated state.  As a result, the sandbox merchant account that is used for integration
            // tests may wind up with a bunch of old credit card entries.
        }
Exemplo n.º 3
0
        [Test] // Braintree enforces a 50-cards-per-user restriction, so we can't keep adding/removing cards for the test user.
        public void DestroyCard()
        {
            IQueryCreditCards   queryClient   = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryCreditCards>();
            IDestroyCreditCards destroyClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyCreditCards>();
            ICreateCreditCards  createClient  = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateCreditCards>();

            var toCreate = createClient.CreateCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                         ClientModuleIntegrationTestingUtilities.SandboxIntegrationTestCreditCard);

            var cards = queryClient.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken);

            Assert.AreEqual(cards.Count, 1);
            Assert.AreEqual(cards[0].Active, true);
            Assert.AreEqual(cards[0].Id, toCreate.Id);

            destroyClient.DeleteCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, toCreate.Id);

            cards = queryClient.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken);
            Assert.AreEqual(cards.Count, 0);

            createClient.CreateCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                          ClientModuleIntegrationTestingUtilities.SandboxIntegrationTestCreditCard);
        }
Exemplo n.º 4
0
        [Test]  // Braintree enforces a 50-cards-per-user restriction, so we can't keep adding/removing cards for the
                // test user.  This test requires adding/removing cards.
        public void QueryCreditCards()
        {
            IQueryCreditCards   queryInterface   = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryCreditCards>();
            ICreateCreditCards  createInterface  = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateCreditCards>();
            IDestroyCreditCards destroyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyCreditCards>();

            var existingCards = queryInterface.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken);

            foreach (var card in existingCards)
            {
                destroyInterface.DeleteCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, card.Id);
            }

            Assert.AreEqual(queryInterface.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken).Count, 0);

            createInterface.CreateCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                             ClientModuleIntegrationTestingUtilities.SandboxIntegrationTestCreditCard);

            var newCards = queryInterface.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken);

            Assert.AreEqual(newCards.Count, 1);
            Assert.AreEqual(newCards[0].State.ToLower(), "active");
            Assert.AreEqual(newCards[0].Promoted, true);
        }