banner image 1 banner image 2

Bank Account Verification — Cashfree

November 21, 2022
5 mins
command
blog-img 1
Muhammediqbal P
Author

This article helps you to tackle bank account verification using Cashfree.

By Muhammediqbal P — A Technophile


Bank Account Verification- Cashfree

We guys at Caratlane started having a problem verifying the bank accounts from users, so we started looking around for solutions, and at last, we are here at Cashfree. Cashfree is a safe payment gateway that is used by over 1 lakh merchants in India. They process 20 million API requests a day and have a 99.99% average system up-time. Cashfree also makes it safe for businesses and freelancers to make payments with a unique bank account verification service. So let’s dive into how we solved our problems using Cashfree and what we did to improve it.

What do we need to get started?

  1. Let’s create an account in Cashfree.
  2. Fill in your information and you will get a call from Cashfree just to verify your details and you are good to go.
  3. Let’s go to this link and generate an API key for the verification of bank details, pan card, and UPI.
  4. Now let’s start using our APIs using the test endpoint, https://payout-gamma.cashfree.com.
  5. Now let’s generate an authorisation token using authorize API and client secret and ID generated from the previous step.
https://gist.github.com/ikku47/06e62855f92142a0f409781378eaaa0c#file-authorize-cashfree-js
{
"status": "SUCCESS",
"message": "Token generated",
"subCode": "200",
"data": {
"token": "eyJ0eXA...fWStg",
"expiry": 1564130052
}
}

As you can see we get a token that can be used in the next APIs and let’s pass it in the Authorisation header.

Let’s try validating a bank account.

Now let’s try this with the test bank account that’s available in this link.

https://gist.github.com/ikku47/4de614b85740f1f1286c93ced908310f#file-bank-validation-cashfree-js

let’s have a look at the response,

{
"status": "SUCCESS",
"subCode": "200",
"message": "Bank Account details verified successfully",
"accountStatus": "VALID",
"accountStatusCode": "ACCOUNT_IS_VALID",
"data":
{
"nameAtBank": "JOHN DOE",
"refId": "219834028",
"bankName": "ICICI BANK LIMITED",
"utr": "210219578183",
"city": "GWALIOR",
"branch": "GWALIOR",
"micr": 0
}
}

As you can see we can get all the above details on this account and let’s just store that data in the database, just in case we have to check for the same number because that request just caused 2.5 rupees as per their pricing.

So, what about the UPI account?

Now let’s try the same for a UPI account with the test UPI account.

https://gist.github.com/ikku47/20d45aac50b9b96277561061bae224cc#file-upi-validation-cashfree-js

let’s have a look at the response again this time,

{
"status": "SUCCESS",
"subCode": "200",
"message": "VPA verification successful",
"data": {
"nameAtBank": "JANE DOE",
"accountExists": "YES"
}
}

As you can see here also get the name of the UPI account holder and whether that account exists or not and let’s just store that data in the database, just in case we don’t want to lose more money.

So, How do we make transactions?

So we have done verifying and validating the bank accounts and UPI accounts, what should we need now ?, Don’t worry Cashfree got you covered. Let’s add a beneficiary to our Cashfree account by providing this user for future transactions, refunds, and redeems.

Let’s first create a unique beneficiary Id and try the API.

https://gist.github.com/ikku47/e33793e89bc429cbbb13451350efdaef#file-add-beneficiary-cashfree-js

So, what’s the response, here?

{
"status": "SUCCESS",
"subCode": "200",
"message": "Beneficiary added successfully"
}

So we have added the user’s bank account as a beneficiary now, Let’s store that data in the database. So now if we are adding a new bank account to the user and we have the same bank account and IFSC, we can use the same beneficiary account as the previous one. To get that info we can use an API for getting the beneficiary ID.

https://gist.github.com/ikku47/ad237408a78d4a0470bba5bed473423a#file-get-beneficiary-id-js
{
"status": "SUCCESS",
"subCode": "200",
"message": "beneId retrieved successfully",
"data": {
"beneId": "JOHN18011"
}
}

So, here we have the beneficiary ID for the bank account we already generated. Do you want more info from that beneficiary ID? Let’s try one more API for that.

https://gist.github.com/ikku47/400836baebd91d4d07e3bd63178cafc8#file-get-beneficiary-details-js

and voila, you get the all details here in the response,

{
"status": "SUCCESS",
"subCode": "200",
"message": "Details of beneficiary",
"data": {
"beneId": "JOHN18011",
"name": "John",
"groupName": "DEFAULT",
"email": "johndoe@cashfree.com",
"phone": "9876543210",
"address1": "ABCavenue",
"address2": "",
"city": "Bangalore",
"state": "Karnataka",
"pincode": "0",
"bankAccount": "00001111222233",
"ifsc": "HDFC0000001",
"status": "VERIFIED"
}
}

And last, if you want that beneficiary account to be removed when the account is deleted or changing the bank account, Let’s look at how it’s managed here.

https://gist.github.com/ikku47/ee7c3a8767cfa8c8b53799c37e9e0df8#file-remove-beneficiary-js
{
"status": "SUCCESS",
"subCode": "200",
"message": "Beneficiary removed"
}

and the beneficiary account is removed.

You can also use this one for IFSC verification alone,

https://gist.github.com/ikku47/777f73611a17709b39ef5cf05599ec9b#file-ifsc-validation-cashfree-js

You can also for pan card and aadhaar verification, you can refer to this postman collection for more API details. Cashfree can carry your business payment needs — collect payments, send payouts, manage international payments and do more and we are looking forward to making the most use of it.

References:

[embed]https://docs.cashfree.com/docs/data-to-test-integration-1[/embed][embed]https://docs.cashfree.com/docs/data-to-test-integration-1[/embed][embed]https://docs.cashfree.com/docs/data-to-test-integration-1[/embed]

Meet the team!

Author

Muhammediqbal P

Reviewed By

Sureshkumar M

Edited By

Seema Jain


We at CaratLane are solving some of the most intriguing challenges to make our mark in the relatively uncharted omnichannel jewellery industry. If you are interested in tackling such obstacles, feel free to drop your updated resume/CV to careers@caratlane.com!
blog-img 2

Discussions

blog-img 3
5 mins
May 17, 2023
Sharing Data Between Controllers: Best Practices S...

This article will help you to understand the diffe

By Naveen C

blog-img 3
5 mins
March 21, 2023
Understanding Auto Layout and Constraints in Swift...

This article gives you an easy way of understandin

By Ramasamy P