automationCRMinvoicingbillingtutorial

How to Auto-Send Invoices When a Deal is Closed in Your CRM

Automiva Team
CRM deal card transforming into invoice with automated workflow arrows

You close a deal in your CRM. Celebration time. Then someone has to create an invoice, enter all the details again, send it to the customer, and update the CRM with invoice status. That process takes time, introduces errors, and delays getting paid.

What if invoicing happened automatically the moment a deal closed? The invoice gets created, sent to the customer, and tracked for payment, all without anyone lifting a finger. This guide shows you how to build exactly that.

What We're Building

This automation will:

  1. Trigger when a deal moves to "Closed Won" in your CRM
  2. Pull deal information (customer, products, pricing, terms)
  3. Create an invoice in your billing/accounting system
  4. Send the invoice to the customer
  5. Update the CRM with invoice details
  6. Track payment status and sync back to CRM

Zero manual work from deal closure to invoice delivery.

Prerequisites

You'll need:

  • CRM with API access or integration support (HubSpot, Pipedrive, Salesforce, etc.)
  • Billing/Invoicing tool (QuickBooks, Xero, FreshBooks, Stripe, etc.)
  • Automation platform (Make, Zapier, or n8n)

Your CRM needs to store:

  • Customer contact information
  • Products/services included in deal
  • Pricing and quantities
  • Payment terms
  • Any discounts or special conditions

If this data isn't in your CRM, you'll need to add it or handle those fields differently.

Step 1: Set Up Your CRM Trigger

The workflow starts when a deal reaches "Closed Won" status.

HubSpot Setup

  • Go to Automations > Workflows
  • Create new workflow with enrollment trigger: "Deal stage becomes Closed Won"
  • Or use Zapier/Make with trigger: "Deal Stage Changed"

Pipedrive Setup

  • Use Pipedrive's native automation or connect via Zapier/Make
  • Trigger: "Deal Stage Changed to Won"

Salesforce Setup

  • Use Process Builder or Flow
  • Trigger: Opportunity Stage = "Closed Won"
  • Or use Zapier/Make with "Opportunity Stage Changed"

What Data to Capture

At trigger, capture:

  • Deal ID
  • Customer/Account name
  • Primary contact email
  • Products with quantities and prices
  • Total deal value
  • Payment terms (Net 30, Due on receipt, etc.)
  • Any notes or special instructions
  • Sales rep (for commission tracking)

Make sure your CRM has this data before the automation runs.

Step 2: Map CRM Data to Invoice Fields

Your billing system needs information in its own format. Create mapping between CRM fields and invoice fields.

Typical mapping:

CRM FieldInvoice Field
Account NameCustomer Name
Billing Contact EmailInvoice Email
Billing AddressCustomer Address
Product Line ItemsInvoice Line Items
Unit PricesLine Item Amounts
QuantitiesLine Item Quantities
DiscountDiscount
Deal TotalInvoice Total
Payment TermsDue Date Calculation
Deal NumberReference Number

Handling Complex Products

If your products have:

  • Multiple pricing tiers: Include tier information in deal, map to correct pricing
  • Recurring vs one-time: Flag appropriately for subscription billing
  • Custom pricing: Ensure custom amounts override defaults
  • Bundles: Break out into line items or invoice as bundle

Build logic into your automation to handle variations.

Step 3: Create Customer in Billing System

Before creating an invoice, ensure the customer exists in your billing system.

Check for Existing Customer

  1. Search billing system by email or company name
  2. If found: use existing customer ID
  3. If not found: create new customer record

New customer data to include:

  • Company name
  • Billing contact name
  • Email address
  • Billing address
  • Phone number
  • Tax ID (if applicable)
  • Default payment terms

Sync Customer IDs

Store the billing system customer ID in your CRM:

  • Create custom field in CRM for "Billing System ID"
  • Update after customer creation
  • Use this for future invoices (no need to create again)

This prevents duplicate customers and speeds up future invoices.

Step 4: Generate the Invoice

Now create the actual invoice.

Invoice Creation API Call

In your automation platform, add action for your billing system:

QuickBooks:

  • Action: "Create Invoice"
  • CustomerRef: [Customer ID from Step 3]
  • Line items: [Map from deal products]
  • DueDate: [Calculate from payment terms]

Xero:

  • Action: "Create Invoice"
  • Contact: [Customer from Step 3]
  • LineItems: [Map from deal products]
  • DueDate: [Calculated date]

Stripe Invoicing:

  • Action: "Create Invoice"
  • Customer: [Stripe Customer ID]
  • Add line items via "Create Invoice Item"
  • Finalize and send

Invoice Details to Include

Beyond line items:

  • Invoice date (usually today)
  • Due date (based on payment terms)
  • Invoice number (auto-generated or custom format)
  • Reference (deal ID for tracking)
  • Notes (any special instructions from deal)
  • Tax (calculated based on location and product taxability)

Handling Tax Calculation

