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>194608142222</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 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 TestOrderRowXml() { _order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(Item.OrderRow() .SetArticleNumber("0") .SetName("Product") .SetDescription("Good product") .SetAmountExVat(4) .SetVatPercent(25) .SetQuantity(1) .SetUnit("kg")) .AddCustomerDetails(Item.CompanyCustomer()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetCurrency(TestingTool.DefaultTestCurrency) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber); var payment = new FakeHostedPayment(_order); payment.SetPayPageLanguageCode(LanguageCode.sv) .SetReturnUrl("http://myurl.se") .CalculateRequestValues(); _xml = _xmlBuilder.GetXml(payment); const string expectedString = "<orderrows><row><sku>0</sku><name>Product</name>" + "<description>Good product</description><amount>500</amount>" + "<vat>100</vat><quantity>1</quantity><unit>kg</unit></row></orderrows>"; Assert.That(_xml.Contains(expectedString), Is.True); }
public void TestXmlCancelUrl() { _order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetCurrency(TestingTool.DefaultTestCurrency) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .AddOrderRow(TestingTool.CreateMiniOrderRow()) .AddCustomerDetails(Item.CompanyCustomer()); var payment = new FakeHostedPayment(_order); payment.SetCancelUrl("http://www.cancel.com") .SetReturnUrl("http://myurl.se") .CalculateRequestValues(); _xml = _xmlBuilder.GetXml(payment); Assert.That(_xml.Contains("<cancelurl>http://www.cancel.com</cancelurl>"), Is.True); }
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 TestFailOnMissingReturnUrl() { const string expectedMessage = "MISSING VALUE - Return url is required, SetReturnUrl(...).\n"; var exception = Assert.Throws <SveaWebPayValidationException>(() => { 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.CalculateRequestValues(); }); Assert.That(exception.Message, Is.EqualTo(expectedMessage)); }