PHP

Validate GSTIN using PHP

Deep
Written by Deep

Hi, here is the function using regular expressions to validate permanent and provisonal GSTIN number issued by Govt of India.

Sample GSTIN Number : 27AASCS2460H1Z0

Explaination of GSTIN:

  • First two digits : 27

Defines state codes as per 2011 census of India are as following :

01-Jammu and Kashmir, 02-Himachal Pradesh, 03-Punjab, 04-Chandigarh, 05-Uttarakhand, 06-Haryana, 07-Delhi, 08-Rajastan, 09-UP, 10-Bihar, 11-Sikkim, 12-Arunachal Pradesh, 13-Nagaland, 14-Manipur, 15-Mizoram, 16-Tripura, 17-Meghalaya, 18-Assam, 19-West Bengal, 20-Jharkhand, 21-Orrissa, 22-Chattisgarh, 23-MP, 24-Gujarat, 25-Daman and Diu, 26-Dadar and Nagar Haveli, 27-Maharashtra, 28-Andhra Pradesh, 29-Karnataka, 30-Goa, 31-Lakshadweep, 32-Kerala, 33-Tamil Nadu, 34-Puducherry and 35-Anadaman and Nicobar Islands.

  • Next 10 digits : AASCS2460H

These 10 digits are PAN number of the organization issued by Govt Of India.

  • 13th digit : 1

This 13th digit indicates the number of registrations as an organization has within a state for the same PAN. It will be an alpha-numeric number (first 1-9 and then A-Z) and will be assigned on the basis of the number of registrations a legal entity (having the same PAN) has within one state.

Say the company XYZ registered in the same state for 7 times for different businesses. In such case, this digit will be printed as 7. Let us assume, the same company registered for around 20 times, then it should be represented as K (1-9 numeric and later on 10th registration be named as A and 11th as B and so on up to Z).

Hence, an organization can register the GSTIN within a single state for the maximum of 35 times (1-9 and later on A-Z).

  • 14th digit : Z

It is default value set by GSTIN generating system.

  • 15th or Last digit : 0

It will be a checksum which will be used for detection of error (0-9 or A to Z).

 

Leave a Comment