public void TestPayPagePaymentWithSetPaymentMethodSveaCardPayPF() { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(Item.IndividualCustomer() .SetNationalIdNumber(TestingTool.DefaultTestIndividualNationalIdNumber)) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetOrderDate(TestingTool.DefaultTestDate) .SetCurrency(TestingTool.DefaultTestCurrency) .SetCustomerReference(TestingTool.DefaultTestCustomerReferenceNumber) .UsePaymentMethod(PaymentMethod.SVEACARDPAY_PF) .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string xml = form.GetXmlMessage(); const string expectedXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<!--Message generated by Integration package C#--><payment><paymentmethod>SVEACARDPAY_PF</paymentmethod><customerrefno>33</customerrefno><currency>SEK</currency><amount>12500</amount><vat>2500</vat><lang>en</lang><returnurl>http://myurl.se</returnurl><iscompany>false</iscompany><customer><unknowncustomer>true</unknowncustomer><country>SE</country></customer><orderrows><row><sku>1</sku><name>Prod</name><description>Specification</description><amount>12500</amount><vat>2500</vat><quantity>2</quantity><unit>st</unit></row><row><sku>1</sku><name>Relative</name><description>RelativeDiscount</description><amount>-12500</amount><vat>-2500</vat><quantity>1</quantity><unit>st</unit></row></orderrows><excludepaymentMethods /><addinvoicefee>false</addinvoicefee></payment>"; Assert.That(xml, Is.EqualTo(expectedXml)); string base64Payment = form.GetXmlMessageBase64(); string html = Base64Util.DecodeBase64String(base64Payment); Assert.That(html.Contains("<paymentmethod>SVEACARDPAY_PF</paymentmethod>"), Is.True); }
public void TestPayPagePaymentIncludePaymentMethodEmpty() { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails( Item.IndividualCustomer().SetNationalIdNumber(TestingTool.DefaultTestIndividualNationalIdNumber)) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetOrderDate(TestingTool.DefaultTestDate) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePayPage() .IncludePaymentMethod() .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string xml = form.GetXmlMessage(); string paymentMethod = xml.Substring( xml.IndexOf("SVEAINVOICESE", System.StringComparison.InvariantCulture), "SVEAINVOICESE".Length); string paymentMethod2 = xml.Substring( xml.IndexOf("DBSWEDBANKSE", System.StringComparison.InvariantCulture), "DBSWEDBANKSE".Length); Assert.That(paymentMethod, Is.EqualTo(InvoiceType.INVOICESE.Value)); Assert.That(paymentMethod2, Is.EqualTo(PaymentMethod.SWEDBANKSE.Value)); }
public void TestFailMissingIdentityInHostedDe() { const string expectedMessage = "MISSING VALUE - Birth date is required for individual customers when countrycode is DE. Use SetBirthDate().\n" + "MISSING VALUE - Name is required for individual customers when countrycode is DE. Use SetName().\n" + "MISSING VALUE - Street address is required for all customers when countrycode is DE. Use SetStreetAddress().\n" + "MISSING VALUE - Locality is required for all customers when countrycode is DE. Use SetLocality().\n" + "MISSING VALUE - Zip code is required for all customers when countrycode is DE. Use SetCustomerZipCode().\n"; var exception = Assert.Throws <SveaWebPayValidationException>(() => WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(Item.IndividualCustomer()) .SetCountryCode(CountryCode.DE) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetOrderDate(TestingTool.DefaultTestDate) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePaymentMethod( PaymentMethod.INVOICE) .SetReturnUrl( "http://myurl.se") .GetPaymentForm()); Assert.That(exception.Message, Is.EqualTo(expectedMessage)); }
public void TestBuildCardPaymentDe() { PaymentForm form = _order.AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddCustomerDetails(TestingTool.CreateMiniCompanyCustomer()) .AddFee(TestingTool.CreateExVatBasedShippingFee()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .SetCountryCode(CountryCode.DE) .SetOrderDate(TestingTool.DefaultTestDate) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePayPageCardOnly() .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string xml = form.GetXmlMessage(); const string expectedAmount = "18750"; const string expectedVat = "3750"; string amount = xml.Substring(xml.IndexOf("<amount>", System.StringComparison.InvariantCulture) + 8, expectedAmount.Length); string vat = xml.Substring(xml.IndexOf("<vat>", System.StringComparison.InvariantCulture) + 5, expectedVat.Length); Assert.That(amount, Is.EqualTo(expectedAmount)); Assert.That(vat, Is.EqualTo(expectedVat)); }
public void TestPayPagePaymentIncludePaymentMethod() { var paymentMethods = new List <PaymentMethod> { PaymentMethod.KORTCERT, PaymentMethod.SKRILL }; PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails( Item.IndividualCustomer().SetNationalIdNumber(TestingTool.DefaultTestIndividualNationalIdNumber)) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetOrderDate(TestingTool.DefaultTestDate) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePayPage() .IncludePaymentMethod(paymentMethods) .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string xml = form.GetXmlMessage(); string paymentMethod = xml.Substring( xml.IndexOf("SVEAINVOICESE", System.StringComparison.InvariantCulture), "SVEAINVOICESE".Length); //check to see if the first value is one of the excluded ones Assert.That(paymentMethod, Is.EqualTo(InvoiceType.INVOICESE.Value)); }
void MakeCardPayment()//OrderRowBuilder orderRowBuilder, CountryCode countryCode = CountryCode.SE, string clientOrderNumber = "33") { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddFee(TestingTool.CreateExVatBasedShippingFee()) .AddFee(TestingTool.CreateExVatBasedInvoiceFee()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(TestingTool.CreateMiniCompanyCustomer()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetOrderDate(TestingTool.DefaultTestDate) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePayPageCardOnly() .SetReturnUrl("http://myurl.se") .GetPaymentForm(); //Card payment /*PaymentForm form = WebpayConnection.CreateOrder() * .AddOrderRow(orderRowBuilder) //required * .SetCountryCode(countryCode) // required * .SetClientOrderNumber(clientOrderNumber) * .SetOrderDate(DateTime.Now) * .UsePaymentMethod(PaymentMethod.SVEACARDPAY) * .SetReturnUrl("http://myurl.se") //Required * .SetCallbackUrl("http://myurl.se") * .SetCancelUrl("http://myurl.se") * .GetPaymentForm();*/ }
public void TestBuildPayPagePaymentWithExcludePaymentMethod() { var paymentMethods = new List <PaymentMethod> { PaymentMethod.INVOICE, PaymentMethod.KORTCERT }; PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddFee(Item.ShippingFee() .SetAmountExVat(50) .SetShippingId("33") .SetDescription("Specification") .SetVatPercent(25)) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails( Item.IndividualCustomer().SetNationalIdNumber(TestingTool.DefaultTestIndividualNationalIdNumber)) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetOrderDate(TestingTool.DefaultTestDate) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePayPage() .ExcludePaymentMethod(paymentMethods) .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string xml = form.GetXmlMessage(); const string expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<!--Message generated by Integration package C#-->" + "<payment><customerrefno>33</customerrefno><currency>SEK</currency>" + "<amount>18750</amount><vat>3750</vat><lang>en</lang>" + "<returnurl>http://myurl.se</returnurl><iscompany>false</iscompany>" + "<customer><ssn>194605092222</ssn><country>SE</country></customer>" + "<orderrows><row><sku>1</sku><name>Prod</name><description>Specification</description>" + "<amount>12500</amount><vat>2500</vat><quantity>2</quantity>" + "<unit>st</unit></row><row><sku>33</sku><name /><description>Specification</description>" + "<amount>6250</amount><vat>1250</vat><quantity>1</quantity></row>" + "<row><sku>1</sku><name>Relative</name><description>RelativeDiscount</description>" + "<amount>-12500</amount><vat>-2500</vat><quantity>1</quantity><unit>st</unit></row>" + "</orderrows><excludepaymentMethods><exclude>SVEAINVOICESE</exclude>" + "<exclude>SVEAINVOICEEU_SE</exclude><exclude>SVEAINVOICEEU_NO</exclude>" + "<exclude>SVEAINVOICEEU_DK</exclude><exclude>SVEAINVOICEEU_FI</exclude>" + "<exclude>SVEAINVOICEEU_NL</exclude><exclude>SVEAINVOICEEU_DE</exclude>" + "<exclude>KORTCERT</exclude></excludepaymentMethods>" + "<addinvoicefee>false</addinvoicefee></payment>"; Assert.That(xml, Is.EqualTo(expected)); }
public void TestPayPagePaymentWithSetPaymentMethodNl() { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(Item.IndividualCustomer() .SetInitials("SB") .SetBirthDate("19460509") .SetName("Sneider", "Boasman") .SetStreetAddress("Gate", "42") .SetLocality("BARENDRECHT") .SetZipCode("1102 HG")) .SetCountryCode(CountryCode.NL) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCustomerReference(TestingTool.DefaultTestCustomerReferenceNumber) .SetOrderDate(TestingTool.DefaultTestDate) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePaymentMethod(PaymentMethod.INVOICE) .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string xml = form.GetXmlMessage(); const string expectedXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<!--Message generated by Integration package C#-->" + "<payment><paymentmethod>INVOICE</paymentmethod><customerrefno>33</customerrefno>" + "<currency>SEK</currency><amount>12500</amount><vat>2500</vat>" + "<lang>en</lang><returnurl>http://myurl.se</returnurl><iscompany>false</iscompany>" + "<customer><ssn>19460509</ssn><firstname>Sneider</firstname><lastname>Boasman</lastname>" + "<initials>SB</initials><address>Gate</address><housenumber>42</housenumber>" + "<zip>1102 HG</zip><city>BARENDRECHT</city><country>NL</country></customer>" + "<orderrows><row><sku>1</sku><name>Prod</name><description>Specification</description>" + "<amount>12500</amount><vat>2500</vat><quantity>2</quantity><unit>st</unit></row>" + "<row><sku>1</sku><name>Relative</name><description>RelativeDiscount</description>" + "<amount>-12500</amount><vat>-2500</vat><quantity>1</quantity><unit>st</unit></row>" + "</orderrows><excludepaymentMethods /><addinvoicefee>false</addinvoicefee></payment>"; Assert.That(xml, Is.EqualTo(expectedXml)); string base64Payment = form.GetXmlMessageBase64(); string html = Base64Util.DecodeBase64String(base64Payment); Assert.That(html.Contains("<paymentmethod>INVOICE</paymentmethod>"), Is.True); }
public void TestDoCardPaymentRequest() { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddFee(TestingTool.CreateExVatBasedShippingFee()) .AddFee(TestingTool.CreateExVatBasedInvoiceFee()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(TestingTool.CreateMiniCompanyCustomer()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetOrderDate(TestingTool.DefaultTestDate) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePayPageCardOnly() .SetReturnUrl("http://myurl.se") .GetPaymentForm(); Assert.That(form, Is.Not.Null); }
public void TestBuildDirectBankPaymentNotSe() { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddFee(TestingTool.CreateExVatBasedShippingFee()) .AddFee(TestingTool.CreateExVatBasedInvoiceFee()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(TestingTool.CreateMiniCompanyCustomer()) .SetCountryCode(CountryCode.DE) .SetOrderDate(TestingTool.DefaultTestDate) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePayPageDirectBankOnly() .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string base64Payment = form.GetXmlMessageBase64(); string html = Base64Util.DecodeBase64String(base64Payment); Assert.That(html.Contains("<amount>18750</amount>"), Is.True); }
public void TestExcludeDirectPaymentMethodLarge() { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(TestingTool.CreateIndividualCustomer()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetOrderDate(TestingTool.DefaultTestDate) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePayPage() .ExcludeDirectPaymentMethod() .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string xml = form.GetXmlMessage(); string paymentMethod = xml.Substring(xml.IndexOf("DBNORDEASE", System.StringComparison.InvariantCulture), "DBNORDEASE".Length); Assert.That(paymentMethod, Is.EqualTo(PaymentMethod.NORDEASE.Value)); }
public void TestSetAuthorization() { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddFee(TestingTool.CreateExVatBasedShippingFee()) .AddFee(TestingTool.CreateExVatBasedInvoiceFee()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(TestingTool.CreateMiniCompanyCustomer()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetOrderDate(TestingTool.DefaultTestDate) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePayPageCardOnly() .SetReturnUrl("http://myurl.se") .GetPaymentForm(); const string expectedMerchantId = "1130"; const string expectedSecretWord = "8a9cece566e808da63c6f07ff415ff9e127909d000d259aba24daa2fed6d9e3f8b0b62e8ad1fa91c7d7cd6fc3352deaae66cdb533123edf127ad7d1f4c77e7a3"; Assert.That(form.GetMerchantId(), Is.EqualTo(expectedMerchantId)); Assert.That(form.GetSecretWord(), Is.EqualTo(expectedSecretWord)); }
private void CreateTestRelativeDiscountBuilder() { _order.AddDiscount(TestingTool.CreateRelativeDiscount()); }