AutomationFlowsFinance › Generate Invoice Pdfs From Stripe Payments Using Templatefox, Gmail and Drive

Generate Invoice Pdfs From Stripe Payments Using Templatefox, Gmail and Drive

ByVince V @templatefox on n8n.io

This workflow automatically generates and delivers professional invoice PDFs whenever a Stripe checkout session completes. It fetches the line items from Stripe, formats them into a clean invoice with your company details, generates a branded PDF via TemplateFox, emails it to…

Event trigger★★★★☆ complexity11 nodesStripe TriggerHTTP RequestN8N Nodes TemplatefoxGmailGoogle Drive
Finance Trigger: Event Nodes: 11 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #14761 — we link there as the canonical source.

This workflow follows the Gmail → Google Drive recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Stripe payment \u2192 Invoice PDF \u2192 Gmail + Google Drive",
  "nodes": [
    {
      "id": "b1000001-0000-4000-a000-000000000001",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        -140
      ],
      "parameters": {
        "width": 440,
        "height": 700,
        "content": "### Stripe payment \u2192 Invoice PDF \u2192 Gmail + Google Drive\nAutomatically generate and deliver professional invoice PDFs when a Stripe payment succeeds.\n\n**Full tutorial:** [pdftemplateapi.com/n8n/automate-invoices](https://pdftemplateapi.com/n8n/automate-invoices)\n\n### How it works\n1. **Stripe Trigger** fires on every successful checkout session\n2. **HTTP Request** fetches the line items for that session\n3. **Code** node formats the data to match your invoice template fields\n4. **TemplateFox** generates a branded PDF invoice\n5. Invoice is **emailed** to the customer and **saved to Google Drive**\n\n### Setup\n- [ ] Add your **Stripe Secret Key** (`sk_live_` or `sk_test_`) from [dashboard.stripe.com/apikeys](https://dashboard.stripe.com/apikeys)\n- [ ] Install the **TemplateFox** community node (`n8n-nodes-templatefox`)\n- [ ] Add your **TemplateFox** API key \u2014 [get one free](https://app.pdftemplateapi.com)\n- [ ] Connect **Gmail** OAuth2\n- [ ] Connect **Google Drive** OAuth2\n- [ ] Select your invoice template in the TemplateFox node\n- [ ] Set your company details directly in the template (not in the Code node)\n- [ ] Set your **Google Drive folder ID** in the Google Drive node\n\n### Customize\n- Change the email body in the Gmail node\n- Adjust the invoice number format in the Code node\n- Add a Slack notification node after Google Drive for team alerts"
      },
      "typeVersion": 1
    },
    {
      "id": "b1000001-0000-4000-a000-000000000002",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        -140
      ],
      "parameters": {
        "color": 7,
        "width": 280,
        "height": 360,
        "content": "## 1. Receive payment\nStripe fires a webhook when a checkout session completes."
      },
      "typeVersion": 1
    },
    {
      "id": "b1000001-0000-4000-a000-000000000003",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -140
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 360,
        "content": "## 2. Fetch & format data\nRetrieve line items from Stripe and format them for the invoice template."
      },
      "typeVersion": 1
    },
    {
      "id": "b1000001-0000-4000-a000-000000000004",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -140
      ],
      "parameters": {
        "color": 7,
        "width": 860,
        "height": 480,
        "content": "## 3. Generate & deliver\nCreate the PDF and send it via email + save to Drive."
      },
      "typeVersion": 1
    },
    {
      "id": "b1000001-0000-4000-a000-000000000010",
      "name": "Stripe Trigger",
      "type": "n8n-nodes-base.stripeTrigger",
      "position": [
        40,
        0
      ],
      "parameters": {
        "events": [
          "checkout.session.completed"
        ]
      },
      "typeVersion": 1
    },
    {
      "id": "b1000001-0000-4000-a000-000000000011",
      "name": "Get Line Items",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        360,
        0
      ],
      "parameters": {
        "url": "=https://api.stripe.com/v1/checkout/sessions/{{ $json.data.object.id }}/line_items",
        "limit": 1,
        "method": "GET",
        "options": {},
        "resource": "checkout",
        "operation": "getAll",
        "returnAll": false,
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "stripeApi"
      },
      "credentials": {},
      "typeVersion": 4.2
    },
    {
      "id": "b1000001-0000-4000-a000-000000000012",
      "name": "Format Invoice Data",
      "type": "n8n-nodes-base.code",
      "position": [
        600,
        0
      ],
      "parameters": {
        "jsCode": "// \u2500\u2500\u2500 Company details (edit these) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nconst company = {\n  company_name: 'Bright Studio LLC',\n  company_tagline: 'Creative solutions for modern brands',\n  company_address_1: '45 Innovation Drive, Suite 200',\n  company_address_2: 'Austin, TX 73301, USA',\n  company_email: 'user@example.com',\n  company_reg: 'REG-2024-BS-7841',\n  company_vat: 'US-VAT-8834201',\n  bank_name: 'First National Bank',\n  account_name: 'Bright Studio LLC',\n  iban: 'US82 FNBK +1234567890',\n  bic: 'FNBKUS33',\n  payment_terms: 'Net 30',\n  notes: 'Thank you for your business!',\n};\n\n// \u2500\u2500\u2500 Extract Stripe data \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nconst trigger = $('Stripe Trigger').first().json;\nconst session = trigger.data.object;\nconst lineItemsRaw = $input.first().json.data || [];\n\n// Customer info from Stripe checkout session\nconst customer = session.customer_details || {};\nconst address = customer.address || {};\n\n// Format line items for invoice template\nconst items = lineItemsRaw.map((item, i) => ({\n  item_description: item.description || item.price?.product?.name || `Item ${i + 1}`,\n  item_quantity: item.quantity || 1,\n  item_price: ((item.amount_total || item.price?.unit_amount || 0) / 100 / (item.quantity || 1)).toFixed(2),\n  item_total: ((item.amount_total || item.price?.unit_amount || 0) / 100).toFixed(2),\n}));\n\n// Generate invoice number from session date + ID\nconst now = new Date();\nconst invoiceNumber = `INV-${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}-${session.id.slice(-6).toUpperCase()}`;\n\n// Calculate due date (Net 30)\nconst dueDate = new Date(now);\ndueDate.setDate(dueDate.getDate() + 30);\n\nconst formatDate = (d) => d.toISOString().split('T')[0];\n\nreturn [{\n  json: {\n    ...company,\n    client_company: customer.name || 'Customer',\n    client_address_1: [address.line1, address.line2].filter(Boolean).join(', ') || '',\n    client_address_2: [address.city, address.state, address.postal_code, address.country].filter(Boolean).join(', ') || '',\n    client_email: customer.email || session.customer_email || '',\n    invoice_number: invoiceNumber,\n    invoice_date: formatDate(now),\n    due_date: formatDate(dueDate),\n    items: items,\n    subtotal: (session.amount_subtotal / 100).toFixed(2),\n    tax: ((session.total_details?.amount_tax || 0) / 100).toFixed(2),\n    total: (session.amount_total / 100).toFixed(2),\n    currency: (session.currency || 'usd').toUpperCase(),\n    _client_email: customer.email || session.customer_email || '',\n    _client_name: customer.name || 'Customer',\n    _pdf_filename: invoiceNumber,\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "b1000001-0000-4000-a000-000000000013",
      "name": "TemplateFox",
      "type": "n8n-nodes-templatefox.templateFox",
      "position": [
        940,
        0
      ],
      "parameters": {
        "options": {
          "filename": "={{ $json._pdf_filename }}"
        },
        "operation": "generatePdf",
        "templateId": "",
        "dataInputMode": "fields",
        "templateFields": {
          "value": null,
          "mappingMode": "defineBelow"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b1000001-0000-4000-a000-000000000014",
      "name": "Email Invoice",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1220,
        -80
      ],
      "parameters": {
        "sendTo": "={{ $('Format Invoice Data').first().json._client_email }}",
        "message": "=Hi {{ $('Format Invoice Data').first().json._client_name }},\n\nThank you for your purchase! Please find your invoice attached below.\n\n\ud83d\udcc4 Download PDF: {{ $json.url }}\n\nInvoice #: {{ $('Format Invoice Data').first().json.invoice_number }}\nAmount: {{ $('Format Invoice Data').first().json.total }} {{ $('Format Invoice Data').first().json.currency }}\nDue date: {{ $('Format Invoice Data').first().json.due_date }}\n\nIf you have any questions, reply to this email.\n\nBest regards,\n{{ $('Format Invoice Data').first().json.company_name }}",
        "options": {},
        "subject": "=Your Invoice {{ $('Format Invoice Data').first().json.invoice_number }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "b1000001-0000-4000-a000-000000000015",
      "name": "Download PDF",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1220,
        140
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "method": "GET",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b1000001-0000-4000-a000-000000000016",
      "name": "Save to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1460,
        140
      ],
      "parameters": {
        "name": "={{ $('Format Invoice Data').first().json._pdf_filename }}.pdf",
        "options": {},
        "folderId": "",
        "operation": "upload"
      },
      "typeVersion": 3
    }
  ],
  "settings": {
    "binaryMode": "separate",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "connections": {
    "TemplateFox": {
      "main": [
        [
          {
            "node": "Email Invoice",
            "type": "main",
            "index": 0
          },
          {
            "node": "Download PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download PDF": {
      "main": [
        [
          {
            "node": "Save to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Line Items": {
      "main": [
        [
          {
            "node": "Format Invoice Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stripe Trigger": {
      "main": [
        [
          {
            "node": "Get Line Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Invoice Data": {
      "main": [
        [
          {
            "node": "TemplateFox",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow automatically generates and delivers professional invoice PDFs whenever a Stripe checkout session completes. It fetches the line items from Stripe, formats them into a clean invoice with your company details, generates a branded PDF via TemplateFox, emails it to…

Source: https://n8n.io/workflows/14761/ — original creator credit. Request a take-down →

More Finance workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Finance

How It Works Trigger: Watches for new emails in Gmail with PDF/image attachments. OCR: Sends the attachment to OCR.space API (https://ocr.space/OCRAPI) to extract invoice text. Parsing: Extracts key f

Gmail Trigger, Google Sheets, Slack +3
Finance

Automated Stripe Payment to QuickBooks Sales Receipt

HTTP Request, Stripe, Stripe Trigger +1
Finance

Invoice PDF to Sheets. Uses googleDriveTrigger, googleDrive, httpRequest, googleSheets. Event-driven trigger; 10 nodes.

Google Drive Trigger, Google Drive, HTTP Request +1
Finance

Automatically processes vendor invoices received by email, creates QuickBooks bills with full details, and attaches the original PDF. Small/medium businesses using QuickBooks Online Bookkeepers proces

Gmail Trigger, Information Extractor, OpenAI Chat +3
Finance

This workflow is a sophisticated, end-to-end solution that automates the entire billing lifecycle, from invoice creation to intelligent payment reminders and status tracking. It's designed to give you

Google Sheets Trigger, Google Docs, OpenAI +4