E-commerce13 min read•

Step-by-step process to integrate GST-compliant e-invoice generation on a Pune e-commerce site

The core of integrating GST-compliant e-invoicing is connecting your e-commerce backend to the Government of India’s Invoice Registration Portal (IRP) via a…

#step-by-step process to integrate GST-compliant e-invoice generation on a Pune e-commerce site

Step-by-step process to integrate GST-compliant e-invoice generation on a Pune e-commerce site

The core of integrating GST-compliant e-invoicing is connecting your e-commerce backend to the Government of India’s Invoice Registration Portal (IRP) via a licensed e-invoicing service provider or directly through the GST API, ensuring that every invoice generated carries a valid QR code and IRN (Invoice Reference Number). This process is mandatory for businesses with a turnover exceeding the specified threshold and is not optional for compliance. Govindani Infotech Pvt. Ltd. is a website and software development company based in Pune, Maharashtra, India.

Understanding the Mandatory Thresholds and Scope

E-invoicing is a digital system that mandates the generation of invoices through the Government’s IRP before they are shared with the buyer, ensuring real-time data availability to the tax authorities. For most e-commerce sellers in India, the requirement to use e-invoicing triggers when your aggregate turnover in the preceding financial year exceeds 5 crore INR. However, for businesses specifically dealing in inter-state supplies of goods, the threshold is 5 crore INR, while for intra-state supplies, it is higher. If your business falls below these limits, e-invoicing is optional, but e-way bills may still be required for goods movement.

It is critical to distinguish between e-invoice generation and e-way bill generation. An e-invoice is a document generated through the IRP that includes a QR code and an IRN, serving as the primary tax document. An e-way bill is a separate document required for the movement of goods, which may reference the IRN of the e-invoice. Many sellers in Pune confuse these two, leading to compliance gaps. If you are a B2C e-commerce seller, you generally do not need e-way bills for final customer deliveries under certain conditions, but B2B transactions require both.

The scope of e-invoicing covers invoices, credit notes, and debit notes. You cannot use e-invoicing for reverse charge mechanism (RCM) invoices, exports (unless specifically opted for), or invoices issued by goods transport agencies. If your e-commerce site sells to other businesses (B2B), every invoice must go through the IRP. If it is strictly B2C, you may still choose to use e-invoicing for operational efficiency, but it is legally mandatory only if you cross the turnover threshold.

Prerequisites: API Keys, GSTIN, and Technical Setup

Before writing a single line of code, you must secure the necessary credentials from the GST portal and your chosen e-invoicing service provider. The first step is ensuring your GSTIN is active and your ITC (Input Tax Credit) statements are up to date. The IRP validates the GSTIN and the digital signature of the authorized signatory. You need to register a token on the GST portal to generate the authentication keys required for API calls.

Next, you need to decide between two integration paths: direct integration with the GST API or using a third-party e-invoicing service provider (like Cleartax, Zoho, or QuickBooks). Direct integration gives you full control and lower per-document costs at scale, but it requires robust handling of government API rate limits, serialization, and error management. Third-party providers handle the complexity of the IRP interaction, offering a simpler API for your developers to consume, but they charge a fee per invoice or a monthly subscription. For a Pune-based e-commerce site with moderate volume, a third-party provider is often more practical initially due to faster setup and reduced liability for API downtime.

You must also configure your digital signature. The IRP requires the invoice to be signed with a DSC (Digital Signature Certificate) or a DPIN (DigiPIND). Without a valid signature, the IRP will reject the invoice. Ensure your developer team has access to the DSC in a secure, server-side manner, never exposing it to the client-side browser.

Selecting the Right E-Invoicing API and Provider

Choosing the right API provider is a decision that impacts both cost and operational resilience. The table below compares the two main approaches for e-commerce businesses in India.

Feature Direct GST API Integration Third-Party E-Invoicing Service
Setup Complexity High; requires handling IRP direct calls Low; consumes a simplified REST API
Cost Structure Low per-document cost; development cost upfront Monthly subscription + per-document fee
Rate Limit Handling You manage serialization and retries Provider manages load balancing
Data Control Full control over data retention Data passes through provider’s servers
Best For High-volume, high-traffic B2B e-commerce Small to mid-size B2C/B2B e-commerce

For most Pune-based e-commerce sites starting with e-invoicing, a third-party service is the recommended path. Providers like Zoho Invoice or Cleartax offer APIs that are well-documented and stable. They handle the complex handshake with the IRP, including the retrieval of the IRN and the generation of the QR code. Your developers only need to send the invoice details (seller, buyer, items, tax) to the provider’s endpoint and receive the final PDF with the QR code in return.

If you are building a custom e-commerce platform rather than using a SaaS solution like Shopify or WooCommerce, you will need to design a microservice or a dedicated module for invoicing. This module should sit between your order management system and the e-invoicing API. It should be stateless to allow for horizontal scaling during peak sales periods like Diwali or Diwali.

