{
  "nodes": [
    {
      "id": "3017bb64-8590-402b-a6cd-b3b6fc629dee",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 860,
        "height": 440,
        "content": "## Data reception & collection via Webhook & HTTP Requests"
      },
      "typeVersion": 1
    },
    {
      "id": "88fdf926-3aed-4066-af7a-17d700c5588d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        0
      ],
      "parameters": {
        "width": 320,
        "height": 440,
        "content": "## Writing checkout data into contact record"
      },
      "typeVersion": 1
    },
    {
      "id": "e61aa408-6776-4284-bd10-1a4a10ef05a9",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        464
      ],
      "parameters": {
        "color": 7,
        "width": 980,
        "height": 1584,
        "content": "### Introduction\nThis workflow automates Stripe checkout confirmations by capturing transaction data and syncing it into KlickTipp. Upon successful checkout, the contact's data is enriched with purchase details and tagged to trigger a personalized confirmation campaign in KlickTipp. Perfect for digital product sellers, course creators, and service providers seeking an end-to-end automated sales confirmation process.\n\n### Benefits\n- **Instant confirmation emails**: Automatically notify customers upon successful checkout\u2014no manual processing needed.\n- **Structured contact data**: Order data (invoice link, amount, transaction ID, products) is stored in KlickTipp custom fields.\n- **Smart campaign triggering**: Assign dynamic tags to start automated confirmation or fulfillment sequences.\n- **Seamless digital delivery**: Ideal for pairing with tools like Memberspot or Mentortools to unlock digital products post-checkout.\n\n### Key Features\n- **Stripe Webhook Trigger**:\n  - Triggers on `Checkout Session.completed` events.\n  - Captures checkout data including product names, order number, and total amount.\n\n- **KlickTipp Contact Sync**:\n  - Adds or updates contacts in KlickTipp.\n  - Maps Stripe data into custom fields\n  - Assigns a tag such as `Stripe Checkout` to initiate a confirmation campaign.\n\n- **Router Logic (optional)**:\n  - Branches logic based on product ID or Stripe payment link.\n  - Enables product-specific campaigns or follow-ups.\n\n### Setup Instructions\n1. **KlickTipp Preparation**\n   - Create the following custom fields in your KlickTipp account:\n- `Stripe | Products` (Text)\n- `Stripe | Total` (Decimal Number)\n- `Stripe | Payment ID` (Text)\n- `Stripe | Receipt URL` (URL)\n   - Define a tag for each product or confirmation flow, e.g., `Order: Course XYZ`.\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\n3. **Field Mapping and Workflow Alignment**\n   - Map Stripe output fields to the KlickTipp custom fields.\n   - Assign the tag to trigger your post-purchase campaign.\n   - Ensure that required data like email and opt-in info are present for the contact to be valid.\n\n### Testing and Deployment\n1. Click on **Inactive** to activate the scenario.\n2. Perform a test payment using a Stripe product link.\n3. Verify in KlickTipp:\n   - The contact appears with email and opt-in status.\n   - Custom fields for Stripe are filled.\n   - The campaign tag is correctly applied and confirmation email is sent.\n\n> \u26a0\ufe0f *Note*: Use real or test-mode API keys in Stripe depending on your testing environment. Stripe events may take a few seconds to propagate.\n\n### Campaign Expansion Ideas\n- Launch targeted upsell flows based on the product tag.\n- Use confirmation placeholders like:\n  - `[[Stripe | Products]]`\n  - `[[Stripe | Total]]`\n  - `[[Stripe | Payment ID]]`\n  - `[[Stripe | Products]]`\n- Route customers to different product access portals (e.g., Memberspot, Mentortools).\n- Send follow-up content over multiple days using KlickTipp sequences.\n\n### Customization\nYou can extend the scenario using a switch node to:\n- Assign different tags per used payment link\n- Branch into upsell or membership activation flows  \n- Chain additional automations like CRM entry, Slack notification, or invoice creation.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7db7360d-21b1-48a6-ac14-d61bf69c6934",
      "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": [
        704,
        208
      ],
      "parameters": {
        "chargeId": "={{ $json.latest_charge }}",
        "resource": "charge"
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "a4a2b947-f4fa-44f5-ae79-ea87d1da5aeb",
      "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": [
        480,
        208
      ],
      "parameters": {
        "url": "=https://api.stripe.com/v1/payment_intents/{{ $('New checkout session completed').item.json.data.object.payment_intent }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "authorization",
              "value": "Basic <YOURKEY>"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "24812761-3133-4e92-81ea-620248d999d1",
      "name": "Getting line items",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "This node gets the line items from the checkout session.",
      "position": [
        288,
        208
      ],
      "parameters": {
        "url": "=https://api.stripe.com/v1/checkout/sessions/{{ $json.data.object.id }}/line_items",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Stripe-Version",
              "value": "2025-05-28.basil"
            },
            {
              "name": "authorization",
              "value": "Basic <YOURKEY>"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "e8a0fd14-2e68-48a2-af30-82941dc08967",
      "name": "New checkout session completed",
      "type": "n8n-nodes-base.stripeTrigger",
      "notes": "This trigger listens to successful checkout completions from Stripe.",
      "position": [
        64,
        208
      ],
      "parameters": {
        "events": [
          "checkout.session.completed"
        ]
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "e3eb5a02-3e9d-4893-a7c5-004e927d385f",
      "name": "Subscribe buyer to KlickTipp",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "Subscribes the buyer to the KlickTipp list using their payment data.",
      "position": [
        992,
        208
      ],
      "parameters": {
        "email": "={{ $json.billing_details.email }}",
        "tagId": "13201265",
        "fields": {
          "dataFields": [
            {
              "fieldId": "field219541",
              "fieldValue": "={{ $json.amount }}"
            },
            {
              "fieldId": "field220266",
              "fieldValue": "={{ $json.receipt_url }}"
            },
            {
              "fieldId": "field219542",
              "fieldValue": "={{ $('New checkout session completed').item.json.data.object.id }}"
            },
            {
              "fieldId": "fieldFirstName",
              "fieldValue": "={{ $json.billing_details.name?.trim()?.split(/\\s+/)?.[0] || '' }}"
            },
            {
              "fieldId": "fieldLastName",
              "fieldValue": "={{ $json.billing_details.name?.trim()?.split(/\\s+/)?.slice(1)?.join(' ') || '' }}"
            },
            {
              "fieldId": "field219540",
              "fieldValue": "={{ $('Getting line items').item.json.data.map(item => item.description).join(', ') }}"
            }
          ]
        },
        "listId": "358895",
        "resource": "subscriber",
        "operation": "subscribe"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    }
  ],
  "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
          }
        ]
      ]
    },
    "Getting invoice link": {
      "main": [
        [
          {
            "node": "Subscribe buyer to KlickTipp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New checkout session completed": {
      "main": [
        [
          {
            "node": "Getting line items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}