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

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:
- Trigger when a deal moves to "Closed Won" in your CRM
- Pull deal information (customer, products, pricing, terms)
- Create an invoice in your billing/accounting system
- Send the invoice to the customer
- Update the CRM with invoice details
- 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 Field | Invoice Field |
|---|---|
| Account Name | Customer Name |
| Billing Contact Email | Invoice Email |
| Billing Address | Customer Address |
| Product Line Items | Invoice Line Items |
| Unit Prices | Line Item Amounts |
| Quantities | Line Item Quantities |
| Discount | Discount |
| Deal Total | Invoice Total |
| Payment Terms | Due Date Calculation |
| Deal Number | Reference 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
- Search billing system by email or company name
- If found: use existing customer ID
- 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:
- Get PDF invoice from billing system
- Send via your email tool with custom template
- 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:
- Test with fake deal: Create a test deal, move to Closed Won
- Verify invoice details: Check all fields mapped correctly
- Confirm email received: Check the invoice email arrives
- Test payment flow: Mark invoice paid, verify CRM updates
- 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.