public void TestBasicXml() { _order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetCurrency(TestingTool.DefaultTestCurrency) .AddCustomerDetails(Item.IndividualCustomer() .SetNationalIdNumber(TestingTool.DefaultTestIndividualNationalIdNumber)) .AddOrderRow(Item.OrderRow() .SetAmountExVat(4) .SetVatPercent(25) .SetQuantity(1)); var payment = new FakeHostedPayment(_order); payment.SetReturnUrl("http://myurl.se") .CalculateRequestValues(); _xml = _xmlBuilder.GetXml(payment); const string expectedXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--Message generated by Integration package C#-->" + "<payment><customerrefno>33</customerrefno><currency>SEK</currency><amount>500</amount>" + "<vat>100</vat><lang>en</lang><returnurl>http://myurl.se</returnurl><iscompany>false</iscompany>" + "<customer><ssn>194605092222</ssn><country>SE</country></customer><orderrows><row><sku /><name />" + "<description /><amount>500</amount><vat>100</vat><quantity>1</quantity></row></orderrows>" + "<excludepaymentMethods /><addinvoicefee>false</addinvoicefee></payment>"; Assert.That(_xml, Is.EqualTo(expectedXml)); }
public void TestAmountIncVatAndAmountExVatCalculation() { CreateOrderBuilder order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .AddOrderRow(TestingTool.CreateMiniOrderRow()); order.SetShippingFeeRows(null); order.SetFixedDiscountRows(null); order.SetRelativeDiscountRows(null); var payment = new FakeHostedPayment(order); payment .SetReturnUrl("myurl") .CalculateRequestValues(); Assert.That(payment.GetAmount(), Is.EqualTo(500L)); }
public void TestCalculateRequestValuesNullExtraRows() { CreateOrderBuilder order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .AddOrderRow(Item.OrderRow() .SetAmountExVat(4) .SetVatPercent(25) .SetQuantity(1)) .AddFee(Item.ShippingFee()) .AddDiscount(Item.FixedDiscount()) .AddDiscount(Item.RelativeDiscount()); var payment = new FakeHostedPayment(order); payment .SetReturnUrl("myurl") .CalculateRequestValues(); Assert.That(payment.GetAmount(), Is.EqualTo(500)); }
public void TestCreatePaymentForm() { CreateOrderBuilder order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .AddOrderRow(Item.OrderRow() .SetAmountExVat(4) .SetVatPercent(25) .SetQuantity(1)) .AddCustomerDetails(TestingTool.CreateCompanyCustomer()); var payment = new FakeHostedPayment(order); payment.SetReturnUrl("myurl"); PaymentForm form = payment.GetPaymentForm(); var formHtmlFields = form.GetFormHtmlFields(); Assert.That(formHtmlFields["form_end_tag"], Is.EqualTo("</form>")); }
public void TestXmlWithIndividualCustomer() { _order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetCurrency(TestingTool.DefaultTestCurrency) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .AddOrderRow(Item.OrderRow() .SetAmountExVat(4) .SetVatPercent(25) .SetQuantity(1)) .AddCustomerDetails(Item.IndividualCustomer() .SetName("Julius", "Caesar") .SetInitials("JS") .SetNationalIdNumber("666666") .SetPhoneNumber("999999") .SetEmail("*****@*****.**") .SetIpAddress("123.123.123.123") .SetStreetAddress("Gatan", "23") .SetCoAddress("c/o Eriksson") .SetZipCode("9999") .SetLocality("Stan")); var payment = new FakeHostedPayment(_order); payment.SetReturnUrl("http://myurl.se") .CalculateRequestValues(); _xml = _xmlBuilder.GetXml(payment); const string expectedString = "<customer><ssn>666666</ssn><firstname>Julius</firstname>" + "<lastname>Caesar</lastname><initials>JS</initials>" + "<phone>999999</phone><email>[email protected]</email>" + "<address>Gatan</address><housenumber>23</housenumber>" + "<address2>c/o Eriksson</address2><zip>9999</zip>" + "<city>Stan</city><country>SE</country></customer>"; Assert.That(_xml.Contains(expectedString), Is.True); Assert.That(_xml.Contains("<ipaddress>123.123.123.123</ipaddress>"), Is.True); }
public void TestXmlWithCompanyCustomer() { _order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(Item.OrderRow() .SetAmountExVat(4) .SetVatPercent(25) .SetQuantity(1)) .SetCurrency(TestingTool.DefaultTestCurrency) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCountryCode(TestingTool.DefaultTestCountryCode) .AddCustomerDetails(TestingTool.CreateCompanyCustomer()); var payment = new FakeHostedPayment(_order); payment.SetReturnUrl("http://myurl.se") .CalculateRequestValues(); _xml = _xmlBuilder.GetXml(payment); const string expectedString = "<customer><ssn>164608142222</ssn><firstname>Tess, T Persson</firstname>" + "<phone>0811111111</phone><email>[email protected]</email>" + "<address>Testgatan</address><housenumber>1</housenumber>" + "<address2>c/o Eriksson, Erik</address2><zip>99999</zip>" + "<city>Stan</city><country>SE</country></customer>"; Assert.That(_xml.Contains(expectedString), Is.True); Assert.That(_xml.Contains("<ipaddress>123.123.123.123</ipaddress>"), Is.True); }
public void TestVatPercentAndAmountIncVatCalculation() { CreateOrderBuilder order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .AddOrderRow(Item.OrderRow() .SetAmountIncVat(5) .SetVatPercent(25) .SetQuantity(1)); order.SetShippingFeeRows(null); order.SetFixedDiscountRows(null); order.SetRelativeDiscountRows(null); var payment = new FakeHostedPayment(order); payment .SetReturnUrl("myUrl") .CalculateRequestValues(); Assert.That(payment.GetAmount(), Is.EqualTo(500)); }
public void TestCreatePaymentForm() { CreateOrderBuilder order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .AddOrderRow(Item.OrderRow() .SetAmountExVat(4) .SetVatPercent(25) .SetQuantity(1)) .AddCustomerDetails(TestingTool.CreateCompanyCustomer()); var payment = new FakeHostedPayment(order); payment.SetReturnUrl("myurl"); PaymentForm form = payment.GetPaymentForm(); var formHtmlFields = form.GetFormHtmlFields(); Assert.That(formHtmlFields["form_end_tag"], Is.EqualTo("</form>")); }