{
  "id": "psPMd959SNyGJq07",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automate Stripe customer data transfer to KlickTipp with dynamic tagging logic",
  "tags": [],
  "nodes": [
    {
      "id": "7dc3997d-6ed4-4297-b9ed-c92714e22676",
      "name": "1. Data reception & collection via Webhook & HTTP Requests",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 1068,
        "height": 952,
        "content": "## 1. Data reception & collection via Webhook & HTTP Requests"
      },
      "typeVersion": 1
    },
    {
      "id": "9e51eb19-9ea1-4e99-9c57-a7e8ea64d858",
      "name": "3. Saving data into contact record",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 952,
        "content": "## 3. Saving data into contact record"
      },
      "typeVersion": 1
    },
    {
      "id": "fc83b35f-6224-4d32-89d9-4bfe9cd0ff24",
      "name": "Getting invoice link",
      "type": "n8n-nodes-base.stripe",
      "notes": "This node gets the details from the payment in order to identify the line items and amount of the payment.",
      "position": [
        736,
        32
      ],
      "parameters": {
        "chargeId": "={{ $json.latest_charge }}",
        "resource": "charge"
      },
      "credentials": {},
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "cbf568d0-366d-4078-8d09-05723f47e83f",
      "name": "Getting charge ID",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "This node gets the charge ID from the checkout completion in order to be able to fetch the receipt url.",
      "position": [
        528,
        32
      ],
      "parameters": {
        "url": "=https://api.stripe.com/v1/payment_intents/{{ $('Watch new Stripe events').item.json.data.object.payment_intent }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "authorization",
              "value": "Basic <YOURKEY>"
            }
          ]
        },
        "nodeCredentialType": "stripeApi"
      },
      "credentials": {},
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "5211e469-88c7-4e50-b3b0-a8ff8777f985",
      "name": "Getting line items",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "This node gets the line items from the checkout session.",
      "position": [
        320,
        32
      ],
      "parameters": {
        "url": "=https://api.stripe.com/v1/checkout/sessions/{{ $json.data.object.id }}/line_items",
        "options": {},
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Stripe-Version",
              "value": "2025-05-28.basil"
            },
            {
              "name": "authorization",
              "value": "Basic <YOURKEY>"
            }
          ]
        },
        "nodeCredentialType": "stripeApi"
      },
      "credentials": {},
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "51d045cd-1ffd-4f24-8021-273cda7fd124",
      "name": "Tag contact for high-value order",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "position": [
        2000,
        -64
      ],
      "parameters": {
        "email": "={{ $json.email }}",
        "tagId": [
          "13629285"
        ],
        "resource": "contact-tagging"
      },
      "credentials": {},
      "typeVersion": 3
    },
    {
      "id": "b485e15e-aae5-4972-aaec-2633af35982c",
      "name": "Tag contact for clothing purchase",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "position": [
        2000,
        128
      ],
      "parameters": {
        "email": "={{ $json.email }}",
        "tagId": [
          "13629293"
        ],
        "resource": "contact-tagging"
      },
      "credentials": {},
      "typeVersion": 3
    },
    {
      "id": "941a5287-7a8f-4ea3-905e-1350787ece96",
      "name": "Route by SKU and total amount",
      "type": "n8n-nodes-base.switch",
      "position": [
        1680,
        32
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Order Value \u2265 100",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "60e8a476-a06c-4d95-9bc2-e8c621bd9a1a",
                    "operator": {
                      "type": "number",
                      "operation": "gte"
                    },
                    "leftValue": "={{ $('Getting invoice link').item.json.amount }}",
                    "rightValue": 100
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Order contains clothing",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c42480ed-b454-4604-a4d3-28c5c120497f",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{\n  ($('Getting line items').item.json.data ?? []).some(it => (it.price.metadata.sku ?? '') === 'TEST-002')\n}}",
                    "rightValue": "TEST-002"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "allMatchingOutputs": true
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "d42a3103-dc6e-40b5-8b29-6eeeb3d16005",
      "name": "4. Routing for tagging",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 952,
        "content": "## 4. Routing for tagging"
      },
      "typeVersion": 1
    },
    {
      "id": "63e25a4b-0f3f-42f2-b78f-f85a2f6f2a73",
      "name": "5. Contact tagging",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1920,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 952,
        "content": "## 5. Contact tagging"
      },
      "typeVersion": 1
    },
    {
      "id": "e3ae4550-7369-499b-875a-84a62b11f5d6",
      "name": "Route by event type",
      "type": "n8n-nodes-base.switch",
      "position": [
        96,
        224
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "checkout",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "602621f4-64b2-4c9d-887a-69197a9668c5",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.object.object }}",
                    "rightValue": "checkout.session"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "customer",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7df2eee0-d96c-4c6d-8600-15bd6d51eb1f",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.object.object }}",
                    "rightValue": "customer"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.3
    },
    {
      "id": "502785fe-92d4-4b93-8f29-8abb0c87058e",
      "name": "Watch new Stripe events",
      "type": "n8n-nodes-base.stripeTrigger",
      "position": [
        -112,
        224
      ],
      "parameters": {
        "events": [
          "checkout.session.completed",
          "customer.created",
          "customer.updated"
        ]
      },
      "credentials": {},
      "notesInFlow": false,
      "typeVersion": 1
    },
    {
      "id": "7e807b8f-e2fd-4bf0-af3b-91c722a66718",
      "name": "Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        -176
      ],
      "parameters": {
        "width": 820,
        "height": 688,
        "content": "Community Node Disclaimer: This workflow uses KlickTipp community nodes.\n\n### How It Works\nThis workflow listens for new or updated customers and for checkout confirmations in **Stripe** and automatically creates or updates contacts in KlickTipp, enriching profiles for segmentation and automated messaging. Tags are applied dynamically: high-value orders (\u2265100) get a Premium Customer tag, and purchases with certain SKUs (e.g., clothing) receive product-based tags. The process keeps your database clean, accurate, and updated in real time for targeted campaigns. Perfect for digital product sellers, course creators, and service providers seeking an end-to-end automated sales confirmation process.\n\n### Setup Instructions\n1. **KlickTipp Preparation**\n      - Prepare **custom fields**\n       - `Products` (Text)\n       - `Total` (Decimal Number)\n       - `Payment ID` (Text)\n       - `Receipt URL` (URL)\n      - Prepare **tags**:\n       - `Premium customer`\n       - `Clothing buyer`\n\n2. **Credential Configuration**\n     - Connect your Stripe account using an API key from the Stripe Dashboard.\n     - Authenticate your KlickTipp connection with username/password credentials (API access required).\n\n### Customization\n- Launch upsell or membership campaigns using tags.  \n- Use KlickTipp placeholders (`[[Stripe | Products]]`, `[[Stripe | Total]]`, etc.) for dynamic emails.  \n- Route buyers to portals (e.g., Memberspot, Mentortools).  \n- Trigger CRM, Slack notification, or invoice creation.  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "fcff9804-63e3-446a-9f2e-a902fd5e70f2",
      "name": "Update contact in KlickTipp",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "position": [
        1360,
        368
      ],
      "parameters": {
        "fields": {
          "dataFields": [
            {
              "fieldId": "fieldFirstName",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.name.split(' ')[0] }}"
            },
            {
              "fieldId": "fieldLastName",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.name.split(' ')[1] }}"
            },
            {
              "fieldId": "fieldPhone",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.phone }}"
            },
            {
              "fieldId": "fieldCountry",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.country }}"
            },
            {
              "fieldId": "fieldState",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.state }}"
            },
            {
              "fieldId": "fieldCity",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.city }}"
            },
            {
              "fieldId": "fieldStreet1",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.line1 }}"
            },
            {
              "fieldId": "fieldStreet2",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.line2 }}"
            },
            {
              "fieldId": "fieldZip",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.postal_code }}"
            }
          ]
        },
        "resource": "subscriber",
        "operation": "update",
        "lookupEmail": "={{ $('Watch new Stripe events').item.json.data.object.email }}"
      },
      "credentials": {},
      "typeVersion": 3
    },
    {
      "id": "d1f9f780-b380-4e81-82b8-b7903197d12a",
      "name": "Transfer customers to KlickTipp with SOI",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "position": [
        1360,
        576
      ],
      "parameters": {
        "email": "={{ $('Watch new Stripe events').item.json.data.object.email }}",
        "fields": {
          "dataFields": [
            {
              "fieldId": "fieldFirstName",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.name.split(' ')[0] }}"
            },
            {
              "fieldId": "fieldLastName",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.name.split(' ')[1] }}"
            },
            {
              "fieldId": "fieldPhone",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.phone }}"
            },
            {
              "fieldId": "fieldCountry",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.country }}"
            },
            {
              "fieldId": "fieldState",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.state }}"
            },
            {
              "fieldId": "fieldCity",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.city }}"
            },
            {
              "fieldId": "fieldStreet1",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.line1 }}"
            },
            {
              "fieldId": "fieldStreet2",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.line2 }}"
            },
            {
              "fieldId": "fieldZip",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.shipping.address.postal_code }}"
            }
          ]
        },
        "listId": "364353",
        "resource": "subscriber",
        "operation": "subscribe"
      },
      "credentials": {},
      "typeVersion": 3
    },
    {
      "id": "b0354467-baea-48cd-869a-2019bbfc1e80",
      "name": "Check if customer exists as contact",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "onError": "continueErrorOutput",
      "position": [
        1024,
        464
      ],
      "parameters": {
        "resource": "subscriber",
        "operation": "get",
        "lookupEmail": "={{ $json.data.object.email }}"
      },
      "credentials": {},
      "typeVersion": 3
    },
    {
      "id": "430f5654-b06d-41ca-8dc0-9b468b0febc8",
      "name": "2. Check for contact",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 952,
        "content": "## 2. Check for contact"
      },
      "typeVersion": 1
    },
    {
      "id": "8d4a5388-6027-485a-a5e3-878b7d61f360",
      "name": "Subscribe buyer to KlickTipp with DOI",
      "type": "CUSTOM.klicktipp",
      "notes": "Subscribes the buyer to the KlickTipp list using their payment data.",
      "position": [
        1360,
        32
      ],
      "parameters": {
        "email": "={{ $json.billing_details.email }}",
        "tagId": "13201265",
        "fields": {
          "dataFields": [
            {
              "fieldId": "field219541",
              "fieldValue": "={{ $json.amount }}"
            },
            {
              "fieldId": "field220266",
              "fieldValue": "={{ $json.receipt_url }}"
            },
            {
              "fieldId": "field219542",
              "fieldValue": "={{ $('Watch new Stripe events').item.json.data.object.id }}"
            },
            {
              "fieldId": "fieldFirstName",
              "fieldValue": "={{ \n  // Access the full name string from the JSON input\n  $json.billing_details.name\n  \n  // Remove any leading/trailing whitespace\n  ?.trim()\n  \n  // Split the name string into an array using one or more whitespace characters (handles multiple spaces)\n  .split(/\\s+/)\n  \n  // Select the first word from the array (typically the first name)\n  [0] \n}}\n"
            },
            {
              "fieldId": "fieldLastName",
              "fieldValue": "={{ \n  // Access the full name from the input JSON\n  $json.billing_details.name\n\n  // Remove any leading/trailing whitespace\n  ?.trim()\n\n  // Split the string into an array of words using any whitespace\n  .split(/\\s+/)\n\n  // Get the last word in the array \u2014 typically the last name\n  .at(-1) \n}}"
            },
            {
              "fieldId": "field219540",
              "fieldValue": "={{ $('Getting line items').item.json.data.map(item => item.description) }}\n"
            }
          ]
        },
        "listId": "358895",
        "resource": "subscriber",
        "operation": "subscribe"
      },
      "credentials": {},
      "notesInFlow": true,
      "typeVersion": 2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "48135f31-a62d-4af4-88ec-92e813062890",
  "connections": {
    "Getting charge ID": {
      "main": [
        [
          {
            "node": "Getting invoice link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Getting line items": {
      "main": [
        [
          {
            "node": "Getting charge ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by event type": {
      "main": [
        [
          {
            "node": "Getting line items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check if customer exists as contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Getting invoice link": {
      "main": [
        [
          {
            "node": "Subscribe buyer to KlickTipp with DOI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Watch new Stripe events": {
      "main": [
        [
          {
            "node": "Route by event type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by SKU and total amount": {
      "main": [
        [
          {
            "node": "Tag contact for high-value order",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Tag contact for clothing purchase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if customer exists as contact": {
      "main": [
        [
          {
            "node": "Update contact in KlickTipp",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Transfer customers to KlickTipp with SOI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Subscribe buyer to KlickTipp with DOI": {
      "main": [
        [
          {
            "node": "Route by SKU and total amount",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}