{
  "name": "Stripe Payment \u2192 Invoice + Email",
  "nodes": [
    {
      "parameters": {
        "events": [
          "payment_intent.succeeded"
        ]
      },
      "id": "stripe",
      "name": "Stripe Trigger",
      "type": "n8n-nodes-base.stripeTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const p = $input.first().json;\nreturn {customer: p.customer_name, email: p.receipt_email, amount: '$'+(p.amount/100).toFixed(2), date: new Date().toLocaleDateString(), invoice: 'INV-'+Date.now()};"
      },
      "id": "fmt",
      "name": "Format Invoice",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const d=$input.first().json; return {html:'<h1>Invoice '+d.invoice+'</h1><p>Customer: '+d.customer+'</p><p>Amount: '+d.amount+'</p>'};"
      },
      "id": "html",
      "name": "Build HTML",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "fromEmail": "billing@example.com",
        "toEmail": "={{ $('Format Invoice').first().json.email }}",
        "subject": "Your Invoice",
        "html": "={{ $json.html }}"
      },
      "id": "email",
      "name": "Send Invoice",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "Stripe Trigger": {
      "main": [
        [
          {
            "node": "Format Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Invoice": {
      "main": [
        [
          {
            "node": "Build HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build HTML": {
      "main": [
        [
          {
            "node": "Send Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}