using System.Security.Cryptography;
public static string baseurl = "https://trippublic.dcsplus.net/dynapack/clients/bitusi/public/index.php";
public static string appid = "developer";
public static string skey = "developer321";
public static void Main()
'checkout': '2019-03-24',
'resultCode': 'HOTEL-WS-CSBT-9947dedb798279ce4e7b59ec761ceb30',
'packageCode': '7813:0:6:dbe24bea1df9cb442da34fd3c25366f6',
'email': 'john.doe@gmall.com',
'name': 'Basic+Quadruple+Room,+Shared+Bathroom',
string sortedRequestData = @"{
'checkout': '2019-03-24',
'packageCode': '7813:0:6:dbe24bea1df9cb442da34fd3c25366f6',
'resultCode': 'HOTEL-WS-CSBT-9947dedb798279ce4e7b59ec761ceb30',
'email': 'john.doe@gmall.com',
'name': 'Basic+Quadruple+Room,+Shared+Bathroom',
string sortedRequestDataHTTPQuery = "adultsNr=1&amount=73.55&checkin=2019-03-23&checkout=2019-03-24&childrenNr=0&comment=¤cy=EUR&hotelId=7813&packageCode=7813:0:6:dbe24bea1df9cb442da34fd3c25366f6&resultCode=HOTEL-WS-CSBT-9947dedb798279ce4e7b59ec761ceb30&room[0][adults][0][title]=Mr&room[0][adults][0][firstname]=John&room[0][adults][0][lastname]=Doe&room[0][adults][0][email]=john.doe@gmall.com&room[0][adults][0][phone]=0756912347&room[0][code]=6&room[0][price]=&room[0][currency]=&room[0][name]=Basic+Quadruple+Room,+Shared+Bathroom&room[0][board]=&room[0][packageCode]=0&room[0][status]=OK&serviceType=hotel";
string orderUrl = baseurl + "/orders/1226/services?timestamp=" + DateTimeOffset.UtcNow.ToUnixTimeSeconds() + "&applicationId=" + appid;
string orderHash = Hash(orderUrl + "&" + sortedRequestDataHTTPQuery);
token = "9ab66f3b125a6df55a1fba01ded852808bfcaccf";
requestData = "{\"serviceType\":\"hotel\",\"amount\":\"73.55\",\"currency\":\"EUR\",\"hotelId\":\"7813\",\"adultsNr\":\"1\",\"childrenNr\":\"0\",\"checkin\":\"2019-03-23\",\"checkout\":\"2019-03-24\",\"resultCode\":\"HOTEL-WS-CSBT-9947dedb798279ce4e7b59ec761ceb30\",\"packageCode\":\"7813:0:6:dbe24bea1df9cb442da34fd3c25366f6\",\"comment\":\"\",\"room\":[{\"adults\":[{\"title\":\"Mr\",\"firstname\":\"John\",\"lastname\":\"Doe\",\"email\":\"john.doe@gmall.com\",\"phone\":\"0756912347\"}],\"code\":\"6\",\"price\":\"\",\"currency\":\"\",\"name\":\"Basic+Quadruple+Room,+Shared+Bathroom\",\"board\":\"\",\"packageCode\":\"0\",\"status\":\"OK\"}]}";
string orderResponse = Post(orderUrl, orderHash, token, requestData);
Console.WriteLine("url: " + orderUrl);
Console.WriteLine("hash url: " + orderUrl + sortedRequestDataHTTPQuery);
Console.WriteLine("token: " + token);
Console.WriteLine("hash: " + orderHash);
Console.WriteLine("response: " + orderResponse);
Console.WriteLine("Hello World" + DateTimeOffset.UtcNow.ToUnixTimeSeconds());
public static string Hash(string rurl)
SHA1 sha = new SHA1CryptoServiceProvider();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
byte[] buffer = encode.GetBytes(rurl + skey);
byte[] result = sha.ComputeHash(buffer);
hash = HexStringFromBytes(result);
public static string Token()
string url = baseurl + "/en/authentication/token/generate?timestamp=" + DateTimeOffset.UtcNow.ToUnixTimeSeconds() + "&applicationId=" + appid;
public static string Get(string url, string hash)
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
myHttpWebRequest.Headers["x-hash"] = hash;
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader( receiveStream, encode );
return readStream.ReadToEnd();
public static string Post(string url, string hash, string token, string jsonData)
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
myHttpWebRequest.Headers["x-hash"] = hash;
myHttpWebRequest.Headers["Authorization"] = token;
myHttpWebRequest.ContentType = "application/json";
myHttpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(myHttpWebRequest.GetRequestStream()))
streamWriter.Write(jsonData);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader( receiveStream, encode );
return readStream.ReadToEnd();
using (WebResponse response = e.Response)
HttpWebResponse httpResponse = (HttpWebResponse) response;
Console.WriteLine("Error code: {0}", httpResponse.StatusCode);
using (Stream data = response.GetResponseStream())
using (var reader = new StreamReader(data))
text = reader.ReadToEnd();
public static string HexStringFromBytes(byte[] bytes)
var sb = new StringBuilder();
foreach (byte b in bytes)
var hex = b.ToString("x2");
public static string Postaa(string uri, string data, string contentType, string method = "POST")
byte[] dataBytes = Encoding.UTF8.GetBytes(data);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
request.ContentLength = dataBytes.Length;
request.ContentType = contentType;
using(Stream requestBody = request.GetRequestStream())
requestBody.Write(dataBytes, 0, dataBytes.Length);
using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using(Stream stream = response.GetResponseStream())
using(StreamReader reader = new StreamReader(stream))
return reader.ReadToEnd();