{
  "name": "Stripe Payment → Receipt + Slack Alert (FlowsOnDemand)",
  "nodes": [
    {
      "parameters": {
        "events": ["payment_intent.succeeded"]
      },
      "id": "node-stripe",
      "name": "Stripe Payment Succeeded",
      "type": "n8n-nodes-base.stripeTrigger",
      "typeVersion": 1,
      "position": [240, 300],
      "notesInFlow": true,
      "notes": "Connect your Stripe credential. Fires when a payment succeeds."
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Normalize the Stripe payment payload into clean receipt fields.\nconst p = $input.item.json.data?.object || $input.item.json;\n\nconst amount = (Number(p.amount_received ?? p.amount ?? 0) / 100).toFixed(2);\nconst currency = String(p.currency || 'usd').toUpperCase();\nconst email = p.receipt_email || p.charges?.data?.[0]?.billing_details?.email || 'unknown';\nconst name = p.charges?.data?.[0]?.billing_details?.name || 'Customer';\n\nreturn {\n  json: {\n    customer_name: name,\n    customer_email: email,\n    amount,\n    currency,\n    payment_id: p.id,\n    paid_at: new Date().toISOString()\n  }\n};"
      },
      "id": "node-format",
      "name": "Format Receipt Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "sendTo": "={{ $json.customer_email }}",
        "subject": "=Your receipt — {{ $json.currency }} {{ $json.amount }}",
        "emailType": "html",
        "message": "=<h2>Thanks for your payment, {{ $json.customer_name }}!</h2><p>We've received <strong>{{ $json.currency }} {{ $json.amount }}</strong>.</p><p>Payment reference: {{ $json.payment_id }}</p><p>This email is your receipt.</p>",
        "options": {}
      },
      "id": "node-gmail",
      "name": "Email Receipt",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [680, 220],
      "notesInFlow": true,
      "notes": "Connect Gmail (or swap for the SMTP node). Sends the customer their receipt."
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": { "__rl": true, "value": "#revenue", "mode": "name" },
        "text": "=:moneybag: New payment: *{{ $json.currency }} {{ $json.amount }}* from {{ $json.customer_name }} ({{ $json.customer_email }})",
        "otherOptions": {}
      },
      "id": "node-slack",
      "name": "Post Revenue Alert",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [680, 400],
      "notesInFlow": true,
      "notes": "Connect Slack and pick your revenue channel."
    }
  ],
  "connections": {
    "Stripe Payment Succeeded": { "main": [[{ "node": "Format Receipt Data", "type": "main", "index": 0 }]] },
    "Format Receipt Data": {
      "main": [
        [
          { "node": "Email Receipt", "type": "main", "index": 0 },
          { "node": "Post Revenue Alert", "type": "main", "index": 0 }
        ]
      ]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "pinData": {},
  "meta": { "templatecredsSetupCompleted": false },
  "tags": [{ "name": "FlowsOnDemand" }]
}
