在支付事件发生时自动发送事务性电子邮件并管理客户沟通。通过 Loops 的电子邮件基础设施发送支付确认、订阅更新和重要通知。
此集成需要您的 Loops API 密钥进行身份验证。
开始使用
Open the Webhook Section
在您的 Dodo Payments 控制面板中,导航至 Webhooks → + Add Endpoint 并展开集成下拉菜单。 Select Loops
选择 Loops 集成卡片。
Enter API Key
在配置中提供您的 Loops API 密钥。
Configure Transformation
编辑转换代码以格式化适用于 Loops API 的电子邮件。
Test & Create
使用示例有效负载进行测试,然后点击 Create 以激活电子邮件发送。
Done!
🎉 付款事件现已通过 Loops 自动触发事务性电子邮件。
转换代码示例
支付确认电子邮件
function handler(webhook) {
if (webhook.eventType === "payment.succeeded") {
const p = webhook.payload.data;
webhook.url = "https://api.loops.so/v1/events/send";
webhook.payload = {
eventName: "payment_confirmation",
email: p.customer.email,
properties: {
customer_name: p.customer.name,
payment_id: p.payment_id,
amount: (p.total_amount / 100).toFixed(2),
currency: p.currency || "USD",
payment_method: p.payment_method || "unknown",
payment_date: new Date(webhook.payload.timestamp).toLocaleDateString()
}
};
}
return webhook;
}
订阅欢迎电子邮件
function handler(webhook) {
if (webhook.eventType === "subscription.active") {
const s = webhook.payload.data;
webhook.url = "https://api.loops.so/v1/events/send";
webhook.payload = {
eventName: "subscription_welcome",
email: s.customer.email,
properties: {
customer_name: s.customer.name,
subscription_id: s.subscription_id,
product_id: s.product_id,
amount: (s.recurring_pre_tax_amount / 100).toFixed(2),
frequency: s.payment_frequency_interval,
next_billing: s.next_billing_date
}
};
}
return webhook;
}
支付失败通知
function handler(webhook) {
if (webhook.eventType === "payment.failed") {
const p = webhook.payload.data;
webhook.url = "https://api.loops.so/v1/events/send";
webhook.payload = {
eventName: "payment_failed",
email: p.customer.email,
properties: {
customer_name: p.customer.name,
payment_id: p.payment_id,
amount: (p.total_amount / 100).toFixed(2),
error_message: p.error_message || "Payment processing failed",
retry_link: `https://yourdomain.com/retry-payment/${p.payment_id}`
}
};
}
return webhook;
}
- 使用描述性事件名称以更好地组织电子邮件模板
- 包含相关客户属性以实现个性化
- 在 Loops 仪表板中为每个事件设置电子邮件模板
- 在事件之间使用一致的属性命名
- 在上线前测试电子邮件发送
故障排除
- 验证 API 密钥是否正确且处于激活状态
- 检查事件名称是否与 Loops 模板匹配
- 确保收件人电子邮件地址有效
- 审查 Loops 发送限制和配额