{
  "name": "Create Stripe invoices from Airtable orders with Google Sheets logging",
  "nodes": [
    {
      "id": "7e7fd28b-de0f-4be1-806f-ff05fe0d383d",
      "name": "Workflow Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        80
      ],
      "parameters": {
        "width": 320,
        "height": 708,
        "content": "## 🚀 B2B Invoice Automation Workflow\n\nThis workflow automatically creates Stripe invoices for B2B paid orders and logs them to Google Sheets.\n\n### What it does:\n- Triggers every hour to check for new "
      }
    },
    {
      "id": "ff6b94d0-1292-4413-a374-72c9304d2bb2",
      "name": "Schedule Setup Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -160
      ],
      "parameters": {
        "width": 280,
        "height": 340,
        "content": "## ⏰ Schedule Setup\n\n**Purpose:** Triggers the workflow every hour to check for new orders\n\n**Configuration:**\n- Interval: 1 hour\n- Can be changed based on your needs\n\n**Tips:**\n- For testing, use man"
      }
    },
    {
      "id": "9d95e100-66c2-4bad-b3a3-9aafcdc6ea52",
      "name": "Hourly Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        80,
        208
      ]
    },
    {
      "id": "1e771a28-cf1d-4f20-bb4a-5f212bc5ef81",
      "name": "Airtable Setup Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        368
      ],
      "parameters": {
        "width": 300,
        "height": 376,
        "content": "## 📋 Airtable Setup\n\n**Purpose:** Fetch order data from your Airtable\n\n**Required Steps:**\n1. Replace the hardcoded record ID with your actual record ID\n2. Update base ID and table ID to match your se"
      }
    },
    {
      "id": "fdd91819-6baa-4c0c-bf05-2ef2ae931625",
      "name": "Fetch B2B Order",
      "type": "n8n-nodes-base.airtable",
      "position": [
        288,
        208
      ]
    },
    {
      "id": "87e76054-5d3e-4f98-b565-b2be586673ac",
      "name": "Order Filter Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        -176
      ],
      "parameters": {
        "width": 280,
        "height": 336,
        "content": "## 🔍 Order Filtering\n\n**Purpose:** Only process B2B orders that are already paid\n\n**Filter Conditions:**\n- financial_status = \"paid\"\n- tags contains \"B2B\"\n- Both conditions must be true (AND logic)\n\n*"
      }
    },
    {
      "id": "72e1a601-e9c4-4e65-93db-f4dcb23d9530",
      "name": "Filter B2B Paid Orders",
      "type": "n8n-nodes-base.if",
      "position": [
        512,
        208
      ]
    },
    {
      "id": "aa6e2bc9-1e47-4a4a-9236-cd2066c8b1ac",
      "name": "Stripe Customer Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        384
      ],
      "parameters": {
        "width": 300,
        "height": 452,
        "content": "## 👤 Stripe Customer Creation\n\n**Purpose:** Create or update customer in Stripe\n\n**Configuration:**\n- Maps customer data from Airtable\n- Uses continueOnFail to handle existing customers\n- Stores custo"
      }
    },
    {
      "id": "162bda8f-8ab2-467b-a856-ee7796da8e81",
      "name": "Create Stripe Customer",
      "type": "n8n-nodes-base.stripe",
      "position": [
        736,
        208
      ]
    },
    {
      "id": "bc462aa9-f034-4e7f-8a07-5668b462396a",
      "name": "Line Items Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -208
      ],
      "parameters": {
        "width": 280,
        "height": 384,
        "content": "## 📄 Line Item Processing\n\n**Purpose:** Split orders into individual line items for invoicing\n\n**What it does:**\n- Processes each product in the order separately\n- Formats data for Stripe invoice crea"
      }
    },
    {
      "id": "8d23c8a5-9ca5-43ac-a69c-c0ae0e71d1f5",
      "name": "Process Line Items",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        208
      ]
    },
    {
      "id": "188a61b7-5c0f-4bab-a2e9-8c15ebf18d7b",
      "name": "Invoice Creation Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        384
      ],
      "parameters": {
        "width": 300,
        "height": 372,
        "content": "## 🧾 Invoice Creation\n\n**Purpose:** Create draft invoice in Stripe\n\n**Configuration:**\n- Creates invoice for the customer\n- Sets 30-day payment terms\n- Uses send_invoice collection method\n- Includes a"
      }
    },
    {
      "id": "8e7661ce-e5e0-4011-96ad-c63f561ddfee",
      "name": "Create Stripe Invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1184,
        208
      ]
    },
    {
      "id": "4f617671-ca7c-4da7-8d32-f15e5845431a",
      "name": "Finalization Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1312,
        -192
      ],
      "parameters": {
        "width": 280,
        "height": 384,
        "content": "## ✅ Invoice Finalization\n\n**Purpose:** Finalize the draft invoice to make it payable\n\n**What happens:**\n- Converts draft to final invoice\n- Generates invoice number\n- Makes invoice payable by custome"
      }
    },
    {
      "id": "fdf51683-a973-4a01-9872-3df221a34526",
      "name": "Finalize Invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1392,
        208
      ]
    },
    {
      "id": "6811b3d3-4b24-4637-97be-d5d32b9576e8",
      "name": "Data Formatting Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1536,
        400
      ],
      "parameters": {
        "width": 280,
        "height": 368,
        "content": "## 📊 Data Formatting\n\n**Purpose:** Format invoice data for Google Sheets logging\n\n**Data includes:**\n- Invoice details (ID, number, status)\n- Customer information\n- Financial amounts (converted from c"
      }
    },
    {
      "id": "60bf510e-5a75-4e55-af01-0ca305ddeee5",
      "name": "Format Data for Sheets",
      "type": "n8n-nodes-base.code",
      "position": [
        1584,
        208
      ]
    },
    {
      "id": "57fcfb57-b703-4f89-baa9-d784b1f3dd48",
      "name": "Sheets Logging Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        -304
      ],
      "parameters": {
        "width": 300,
        "height": 488,
        "content": "## 📋 Google Sheets Logging\n\n**Purpose:** Log invoice data to spreadsheet for tracking\n\n**Setup Required:**\n1. Replace YOUR_SPREADSHEET_ID with your actual Google Sheets ID\n2. Ensure proper column head"
      }
    },
    {
      "id": "c36e89ac-03af-42c7-9c0e-6ca4c1780171",
      "name": "Log to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1792,
        208
      ]
    }
  ],
  "connections": {
    "Hourly Trigger": {
      "main": [
        [
          {
            "node": "Fetch B2B Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch B2B Order": {
      "main": [
        [
          {
            "node": "Filter B2B Paid Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Finalize Invoice": {
      "main": [
        [
          {
            "node": "Format Data for Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Line Items": {
      "main": [
        [
          {
            "node": "Create Stripe Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Stripe Invoice": {
      "main": [
        [
          {
            "node": "Finalize Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Stripe Customer": {
      "main": [
        [
          {
            "node": "Process Line Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter B2B Paid Orders": {
      "main": [
        [
          {
            "node": "Create Stripe Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Data for Sheets": {
      "main": [
        [
          {
            "node": "Log to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}