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 TestExcludeInvoicesAndAllInstallmentsAllCountries() { var payment = new FakeHostedPayment(null); var exclude = new ExcludePayments(); List <string> excludedPaymentMethod = payment.GetExcludedPaymentMethod(); excludedPaymentMethod.AddRange(exclude.ExcludeInvoicesAndPaymentPlan()); var expectedValues = new List <string> { InvoiceType.INVOICESE.Value, InvoiceType.INVOICEEUSE.Value, PaymentPlanType.PAYMENTPLANSE.Value, PaymentPlanType.PAYMENTPLANEUSE.Value, InvoiceType.INVOICEDE.Value, PaymentPlanType.PAYMENTPLANDE.Value, InvoiceType.INVOICEDK.Value, PaymentPlanType.PAYMENTPLANDK.Value, InvoiceType.INVOICEFI.Value, PaymentPlanType.PAYMENTPLANFI.Value, InvoiceType.INVOICENL.Value, PaymentPlanType.PAYMENTPLANNL.Value, InvoiceType.INVOICENO.Value, PaymentPlanType.PAYMENTPLANNO.Value }; Assert.That(excludedPaymentMethod, Is.EqualTo(expectedValues)); }
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 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)); }
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 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 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 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 TestExcludeInvoicesAndAllInstallmentsAllCountries() { var payment = new FakeHostedPayment(null); var exclude = new ExcludePayments(); List<string> excludedPaymentMethod = payment.GetExcludedPaymentMethod(); excludedPaymentMethod.AddRange(exclude.ExcludeInvoicesAndPaymentPlan()); var expectedValues = new List<string> { InvoiceType.INVOICESE.Value, InvoiceType.INVOICEEUSE.Value, PaymentPlanType.PAYMENTPLANSE.Value, PaymentPlanType.PAYMENTPLANEUSE.Value, InvoiceType.INVOICEDE.Value, PaymentPlanType.PAYMENTPLANDE.Value, InvoiceType.INVOICEDK.Value, PaymentPlanType.PAYMENTPLANDK.Value, InvoiceType.INVOICEFI.Value, PaymentPlanType.PAYMENTPLANFI.Value, InvoiceType.INVOICENL.Value, PaymentPlanType.PAYMENTPLANNL.Value, InvoiceType.INVOICENO.Value, PaymentPlanType.PAYMENTPLANNO.Value }; Assert.That(excludedPaymentMethod, Is.EqualTo(expectedValues)); }