Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Generic User Avatar

My site KYC api need document_types parameter


  • Please log in to reply
2 replies to this topic

#1 GabrielLuke

GabrielLuke

  •  Avatar image
  • Members
  • 10 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:10:55 AM

Posted 16 January 2020 - 02:51 AM

Hi,
Implemented Shufti pro api using KYC in C#
I am struck in document type parameter. Here is my site: https://shuftipro.com

Here if

document_type = "",

this will default shows all four document verification but i dont want debit credit card verification
In javascript its like,

"supported_types" : ["id_card","driving_license","passport"],

So how i Can use it in my below C# code

What I have tried:

using (var client = new WebClient())
           {
               var postData = new NameValueCollection();
               postData["client_id"] = "";
               postData["reference"] = Guid.NewGuid().ToString();
               postData["email"] = email;
               postData["phone_number"] = "";
               postData["country"] = "";
               postData["lang"] = "EN";
               postData["callback_url"] = "";
               postData["redirect_url"] = "";

               //string docTypeArr = "['id_card', 'driving_license', 'passport']";
               //var doctype = JsonConvert.SerializeObject(docTypeArr);
               //postData["supported_types"] = doctype;

               var sericesData = new
               {
                   document_type = "",
                   document_id_no = "",
                   document_expiry_date = "",
                   address = "",
                   first_name = "",
                   last_name = "",
                   dob = "",
                   background_checks = "0",
               };

               var jsonServicesData = JsonConvert.SerializeObject(sericesData);

               postData["verification_services"] = jsonServicesData;

               string rawData = "";
               //Sort the All request data to calculate signature
               foreach (var item in postData.AllKeys.OrderBy(k => k))
               {
                   rawData += postData[item];
               }
               //Append the secret key in the end
               rawData = rawData + "";
               //get sha256 hash for signature value by using the below function
               string hash = GetHashSha256(rawData);

               postData["signature"] = hash;

               //send the request to shuftipro
               var response = client.UploadValues("https://api.shuftipro.com", postData);
               var responseString = Encoding.Default.GetString(response);

               //print your response here
               //If want to parse the JSON response uncomment the below lines
               dynamic stuff = JObject.Parse(responseString);
               VerificationURL = stuff.message;
           }

Any help will be appreciated.



BC AdBot (Login to Remove)

 


#2 lokeshjoshi

lokeshjoshi

  •  Avatar image
  • Members
  • 1 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:India
  • Local time:11:25 AM

Posted 27 October 2023 - 02:35 AM

It seems that you're trying to make an HTTP POST request to an API using the WebClient class in C#. The code you provided includes some placeholders and missing values, which might be causing issues.

 

You can try this:

 

using System;
using System.Collections.Specialized;
using System.Net;
using Newtonsoft.Json.Linq;


class KYCApiExample
{
    static void Main()
    {
        using (var client = new WebClient())
        {
            // Define the API endpoint URL
            string apiUrl = "https://api.shuftipro.com";


            // Define your API credentials
            string clientId = "your_client_id_here";
            string secretKey = "your_secret_key_here";


            var postData = new NameValueCollection();
            postData["client_id"] = clientId;
            postData["reference"] = Guid.NewGuid().ToString();
            postData["email"] = "user@example.com";  // Replace with the user's email
            postData["phone_number"] = "1234567890"; // Replace with the user's phone number
            postData["country"] = "US";  // Replace with the user's country
            postData["lang"] = "EN";
            postData["callback_url"] = "https://your-callback-url.com";  // Replace with your callback URL
            postData["redirect_url"] = "https://your-redirect-url.com";  // Replace with your redirect URL


            var servicesData = new
            {
                document_type = "id_card", // Replace with the actual document type
                document_id_no = "12345", // Replace with the document ID
                document_expiry_date = "2023-12-31", // Replace with the document's expiry date
                address = "123 Main St, City, Country", // Replace with the address
                first_name = "John", // Replace with the first name
                last_name = "Doe", // Replace with the last name
                dob = "1990-01-01", // Replace with the date of birth
                background_checks = "0",
            };


            var jsonServicesData = Newtonsoft.Json.JsonConvert.SerializeObject(servicesData);


            postData["verification_services"] = jsonServicesData;


            string rawData = "";
            // Sort the request data keys for calculating the signature
            foreach (var item in postData.AllKeys.OrderBy(k => k))
            {
                rawData += postData[item];
            }


            // Append the secret key to the rawData
            rawData = rawData + secretKey;


            // Calculate the SHA-256 hash for the signature value
            string hash = GetHashSha256(rawData);


            postData["signature"] = hash;


            try
            {
                // Send the POST request to the API
                var response = client.UploadValues(apiUrl, postData);
                var responseString = System.Text.Encoding.Default.GetString(response);


                // Print the response
                Console.WriteLine("API Response: " + responseString);


                // If you want to parse the JSON response, uncomment the following lines
                dynamic stuff = JObject.Parse(responseString);
                string verificationURL = stuff.message;
                Console.WriteLine("Verification URL: " + verificationURL);
            }
            catch (WebException ex)
            {
                // Handle any exceptions, such as network errors
                Console.WriteLine("Error: " + ex.Message);
            }
        }
    }


    static string GetHashSha256(string text)
    {
        using (System.Security.Cryptography.SHA256 sha256 = System.Security.Cryptography.SHA256.Create())
        {
            byte[] hashBytes = sha256.ComputeHash(System.Text.Encoding.UTF8.GetBytes(text));
            return BitConverter.ToString(hashBytes).Replace("-", string.Empty);
        }
    }
}

hope this will help you. 



#3 MoxieMomma

MoxieMomma

  •  Avatar image
  • BC Advisor
  • 2,642 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Local time:12:55 AM

Posted 27 October 2023 - 05:45 AM

Hello and welcome to BC:



Thanks for taking the time to post such a detailed reply.

Since this thread was abandoned in January 2020, it's likely that the Topic Starter has already found a solution.

In general, there's no need to revive such old, dead threads.

Thanks




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users