public void CreateGiftCardValue() { const int valueToAdd = 1000; ICreateGiftCardValue createInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateGiftCardValue>(); ILookupUserLoyalty loyaltyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ILookupUserLoyalty>(); IDestroyGiftCardValue destroyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyGiftCardValue>(); Loyalty initialLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, LevelUpTestConfiguration.Current.MerchantId); var createdGiftCard = createInterface.GiftCardAddValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantId, LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, valueToAdd); Assert.AreEqual(createdGiftCard.AmountAddedInCents, valueToAdd); Loyalty postAdditionLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, LevelUpTestConfiguration.Current.MerchantId); Assert.AreEqual(postAdditionLoyalty.PotentialCreditAmount - initialLoyalty.PotentialCreditAmount, valueToAdd); // Cleanup destroyInterface.GiftCardDestroyValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantId, LevelUpTestConfiguration.Current.ConsumerQrData, valueToAdd); Loyalty postDestructionLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, LevelUpTestConfiguration.Current.MerchantId); Assert.AreEqual(postDestructionLoyalty.PotentialCreditAmount, initialLoyalty.PotentialCreditAmount); }
public void CreateGiftCardValue_NegativeAmount() { const int valueToAdd = -50; ICreateGiftCardValue createInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateGiftCardValue>(); createInterface.GiftCardAddValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantId, LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, valueToAdd); }
public void GiftCardAddValueShouldSucceed() { const string accessToken = "abc"; const int merchant_id = 3554; const string payment_token_data = "LU020000029080KFZ02I9A8V030000LU"; const int value_amount = 1000; const int location_id = 1234; const string order_uuid = "a7e23820d56802321bb64ab3b58dfe6c"; const string identifier_from_merchant = "012345"; const string tender_types = "cash"; string expectedRequestUrl = string.Format(ClientModuleFunctionalTestingUtilities.SANDBOX_URL_PREFIX + "/v15/merchants/{0}/gift_card_value_additions", merchant_id); string expectedRequestbody = string.Format( "{{" + "\"gift_card_value_addition\": {{" + "\"payment_token_data\": \"{0}\"," + "\"value_amount\": {1}," + "\"location_id\": {2}," + "\"order_uuid\": \"{3}\"," + "\"tender_types\": [\"{4}\"], " + "\"identifier_from_merchant\": \"{5}\" " + "}}" + "}}", payment_token_data, value_amount, location_id, order_uuid, tender_types, identifier_from_merchant); RestResponse expectedResponse = new RestResponse { StatusCode = HttpStatusCode.OK, Content = "{" + "\"gift_card_value_addition\": {" + "\"added_value_amount\": 1000," + "\"new_value_at_merchant_amount\": 1000," + "\"old_value_at_merchant_amount\": 0," + "}" + "}" }; ICreateGiftCardValue client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule <ICreateGiftCardValue, GiftCardAddValueRequest>( expectedResponse, expectedRequestbody, expectedAccessToken: accessToken, expectedRequestUrl: expectedRequestUrl); var valueAddition = client.GiftCardAddValue(accessToken, merchant_id, location_id, payment_token_data, value_amount, identifier_from_merchant, new List <string>(new[] { tender_types }), order_uuid); Assert.AreEqual(valueAddition.AmountAddedInCents, 1000); Assert.AreEqual(valueAddition.NewGiftCardAmountInCents, 1000); Assert.AreEqual(valueAddition.PreviousGiftCardAmountInCents, 0); }
public void CreateGiftCardValue_NegativeAmount() { const int valueToAdd = -50; ICreateGiftCardValue createInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateGiftCardValue>(); Assert.Throws <LevelUpApiException>(() => { createInterface.GiftCardAddValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantId, LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, valueToAdd); }, "Failed to throw exception for a negative gift card value."); }
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); }