public void IdempotencyKeyNotPresentInHeaderIfExcluded() { var httpWebRequest = _httpUrlConnectionClient.GetHttpWebRequest(_endpoint, MockPaymentData.CreateConfingApiKeyBasedMock(), true); Assert.IsNull(httpWebRequest.Headers["Idempotency-Key"]); }
public void ApiKeyBasedHeadersTest() { var httpWebRequest = _httpUrlConnectionClient.GetHttpWebRequest(_endpoint, MockPaymentData.CreateConfingApiKeyBasedMock(), true); Assert.IsNotNull(httpWebRequest.UserAgent); Assert.AreEqual(httpWebRequest.Address, _endpoint); Assert.AreEqual(httpWebRequest.Headers["Accept-Charset"], "UTF-8"); Assert.AreEqual(httpWebRequest.Headers["Cache-Control"], "no-cache"); Assert.AreEqual(httpWebRequest.ContentType, "application/json"); Assert.IsNull(httpWebRequest.Headers["Authorization"]); Assert.IsFalse(httpWebRequest.UseDefaultCredentials); Assert.IsNotNull(httpWebRequest.Headers["x-api-key"]); Assert.AreEqual(httpWebRequest.Headers["x-api-key"], "AQEyhmfxK....LAG84XwzP5pSpVd"); }
public void BasicAuthenticationHeadersTest() { var httpWebRequest = _httpUrlConnectionClient.GetHttpWebRequest(_endpoint, MockPaymentData.CreateConfingMock(), false); Assert.IsNotNull(httpWebRequest.UserAgent); Assert.AreEqual(httpWebRequest.Address, _endpoint); Assert.AreEqual(httpWebRequest.Headers["Accept-Charset"], "UTF-8"); Assert.AreEqual(httpWebRequest.Headers["Cache-Control"], "no-cache"); Assert.AreEqual(httpWebRequest.ContentType, "application/json"); Assert.IsNotNull(httpWebRequest.Headers["Authorization"]); Assert.IsTrue(httpWebRequest.UseDefaultCredentials); Assert.AreEqual(httpWebRequest.Headers["Cache-Control"], "no-cache"); Assert.IsNull(httpWebRequest.Headers["x-api-key"]); }
public void IdempotencyKeyPresentInHeaderIfSpecified() { var requestOptions = new RequestOptions { IdempotencyKey = "idempotencyKey" }; var httpWebRequest = _httpUrlConnectionClient.GetHttpWebRequest(_endpoint, MockPaymentData.CreateConfingApiKeyBasedMock(), true, requestOptions); Assert.IsNotNull(httpWebRequest.Headers["Idempotency-Key"]); Assert.AreEqual(requestOptions.IdempotencyKey, httpWebRequest.Headers["Idempotency-Key"]); }
public void IdempotencyKeyNotPresentInHeaderIfWhitespaceString() { var requestOptions = new RequestOptions { IdempotencyKey = " " }; var httpWebRequest = _httpUrlConnectionClient.GetHttpWebRequest(_endpoint, MockPaymentData.CreateConfingApiKeyBasedMock(), true, requestOptions); Assert.IsNull(httpWebRequest.Headers["Idempotency-Key"]); }
public static PaymentRequest CreateOpenInvoicePaymentRequest() { DateTime dateOfBirth = DateTime.Parse("1970-07-10"); PaymentRequest paymentRequest = MockPaymentData.CreateFullPaymentRequest(); // Set Shopper Data paymentRequest.ShopperEmail = "*****@*****.**"; paymentRequest.DateOfBirth = dateOfBirth; paymentRequest.TelephoneNumber = "0612345678"; paymentRequest.ShopperReference = "4"; // Set Shopper Info Name shopperName = new Name { FirstName = "Testperson-nl", LastName = "Approved", Gender = GenderEnum.MALE }; paymentRequest.ShopperName = shopperName; // Set Billing and Delivery address Address address = new Address { City = "Gravenhage", Country = "NL", HouseNumberOrName = "1", PostalCode = "2521VA", StateOrProvince = "Zuid-Holland", Street = "Neherkade" }; paymentRequest.DeliveryAddress = address; paymentRequest.BillingAddress = address; // Use OpenInvoice Provider (klarna, ratepay) paymentRequest.SelectedBrand = "klarna"; long itemAmount = long.Parse("9000"); long itemVatAmount = long.Parse("1000"); long itemVatPercentage = long.Parse("1000"); List <InvoiceLine> invoiceLines = new List <InvoiceLine>(); // invoiceLine1 InvoiceLine invoiceLine = new InvoiceLine { CurrencyCode = ("EUR"), Description = ("Test product"), VatAmount = (itemVatAmount), ItemAmount = (itemAmount), ItemVatPercentage = (itemVatPercentage), VatCategory = (VatCategory.None), NumberOfItems = (1), ItemId = ("1234") }; // invoiceLine2 // invoiceLine1 InvoiceLine invoiceLine2 = new InvoiceLine { CurrencyCode = ("EUR"), Description = ("Test product2"), VatAmount = (itemVatAmount), ItemAmount = (itemAmount), ItemVatPercentage = (itemVatPercentage), VatCategory = (VatCategory.None), NumberOfItems = (1), ItemId = ("456") }; invoiceLines.Add(invoiceLine); invoiceLines.Add(invoiceLine2); paymentRequest.InvoiceLines(invoiceLines); return(paymentRequest); }