Tax is tricky. Options:

  • Simple: Set tax rate in billing system, apply to all invoices
  • Automatic: Use billing system's tax calculation (QuickBooks and others have this)
  • Tax service: Integrate Avalara or TaxJar for complex multi-jurisdiction tax

For most B2B services, tax is either straightforward or not applicable. B2C and physical goods get more complex.

Step 5: Send the Invoice

Most billing systems can send invoices directly via email.

Direct Send from Billing System

After invoice creation:

  • Action: "Send Invoice"
  • Email to: Billing contact from deal
  • Include: PDF attachment, payment link, due date

The billing system handles email formatting and delivery tracking.

Custom Email via Automation

If you want more control over the email:

  1. Get PDF invoice from billing system
  2. Send via your email tool with custom template
  3. Include personalization from CRM

Custom email lets you add:

  • Personal note from sales rep
  • Links to resources or next steps
  • Your branding and tone

Step 6: Update CRM with Invoice Info

Keep everything in sync.

Update Deal Record

After invoice sends:

  • Update custom field "Invoice Number"
  • Update custom field "Invoice Amount"
  • Update custom field "Invoice Date"
  • Update custom field "Invoice Status" = "Sent"
  • Update custom field "Due Date"

Create Invoice Activity

Add activity/note to deal:

  • "Invoice #[number] for $[amount] sent to [email] on [date]. Due [due date]."

This creates an audit trail visible in CRM.

Link Invoice

If your CRM supports it, store the invoice URL or PDF link for easy access.

Step 7: Payment Tracking

The workflow shouldn't stop at invoice send. Track payment and sync status.

Payment Triggers

Set up a separate workflow triggered by:

  • "Invoice Paid" in billing system
  • "Invoice Overdue" in billing system

On Payment Received

Update CRM:

  • "Invoice Status" = "Paid"
  • "Payment Date" = [Date]
  • "Payment Amount" = [Amount]
  • Add activity note with payment details

This keeps sales team informed about payment status without checking another system.

On Invoice Overdue

When invoice passes due date without payment:

  • Update CRM status to "Overdue"
  • Notify accounts receivable
  • Optionally trigger payment reminder sequence

You can build full AR automation on top of this basic integration.

Complete Workflow Diagram

Deal marked "Closed Won"
          ↓
Get deal data (customer, products, pricing)
          ↓
Check: Customer exists in billing system?
    ↓               ↓
   Yes             No
    ↓               ↓
Get customer ID   Create customer
    ↓               ↓
    └───────┬───────┘
            ↓
    Create invoice
    - Line items from deal products
    - Calculate tax
    - Set due date from terms
            ↓
    Send invoice to customer
            ↓
    Update CRM with invoice details
            ↓
    Monitor for payment
            ↓
    ┌───────┴───────┐
    ↓               ↓
  Paid           Overdue
    ↓               ↓
Update CRM    Trigger reminder
status        sequence

Handling Edge Cases

Partial Payments

Some billing systems support partial payments:

  • Track remaining balance
  • Update CRM with partial status
  • Continue reminders until fully paid

Refunds and Credits

If deals need adjustment after invoicing:

  • Build workflow for credit memo creation
  • Update CRM with adjusted amounts
  • Maintain audit trail

Multiple Invoices per Deal

For milestone billing or split payments:

  • Create invoice schedule in deal
  • Generate invoices at each milestone
  • Track total billed vs total value

Currency and International Billing

For multi-currency deals:

  • Store currency in deal record
  • Create invoice in correct currency
  • Handle exchange rates per your billing system

Testing Your Automation

Before going live:

  1. Test with fake deal: Create a test deal, move to Closed Won
  2. Verify invoice details: Check all fields mapped correctly
  3. Confirm email received: Check the invoice email arrives
  4. Test payment flow: Mark invoice paid, verify CRM updates
  5. Check edge cases: What happens with missing data? Custom pricing?

Create a test customer in your billing system that doesn't receive real emails.

Common Issues and Fixes

Products don't match between systems: Create product mapping table. When CRM product = "X", billing product = "Y".

Tax calculation wrong: Verify tax settings in billing system. Check customer location is correct. For more accounting automation, see our QuickBooks automation guide.

Invoice amounts don't match deal: Trace line items through the flow. Look for rounding issues or missed products.

Customer not found: Search criteria might be too strict. Try email-only match if name matching fails.

Duplicate invoices: Add check: "Has this deal already been invoiced?" before creating new invoice.

Results to Expect

Companies implementing CRM-to-invoice automation report:

  • Invoicing delay reduced from 1-3 days to instant
  • 90%+ reduction in invoice errors
  • Days Sales Outstanding (DSO) improvement of 5-10 days
  • Finance team time savings of 5-10 hours weekly

The biggest win is often consistency. Every deal gets invoiced immediately. No deals slip through cracks. No manual errors in amounts or customer details.


Need help connecting your CRM to billing? Contact Automiva or read about AI for finance teams.