Bank Account Verification — Cashfree
By Muhammediqbal P — A Technophile
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.
{
"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.
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-jslet’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.
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-jslet’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 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-jsSo, 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-jsand 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-jsYou 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.
Author
Reviewed By
Edited By
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!
Leave a Reply