Airtable订单到Stripe发票(B2B/手动收款)
高级
这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 19 个节点。主要使用 If, Code, Stripe, Airtable, HttpRequest 等节点。 从Airtable订单创建Stripe发票,并使用Google表格记录
前置要求
- •Stripe API Key
- •Airtable API Key
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "2ko7gxYzw5Uy6lFh",
"meta": {
"instanceId": "8443f10082278c46aa5cf3acf8ff0f70061a2c58bce76efac814b16290845177",
"templateCredsSetupCompleted": true
},
"name": "Airtable 订单到 Stripe 发票(B2B/手动收款)",
"tags": [],
"nodes": [
{
"id": "7e7fd28b-de0f-4be1-806f-ff05fe0d383d",
"name": "工作流描述",
"type": "n8n-nodes-base.stickyNote",
"position": [
-528,
80
],
"parameters": {
"width": 320,
"height": 708,
"content": "## 🚀 B2B 发票自动化工作流"
},
"typeVersion": 1
},
{
"id": "ff6b94d0-1292-4413-a374-72c9304d2bb2",
"name": "计划设置指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
-96,
-160
],
"parameters": {
"width": 280,
"height": 340,
"content": "## ⏰ 计划设置"
},
"typeVersion": 1
},
{
"id": "9d95e100-66c2-4bad-b3a3-9aafcdc6ea52",
"name": "每小时触发",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
80,
208
],
"parameters": {
"rule": {
"interval": [
{
"field": "hours"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "1e771a28-cf1d-4f20-bb4a-5f212bc5ef81",
"name": "Airtable 设置指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
208,
368
],
"parameters": {
"width": 300,
"height": 376,
"content": "## 📋 Airtable 设置"
},
"typeVersion": 1
},
{
"id": "fdd91819-6baa-4c0c-bf05-2ef2ae931625",
"name": "获取 B2B 订单",
"type": "n8n-nodes-base.airtable",
"position": [
288,
208
],
"parameters": {
"id": "rec5GbGenP8Wurf4W",
"base": {
"__rl": true,
"mode": "list",
"value": "appxjEpOgye5YQG1J",
"cachedResultUrl": "https://airtable.com/appxjEpOgye5YQG1J",
"cachedResultName": "Lead Manager"
},
"table": {
"__rl": true,
"mode": "list",
"value": "tbl56YM9iZKaIhAB3",
"cachedResultUrl": "https://airtable.com/appxjEpOgye5YQG1J/tbl56YM9iZKaIhAB3",
"cachedResultName": "Orders"
},
"options": {}
},
"credentials": {
"airtableTokenApi": {
"id": "nWc9JHR6t25WPWVV",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2.1
},
{
"id": "87e76054-5d3e-4f98-b565-b2be586673ac",
"name": "订单筛选指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
416,
-176
],
"parameters": {
"width": 280,
"height": 336,
"content": "## 🔍 订单筛选"
},
"typeVersion": 1
},
{
"id": "72e1a601-e9c4-4e65-93db-f4dcb23d9530",
"name": "筛选 B2B 已付款订单",
"type": "n8n-nodes-base.if",
"position": [
512,
208
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "condition1",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.financial_status }}",
"rightValue": "paid"
},
{
"id": "condition2",
"operator": {
"type": "string",
"operation": "contains"
},
"leftValue": "={{ $json.tags }}",
"rightValue": "B2B"
}
]
}
},
"typeVersion": 2
},
{
"id": "aa6e2bc9-1e47-4a4a-9236-cd2066c8b1ac",
"name": "Stripe 客户指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
656,
384
],
"parameters": {
"width": 300,
"height": 452,
"content": "## 👤 Stripe 客户创建"
},
"typeVersion": 1
},
{
"id": "162bda8f-8ab2-467b-a856-ee7796da8e81",
"name": "创建 Stripe 客户",
"type": "n8n-nodes-base.stripe",
"position": [
736,
208
],
"parameters": {
"name": "={{ $json[\"Customer Name\"] }}",
"resource": "customer",
"operation": "create",
"additionalFields": {
"email": "={{ $json.Email }}",
"phone": "={{ $json[\"Phone Number\"] }}"
}
},
"credentials": {
"stripeApi": {
"id": "DV4tPpxjbOUkGfAx",
"name": "Stripe account"
}
},
"typeVersion": 1,
"continueOnFail": true
},
{
"id": "bc462aa9-f034-4e7f-8a07-5668b462396a",
"name": "行项目指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
880,
-208
],
"parameters": {
"width": 280,
"height": 384,
"content": "## 📄 行项目处理"
},
"typeVersion": 1
},
{
"id": "8d23c8a5-9ca5-43ac-a69c-c0ae0e71d1f5",
"name": "处理行项目",
"type": "n8n-nodes-base.code",
"position": [
960,
208
],
"parameters": {
"jsCode": "// Get the current input (Stripe customer)\nconst stripeCustomer = $input.item.json;\n\n// Try to get Shopify order from various sources\nlet shopifyOrder = null;\n\n// Method 1: Try from execution data\ntry {\n const executionData = $workflow.data;\n console.log('Execution Data:', JSON.stringify(executionData, null, 2));\n} catch (e) {\n console.log('Cannot access execution data');\n}\n\n// Method 2: Try from items\ntry {\n const items = $items();\n console.log('Items:', JSON.stringify(items, null, 2));\n \n // Look for Shopify order in items\n for (const item of items) {\n if (item.line_items) {\n shopifyOrder = item;\n break;\n }\n }\n} catch (e) {\n console.log('Cannot access items');\n}\n\n// Method 3: Create a test line item if no Shopify data found\nif (!shopifyOrder || !shopifyOrder.line_items || shopifyOrder.line_items.length === 0) {\n console.log('No Shopify order found, creating test data');\n \n // Return test data to verify the node works\n return [\n {\n stripe_customer: stripeCustomer,\n line_item: {\n id: 'test_item_1',\n title: 'Test Product',\n price: '99.99',\n quantity: 1\n },\n price: 99.99,\n quantity: 1,\n title: 'Test Product',\n customer_id: stripeCustomer.id,\n currency: 'USD'\n }\n ];\n}\n\n// If we have Shopify order, process it\nconst lineItems = shopifyOrder.line_items || [];\nconsole.log('Processing line items:', lineItems);\n\n// Return processed line items\nreturn lineItems.map((item, index) => ({\n shopify_order: shopifyOrder,\n stripe_customer: stripeCustomer,\n line_item: item,\n price: parseFloat(item.price || '0'),\n quantity: parseInt(item.quantity || '1'),\n title: item.title || `Item ${index + 1}`,\n customer_id: stripeCustomer.id,\n currency: shopifyOrder.currency || 'USD'\n}));"
},
"typeVersion": 2
},
{
"id": "188a61b7-5c0f-4bab-a2e9-8c15ebf18d7b",
"name": "发票创建指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
1136,
384
],
"parameters": {
"width": 300,
"height": 372,
"content": "## 🧾 发票创建"
},
"typeVersion": 1
},
{
"id": "8e7661ce-e5e0-4011-96ad-c63f561ddfee",
"name": "创建 Stripe 发票",
"type": "n8n-nodes-base.httpRequest",
"position": [
1184,
208
],
"parameters": {
"url": "https://api.stripe.com/v1/invoices",
"method": "POST",
"options": {},
"sendBody": true,
"sendHeaders": true,
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "customer",
"value": "={{ $json.customer_id }}"
},
{
"name": "currency",
"value": "={{ $json.currency }}"
},
{
"name": "auto_advance",
"value": "false"
},
{
"name": "collection_method",
"value": "send_invoice"
},
{
"name": "days_until_due",
"value": "30"
},
{
"name": "pending_invoice_items_behavior",
"value": "include"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
]
},
"nodeCredentialType": "stripeApi"
},
"credentials": {
"stripeApi": {
"id": "DV4tPpxjbOUkGfAx",
"name": "Stripe account"
}
},
"typeVersion": 4.1
},
{
"id": "4f617671-ca7c-4da7-8d32-f15e5845431a",
"name": "完成指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
1312,
-192
],
"parameters": {
"width": 280,
"height": 384,
"content": "## ✅ 发票完成"
},
"typeVersion": 1
},
{
"id": "fdf51683-a973-4a01-9872-3df221a34526",
"name": "完成发票",
"type": "n8n-nodes-base.httpRequest",
"position": [
1392,
208
],
"parameters": {
"url": "=https://api.stripe.com/v1/invoices/{{ $json.id }}/finalize ",
"method": "POST",
"options": {},
"sendBody": true,
"sendHeaders": true,
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "auto_advance",
"value": "true"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
]
},
"nodeCredentialType": "stripeApi"
},
"credentials": {
"stripeApi": {
"id": "DV4tPpxjbOUkGfAx",
"name": "Stripe account"
}
},
"typeVersion": 4.1
},
{
"id": "6811b3d3-4b24-4637-97be-d5d32b9576e8",
"name": "数据格式化指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
1536,
400
],
"parameters": {
"width": 280,
"height": 368,
"content": "## 📊 数据格式化"
},
"typeVersion": 1
},
{
"id": "60bf510e-5a75-4e55-af01-0ca305ddeee5",
"name": "为 Sheets 格式化数据",
"type": "n8n-nodes-base.code",
"position": [
1584,
208
],
"parameters": {
"jsCode": "// Get the invoice data from the HTTP response\nconst invoice = $input.item.json;\n\n// Format the data for Google Sheets\nconst formattedData = {\n // Invoice Information\n stripe_invoice_id: invoice.id,\n invoice_number: invoice.number,\n invoice_status: invoice.status,\n \n // Customer Information\n customer_id: invoice.customer,\n customer_name: invoice.customer_name,\n customer_email: invoice.customer_email,\n customer_phone: invoice.customer_phone,\n \n // Financial Information\n currency: invoice.currency.toUpperCase(),\n amount_due: (invoice.amount_due / 100).toFixed(2), // Convert from cents to dollars\n amount_paid: (invoice.amount_paid / 100).toFixed(2),\n amount_remaining: (invoice.amount_remaining / 100).toFixed(2),\n subtotal: (invoice.subtotal / 100).toFixed(2),\n total: (invoice.total / 100).toFixed(2),\n \n // Invoice URLs\n hosted_invoice_url: invoice.hosted_invoice_url,\n invoice_pdf: invoice.invoice_pdf,\n \n // Dates (converted to readable format)\n created_date: new Date(invoice.created * 1000).toISOString(),\n due_date: invoice.due_date ? new Date(invoice.due_date * 1000).toISOString() : null,\n finalized_at: invoice.status_transitions.finalized_at ? new Date(invoice.status_transitions.finalized_at * 1000).toISOString() : null,\n paid_at: invoice.status_transitions.paid_at ? new Date(invoice.status_transitions.paid_at * 1000).toISOString() : null,\n \n // Additional Information\n collection_method: invoice.collection_method,\n billing_reason: invoice.billing_reason,\n line_items_count: invoice.lines.total_count,\n \n // Timestamp for when this record was processed\n processed_timestamp: new Date().toISOString(),\n \n // Original Shopify Order Reference (if available from previous nodes)\n shopify_order_id: null // This will be populated if you have Shopify data in workflow\n};\n\n// Try to get Shopify order ID from previous nodes if available\ntry {\n const shopifyData = $('Process Line Items').item.json.shopify_order;\n if (shopifyData && shopifyData.id) {\n formattedData.shopify_order_id = shopifyData.id;\n }\n} catch (e) {\n console.log('No Shopify order data found');\n}\n\n// Log the formatted data for debugging\nconsole.log('Formatted data for Google Sheets:', formattedData);\n\nreturn formattedData;"
},
"typeVersion": 2
},
{
"id": "57fcfb57-b703-4f89-baa9-d784b1f3dd48",
"name": "Sheets 记录指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
1760,
-304
],
"parameters": {
"width": 300,
"height": 488,
"content": "## 📋 Google Sheets 记录"
},
"typeVersion": 1
},
{
"id": "c36e89ac-03af-42c7-9c0e-6ca4c1780171",
"name": "记录到 Google Sheets",
"type": "n8n-nodes-base.googleSheets",
"position": [
1792,
208
],
"parameters": {
"columns": {
"value": {},
"schema": [
{
"id": "stripe_invoice_id",
"type": "string",
"display": true,
"required": false,
"displayName": "stripe_invoice_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "invoice_number",
"type": "string",
"display": true,
"required": false,
"displayName": "invoice_number",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "invoice_status",
"type": "string",
"display": true,
"required": false,
"displayName": "invoice_status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_id",
"type": "string",
"display": true,
"required": false,
"displayName": "customer_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_name",
"type": "string",
"display": true,
"required": false,
"displayName": "customer_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_email",
"type": "string",
"display": true,
"required": false,
"displayName": "customer_email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_phone",
"type": "string",
"display": true,
"required": false,
"displayName": "customer_phone",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "currency",
"type": "string",
"display": true,
"required": false,
"displayName": "currency",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "amount_due",
"type": "string",
"display": true,
"required": false,
"displayName": "amount_due",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "amount_paid",
"type": "string",
"display": true,
"required": false,
"displayName": "amount_paid",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "amount_remaining",
"type": "string",
"display": true,
"required": false,
"displayName": "amount_remaining",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "subtotal",
"type": "string",
"display": true,
"required": false,
"displayName": "subtotal",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "total",
"type": "string",
"display": true,
"required": false,
"displayName": "total",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "hosted_invoice_url",
"type": "string",
"display": true,
"required": false,
"displayName": "hosted_invoice_url",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "invoice_pdf",
"type": "string",
"display": true,
"required": false,
"displayName": "invoice_pdf",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "created_date",
"type": "string",
"display": true,
"required": false,
"displayName": "created_date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "due_date",
"type": "string",
"display": true,
"required": false,
"displayName": "due_date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "finalized_at",
"type": "string",
"display": true,
"required": false,
"displayName": "finalized_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "paid_at",
"type": "string",
"display": true,
"required": false,
"displayName": "paid_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "collection_method",
"type": "string",
"display": true,
"required": false,
"displayName": "collection_method",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "billing_reason",
"type": "string",
"display": true,
"required": false,
"displayName": "billing_reason",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "line_items_count",
"type": "string",
"display": true,
"required": false,
"displayName": "line_items_count",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "processed_timestamp",
"type": "string",
"display": true,
"required": false,
"displayName": "processed_timestamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "shopify_order_id",
"type": "string",
"display": true,
"required": false,
"displayName": "shopify_order_id",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uc9oXoocsPsu5X0oDx6Q552389F28K8X_Yp75tAvhaU/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1Uc9oXoocsPsu5X0oDx6Q552389F28K8X_Yp75tAvhaU",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Uc9oXoocsPsu5X0oDx6Q552389F28K8X_Yp75tAvhaU/edit?usp=drivesdk",
"cachedResultName": "Orders Invoices Data"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "kpPEOLCGn963qpoh",
"name": "automations@techdome.ai"
}
},
"typeVersion": 4
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "9cba8243-00ab-42f0-a229-fcf7e559a4b3",
"connections": {
"Hourly Trigger": {
"main": [
[
{
"node": "Fetch B2B Order",
"type": "main",
"index": 0
}
]
]
},
"Fetch B2B Order": {
"main": [
[
{
"node": "Filter B2B Paid Orders",
"type": "main",
"index": 0
}
]
]
},
"Finalize Invoice": {
"main": [
[
{
"node": "Format Data for Sheets",
"type": "main",
"index": 0
}
]
]
},
"Process Line Items": {
"main": [
[
{
"node": "Create Stripe Invoice",
"type": "main",
"index": 0
}
]
]
},
"Create Stripe Invoice": {
"main": [
[
{
"node": "Finalize Invoice",
"type": "main",
"index": 0
}
]
]
},
"Create Stripe Customer": {
"main": [
[
{
"node": "Process Line Items",
"type": "main",
"index": 0
}
]
]
},
"Filter B2B Paid Orders": {
"main": [
[
{
"node": "Create Stripe Customer",
"type": "main",
"index": 0
}
]
]
},
"Format Data for Sheets": {
"main": [
[
{
"node": "Log to Google Sheets",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 内容创作, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Stripe 税务摘要到 Google Sheets 并附带 Slack 提醒
从 Stripe 生成税务摘要,存储到 Google Sheets,并发送 Slack 提醒
If
Set
Code
+5
17 节点Rahul Joshi
内容创作
从 Stripe 支付自动交付模板给客户
使用Stripe、GPT-4o和Gmail的自动化模板交付系统
If
Code
Gmail
+12
44 节点Rahul Joshi
客户关系管理
GoHighLevel管道速度跟踪器和自动化停滞交易提醒
使用GoHighLevel、Gmail和Slack分析管道速度并提醒停滞交易
If
Code
Gmail
+5
25 节点Rahul Joshi
内容创作
使用 GoHighLevel、Gmail 和 Notion 自动化 NPS 调查收集与响应处理
使用GoHighLevel、Gmail和Notion自动化NPS调查收集与响应处理
If
Code
Gmail
+5
27 节点Rahul Joshi
内容创作
CRM交易阶段更新
使用Stripe和Google Sheets的自动CRM交易阶段更新
Code
Split Out
Http Request
+3
13 节点Rahul Joshi
内容创作
季度/月度收入摘要发送至 Slack
使用财务洞察自动将月度及季度 Stripe 收入报告发送至 Slack
Code
Merge
Slack
+4
18 节点Rahul Joshi
内容创作
工作流信息
难度等级
高级
节点数量19
分类2
节点类型8
作者
Rahul Joshi
@rahul08Rahul Joshi is a seasoned technology leader specializing in the n8n automation tool and AI-driven workflow automation. With deep expertise in building open-source workflow automation and self-hosted automation platforms, he helps organizations eliminate manual processes through intelligent n8n ai agent automation solutions.
外部链接
在 n8n.io 查看 →
分享此工作流