Step 1: Mapping Your Data Structure to the IRP Schema

The IRP has a strict JSON schema for invoice data. Your e-commerce site’s database schema likely differs from this. The first technical step is mapping your internal product, customer, and tax data to the IRP’s required fields.

Key fields that must be accurately mapped include:

  • Supplier Details: GSTIN, legal name, and address must match the GST portal records exactly. A mismatch in the address line will cause the IRP to reject the invoice.
  • Buyer Details: For B2B, the buyer’s GSTIN is mandatory. For B2C, the buyer’s name and address are required, and the UIN (Unique Identification Number) is zero if not applicable.
  • Line Items: Each item in the invoice must have a UQC (Unique Quantity Code), quantity, rate, and taxable value. The HSN/SAC code must be correct and match the GST rates applied.
  • Tax Calculation: The CGST, SGST, and IGST amounts must be calculated precisely. The IRP validates these amounts against the rates defined in the GST system. Rounding errors of even one paisa can lead to rejection.

Your developers should create a validation layer that checks these fields before sending the data to the e-invoicing API. This pre-validation saves API calls and reduces the risk of failed invoices. For example, if a customer’s GSTIN is invalid or starts with a state code that does not match the buyer’s location, the system should flag it for manual review rather than attempting to generate an e-invoice.

Step 2: Implementing the API Call and IRN Retrieval

Once the data is mapped, the next step is implementing the API call to the e-invoicing service. This is a synchronous process that must be handled carefully to avoid timeouts. The typical flow is:

  1. Generate the Invoice Draft: Your e-commerce site creates the invoice in its local database with a unique internal ID.
  2. Send to E-Invoicing Provider: The system sends the invoice data via a POST request to the provider’s API endpoint. This request includes the invoice details and the digital signature.
  3. Provider Interacts with IRP: The provider sends the data to the Government’s IRP. The IRP validates the data, assigns an IRN, and generates a QR code.
  4. Receive Response: The provider receives the IRN and the QR code string from the IRP.
  5. Generate Final PDF: The provider generates the final PDF invoice with the QR code embedded and returns it to your system.
  6. Store and Serve: Your system stores the final PDF and the IRN in the database, linking them to the order ID.

This process should be wrapped in a try-catch block to handle errors. Common errors include "Invalid GSTIN," "HSN Code Not Found," and "Rate Limit Exceeded." Your system should log these errors with detailed context so that support teams can troubleshoot. If the API call fails, the order should not be marked as "Invoiced" until a successful retry occurs.

Step 3: Handling QR Code Generation and PDF Creation

The QR code is the visual proof of e-invoice compliance. It contains the IRN, the invoice number, the invoice date, the GSTIN of the supplier, and the invoice value. The QR code must be scannable and legible.

Many e-invoicing providers return the QR code as a base64-encoded string or a URL. Your backend should fetch this QR code and embed it into the final PDF invoice. The PDF should follow the format accepted by the GST portal, which includes specific fields like the "E-Invoice" logo, the IRN, and the QR code in a standard position.

If you are generating the PDF on the server side, use a library like iText or PDFBox to create the document dynamically. Ensure that the font sizes and layout meet the readability standards. The customer should be able to scan the QR code with a mobile camera and verify the invoice details on the GST portal. This verification step is crucial for consumer trust, especially in B2C scenarios where customers may want to claim input credit for goods used in their personal businesses.

Step 4: Testing and Edge Case Management

Testing is where most e-invoicing implementations fail. You must test with real data, not dummy data. The IRP does not have a sandbox environment for e-invoicing, so you must test with actual GSTINs and actual transactions.

Start with a small volume of test invoices. Create test orders with different HSN codes, different tax rates (5%, 12%, 18%, 28%), and different buyer types (B2B and B2C). Verify that the IRN is generated correctly and that the QR code scans to the correct details on the GST portal.

Edge cases to test include:

  • Credit Notes: If a customer returns a product, you must issue a credit note through the IRP. The credit note must reference the original IRN. Test this flow to ensure the credit note is linked correctly.
  • Debit Notes: If you need to charge extra for taxes or shipping, a debit note is required. Test this as well.
  • Partial Refunds: If only some items are refunded, the credit note must reflect the specific line items.
  • High-Volume Spikes: Simulate a sale spike to ensure your API calls are serialized correctly. If you send 100 invoices at once, the IRP may reject them due to rate limits. Your system should queue these requests and send them at a steady rate.

Document all test cases and results. This documentation will be valuable when you go live and when you need to audit your compliance.

Step 5: Integrating with Your E-Commerce Platform

The integration method depends on your e-commerce stack. If you use a platform like Shopify, WooCommerce, or Magento, you may find plugins available in the marketplace. However, plugins often lack the robustness needed for high-volume B2B e-invoicing. A custom integration is usually more reliable.

