-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathConnectionTests.cs
59 lines (53 loc) · 1.65 KB
/
ConnectionTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using e24PaymentPipe.Exceptions;
using NUnit.Framework;
using e24PaymentPipe;
namespace e24PaymentPipeTests
{
[TestFixture]
public class ConnectionTests
{
Uri paymentServerUrl;
[SetUp]
public void SetUp()
{
var paymentServer = new PaymentServerUrlBuilder("bankserver.example.com","/context", UseSSL.on, 443);
paymentServerUrl = paymentServer.ToUrl();
}
[Test, Explicit("This test actually connects to the bank to initiate a transaction!")]
public void PaymentInitializationTest()
{
var sku = "SKU";
var size="medium";
var desc = "a product";
string details = sku + "#" + desc + "#" + size;
// // build Payment Init message
var init=new PaymentInitMessage(
id: "11111111",
password: "test",
action: RequiredAction.Authorization,
amount: 5.30,
language: RequiredLanguage.ITA,
responseURL: new Uri("http://www.example.com/TransactionOK.htm"),
errorURL: new Uri("http://www.example.com/TransactionKO.htm"),
trackId: new Guid().ToString(),
currency: 978,
udf1:details
);
var pipe = new PaymentPipe(paymentServerUrl);
PaymentDetails paymentdetails=null;
try
{
paymentdetails = pipe.PerformPaymentInitialization(init);
}
catch(BadResponseFromWebServiceException ex)
{
Console.Error.WriteLine("attemptedUrl:", ex.AttemptedUrl);
Console.Error.WriteLine("attemptedParameters:", ex.AttemptedParams);
}
Assert.IsNotNull(paymentdetails);
Console.Error.WriteLine("paymentID: {0}", paymentdetails.PaymentId);
Console.Error.WriteLine("paymentpage: {0}", paymentdetails.PaymentPage);
}
}
}