{
  "id": "YAlJiB1cYsqCxewZ",
  "name": "Automated Stripe Invoicing",
  "tags": [],
  "nodes": [
    {
      "id": "661eebe4-d77c-4a2e-a138-08c869acaa4e",
      "name": "ClickUp Trigger",
      "type": "n8n-nodes-base.clickUpTrigger",
      "position": [
        160,
        208
      ],
      "parameters": {
        "team": "90151078626",
        "events": [
          "taskStatusUpdated"
        ],
        "filters": {
          "listId": "901510285394"
        },
        "authentication": "oAuth2"
      },
      "typeVersion": 1
    },
    {
      "id": "3613ad72-0147-4808-94a5-73ff6eb52fce",
      "name": "Status = send invoice ",
      "type": "n8n-nodes-base.if",
      "position": [
        528,
        208
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "77c57b59-0fa4-4937-9580-aafc1ca5e11a",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.history_items[0].after.status }}",
              "rightValue": "send invoice"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "5a3d85b3-5cda-4dde-90ec-5246c6996e8d",
      "name": "Create Invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1264,
        192
      ],
      "parameters": {
        "url": "https://api.stripe.com/v1/invoices",
        "method": "POST",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "collection_method",
              "value": "send_invoice"
            },
            {
              "name": "customer",
              "value": "={{ $json.id }}"
            },
            {
              "name": "description",
              "value": "Thanks for working with SaviFlow!"
            },
            {
              "name": "due_date",
              "value": "={{ $today.toSeconds() +604800 }}"
            },
            {
              "name": "footer",
              "value": "This is the very cool footer"
            }
          ]
        },
        "nodeCredentialType": "stripeApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "4f7ab760-d0ea-4bf6-958c-d3dae124616c",
      "name": "Create Customer",
      "type": "n8n-nodes-base.stripe",
      "position": [
        1024,
        192
      ],
      "parameters": {
        "name": "={{ $json.name }}",
        "resource": "customer",
        "operation": "create",
        "additionalFields": {
          "email": "={{ $json.creator.email }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e186f44a-1b2a-4d6c-a969-aa914e656936",
      "name": "Create item invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1488,
        192
      ],
      "parameters": {
        "url": "https://api.stripe.com/v1/invoiceitems",
        "method": "POST",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "customer",
              "value": "={{ $('Create Customer').last().json.id }}"
            },
            {
              "name": "amount",
              "value": "={{ $('ClickUp').last().json.custom_fields[1].value *100 }}"
            },
            {
              "name": "description",
              "value": "Thanks for building the coolest automation with SaviFlow"
            },
            {
              "name": "currency",
              "value": "={{ $json.currency }}"
            },
            {
              "name": "invoice",
              "value": "={{ $json.id }}"
            }
          ]
        },
        "nodeCredentialType": "stripeApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "6188d291-3075-4e73-85f3-7cb095d765f2",
      "name": "Send invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1712,
        192
      ],
      "parameters": {
        "url": "=https://api.stripe.com/v1/invoices/{{ $('Create Invoice').item.json.id }}/send",
        "method": "POST",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "stripeApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "9b1b3f6e-1365-407a-aed9-51c320d9482a",
      "name": "Send email to you/team",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1968,
        192
      ],
      "parameters": {
        "sendTo": "={{ $('ClickUp').item.json.custom_fields[0].value }}",
        "message": "=Hi Seb, \n\nCongrats! You have sent a new invoice to {{ $('ClickUp').item.json.name }}\n\nView the task: https://app.clickup.com/t/{{ $('ClickUp Trigger').item.json.task_id }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "Yay! New invoice has been sent",
        "emailType": "text"
      },
      "typeVersion": 2.1
    },
    {
      "id": "71709554-e89e-46db-a457-7b600eea585b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 460,
        "height": 380,
        "content": "### Watches ClickUp For Updated Status\n\n\ud83d\udea8 Would recommend for this flow to put your Stripe account in \"Test Mode\" when running for the first time \ud83d\udea8 \n\nJust so you don't risk messing up any of your details on the live account. Would be worth making sure it works by first testing on \"Test Mode\" within Stripe"
      },
      "typeVersion": 1
    },
    {
      "id": "86234a6c-ecf1-490d-9f23-e6d218b81538",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        80
      ],
      "parameters": {
        "width": 680,
        "height": 300,
        "content": "## Invoice creation and Sending the invoice"
      },
      "typeVersion": 1
    },
    {
      "id": "e718ec9f-4901-406d-95c7-a59c9fd8b96e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1888,
        80
      ],
      "parameters": {
        "width": 260,
        "height": 300,
        "content": "### Notify's you or your team that a new invoice has been sent"
      },
      "typeVersion": 1
    },
    {
      "id": "1da341b2-bf43-4474-9210-5f251c3a19eb",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        80
      ],
      "parameters": {
        "width": 180,
        "height": 300,
        "content": "Creates a new customer in your Stripe Account"
      },
      "typeVersion": 1
    },
    {
      "id": "53aac334-3d04-4f5e-bbe0-c43f8b967933",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        80
      ],
      "parameters": {
        "height": 300,
        "content": "#### Gets the task that was updated and gets all of that tasks info to be processed in the invoice"
      },
      "typeVersion": 1
    },
    {
      "id": "427f5d4f-eeb7-4525-b5ba-4daa0c44a34b",
      "name": "ClickUp",
      "type": "n8n-nodes-base.clickUp",
      "position": [
        784,
        192
      ],
      "parameters": {
        "id": "={{ $('ClickUp Trigger').item.json.task_id }}",
        "operation": "get",
        "authentication": "oAuth2"
      },
      "typeVersion": 1
    },
    {
      "id": "b28e4195-bf48-4a42-b61e-9166e322e70d",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -448
      ],
      "parameters": {
        "color": 6,
        "width": 560,
        "height": 368,
        "content": "# Find my Socials: \n\n## YouTube: https://www.youtube.com/@SebGardners\n\n## LinkedIn: https://www.linkedin.com/in/seb-gardner-5b439a260/\n\n# Enjoy!"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "be82212f-4dd5-4301-87e0-781fdac5ea19",
  "connections": {
    "ClickUp": {
      "main": [
        [
          {
            "node": "Create Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send invoice": {
      "main": [
        [
          {
            "node": "Send email to you/team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Invoice": {
      "main": [
        [
          {
            "node": "Create item invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ClickUp Trigger": {
      "main": [
        [
          {
            "node": "Status = send invoice ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Customer": {
      "main": [
        [
          {
            "node": "Create Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create item invoice": {
      "main": [
        [
          {
            "node": "Send invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Status = send invoice ": {
      "main": [
        [
          {
            "node": "ClickUp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}