Revolutionizing Fintech with Decentro APIs: A Comprehensive Guide for Programmers

Revolutionizing Fintech with Decentro APIs: A Comprehensive Guide for Programmers

·

3 min read

Introduction to Decentro

Decentro is a fintech platform that allows developers to integrate banking and financial services into their applications. It is a one-stop-shop for developers looking to incorporate banking APIs, and KYC/AML compliance tools into their software.

The platform is built on top of the latest security standards, ensuring that customer data is protected at all times. Decentro is quickly becoming a go-to platform for startups and businesses looking to simplify their financial operations. In this article, we'll explore how to connect to Decentro's API using Nodejs and build a KYC system using Decentro.

Building a KYC system on Decentro using Node.js

To use Decentro's APIs, you will need to sign up for an account on their website and obtain an API key. Once you have an API key, you can use it to authenticate your requests to Decentro's APIs.

For this example, we will assume that we have a Node.js backend where users can submit their KYC information.

First, let's install the necessary dependencies:

npm i express axios

Now, Let's first create our server.js file

 const express = require('express');
 const app = express();
 const port = 3000;
 const {verifyPan} =  require("../controllers/controller") 

 app.use(express.json());

 app.post('/verify-pan', (req, res) => {

 const {
  reference_id, 
  document_type,
  id_number,
  consent,
  consent_purpose 
  } = req.body;

  const isPanValid = await verifyPan(
   reference_id, 
   document_type,
   id_number,
   consent,
   consent_purpose
  );
    res.status(200).json({ isPanValid });
  }); 

 app.listen(port, () => {
  console.log(`Server listening at http://localhost:${port}`);
 });

Create a new directory called controllers, and in that directory, create a new file called controller.js. Add the following code to controller.js:

const axios = require('axios');

exports.verifyPan = async (
reference_id, 
document_type,
id_number,
consent,
consent_purpose
) => {

const url = 'https://in.staging.decentro.tech';

try {
 const response = await axios.post(
   url + '/kyc/public_registry/validate',
   { 
    reference_id, 
    document_type,
    id_number,
    consent,
    consent_purpose
   },
   {
     headers: {
       'client_id': '<your_client_id>',
       'client_secret': '<your_client_secret>' ,
       'module_secret': '<your_module_secret>',
       'Content-Type': 'application/json',
     },
   }
 );
 return response.data;
} catch (error) {
 console.error(error);
 return null;
}
};

Explanation of the above code:

The code defines a function called verifyPan that takes in five parameters: reference_id, document_type, id_number, consent, and consent_purpose.

Within the function, there is a declaration of a URL which is used to call the Decentro API for PAN card verification. The function then makes a POST request to the Decentro API's /kyc/public_registry/validate endpoint, passing in the function's input parameters as data, along with headers that include a client ID, client secret, module secret, and content type.

If the request is successful, the function returns the data from the response. If there is an error, the function logs the error to the console and returns null.

Conclusion:

In this solution, we have demonstrated how to use the Decentro API to verify PAN card numbers in a Node.js application using the axios library. The Decentro API provides a simple and straightforward way to do KYC verification, which is a critical requirement for many financial applications.

Overall, Decentro is a valuable resource for developers looking to build financial applications in India.

You can read more about decentro on their website: https://docs.decentro.tech/docs/overview

Thanks for reading.