{
  "name": "Automate payment receipts: Email, archive, and track with Stripe and Google Workspace",
  "nodes": [
    {
      "id": "cdfad755-0724-4156-b4ec-04a671a85013",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1104,
        -32
      ]
    },
    {
      "id": "a511f05a-495d-4066-af54-9b977ca59aec",
      "name": "Fetch Invoices",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -848,
        -32
      ]
    },
    {
      "id": "c24bc890-1e3e-4334-88a2-69fcd2c0be5e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        128
      ],
      "parameters": {
        "width": null,
        "height": 272,
        "content": "Fetch Invoices\n\nDescription: Makes an authenticated request to the Stripe API and retrieves the 5 most recent invoices. This serves as the raw dataset that contains invoice details such as customer in"
      }
    },
    {
      "id": "1d8ec260-aa38-4dfa-8f73-98ea5e5e671c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        -544
      ],
      "parameters": {
        "width": null,
        "height": 288,
        "content": "Send Receipt Email – \n\nDescription: Sends an email to the customer using the invoice details (customer name, invoice number, amount, etc.). The previously downloaded invoice PDF is attached automatica"
      }
    },
    {
      "id": "94dac976-2243-463c-8ac0-5bf2b3061a95",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        80
      ],
      "parameters": {
        "width": null,
        "height": 240,
        "content": "Download File \n\nDescription: Uses the invoice’s hosted PDF link (invoice_pdf) to fetch the actual receipt document. It retrieves the PDF from Stripe as binary data, making it usable as an email attach"
      }
    },
    {
      "id": "afba0c2a-08e2-4d19-ab7f-29e79b70c29a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        -352
      ],
      "parameters": {
        "width": null,
        "height": 256,
        "content": "IF (Already Receipted?) \n\nDescription: Looks into the invoice metadata field receipt_sent. If the receipt has already been generated and sent, the workflow will skip. Otherwise, it continues to genera"
      }
    },
    {
      "id": "64a4d0dc-6d8f-4728-adaf-ce509afce060",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        96
      ],
      "parameters": {
        "width": null,
        "height": 224,
        "content": "IF (Paid?)\n\nDescription: Evaluates whether the invoice is marked as status = paid. Only paid invoices should move forward to receipt generation. Unpaid or draft invoices are skipped here.\nAction: Rout"
      }
    },
    {
      "id": "d776ef15-e417-4449-a2a5-e1c53319f87e",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -368
      ],
      "parameters": {
        "width": null,
        "height": 288,
        "content": "Expand List\n\nDescription: Since Stripe returns a bundled list of invoices, this node breaks them into individual records. That way, each invoice can be independently evaluated (paid/unpaid, receipted/"
      }
    },
    {
      "id": "8c3f5034-5e26-429d-9d30-4f56dd99db5d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        288
      ],
      "parameters": {
        "width": null,
        "height": 288,
        "content": "Append to Ledger \n\nDescription: Adds a new row in the “Payment Receipts” Google Sheet ledger with key invoice details such as date, invoice number, file name, Drive link, file ID, and file size. This "
      }
    },
    {
      "id": "aacfb7d2-7acb-4b1a-a7c7-39069a01055f",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        272
      ],
      "parameters": {
        "width": null,
        "height": 208,
        "content": "Upload Invoice PDF \n\nDescription: Uploads the invoice PDF into a specific Google Drive folder. The file is named according to the invoice number, making it easy to search and retrieve later.\nAction: S"
      }
    },
    {
      "id": "b107aa2b-90b9-48fe-98dc-d828012444e7",
      "name": "Expand List",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -336,
        -48
      ]
    },
    {
      "id": "a83ac85d-4737-44bc-877e-6844389a9689",
      "name": "IF (Paid?)",
      "type": "n8n-nodes-base.if",
      "position": [
        -128,
        -48
      ]
    },
    {
      "id": "d7fec273-c100-43bf-9ddc-311f31b34493",
      "name": "IF (Already Receipted?)",
      "type": "n8n-nodes-base.if",
      "position": [
        128,
        -64
      ]
    },
    {
      "id": "c2dbb175-469f-4c19-8466-08afba27115d",
      "name": "Download File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        464,
        -80
      ]
    },
    {
      "id": "49c0e75c-8b77-4d43-bc71-60b6bd02519a",
      "name": "Send Receipt Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        736,
        -240
      ]
    },
    {
      "id": "b4401084-8c70-47f3-8804-637c9bef9834",
      "name": "Upload Invoice PDF",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        768,
        112
      ]
    },
    {
      "id": "1efedacb-1e07-4e23-ab7c-19e0e21b6b08",
      "name": "Append to Ledger",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1040,
        112
      ]
    },
    {
      "id": "f535062a-1ced-46d3-8b4e-73aaeb6c6e3b",
      "name": " Error Logging",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -384,
        272
      ]
    },
    {
      "id": "6f14b401-170b-4fb8-ae5d-aa079f7549cb",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        432
      ],
      "parameters": {
        "width": null,
        "height": 320,
        "content": "Action: Logs workflow errors and failures to a dedicated error tracking spreadsheet for monitoring and debugging purposes. \n\nDescription: This Google Sheets append node serves as the error logging des"
      }
    },
    {
      "id": "4cd976cd-8739-47ad-bddd-25d0973c3cd8",
      "name": "Check API Response",
      "type": "n8n-nodes-base.if",
      "position": [
        -608,
        -32
      ]
    },
    {
      "id": "89781301-0ca4-4dc7-924f-0ea978d6bc83",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        -400
      ],
      "parameters": {
        "width": null,
        "height": 336,
        "content": "Action: Validates that the Stripe API returned a proper data array before attempting to process invoices. \n\nDescription: This conditional node acts as a data quality gate that prevents the workflow fr"
      }
    }
  ],
  "connections": {
    "IF (Paid?)": {
      "main": [
        [
          {
            "node": "IF (Already Receipted?)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Expand List": {
      "main": [
        [
          {
            "node": "IF (Paid?)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Send Receipt Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload Invoice PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Invoices": {
      "main": [
        [
          {
            "node": "Check API Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check API Response": {
      "main": [
        [
          {
            "node": "Expand List",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": " Error Logging",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Receipt Email": {
      "main": [
        []
      ]
    },
    "Upload Invoice PDF": {
      "main": [
        [
          {
            "node": "Append to Ledger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF (Already Receipted?)": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Fetch Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}