Skip to main content

介绍

当支付和订阅事件发生时,自动发送事务性电子邮件。支付确认、订阅更新和失败通知将通过 Keplars 发送,无需 middleware server:Dodo Payments 直接调用 Keplars API,并使用 JavaScript transformation handler。
此集成使用你的 Keplars API key 进行身份验证。你可以在 Keplars dashboard 的 Settings → API Keys 下找到它,并在 Domains 下验证 sender domain 或 address。

入门指南

1

Open the Webhook Section

在 Dodo Payments dashboard 中,前往 Developer → Webhooks,然后点击 Add endpoint。
2

Select Keplars

在 Integration 中选择 Keplars。模板会填入 Keplars API URL 和 transformation code。
选择 Keplars 集成卡片
3

Enter API Key

将你的 Keplars API key 粘贴到 API key 中。Dodo Payments 会在每次请求中将其作为 Bearer token 发送。在 Subscribed events 下,选择应触发电子邮件发送的事件。
输入 Keplars API URL、API Key 并订阅事件
4

Configure Transformation

在 Transformation code 中编辑代码,以便为 Keplars 设置电子邮件格式。将 sender address 占位符和 template IDs 替换为你自己的值。
5

Test & Create

在 Test this code 下选择事件类型,然后点击 Simulate,针对示例 payload 运行 transformation。然后点击 Create endpoint,开始发送电子邮件。
6

Done

Dodo Payments 事件现在会通过 Keplars 发送事务性电子邮件。

转换代码示例

每个 handler 都会将 webhook.url 设置为 Keplars high-priority send endpoint,并将 webhook.payload 重写为 Keplars request。Dodo Payments 会将 API key 添加为 Bearer token。将 payments@mail.yourdomain.com 替换为你已验证的 sender,并将 your-keplars-*-template-id 替换为你的 template IDs。
即使只有一个收件人,to 也必须是 array。使用 template_id 时,不要同时发送 subject 或 body,因为模板会提供这些内容。

支付确认电子邮件

payment_succeeded.js

支付失败通知

payment_failed.js

订阅欢迎电子邮件

subscription_active.js

订阅取消电子邮件

subscription_cancelled.js

提示

  • 使用已验证的 domain 或 address 发送,以提高送达率。
  • 为每种事件类型创建一个 Keplars template,使每封电子邮件都保持品牌一致且信息明确。
  • 通过在 params 中传递客户数据(例如姓名、金额和支付 ID)来个性化每封电子邮件。
  • 首先在 sandbox mode 中进行测试。Keplars 会将 sandbox 发送捕获到其 Test Inbox 中,而不是实际发送出去。

故障排除

  • 检查你的 API key 是否正确,并确认其在 Keplars 的 Settings → API Keys 中处于 active 状态。
  • 检查你的 sender domain 或 address 是否已验证。
  • 在 Dodo Payments dashboard 中,打开 Developer → Webhooks 的 Logs 标签页中的消息。每次 delivery attempt 都会显示 Keplars 返回的 raw error response。
  • handler 中的 template_id 必须与 Keplars account 中处于 active 状态的 template 匹配。在 Keplars dashboard 中检查 ID,并确认 template 处于 active 状态。
  • 每个 handler 都会检查 webhook.eventType;如果事件不匹配,则原样返回 webhook。检查 endpoint 的 Subscribed events 是否仅包含你需要的事件。
最后修改于 2026年9月26日