使用Stripe支付触发器和Gmail自动发送PDF发票
初级
这是一个Invoice Processing, Multimodal AI领域的自动化工作流,包含 5 个节点。主要使用 Code, Gmail, Webhook 等节点。 使用Stripe支付触发器和Gmail自动发送PDF发票
前置要求
- •Google 账号和 Gmail API 凭证
- •HTTP Webhook 端点(n8n 会自动生成)
使用的节点 (5)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc"
},
"nodes": [
{
"id": "3c9c65d5-e8ef-472b-994f-14d67bf92479",
"name": "设置说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
0
],
"parameters": {
"width": 280,
"height": 200,
"content": "💰 **需要设置:**"
},
"typeVersion": 1
},
{
"id": "9d2296bf-2617-4b8c-9d5b-ff87e3cf8360",
"name": "Stripe 支付 Webhook",
"type": "n8n-nodes-base.webhook",
"position": [
0,
224
],
"webhookId": "stripe-payment-webhook",
"parameters": {
"path": "stripe-webhook",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 1
},
{
"id": "25314ce6-fbec-41b1-9328-2e075eb658a2",
"name": "标准化支付数据",
"type": "n8n-nodes-base.code",
"position": [
208,
224
],
"parameters": {
"jsCode": "// Normalize Stripe payment data\nconst event = $input.first().json;\nconst paymentIntent = event.data?.object || event;\n\n// Only proceed if this is a successful payment\nif (event.type !== 'payment_intent.succeeded' && event.type !== 'charge.succeeded') {\n console.log('Not a successful payment event, skipping...');\n return null;\n}\n\n// Extract payment and customer details\nconst normalizedData = {\n payment_id: paymentIntent.id,\n amount: paymentIntent.amount / 100, // Convert from cents\n currency: paymentIntent.currency?.toUpperCase() || 'USD',\n customer_email: paymentIntent.receipt_email || paymentIntent.billing_details?.email || '',\n customer_name: paymentIntent.billing_details?.name || 'Valued Customer',\n payment_date: new Date(paymentIntent.created * 1000).toISOString(),\n description: paymentIntent.description || 'Service Payment',\n invoice_number: `INV-${Date.now()}`,\n status: 'paid'\n};\n\n// Validate required fields\nif (!normalizedData.customer_email) {\n throw new Error('Customer email is required for invoice generation');\n}\n\nconsole.log('Normalized Payment Data:', normalizedData);\n\nreturn {\n json: normalizedData\n};"
},
"typeVersion": 2
},
{
"id": "8439384c-a885-4ad5-bc5d-e587b667fe61",
"name": "生成发票 HTML",
"type": "n8n-nodes-base.code",
"position": [
400,
224
],
"parameters": {
"jsCode": "// Generate HTML invoice content\nconst data = $input.first().json;\n\nconst invoiceHTML = `\n<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\">\n <style>\n body { font-family: Arial, sans-serif; margin: 40px; }\n .header { text-align: center; margin-bottom: 40px; }\n .invoice-details { margin: 30px 0; }\n .amount { font-size: 24px; font-weight: bold; color: #2E7D32; }\n table { width: 100%; border-collapse: collapse; margin: 20px 0; }\n th, td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }\n .footer { margin-top: 50px; text-align: center; color: #666; }\n </style>\n</head>\n<body>\n <div class=\"header\">\n <h1>INVOICE</h1>\n <h2>Your Company Name</h2>\n </div>\n \n <div class=\"invoice-details\">\n <p><strong>Invoice #:</strong> ${data.invoice_number}</p>\n <p><strong>Date:</strong> ${new Date(data.payment_date).toLocaleDateString()}</p>\n <p><strong>Payment ID:</strong> ${data.payment_id}</p>\n </div>\n \n <div>\n <h3>Bill To:</h3>\n <p><strong>${data.customer_name}</strong></p>\n <p>${data.customer_email}</p>\n </div>\n \n <table>\n <thead>\n <tr>\n <th>Description</th>\n <th>Amount</th>\n <th>Status</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>${data.description}</td>\n <td class=\"amount\">${data.currency} ${data.amount.toFixed(2)}</td>\n <td style=\"color: green; font-weight: bold;\">PAID</td>\n </tr>\n </tbody>\n </table>\n \n <div class=\"footer\">\n <p>Thank you for your business!</p>\n <p>This invoice was automatically generated.</p>\n </div>\n</body>\n</html>\n`;\n\nreturn {\n json: {\n ...data,\n invoice_html: invoiceHTML,\n filename: `invoice_${data.invoice_number}.pdf`\n }\n};"
},
"typeVersion": 2
},
{
"id": "7cb20e9e-dec4-4c7b-9029-05f3ddd5ef0a",
"name": "发送发票邮件",
"type": "n8n-nodes-base.gmail",
"position": [
608,
224
],
"webhookId": "6a6f3511-443a-4ff0-bd1b-c1a6b3890e98",
"parameters": {
"message": "Dear {{ $json.customer_name }},\\n\\nThank you for your payment! Please find your invoice attached.\\n\\nPayment Details:\\n- Amount: {{ $json.currency }} {{ $json.amount }}\\n- Payment ID: {{ $json.payment_id }}\\n- Date: {{ $json.payment_date }}\\n\\nBest regards,\\nYour Company Name",
"options": {
"attachmentsUi": {
"attachmentsBinary": [
{
"property": "invoice_pdf"
}
]
}
},
"subject": "Invoice {{ $json.invoice_number }} - Payment Confirmation"
},
"typeVersion": 2.1
}
],
"pinData": {},
"connections": {
"Generate Invoice HTML": {
"main": [
[
{
"node": "Send Invoice Email",
"type": "main",
"index": 0
}
]
]
},
"Normalize Payment Data": {
"main": [
[
{
"node": "Generate Invoice HTML",
"type": "main",
"index": 0
}
]
]
},
"Stripe Payment Webhook": {
"main": [
[
{
"node": "Normalize Payment Data",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
初级 - 发票处理, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用GPT-4自动总结Zoom录制并发送到Slack和邮件
使用GPT-4自动总结Zoom录制并发送到Slack和邮件
Code
Gmail
Slack
+3
6 节点David Olusola
AI 摘要总结
使用 GPT-4 和 Gmail 为 Zoom 参会者发送个性化跟进邮件
使用 GPT-4 和 Gmail 为 Zoom 参会者发送个性化跟进邮件
Code
Gmail
Open Ai
+2
5 节点David Olusola
客户培育
自动将新Calendly预约添加到Google表格
自动将新Calendly预约添加到Google表格
Code
Webhook
Google Sheets
+1
5 节点David Olusola
客户关系管理
为Zoom参会者自动创建Airtable CRM记录
为Zoom参会者自动创建Airtable CRM记录
Code
Webhook
Airtable
+1
4 节点David Olusola
客户关系管理
自动保存Instagram潜在客户到Google表格
自动保存Instagram潜在客户到Google表格
Code
Webhook
Google Sheets
+1
4 节点David Olusola
潜在客户开发
自动保存Zoom录制到Google云端硬盘并在Airtable记录会议
自动保存Zoom录制到Google云端硬盘并在Airtable记录会议
Code
Webhook
Airtable
+3
7 节点David Olusola
文件管理
工作流信息
难度等级
初级
节点数量5
分类2
节点类型4
作者
David Olusola
@dae221I help ambitious businesses eliminate operational bottlenecks and scale faster with AI automation. My clients typically see 40-60% efficiency gains within 90 days. Currently accepting 3 new projects this quarter - david@daexai.com
外部链接
在 n8n.io 查看 →
分享此工作流