Documentation Index
Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
Use this file to discover all available pages before exploring further.
通过 Microsoft Teams 中的实时支付通知,让您的业务团队保持信息同步。此集成将支付事件作为丰富的自适应卡片传递——非常适合 Teams 作为主要协作工具的企业环境。
本指南假设您在 Microsoft Teams 工作区拥有创建 Webhook 的管理员权限。
开始使用
Open the Webhook Section
在您的 Dodo Payments 仪表板中,导航至 Webhooks → + 添加终端 并展开集成下拉菜单。 Select Microsoft Teams
选择 Microsoft Teams 集成卡。
Create Teams Webhook
在 Teams 中,前往您的频道 → ⋯ → 连接器 → 传入 Webhook → 配置。复制该 Webhook URL。
Paste Webhook URL
将 Teams Webhook URL 粘贴到端点配置中。
Customize Transformation
编辑转换代码,使消息格式为 Teams 的自适应卡片。
Test & Create
使用示例有效负载进行测试,然后点击 创建 以激活。
Done!
🎉 现在,您的 Teams 频道将以自适应卡片形式接收 Dodo Payments 更新。
转换代码示例
基本支付卡
function handler(webhook) {
if (webhook.eventType === "payment.succeeded") {
const p = webhook.payload.data;
webhook.payload = {
type: "message",
attachments: [{
contentType: "application/vnd.microsoft.card.adaptive",
content: {
type: "AdaptiveCard",
body: [
{
type: "TextBlock",
text: "✅ Payment Successful",
weight: "Bolder",
size: "Medium"
},
{
type: "FactSet",
facts: [
{ title: "Amount", value: `$${(p.total_amount / 100).toFixed(2)}` },
{ title: "Customer", value: p.customer.email },
{ title: "Payment ID", value: p.payment_id }
]
}
]
}
}]
};
}
return webhook;
}
订阅管理
function handler(webhook) {
const s = webhook.payload.data;
switch (webhook.eventType) {
case "subscription.active":
webhook.payload = {
type: "message",
attachments: [{
contentType: "application/vnd.microsoft.card.adaptive",
content: {
type: "AdaptiveCard",
body: [
{
type: "TextBlock",
text: "📄 Subscription Activated",
weight: "Bolder",
color: "Good"
},
{
type: "FactSet",
facts: [
{ title: "Customer", value: s.customer.email },
{ title: "Product", value: s.product_id },
{ title: "Amount", value: `$${(s.recurring_pre_tax_amount / 100).toFixed(2)}/${s.payment_frequency_interval}` },
{ title: "Next Billing", value: new Date(s.next_billing_date).toLocaleDateString() }
]
}
]
}
}]
};
break;
case "subscription.cancelled":
webhook.payload = {
type: "message",
attachments: [{
contentType: "application/vnd.microsoft.card.adaptive",
content: {
type: "AdaptiveCard",
body: [
{
type: "TextBlock",
text: "⚠️ Subscription Cancelled",
weight: "Bolder",
color: "Warning"
},
{
type: "FactSet",
facts: [
{ title: "Customer", value: s.customer.email },
{ title: "Product", value: s.product_id },
{ title: "Cancelled At", value: new Date(s.cancelled_at).toLocaleDateString() }
]
}
]
}
}]
};
break;
}
return webhook;
}
争议警报
function handler(webhook) {
if (webhook.eventType.startsWith("dispute.")) {
const d = webhook.payload.data;
const color = d.dispute_status === "won" ? "Good" : d.dispute_status === "lost" ? "Attention" : "Warning";
const title = d.dispute_status === "won" ? "🏆 Dispute Won" : d.dispute_status === "lost" ? "❌ Dispute Lost" : "🚨 Dispute Update";
webhook.payload = {
type: "message",
attachments: [{
contentType: "application/vnd.microsoft.card.adaptive",
content: {
type: "AdaptiveCard",
body: [
{
type: "TextBlock",
text: title,
weight: "Bolder",
color: color
},
{
type: "FactSet",
facts: [
{ title: "Payment ID", value: d.payment_id },
{ title: "Amount", value: `$${(d.amount / 100).toFixed(2)}` },
{ title: "Status", value: d.dispute_status },
{ title: "Stage", value: d.dispute_stage }
]
}
]
}
}]
};
}
return webhook;
}
- 使用自适应卡片进行丰富的交互式格式化
- 选择适当的颜色:良好(绿色)、警告(黄色)、注意(红色)
- 保持事实集简洁易读
- 在部署之前使用 Teams Webhook 测试工具进行测试
故障排除
- 验证 Webhook URL 是否正确且处于活动状态
- 检查转换是否返回有效的自适应卡片 JSON
- 确保该 Webhook 拥有在频道发布的权限