Introduction

Send professional transactional emails automatically when payment events occur. Deliver payment confirmations, subscription updates, and important notifications with Resend’s reliable email infrastructure and excellent deliverability rates.
This integration requires your Resend API Key for authentication.

Getting Started

1

Open the Webhook Section

In your Dodo Payments dashboard, navigate to Webhooks → + Add Endpoint and expand the integrations dropdown.
Add Endpoint and integrations dropdown
2

Select Resend

Choose the Resend integration card.
3

Enter API Key

Provide your Resend API Key in the configuration.
4

Configure Transformation

Edit the transformation code to format emails for Resend’s API.
5

Test & Create

Test with sample payloads and click Create to activate the email sending.
6

Done!

🎉 Payment events will now automatically trigger transactional emails via Resend.

Transformation Code Examples

Payment Confirmation Email

payment_confirmation.js
function handler(webhook) {
  if (webhook.eventType === "payment.succeeded") {
    const p = webhook.payload.data;
    webhook.url = "https://api.resend.com/emails";
    webhook.payload = {
      from: "[email protected]",
      to: [p.customer.email],
      subject: "Payment Confirmation - $" + p.total_amount,
      html: `
        <h2>Payment Successful!</h2>
        <p>Hi ${p.customer.name},</p>
        <p>Your payment of $${p.total_amount} has been processed successfully.</p>
        <ul>
          <li><strong>Payment ID:</strong> ${p.payment_id}</li>
          <li><strong>Amount:</strong> $${p.total_amount}</li>
          <li><strong>Date:</strong> ${new Date(webhook.payload.timestamp).toLocaleDateString()}</li>
          <li><strong>Method:</strong> ${p.payment_method || "Unknown"}</li>
        </ul>
        <p>Thank you for your business!</p>
      `,
      text: `Payment Successful! Your payment of $${p.total_amount} has been processed. Payment ID: ${p.payment_id}`
    };
  }
  return webhook;
}

Subscription Welcome Email

subscription_welcome.js
function handler(webhook) {
  if (webhook.eventType === "subscription.active") {
    const s = webhook.payload.data;
    webhook.url = "https://api.resend.com/emails";
    webhook.payload = {
      from: "[email protected]",
      to: [s.customer.email],
      subject: "Welcome to Your Subscription!",
      html: `
        <h2>Welcome to Your Subscription!</h2>
        <p>Hi ${s.customer.name},</p>
        <p>Your subscription has been activated successfully.</p>
        <ul>
          <li><strong>Subscription ID:</strong> ${s.subscription_id}</li>
          <li><strong>Product:</strong> ${s.product_id}</li>
          <li><strong>Amount:</strong> $${s.recurring_pre_tax_amount}/${s.payment_frequency_interval}</li>
          <li><strong>Next Billing:</strong> ${new Date(s.next_billing_date).toLocaleDateString()}</li>
        </ul>
        <p>You can manage your subscription anytime from your account dashboard.</p>
      `,
      text: `Welcome! Your subscription is now active. Amount: $${s.recurring_pre_tax_amount}/${s.payment_frequency_interval}`
    };
  }
  return webhook;
}

Payment Failure Notification

payment_failure.js
function handler(webhook) {
  if (webhook.eventType === "payment.failed") {
    const p = webhook.payload.data;
    webhook.url = "https://api.resend.com/emails";
    webhook.payload = {
      from: "[email protected]",
      to: [p.customer.email],
      subject: "Payment Failed - Action Required",
      html: `
        <h2>Payment Failed</h2>
        <p>Hi ${p.customer.name},</p>
        <p>We were unable to process your payment of $${p.total_amount}.</p>
        <ul>
          <li><strong>Payment ID:</strong> ${p.payment_id}</li>
          <li><strong>Amount:</strong> $${p.total_amount}</li>
          <li><strong>Error:</strong> ${p.error_message || "Payment processing failed"}</li>
        </ul>
        <p>Please update your payment method or contact support for assistance.</p>
        <a href="https://yourdomain.com/update-payment">Update Payment Method</a>
      `,
      text: `Payment Failed: We couldn't process your $${p.total_amount} payment. Please update your payment method.`
    };
  }
  return webhook;
}

Tips

  • Use verified sender domains for better deliverability
  • Include both HTML and text versions of emails
  • Personalize content with customer data
  • Use clear, action-oriented subject lines
  • Include unsubscribe links for compliance
  • Test email templates before going live

Troubleshooting