public void CreateFails_WhenQrCodeIsInvalid() { const string invalidQRCode = "LU02000ROETEST_BAD_QR_DATA_D40200A0LU"; ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount(); const int refundAmountCents = 50; ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(refundAmountCents); ICreateDetachedRefund refundInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateDetachedRefund>(); var refundData = new DetachedRefundRequestBody(LevelUpTestConfiguration.Current.MerchantLocationId, invalidQRCode, refundAmountCents); try { refundInterface.CreateDetachedRefund(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, refundData); Assert.Fail("Expected LevelUpApiException on refund with bad Qr data but did not catch it!"); } catch (LevelUpApiException) { } // Cleanup, refund the order. refundData = new DetachedRefundRequestBody(LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, refundAmountCents); refundInterface.CreateDetachedRefund(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, refundData); }
public void CreateDetachedRefundShouldFailDeserialization() { // Note: This test is not really specific to Detached Refunds. RestResponse expectedResponse = new RestResponse { StatusCode = HttpStatusCode.OK, Content = "{{" + "\"detached_refund\": {{" + "\"cashier\": \"blah\"," + "}}" + "}}" }; ICreateDetachedRefund client = ClientModuleUnitTestingUtilities.GetMockedLevelUpModule <ICreateDetachedRefund>(expectedResponse); var resp = client.CreateDetachedRefund("we", 0, "are", 0, "not", "checking", "any", "of", "these", "strings"); }
public void CreateDetachedRefund() { ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount(); const int refundAmountCents = 50; ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(refundAmountCents); ICreateDetachedRefund refundInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateDetachedRefund>(); var refundData = new DetachedRefundRequestBody(LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, refundAmountCents); var refund = refundInterface.CreateDetachedRefund(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, refundData); Assert.AreEqual(refund.CreditAmountCents, refundAmountCents); }
public void CreateDetachedRefundShouldFailDeserialization() { // Note: This test is not really specific to Detached Refunds. RestResponse expectedResponse = new RestResponse { StatusCode = HttpStatusCode.OK, Content = "{{" + "\"detached_refund\": {{" + "\"cashier\": \"blah\"," + "}}" + "}}" }; ICreateDetachedRefund client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule <ICreateDetachedRefund>(expectedResponse); Assert.Throws <LevelUpApiException>(() => { var resp = client.CreateDetachedRefund("we", 0, "are", 0, "not", "checking", "any", "of", "these", "strings"); }, "No LevelUpAPI exception was thrown for an invalid response body."); }
public void CreateDetachedRefundShouldSucceed() { const string expectedRequestUrl = ClientModuleFunctionalTestingUtilities.SANDBOX_URL_PREFIX + "/v15/detached_refunds"; const string accessToken = "abcdef"; const string cashier = "Andrew Jones"; const string customer_facing_reason = "Sorry about your coffee!"; const string identifier_from_merchant = "001001"; const string internal_reason = "Andrew didn't like his coffee"; const string manager_confirmation = "12345"; const string payment_token_data = "LU020000029080KFZ02I9A8V030000LU"; const string register = "03"; const string refunded_at = "2014-01-01T00:00:00-04:00"; const int credit_amount = 743; const int location_id = 1855; const int loyalty_id = 123; string expectedRequestBody = string.Format("{{" + "\"detached_refund\": {{" + "\"cashier\": \"{0}\"," + "\"credit_amount\": {1}," + "\"customer_facing_reason\": \"{2}\"," + "\"identifier_from_merchant\": \"{3}\"," + "\"internal_reason\": \"{4}\"," + "\"location_id\": {5}," + "\"manager_confirmation\": \"{6}\"," + "\"payment_token_data\": \"{7}\"," + "\"register\": \"{8}\"" + "}}" + "}}", cashier, credit_amount, customer_facing_reason, identifier_from_merchant, internal_reason, location_id, manager_confirmation, payment_token_data, register); RestResponse expectedResponse = new RestResponse { StatusCode = HttpStatusCode.OK, Content = string.Format("{{" + "\"detached_refund\": {{" + "\"cashier\": \"{0}\"," + "\"credit_amount\": {1}," + "\"customer_facing_reason\": \"{2}\"," + "\"identifier_from_merchant\": \"{3}\"," + "\"internal_reason\": \"{4}\"," + "\"location_id\": {5}," + "\"loyalty_id\": \"{6}\"," + "\"refunded_at\": \"{7}\"," + "\"register\": \"{8}\"" + "}}" + "}}", cashier, credit_amount, customer_facing_reason, identifier_from_merchant, internal_reason, location_id, loyalty_id, refunded_at, register) }; ICreateDetachedRefund client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule <ICreateDetachedRefund, DetachedRefundRequest>( expectedResponse, expectedRequestBody, expectedAccessToken: accessToken, expectedRequestUrl: expectedRequestUrl); var resp = client.CreateDetachedRefund(accessToken, location_id, payment_token_data, credit_amount, register, cashier, identifier_from_merchant, manager_confirmation, customer_facing_reason, internal_reason); Assert.AreEqual(resp.Cashier, cashier); Assert.AreEqual(resp.CreditAmountCents, credit_amount); Assert.AreEqual(resp.CustomerFacingReason, customer_facing_reason); Assert.AreEqual(resp.Identifier, identifier_from_merchant); Assert.AreEqual(resp.InternalReason, internal_reason); Assert.AreEqual(resp.LocationId, location_id); Assert.AreEqual(resp.UserId, loyalty_id); Assert.AreEqual(resp.RefundedAt, DateTime.Parse(refunded_at)); Assert.AreEqual(resp.Register, register); }