AutomationFlowsData & Sheets › Fan Monetization Events

Fan Monetization Events

05 - Fan Monetization Events. Uses postgres, httpRequest. Webhook trigger; 6 nodes.

Webhook trigger★★★★☆ complexity6 nodesPostgresHTTP Request
Data & Sheets Trigger: Webhook Nodes: 6 Complexity: ★★★★☆ Added:

This workflow follows the HTTP Request → Postgres recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "05 - Fan Monetization Events",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "stripe-webhook",
        "responseMode": "onReceived"
      },
      "name": "Webhook: Stripe Event",
      "type": "n8n-nodes-base.webhook",
      "position": [
        250,
        300
      ],
      "id": "node-stripe-webhook"
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.type }}",
              "operation": "contains",
              "value2": "payment_intent.succeeded"
            }
          ]
        }
      },
      "name": "If: Payment Succeeded",
      "type": "n8n-nodes-base.if",
      "position": [
        500,
        300
      ],
      "id": "node-if-payment"
    },
    {
      "parameters": {
        "jsCode": "// Parse metadata from Stripe payment\nconst data = $json.data.object;\nconst meta = data.metadata;\n\n// Calculate royalty splits\nconst gross = data.amount;\nconst platform_cut = Math.floor(gross * 0.15); // 15% platform fee\nconst creator_cut = Math.floor(gross * 0.70); // 70% to creator\nconst remixer_cut = meta.remixer_id ? Math.floor(gross * 0.15) : 0; // 15% to remixer if remix\n\nreturn [{\n  json: {\n    track_id: meta.track_id,\n    creator_id: meta.creator_id,\n    remixer_id: meta.remixer_id || null,\n    event_type: meta.event_type, // stream | stem_sale | remix_license | subscription\n    gross_cents: gross,\n    splits: {\n      platform: platform_cut,\n      creator: creator_cut,\n      remixer: remixer_cut\n    },\n    fan_id: meta.fan_id,\n    stripe_payment_id: data.id\n  }\n}];"
      },
      "name": "Code: Calculate Splits",
      "type": "n8n-nodes-base.code",
      "position": [
        750,
        300
      ],
      "id": "node-splits"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO royalty_events (id, track_id, event_type, gross_cents, splits, paid_at) VALUES (gen_random_uuid(), '{{ $json.track_id }}', '{{ $json.event_type }}', {{ $json.gross_cents }}, '{{ JSON.stringify($json.splits) }}'::jsonb, NOW())"
      },
      "name": "Neon: Log Royalty Event",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1000,
        200
      ],
      "id": "node-log-royalty"
    },
    {
      "parameters": {
        "url": "={{ $env.BRAIN_URL }}/events/core",
        "method": "POST",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "event",
              "value": "royalty.earned"
            },
            {
              "name": "payload",
              "value": "={{ $json }}"
            }
          ]
        }
      },
      "name": "Brain: Emit royalty.earned",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1000,
        400
      ],
      "id": "node-brain-royalty"
    },
    {
      "parameters": {
        "url": "={{ $env.THINKZONE_API_URL }}/v1/tools",
        "method": "POST",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "tool",
              "value": "notify_owner"
            },
            {
              "name": "message",
              "value": "\ud83d\udcb8 Royalty earned: ${{ ($json.gross_cents / 100).toFixed(2) }} on track {{ $json.track_id }} ({{ $json.event_type }}). Creator gets ${{ ($json.splits.creator / 100).toFixed(2) }}."
            }
          ]
        }
      },
      "name": "Notify Creator",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1250,
        300
      ],
      "id": "node-notify"
    }
  ],
  "connections": {
    "Webhook: Stripe Event": {
      "main": [
        [
          {
            "node": "If: Payment Succeeded",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If: Payment Succeeded": {
      "main": [
        [
          {
            "node": "Code: Calculate Splits",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code: Calculate Splits": {
      "main": [
        [
          {
            "node": "Neon: Log Royalty Event",
            "type": "main",
            "index": 0
          },
          {
            "node": "Brain: Emit royalty.earned",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Neon: Log Royalty Event": {
      "main": [
        [
          {
            "node": "Notify Creator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    "disco-bass",
    "monetization",
    "royalties"
  ]
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

05 - Fan Monetization Events. Uses postgres, httpRequest. Webhook trigger; 6 nodes.

Source: https://github.com/think-zone/creator-os/blob/main/n8n-workflows/05-fan-monetization.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

CMM. Uses httpRequest, postgres, redis. Webhook trigger; 90 nodes.

HTTP Request, Postgres, Redis
Data & Sheets

Scraping. Uses httpRequest, postgres, @apify/n8n-nodes-apify, respondToWebhook. Webhook trigger; 61 nodes.

HTTP Request, Postgres, @Apify/N8N Nodes Apify
Data & Sheets

Workflow B — AI Listing Engine. Uses httpRequest, postgres, errorTrigger. Webhook trigger; 47 nodes.

HTTP Request, Postgres, Error Trigger
Data & Sheets

LogSentinel Workflow. Uses postgres, emailSend, httpRequest. Webhook trigger; 44 nodes.

Postgres, Email Send, HTTP Request
Data & Sheets

Post-Prayer. Uses postgres, httpRequest. Webhook trigger; 44 nodes.

Postgres, HTTP Request