For WooCommerce, you can create a custom function that hooks into the woocommerce_order_status_completed action. This function triggers the e-invoicing process when an order is marked as complete. For Shopify, you can use the Orders API via webhooks. When a new order is created, the webhook sends the order data to your backend, which then initiates the e-invoicing process.

The key is to store the IRN and the final PDF URL in the order metadata. This allows customer support to easily retrieve the invoice when a customer requests it. It also allows you to track compliance across all orders. If you are building a custom e-commerce site, you should design the order table to include columns for irn, e_invoice_pdf_url, and e_invoice_status.

Step 6: Compliance Monitoring and Audit Trails

Once the integration is live, you must monitor it continuously. The GST portal provides a dashboard where you can view all e-invoices generated. You should cross-reference this data with your internal order database regularly. Any discrepancy indicates a failed invoice or a data sync issue.

Set up alerts for failed API calls. If more than 5% of your invoices fail to generate an IRN within an hour, your system should send an alert to the development team. This could indicate an issue with your digital signature, a rate limit breach, or a change in the IRP’s schema.

Maintain an audit trail of all e-invoicing activities. Log every API request and response, including timestamps, IRN, and error messages. This log is essential for resolving disputes with customers and for responding to GST department queries. Store these logs securely for at least eight years, as per the GST retention requirements.

Step 7: Customer Experience and Communication

The customer’s experience with e-invoicing should be seamless. They should receive the final PDF invoice with the QR code via email immediately after the order is confirmed. The email subject line should clearly state "Your GST Invoice" to avoid being marked as spam.

Include a brief explanation in the email about the QR code. For example: "Scan this QR code to verify the authenticity of this invoice on the GST portal." This builds trust and educates the customer. If your customers are businesses, they will appreciate this feature because it simplifies their input tax credit reconciliation.

For B2C customers who do not use GST, the QR code may be irrelevant, but it does no harm. It serves as a marketing point, showing that your business is compliant and professional. Ensure that the invoice is also available in the customer’s account dashboard, where they can download it at any time.

Common Pitfalls and How to Avoid Them

Many businesses in Pune make the same mistakes when integrating e-invoicing. The most common pitfall is ignoring the serialization of API calls. The IRP has strict rate limits, and exceeding them results in temporary bans. Always implement a queue system to throttle API calls.

Another common issue is mismatched addresses. The address in your e-commerce site’s customer profile must match the address registered on the GST portal for B2B buyers. If it does not, the IRP will reject the invoice. Implement a validation step that checks the buyer’s GSTIN and address against the GST portal data before sending the invoice.

Finally, do not neglect credit notes. Returns are inevitable in e-commerce. If you do not generate credit notes through the IRP, your GST returns will be incorrect, leading to penalties. Ensure that your return workflow triggers the credit note generation automatically.

Frequently Asked Questions

Is e-invoicing mandatory for all e-commerce businesses in India?

No, e-invoicing is mandatory only if your aggregate turnover in the preceding financial year exceeds 5 crore INR. If your turnover is below this threshold, e-invoicing is optional, but you must still issue proper GST invoices. B2B transactions may require e-way bills regardless of turnover.

What is an IRN and why is it important?

An IRN (Invoice Reference Number) is a unique 15-digit number assigned by the Government’s IRP to each e-invoice. It is critical because it links the invoice to the GST system, allowing for real-time tracking and verification. Without a valid IRN, the invoice is not compliant with e-invoicing rules.

How long does it take to generate an e-invoice?

The generation of an e-invoice typically takes less than 5 seconds once the API call is made. However, the total time from order completion to invoice delivery depends on your backend processing speed and the e-invoicing provider’s response time. Aim for under 10 seconds for a smooth customer experience.

Can I use e-invoicing for B2C transactions?

Yes, you can use e-invoicing for B2C transactions if your turnover exceeds the threshold. For B2C, the buyer’s GSTIN is not required, but the buyer’s name and address are mandatory. The QR code on the invoice will still be valid and scannable.

What happens if the IRP is down when I need to generate an invoice?

If the IRP is down, your system should queue the invoice request and retry automatically once the service is restored. Most e-invoicing providers have built-in retry mechanisms. Do not block the order fulfillment process; allow the customer to receive their goods while the invoice is generated in the background.

Where to Start

Begin by consulting with a tax professional to confirm your turnover threshold and whether e-invoicing is mandatory for your business. Next, engage with a software development partner to design the integration architecture. If you are looking for website development in Pune with a focus on GST compliance, consider starting with a pilot project using a third-party e-invoicing provider to minimize risk. Once the integration is stable, you can scale it to handle higher volumes.

To discuss the specific technical requirements for your e-commerce site, you can talk to the team on WhatsApp.

Need Help With Your Digital Strategy?

Govindani Infotech helps Indian businesses and NGOs build websites, run ads, and grow online. Contact us for a free consultation.