public void GetCustomerList() { var startTime = DateTime.UtcNow.AddMinutes(-5); // records for the past 5 minutes var customer1 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var customer2 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var customer3 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var customer4 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var custGetListRequest = new CustomerGetList { FromDate = startTime, ToDate = DateTime.UtcNow }; // Get all customers created var response = CheckoutClient.CustomerService.GetCustomerList(custGetListRequest); response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Count.Should().BeGreaterOrEqualTo(4); // Verify if customers are contained in the customer list regardless of parallel customer creation and sorting response.Model.Data.ToString().Should().Contain(customer1.Model.ToString()); response.Model.Data.ToString().Should().Contain(customer2.Model.ToString()); response.Model.Data.ToString().Should().Contain(customer3.Model.ToString()); response.Model.Data.ToString().Should().Contain(customer4.Model.ToString()); }
public void GetCustomer(string method) { var customerCreateModel = TestHelper.GetCustomerCreateModelWithCard(); var customer = CheckoutClient.CustomerService.CreateCustomer(customerCreateModel).Model; string identifier = ""; switch (method) { case "Id": identifier = customer.Id; break; case "Email": identifier = customer.Email; break; default: throw new InvalidOperationException("Unknown method for Unit Test GetCustomer(string method). method must be either 'Id' or 'Email'."); } var response = CheckoutClient.CustomerService.GetCustomer(identifier); response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Id.Should().Be(customer.Id); response.Model.Id.Should().StartWith("cust_"); }
public void GetCustomerList() { var startTime = DateTime.UtcNow.AddHours(-1); // records for the past hour var customer1 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var customer2 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var customer3 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var customer4 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var custGetListRequest = new CustomerGetList { FromDate = startTime, ToDate = DateTime.UtcNow }; //Get all customers created var response = CheckoutClient.CustomerService.GetCustomerList(custGetListRequest); response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Count.Should().BeGreaterOrEqualTo(4); response.Model.Data[0].Id.Should().Be(customer4.Model.Id); response.Model.Data[1].Id.Should().Be(customer3.Model.Id); response.Model.Data[2].Id.Should().Be(customer2.Model.Id); response.Model.Data[3].Id.Should().Be(customer1.Model.Id); }
public void CreateChargeWithCardId() { var customer = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()).Model; var cardIdChargeCreateModel = TestHelper.GetCardIdChargeCreateModel(customer.Cards.Data[0].Id, customer.Email); var response = CheckoutClient.ChargeService.ChargeWithCardId(cardIdChargeCreateModel); ////Check if charge details match Assert.NotNull(response); Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(response.Model.Id.StartsWith("charge_")); Assert.IsTrue(response.Model.AutoCapTime == cardIdChargeCreateModel.AutoCapTime); Assert.IsTrue(response.Model.AutoCapture.Equals(cardIdChargeCreateModel.AutoCapture, System.StringComparison.OrdinalIgnoreCase)); Assert.IsTrue(response.Model.Email.Equals(cardIdChargeCreateModel.Email, System.StringComparison.OrdinalIgnoreCase)); Assert.IsTrue(response.Model.Currency.Equals(cardIdChargeCreateModel.Currency, System.StringComparison.OrdinalIgnoreCase)); Assert.IsTrue(response.Model.Description.Equals(cardIdChargeCreateModel.Description, System.StringComparison.OrdinalIgnoreCase)); Assert.IsTrue(response.Model.Value == cardIdChargeCreateModel.Value); Assert.IsTrue(response.Model.Card.Id == cardIdChargeCreateModel.CardId); Assert.IsNotNullOrEmpty(response.Model.Status); Assert.IsNotNullOrEmpty(response.Model.AuthCode); Assert.IsNotNullOrEmpty(response.Model.ResponseCode); }
public void CreateChargeWithCardId() { var customer = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()).Model; var cardIdChargeCreateModel = TestHelper.GetCardIdChargeCreateModel(customer.Cards.Data[0].Id, customer.Email); var response = CheckoutClient.ChargeService.ChargeWithCardId(cardIdChargeCreateModel); ////Check if charge details match response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Id.Should().StartWith("charge_"); response.Model.AutoCapTime.Should().Be(cardIdChargeCreateModel.AutoCapTime); response.Model.AutoCapture.Should().BeEquivalentTo(cardIdChargeCreateModel.AutoCapture); response.Model.Email.Should().BeEquivalentTo(cardIdChargeCreateModel.Email); response.Model.Currency.Should().BeEquivalentTo(cardIdChargeCreateModel.Currency); response.Model.Description.Should().BeEquivalentTo(cardIdChargeCreateModel.Description); response.Model.Value.Should().Be(cardIdChargeCreateModel.Value); response.Model.Card.Id.Should().Be(cardIdChargeCreateModel.CardId); response.Model.Status.Should().NotBeNullOrEmpty(); response.Model.AuthCode.Should().NotBeNullOrEmpty(); response.Model.ResponseCode.Should().NotBeNullOrEmpty(); }
public void GetCustomerList() { var startTime = DateTime.UtcNow.AddHours(-1);// records for the past hour var customer1 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var customer2 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var customer3 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var customer4 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()); var custGetListRequest = new CustomerGetList() { FromDate = startTime, ToDate = DateTime.UtcNow }; //Get all customers created var response = CheckoutClient.CustomerService.GetCustomerList(custGetListRequest); Assert.NotNull(response); Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(response.Model.Count >= 4); Assert.IsTrue(response.Model.Data[0].Id == customer4.Model.Id); Assert.IsTrue(response.Model.Data[1].Id == customer3.Model.Id); Assert.IsTrue(response.Model.Data[2].Id == customer2.Model.Id); Assert.IsTrue(response.Model.Data[3].Id == customer1.Model.Id); }
public void UpdateCustomer() { var customer = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()).Model; var customerUpdateModel = TestHelper.GetCustomerUpdateModel(); var response = CheckoutClient.CustomerService.UpdateCustomer(customer.Id, customerUpdateModel); response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Message.Should().BeEquivalentTo("Ok"); }
public void DeleteCustomer() { var customer = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()).Model; var response = CheckoutClient.CustomerService.DeleteCustomer(customer.Id); Assert.NotNull(response); Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(response.Model.Message.Equals("Ok", System.StringComparison.OrdinalIgnoreCase)); }
public void DeleteOnlyCard() { var customer = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()).Model; var customerOnlyCardId = customer.Cards.Data.First().Id; var response = CheckoutClient.CardService.DeleteCard(customer.Id, customerOnlyCardId); response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.BadRequest); response.Error.ErrorCode.Should().BeEquivalentTo("83041"); }
public void CreateCustomerWithCard() { var customerCreateModel = TestHelper.GetCustomerCreateModelWithCard(); var response = CheckoutClient.CustomerService.CreateCustomer(customerCreateModel); Assert.NotNull(response); Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(response.Model.Id.StartsWith("cust_")); Assert.IsTrue(ReflectionHelper.CompareProperties(customerCreateModel, response.Model, new string[] { "Card" })); Assert.IsTrue(ReflectionHelper.CompareProperties(customerCreateModel.Card, response.Model.Cards.Data[0], new string[] { "Number", "Cvv", "DefaultCard" })); }
public void DeleteSecondaryCard() { var customer = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()).Model; var customerPrimaryCardId = customer.Cards.Data.First().Id; var customerSecondaryCardId = CheckoutClient.CardService.CreateCard(customer.Id, TestHelper.GetCardCreateModel(CardProvider.Mastercard)).Model.Id; var response = CheckoutClient.CardService.DeleteCard(customer.Id, customerSecondaryCardId); response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Message.Should().BeEquivalentTo("Ok"); }
public void CreateCustomerWithCard() { var customerCreateModel = TestHelper.GetCustomerCreateModelWithCard(); var response = CheckoutClient.CustomerService.CreateCustomer(customerCreateModel); response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Id.Should().StartWith("cust_"); customerCreateModel.ShouldBeEquivalentTo(response.Model, options => options.Excluding(x => x.Card)); customerCreateModel.Card.ShouldBeEquivalentTo(response.Model.Cards.Data[0], options => options.Excluding(c => c.Number).Excluding(c => c.Cvv).Excluding(c => c.DefaultCard)); }
public void GetCustomer() { var customerCreateModel = TestHelper.GetCustomerCreateModelWithCard(); var customer = CheckoutClient.CustomerService.CreateCustomer(customerCreateModel).Model; var response = CheckoutClient.CustomerService.GetCustomer(customer.Id); response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Id.Should().Be(customer.Id); response.Model.Id.Should().StartWith("cust_"); customer.ShouldBeEquivalentTo(response.Model); }
public void GetCustomer() { var customerCreateModel = TestHelper.GetCustomerCreateModelWithCard(); var customer = CheckoutClient.CustomerService.CreateCustomer(customerCreateModel).Model; var response = CheckoutClient.CustomerService.GetCustomer(customer.Id); Assert.NotNull(response); Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(response.Model.Id == customer.Id); Assert.IsTrue(response.Model.Id.StartsWith("cust_")); Assert.IsTrue(ReflectionHelper.CompareProperties(customer, response.Model)); }
public void GetCard() { var customerCreateModel = TestHelper.GetCustomerCreateModelWithCard(); var customer = CheckoutClient.CustomerService.CreateCustomer(customerCreateModel).Model; var customerCard = customer.Cards.Data.First(); var response = CheckoutClient.CardService.GetCard(customer.Id, customerCard.Id); Assert.NotNull(response); Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(response.Model.Id == customerCard.Id); Assert.IsTrue(response.Model.CustomerId.Equals(customer.Id, System.StringComparison.OrdinalIgnoreCase)); Assert.IsTrue(response.Model.Name == customerCard.Name); Assert.IsTrue(response.Model.ExpiryMonth == customerCard.ExpiryMonth); Assert.IsTrue(response.Model.ExpiryYear == customerCard.ExpiryYear); Assert.IsTrue(customerCreateModel.Card.Number.EndsWith(response.Model.Last4)); Assert.IsTrue(ReflectionHelper.CompareProperties(customerCard.BillingDetails, response.Model.BillingDetails)); }
public void GetCard() { var customerCreateModel = TestHelper.GetCustomerCreateModelWithCard(); var customer = CheckoutClient.CustomerService.CreateCustomer(customerCreateModel).Model; var customerCard = customer.Cards.Data.First(); var response = CheckoutClient.CardService.GetCard(customer.Id, customerCard.Id); response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Id.Should().Be(customerCard.Id); response.Model.CustomerId.Should().BeEquivalentTo(customer.Id); response.Model.Name.Should().Be(customerCard.Name); response.Model.ExpiryMonth.Should().Be(customerCard.ExpiryMonth); response.Model.ExpiryYear.Should().Be(customerCard.ExpiryYear); customerCreateModel.Card.Number.Should().EndWith(response.Model.Last4); customerCard.BillingDetails.ShouldBeEquivalentTo(response.Model.BillingDetails); }
public void FailPayout() { // Create Customer with Card var customerCreateModel = TestHelper.GetCustomerCreateModelWithCard(CardProvider.Mastercard); var customer = CheckoutClient.CustomerService.CreateCustomer(customerCreateModel).Model; var customerId = customer.Id; var cardId = customer.Cards.Data[0].Id; var cardholderName = customer.Cards.Data[0].Name; var cardholderFirstName = cardholderName.Split(' ').First(); var cardholderLastName = cardholderName.Split(' ').Last(); // Make Payout var payoutsCreateModel = TestHelper.GetPayoutModel(cardId, cardholderFirstName, cardholderLastName, "DUCKS"); var payoutResponse = CheckoutClient.PayoutsService.MakePayout(payoutsCreateModel); var payout = payoutResponse.Error; payoutResponse.HttpStatusCode.Should().Be(HttpStatusCode.BadRequest); payoutResponse.HasError.Should().BeTrue("HasError should be set to True since response should be of type ErrorResponse"); payout.ErrorCode.Should().Be("70000"); payout.Errors.Should().NotBeEmpty(); }
public void CreateChargeWithCardId_N3DChargeMode() { var customer = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()).Model; var cardIdChargeCreateModel = TestHelper.GetCardIdChargeCreateModel(customer.Cards.Data[0].Id, customer.Email); cardIdChargeCreateModel.ChargeMode = 1; cardIdChargeCreateModel.AttemptN3D = true; var response = CheckoutClient.ChargeService.ChargeWithCardId(cardIdChargeCreateModel); //Check if charge details match response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Id.Should().StartWith("charge_test"); response.Model.ChargeMode.Should().Be(1); response.Model.AttemptN3D.Should().BeTrue(); //response.Model.RedirectUrl.Should().StartWith("http"); // only use if redirect URL is configured response.Model.ResponseCode.Should().NotBeNullOrEmpty(); response.Model.TrackId.ShouldBeEquivalentTo(cardIdChargeCreateModel.TrackId); }
public void CreateChargeWithCardId_3DChargeMode() { var customer = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard()).Model; var cardIdChargeCreateModel = TestHelper.GetCardIdChargeCreateModel(customer.Cards.Data[0].Id, customer.Email); cardIdChargeCreateModel.ChargeMode = 2; var response = CheckoutClient.ChargeService.ChargeWithCardId(cardIdChargeCreateModel); //Check if charge details match response.Should().NotBeNull(); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); response.Model.Id.Should().StartWith("pay_tok"); response.Model.ChargeMode.Should().Be(2); response.Model.RedirectUrl.Should().StartWith("http"); response.Model.ResponseCode.Should().NotBeNullOrEmpty(); response.Model.TrackId.ShouldBeEquivalentTo(cardIdChargeCreateModel.TrackId); }
public void MakePayout() { // Create Customer with Card var customerCreateModel = TestHelper.GetCustomerCreateModelWithCard(CardProvider.Mastercard); var customer = CheckoutClient.CustomerService.CreateCustomer(customerCreateModel).Model; var customerId = customer.Id; var cardId = customer.Cards.Data[0].Id; var cardholderName = customer.Cards.Data[0].Name; var cardholderFirstName = cardholderName.Split(' ').First(); var cardholderLastName = cardholderName.Split(' ').Last(); // Make Payout var payoutsCreateModel = TestHelper.GetPayoutModel(cardId, cardholderFirstName, cardholderLastName); var payoutResponse = CheckoutClient.PayoutsService.MakePayout(payoutsCreateModel); var payout = payoutResponse.Model; payoutResponse.HttpStatusCode.Should().Be(HttpStatusCode.OK); payoutResponse.HasError.Should().BeFalse("HasError should only be set to True if response is an ErrorResponse"); payout.ResponseCode.Should().Be("10000"); payout.Status.Should().Be("Authorised"); payout.ResponseSummary.Should().Be("Approved"); payout.ResponseDetails.Should().Be("Approved"); }