private void AddThenDestroyGiftCardValue(int giftCardAmountToAdd, int giftCardAmountToDelete, string QrCode, string merchantToken)
        {
            IDestroyGiftCardValue destroyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyGiftCardValue>();

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerUserAccount(giftCardAmountToAdd);

            var destroyed = destroyInterface.GiftCardDestroyValue(merchantToken,
                                                                  LevelUpTestConfiguration.Current.MerchantId,
                                                                  QrCode,
                                                                  giftCardAmountToDelete);

            Assert.AreEqual(destroyed.AmountRemovedInCents, giftCardAmountToDelete);
            Assert.AreEqual(destroyed.PreviousGiftCardAmountInCents, giftCardAmountToAdd);
            Assert.AreEqual(destroyed.NewGiftCardAmountInCents, giftCardAmountToAdd - giftCardAmountToDelete);

            IRetrieveMerchantFundedGiftCardCredit queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IRetrieveMerchantFundedGiftCardCredit>();
            var loyalty = queryInterface.GetMerchantFundedGiftCardCredit(
                ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                LevelUpTestConfiguration.Current.MerchantLocationId,
                LevelUpTestConfiguration.Current.ConsumerQrData);

            Assert.AreEqual(loyalty.TotalAmount, giftCardAmountToAdd - giftCardAmountToDelete);

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
        }
Exemplo n.º 2
0
        public void RetrieveMerchantFundedGiftCardCreditShouldPass()
        {
            const int    locationId      = 19;
            const string qr_code         = "LU02000008ZS9OJFUBNEL6ZM030000LU";
            const int    gift_card_total = 2000;
            const string auth_Token      = "example_auth_token";

            string expectedRequestUrl = string.Format(ClientModuleFunctionalTestingUtilities.SANDBOX_URL_PREFIX + "/v15/locations/{0}/get_merchant_funded_gift_card_credit", locationId);

            string expectedRequestbody = string.Format(
                "{{\"get_merchant_funded_gift_card_credit\": {{\"payment_token_data\": \"{0}\"}} }}", qr_code);

            RestResponse expectedResponse = new RestResponse
            {
                StatusCode = HttpStatusCode.OK,
                Content    = string.Format("{{\"merchant_funded_gift_card_credit\": {{\"total_amount\": {0} }} }}", gift_card_total)
            };

            IRetrieveMerchantFundedGiftCardCredit client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule
                                                           <IRetrieveMerchantFundedGiftCardCredit, GiftCardCreditQueryRequest>(expectedResponse, expectedRequestbody,
                                                                                                                               expectedAccessToken: auth_Token, expectedRequestUrl: expectedRequestUrl);

            var credit = client.GetMerchantFundedGiftCardCredit(auth_Token, locationId, qr_code);

            Assert.AreEqual(credit.TotalAmount, gift_card_total);
        }
Exemplo n.º 3
0
        public void GetMerchantFundedGiftCardCreditWithInvalidQRCode()
        {
            IRetrieveMerchantFundedGiftCardCredit creditInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IRetrieveMerchantFundedGiftCardCredit>();

            creditInterface.GetMerchantFundedGiftCardCredit(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                            LevelUpTestConfiguration.Current.MerchantLocationId,
                                                            "LU_invalid_qr_code");
        }
        internal static void AddGiftCardCreditOnUserAccount(string userQrCode, int amountToAdd)
        {
            IRetrieveMerchantFundedGiftCardCredit creditClient = GetSandboxedLevelUpModule <IRetrieveMerchantFundedGiftCardCredit>();
            ICreateGiftCardValue giftCardClient = GetSandboxedLevelUpModule <ICreateGiftCardValue>();

            var initialCredit = creditClient.GetMerchantFundedGiftCardCredit(
                ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                LevelUpTestConfiguration.Current.MerchantLocationId, userQrCode);

            giftCardClient.GiftCardAddValue(SandboxedLevelUpMerchantAccessToken,
                                            LevelUpTestConfiguration.Current.MerchantId,
                                            LevelUpTestConfiguration.Current.MerchantLocationId,
                                            userQrCode,
                                            amountToAdd);

            var newCredit = creditClient.GetMerchantFundedGiftCardCredit(SandboxedLevelUpMerchantAccessToken,
                                                                         LevelUpTestConfiguration.Current.MerchantLocationId, userQrCode);

            Assert.AreEqual(newCredit.TotalAmount - initialCredit.TotalAmount, amountToAdd);
        }
Exemplo n.º 5
0
        private static void RemoveAnyGiftCardOnAccount(int merchantId, int merchantLocationId, string userQrCode)
        {
            IRetrieveMerchantFundedGiftCardCredit creditClient = GetSandboxedLevelUpModule <IRetrieveMerchantFundedGiftCardCredit>();
            IDestroyGiftCardValue giftCardDestroyClient        = GetSandboxedLevelUpModule <IDestroyGiftCardValue>();

            var credit = creditClient.GetMerchantFundedGiftCardCredit(SandboxedLevelUpMerchantAccessToken,
                                                                      merchantLocationId, userQrCode);

            if (credit.TotalAmount == 0)
            {
                return;
            }

            giftCardDestroyClient.GiftCardDestroyValue(SandboxedLevelUpMerchantAccessToken,
                                                       merchantId, userQrCode, credit.TotalAmount);

            credit = creditClient.GetMerchantFundedGiftCardCredit(SandboxedLevelUpMerchantAccessToken,
                                                                  merchantLocationId, userQrCode);

            Assert.IsTrue(credit.TotalAmount == 0);
        }
Exemplo n.º 6
0
        public void GetMerchantFundedGiftCardCredit()
        {
            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
            IRetrieveMerchantFundedGiftCardCredit creditInterface =
                ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IRetrieveMerchantFundedGiftCardCredit>();

            var credit = creditInterface.GetMerchantFundedGiftCardCredit(
                ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData);

            Assert.AreEqual(0, credit.TotalAmount);

            const int creditAmountCents = 1000;

            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerUserAccount(creditAmountCents);

            credit = creditInterface.GetMerchantFundedGiftCardCredit(
                ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData);

            Assert.AreEqual(creditAmountCents, credit.TotalAmount);

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
        }