Inheritance: RequestStringConvertible
 public static String generateHash(String apiKey, String secretKey, String randomString, BaseRequest request)
 {
     HashAlgorithm algorithm = new SHA1Managed();
     string hashStr = apiKey + randomString + secretKey + request.ToPKIRequestString();
     byte[] computeHash = algorithm.ComputeHash(Encoding.UTF8.GetBytes(hashStr));
     return Convert.ToBase64String(computeHash);
 }
 protected static WebHeaderCollection GetHttpHeaders(BaseRequest request, Options options)
 {
     string randomString = DateTime.Now.ToString("ddMMyyyyhhmmssffff");
     WebHeaderCollection headers = new WebHeaderCollection();
     headers.Add("Accept", "application/json");
     headers.Add(RANDOM_HEADER_NAME, randomString);
     headers.Add(CLIENT_VERSION, "iyzipay-dotnet-2.1.9");
     headers.Add(AUTHORIZATION, PrepareAuthorizationString(request, randomString, options));
     return headers;
 }
Exemple #3
0
 public static string SerializeToJsonString(BaseRequest request)
 {
     return JsonConvert.SerializeObject(request, new JsonSerializerSettings()
     {
         Formatting = Formatting.None,
         NullValueHandling = NullValueHandling.Ignore,
         DefaultValueHandling = DefaultValueHandling.Ignore,
         ContractResolver = new CamelCasePropertyNamesContractResolver()
     });
 }
 private static String PrepareAuthorizationString(BaseRequest request, String randomString, Options options)
 {
     String hash = HashGenerator.generateHash(options.ApiKey, options.SecretKey, randomString, request);
     return IYZIWS_HEADER_NAME + options.ApiKey + COLON + hash;
 }
Exemple #5
0
 public static StringContent ToJsonString(BaseRequest request)
 {
     return new StringContent(SerializeToJsonString(request), Encoding.Unicode, "application/json");
 }