8
n8n 中文网amn8n.com

退款同步 + 客户通知

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 If, Code, Gmail, HttpRequest, GoogleSheets 等节点。 Stripe争议管理,集成Google Sheets分类账和Gmail通知

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "8qlWHFgfTXIg4fe2",
  "meta": {
    "instanceId": "8443f10082278c46aa5cf3acf8ff0f70061a2c58bce76efac814b16290845177",
    "templateCredsSetupCompleted": true
  },
  "name": "退款同步 + 客户通知",
  "tags": [],
  "nodes": [
    {
      "id": "67a71551-678b-4a04-bb39-a14e54c36c0c",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -128,
        208
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b72c4012-d202-450f-90a6-b99e392343af",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        512
      ],
      "parameters": {
        "height": 320,
        "content": "操作:评估\"获取行\"节点的输出。"
      },
      "typeVersion": 1
    },
    {
      "id": "87cb1c73-99c3-409f-86fa-d49c97074a9a",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        -384
      ],
      "parameters": {
        "height": 432,
        "content": "操作:使用来自 Stripe 的客户电子邮件地址(customer_email)向客户发送邮件。"
      },
      "typeVersion": 1
    },
    {
      "id": "c8f1645c-d695-4861-b009-f905f64185fe",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -256
      ],
      "parameters": {
        "height": 288,
        "content": "操作:每次获取新争议时,在\"争议\"工作表中追加新行。"
      },
      "typeVersion": 1
    },
    {
      "id": "f7312b74-0370-4282-bd6c-a47dda17d737",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        512
      ],
      "parameters": {
        "height": 384,
        "content": "操作:在\"支付\"工作表中搜索行,其中 charge_id 与当前争议中的匹配。"
      },
      "typeVersion": 1
    },
    {
      "id": "83a18437-73c4-4062-9681-1003e3064958",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        -224
      ],
      "parameters": {
        "height": 416,
        "content": "操作:使用 JavaScript 清理 Stripe 响应并仅准备最相关的字段。它还从列表中选择最新的争议。"
      },
      "typeVersion": 1
    },
    {
      "id": "48cba95b-90ac-47ed-879a-ac1a5a6f8283",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        400
      ],
      "parameters": {
        "height": 320,
        "content": "操作:使用您的 Stripe 密钥向 Stripe API 端点发送 GET 请求。"
      },
      "typeVersion": 1
    },
    {
      "id": "33bd715b-5140-4af5-8734-37c90bb2abcc",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        512
      ],
      "parameters": {
        "height": 384,
        "content": "操作:使用争议特定字段更新\"支付\"工作表中的现有行。"
      },
      "typeVersion": 1
    },
    {
      "id": "25b4f24d-99e0-448a-b7f7-7e84e3557243",
      "name": "从 Stripe 获取最新争议",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        112,
        208
      ],
      "parameters": {
        "url": "{{YOUR/STRIPE/URL }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer{{YOUR/STRIPE/ SECRETEKEY}}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "acc142aa-346a-4812-9849-16ad5f1c4c95",
      "name": "格式化 Stripe 争议数据",
      "type": "n8n-nodes-base.code",
      "position": [
        352,
        208
      ],
      "parameters": {
        "jsCode": "// Input is the whole response with data[]\nconst disputes = $json.data || [];\nif (disputes.length === 0) {\n  return [];\n}\n\n// Stripe returns newest first, so just take index 0\nconst d = disputes[0];\n\nreturn [{\n  dispute_id: d.id,\n  charge_id: d.charge,\n  payment_intent: d.payment_intent,\n  amount: (d.amount / 100).toFixed(2),\n  currency: d.currency.toUpperCase(),\n  reason: d.reason,\n  status: d.status,\n  created_at: new Date(d.created * 1000).toISOString(),\n  respond_by: new Date(d.evidence_details.due_by * 1000).toISOString(),\n  customer_email: d.evidence.customer_email_address || \"\",\n  customer_name: d.evidence.customer_name || \"\",\n  dispute_fee: d.balance_transactions?.[0]?.fee || 0,\n  fee_currency: d.balance_transactions?.[0]?.currency || d.currency\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "b9356ab5-af6c-46db-b84b-4f906cc5f259",
      "name": "在争议工作表中记录争议",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        720,
        64
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": "{{YOUR/SHEET/URL}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "{{YOUR/SPREADSHEET/URL}}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "kpPEOLCGn963qpoh",
          "name": "automations@techdome.ai"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "81fc2bb6-7077-4b81-8d65-396685a6cb65",
      "name": "在分类账中查找支付",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        720,
        352
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": "{{YOUR/SHEET/URL}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "{{YOUR/SPREADSHEET/URL}}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "kpPEOLCGn963qpoh",
          "name": "automations@techdome.ai"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "7c4e0a80-3377-4d2a-a424-36cd0f23a09b",
      "name": "检查支付是否存在",
      "type": "n8n-nodes-base.if",
      "position": [
        976,
        352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "45cf7e42-5355-45db-838b-fb4630423d90",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "{{$json.charge_id}}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bc710438-8e6f-4711-ba2b-11c3c9ea06ab",
      "name": "使用争议信息更新支付记录",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1264,
        336
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": "{{YOUR/SHEET/URL}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "{{YOUR/SPREADSHEET/URL}}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "kpPEOLCGn963qpoh",
          "name": "automations@techdome.ai"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "7f6a9fe0-6123-4b8a-9c13-5a24a6117043",
      "name": "发送客户争议通知邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1008,
        64
      ],
      "webhookId": "0c82c299-6938-42ed-bda6-5007d79af34f",
      "parameters": {
        "sendTo": "={{ $json['customer_email '] }}",
        "message": "=Hello, {{ $json['customer_name '] }}\n\nWe’ve received a dispute related to your payment.\n\n🧾 Details of the dispute:\n- Dispute ID: {{ $json['dispute_id '] }}\n- Amount: {{ $json['amount '] }} {{ $json['currency '] }}\n- Reason: {{ $json['reason '] }}\n- Status: {{ $json['status '] }}\n- Respond by: {{ $json['respond_by '] }}\n\nIf you did not intend to raise this dispute, please contact our support team immediately so we can help resolve it.\n\nPlease note: Once the dispute is resolved, it may take 2–3 business days for the payment status or any refund to be reflected in your account, depending on your bank.\n\nThank you,  \n— Team Support\n",
        "options": {},
        "subject": "=⚠️ New Dispute: {{ $json['amount '] }} {{ $json['currency '] }} – Respond by {{ $json['respond_by '] }}\n",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "RchiXdmY8WaQhOSJ",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a40bc07e-eb8a-4e61-bb9d-04e01c292052",
  "connections": {
    "Find Payment in Ledger": {
      "main": [
        [
          {
            "node": "Check if Payment Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Payment Exists": {
      "main": [
        [
          {
            "node": "Update Payment Record with Dispute Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Stripe Dispute Data": {
      "main": [
        [
          {
            "node": "Log Dispute in Disputes Sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "Find Payment in Ledger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Dispute in Disputes Sheet": {
      "main": [
        [
          {
            "node": "Send Customer Dispute Notification Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Latest Disputes from Stripe": {
      "main": [
        [
          {
            "node": "Format Stripe Dispute Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Fetch Latest Disputes from Stripe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 内容创作, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量15
分类2
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Rahul Joshi

Rahul Joshi

@rahul08

Rahul 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 查看

分享此工作流