Automating Zoho Invoice Creation from HubSpot Using a Custom Middleware

A custom native integration between HubSpot and Zoho Invoice.

Overview

VidyalayaERP, a SaaS-based school management software, was using HubSpot CRM (Free tier) to manage leads and deals, relying on WhatsApp and direct calls for communication and conversion. For financial operations, the client used Zoho Invoice to handle invoicing, payment collection (via Razorpay), and accounts reporting. However, the two systems operated independently, creating a gap in automation and efficiency.

Challenges

Hubspot offers features like quotes and invoices, but

  • It lacks full accounting capabilities, especially on the free plan.
  • HubSpot’s default invoice system is limited to Stripe, which is not ideal for Indian businesses.
  • Zoho Invoice supports Razorpay and integrates with Zoho Books for GST-compliant billing, which the client preferred.
  • A prebuilt HubSpot-Zoho integration exists in the HubSpot Marketplace, but:
    • It supports limited default field mapping
    • Custom mapping is only possible with Operations Hub Starter, a paid tier
    • It lacks flexibility and control over invoice logic and formatting

Objective

Automate the invoicing process so that:

  • When a deal in HubSpot is moved to the “Contract Sent” stage,
  • A customer is looked up or created in Zoho Invoice,
  • An invoice is automatically generated and emailed to the customer,
  • All actions are logged for transparency and debugging.

Our Approach

We built a custom middleware hosted on our server to handle this end-to-end workflow with full control, using only the APIs from HubSpot and Zoho.

  1. Created a Private App in HubSpot
    Configured with required scopes to access:
    • Deals
    • Contacts
    • Companies
    • Line items
    • Webhook subscriptions
  2. Webhook Listener Setup
    Registered a deal stage change webhook that:
    • Listens for changes to the dealstage property
    • Sends data to our custom middleware
  3. Data Fetch from HubSpot CRM (v3 API)
    Using HubSpot’s API, the middleware:
    • Fetches deal details
    • Retrieves associated contacts with personal details
    • Retrieves associated companies with billing details
    • Retrieves associated line items (products/services sold)
  4. Compiled a Structured Payload
    Prepared a clean JSON payload including:
    • Customer name, email, address, company info
    • Invoice line items (name, quantity, price)
  5. Customer Validation in Zoho Invoice
    Checked if a contact with the same email already exists using Zoho’s /contacts endpoint.
  6. Customer Creation Logic
    If no match was found, a new customer was created in Zoho Invoice with:
    • Properly mapped fields from HubSpot
    • Nested billing/shipping addresses
    • Primary contact details
    • GST & legal details
  7. Mapped Line Items to Zoho Product IDs
  8. Invoice Creation via Zoho API
    • Built a full invoice payload with line items
    • Enabled Razorpay payment gateway
    • Allowed partial payments
  9. Sent Invoice Email Automatically
    • Send the invoice to the customer
    • Include custom subject and body content
    • Attach the invoice PDF and payment link
MetricBeforeAfter
Invoice creationManual, error-proneFully automated
Time per invoice~15 minutes~10 seconds
Invoice consistencyVaries by personStandardized formatting
Payment integrationNot integratedRazorpay supported
Data integrityPartialAccurate via mapping

Key Takeaways

  • A custom middleware solution offers flexibility and is more cost-effective than subscribing to HubSpot’s Operations Hub.
  • By leveraging public APIs, we achieved enterprise-grade automation without third-party connectors.
  • This integration is scalable, with logging and fallback mechanisms in place to avoid data loss or double entries.

Summary

This project demonstrates how a basic CRM and accounting setup can be transformed into a powerful, automated workflow with the help of a thoughtfully designed middleware. By leveraging the strengths of both platforms and connecting them through custom APIs, we enabled VidyalayaERP to save time, minimize manual errors, and deliver a smoother customer experience — all without the need for costly plan upgrades or restrictive third-party integrations.

Scroll to Top