{
  "name": "Stripe Kauf Fulfillment per E-Mail",
  "nodes": [
    {
      "parameters": {
        "path": "stripe-purchase-fulfillment",
        "httpMethod": "POST",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "stripe-webhook-empfangen",
      "name": "Stripe Webhook empfangen",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "return items.map((item) => ({ json: { ...item.json, signatureValid: true, eventType: item.json.type || \"checkout.session.completed\" } }));"
      },
      "id": "signatur-demo-pruefen",
      "name": "Signatur Demo pruefen",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "leftValue": "={{ $json.signatureValid }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ]
        },
        "options": {}
      },
      "id": "event-akzeptieren",
      "name": "Event akzeptieren?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        520,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "leftValue": "={{ $json.eventType }}",
              "rightValue": "checkout.session.completed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ]
        },
        "options": {}
      },
      "id": "kauf-abgeschlossen",
      "name": "Kauf abgeschlossen?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        780,
        -120
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://example.com/api/orders",
        "sendBody": true,
        "contentType": "json",
        "jsonBody": "={{ $json }}",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "email",
              "value": "kunde@example.com"
            }
          ]
        }
      },
      "id": "bestellung-suchen",
      "name": "Bestellung suchen",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1040,
        -220
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://example.com/api/orders/lock",
        "sendBody": true,
        "contentType": "json",
        "jsonBody": "={\"email\":\"kunde@example.com\",\"event\":\"{{$json.eventType}}\"}",
        "options": {}
      },
      "id": "fulfillment-sperren",
      "name": "Fulfillment sperren",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1040,
        0
      ]
    },
    {
      "parameters": {
        "fromEmail": "team@example.com",
        "toEmail": "kunde@example.com",
        "subject": "Ihr Zugang ist bereit",
        "html": "<p>Ihr Zugang ist unter https://example.com/login vorbereitet.</p>",
        "options": {}
      },
      "id": "zugang-per-e-mail-senden",
      "name": "Zugang per E-Mail senden",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1300,
        -160
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://example.com/api/orders/fulfilled",
        "sendBody": true,
        "contentType": "json",
        "jsonBody": "={\"email\":\"kunde@example.com\",\"status\":\"sent\"}",
        "options": {}
      },
      "id": "fulfillment-protokollieren",
      "name": "Fulfillment protokollieren",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1560,
        -160
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "post",
        "channel": "#team",
        "text": "Neuer Demo-Kauf wurde verarbeitet."
      },
      "id": "team-ueber-kauf-informieren",
      "name": "Team ueber Kauf informieren",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        1560,
        90
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\"received\":true}",
        "options": {}
      },
      "id": "stripe-200-antworten",
      "name": "Stripe 200 antworten",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        1820,
        -20
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\"received\":false}",
        "options": {}
      },
      "id": "webhook-ablehnen",
      "name": "Webhook ablehnen",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        780,
        170
      ]
    }
  ],
  "connections": {
    "Stripe Webhook empfangen": {
      "main": [
        [
          {
            "node": "Signatur Demo pruefen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Signatur Demo pruefen": {
      "main": [
        [
          {
            "node": "Event akzeptieren?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Event akzeptieren?": {
      "main": [
        [
          {
            "node": "Kauf abgeschlossen?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Webhook ablehnen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Kauf abgeschlossen?": {
      "main": [
        [
          {
            "node": "Bestellung suchen",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fulfillment sperren",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stripe 200 antworten",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bestellung suchen": {
      "main": [
        [
          {
            "node": "Zugang per E-Mail senden",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fulfillment sperren": {
      "main": [
        [
          {
            "node": "Zugang per E-Mail senden",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zugang per E-Mail senden": {
      "main": [
        [
          {
            "node": "Fulfillment protokollieren",
            "type": "main",
            "index": 0
          },
          {
            "node": "Team ueber Kauf informieren",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fulfillment protokollieren": {
      "main": [
        [
          {
            "node": "Stripe 200 antworten",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Team ueber Kauf informieren": {
      "main": [
        [
          {
            "node": "Stripe 200 antworten",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}
