{
  "nodes": [
    {
      "id": "800d597d-57cf-4f90-852a-d2af89bd00fc",
      "name": "Log Transaction",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -16,
        -144
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $json.data.object.customer_details.name }}",
            "email": "={{ $json.data.object.customer_details.email }}",
            "country": "={{ $json.data.object.customer_details.address.country }}",
            "created": "={{ DateTime.fromSeconds($json.data.object.created ).toFormat('yyyy-MM-dd HH:mm:ss') }}",
            "currency": "={{ $json.data.object.currency }}",
            "invoice_id": "={{ $json.data.object.invoice }}",
            "postal_code": "={{ $json.data.object.customer_details.address.postal_code }}",
            "amount_total": "={{ new Intl.NumberFormat(\"en-US\", { style: \"currency\", currency: $json.data.object.currency}).format($json.data.object.amount_total/100) }}"
          },
          "schema": [
            {
              "id": "created",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "created",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "amount_total",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "amount_total",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "currency",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "country",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "country",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "postal_code",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "postal_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "invoice_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "invoice_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiUply-FlnrWBS7JRHHpQN_Xr2WJytOzRaWALEJ8O_Y/edit#gid=0",
          "cachedResultName": "transactions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1OiUply-FlnrWBS7JRHHpQN_Xr2WJytOzRaWALEJ8O_Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiUply-FlnrWBS7JRHHpQN_Xr2WJytOzRaWALEJ8O_Y/edit?usp=drivesdk",
          "cachedResultName": "Payments"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "0e4afb98-048a-4041-940c-82f788487fbd",
      "name": "Email Receipt",
      "type": "n8n-nodes-base.gmail",
      "position": [
        608,
        -336
      ],
      "parameters": {
        "sendTo": "={{ $('Log Transaction').item.json.email }}",
        "message": "=<html>\n  <body style=\"font-family: Arial, sans-serif; color: #333;\">\n    <h2 style=\"color: #2c7be5;\">Hello {{ $('Log Transaction').item.json.name }}</h2>\n    <p>\nThank you for your purchase from Demo Karma.\n<br><br>\n<div style=\"margin-left: 40px;\">\n  <p>Date: {{ $('Log Transaction').item.json.created }}</p>\n  <p>Country: {{ $('Log Transaction').item.json.country }}</p>\n  <p>Postal Code: {{ $('Log Transaction').item.json.postal_code }}</p>\n  <p>Amount: {{ $('Log Transaction').item.json.amount_total }}</p>\n</div>\n<br><br>\nClick here to <a href=\"{{ $json.invoice_pdf }}\" target=\"_blank\">download your receipt</a>.\n    </p>\n    <p style=\"margin-top:20px;\">Best regards,<br/>Demo Karma Team</p>\n  </body>\n</html>",
        "options": {},
        "subject": "Your Demo Karma purchase"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "baa333c7-de1d-4715-a347-d1646b5a5038",
      "name": "Invoice Created",
      "type": "n8n-nodes-base.stripeTrigger",
      "position": [
        -272,
        192
      ],
      "parameters": {
        "events": [
          "invoice.created"
        ]
      },
      "credentials": {
        "stripeApi": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "bce59371-6ffe-423c-9f58-f0856d64d994",
      "name": "Checkout Completed",
      "type": "n8n-nodes-base.stripeTrigger",
      "position": [
        -256,
        -144
      ],
      "parameters": {
        "events": [
          "checkout.session.completed"
        ]
      },
      "credentials": {
        "stripeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b7002dce-081a-424e-a2d2-1ca41f719a45",
      "name": "Log Invoice",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -16,
        192
      ],
      "parameters": {
        "columns": {
          "value": {
            "customer": "={{ $json.data.object.customer_name }}",
            "invoice_id": "={{ $json.data.object.id }}",
            "amount_paid": "={{ new Intl.NumberFormat(\"en-US\", { style: \"currency\", currency: $json.data.object.currency}).format($json.data.object.amount_paid/100) }}",
            "invoice_pdf": "={{ $json.data.object.invoice_pdf }}"
          },
          "schema": [
            {
              "id": "invoice_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "invoice_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "customer",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "customer",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "amount_paid",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "amount_paid",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "invoice_pdf",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "invoice_pdf",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 983603502,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiUply-FlnrWBS7JRHHpQN_Xr2WJytOzRaWALEJ8O_Y/edit#gid=983603502",
          "cachedResultName": "invoices"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1OiUply-FlnrWBS7JRHHpQN_Xr2WJytOzRaWALEJ8O_Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiUply-FlnrWBS7JRHHpQN_Xr2WJytOzRaWALEJ8O_Y/edit?usp=drivesdk",
          "cachedResultName": "Payments"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "26f150b9-f2b4-49ca-895f-76b157e0df48",
      "name": "Wait for Invoice",
      "type": "n8n-nodes-base.wait",
      "position": [
        272,
        -336
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "5467970e-5117-46af-a2cb-f74985ff8964",
      "name": "Lookup Invoice",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        448,
        -336
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.invoice_id }}",
              "lookupColumn": "invoice_id"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 983603502,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiUply-FlnrWBS7JRHHpQN_Xr2WJytOzRaWALEJ8O_Y/edit#gid=983603502",
          "cachedResultName": "invoices"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1OiUply-FlnrWBS7JRHHpQN_Xr2WJytOzRaWALEJ8O_Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiUply-FlnrWBS7JRHHpQN_Xr2WJytOzRaWALEJ8O_Y/edit?usp=drivesdk",
          "cachedResultName": "Payments"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "8c40f5f4-8d60-45f8-ae73-e45b24c88d25",
      "name": "Message to RevOps",
      "type": "n8n-nodes-base.slack",
      "position": [
        288,
        0
      ],
      "parameters": {
        "text": "={{ $json.amount_total }} - new order from {{ $json.name }} ( {{ $json.email }} ). Link to payment: <https://dashboard.stripe.com/acct_1SD3OCEhbbYR1XBf/test/payments/{{ $('Checkout Completed').item.json.data.object.payment_intent }}|{{ $('Checkout Completed').item.json.data.object.payment_intent }}>",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09J4AJU7F0",
          "cachedResultName": "revops"
        },
        "otherOptions": {
          "unfurl_links": false,
          "unfurl_media": false,
          "includeLinkToWorkflow": false
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "a92e9140-637f-483b-97c3-a4362685f4e0",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -480
      ],
      "parameters": {
        "width": 560,
        "height": 176,
        "content": "## Followup Stripe Checkouts with Gmail Receipts, Internal Slack, and Sheets Logs\n\nThis n8n template demonstrates how to automate the followup when your customer completes a checkout in Stripe by emailing a receipt, logging the transaction, and sending an internal notification.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5fc4a0c3-126e-4fc0-9439-f3337203e383",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        -288
      ],
      "parameters": {
        "color": 7,
        "width": 448,
        "height": 288,
        "content": "### Log the checkout transaction \n\nReceive the checkout transaction from Stripe and append the details to a log we are keeping in a Google Sheet."
      },
      "typeVersion": 1
    },
    {
      "id": "cc164e57-5cd8-446e-adb8-1f0702907c90",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -448
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 288,
        "content": "### Email a receipt\n\nWait a few seconds for the invoice to be received from Stripe and logged to the Sheet.  Then look up the link to the PDF and email it out to the customer.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8bc08914-53c3-465e-83d4-54db5ea2dd74",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 448,
        "height": 336,
        "content": "### Log the invoice \n\nReceive the invoice created event from Stripe. This happens separately from the checkout event. Store the invoice details in a Google Sheet log where we can look them up."
      },
      "typeVersion": 1
    },
    {
      "id": "6f205642-37d0-4dcd-bd94-65c54fd568ea",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 288,
        "content": "### Notify internal users\n\nThe data from the Stripe checkout event is also used to send a notification to the #revops channel for the Sales team.\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Log Invoice": {
      "main": [
        []
      ]
    },
    "Email Receipt": {
      "main": [
        []
      ]
    },
    "Lookup Invoice": {
      "main": [
        [
          {
            "node": "Email Receipt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invoice Created": {
      "main": [
        [
          {
            "node": "Log Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Transaction": {
      "main": [
        [
          {
            "node": "Message to RevOps",
            "type": "main",
            "index": 0
          },
          {
            "node": "Wait for Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Invoice": {
      "main": [
        [
          {
            "node": "Lookup Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Checkout Completed": {
      "main": [
        [
          {
            "node": "Log Transaction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}