Introduktion
Skicka professionella transaktionella e-postmeddelanden automatiskt när betalningshändelser inträffar. Leverera betalningsbekräftelser, abonnemangsuppdateringar och viktiga meddelanden med Resends pålitliga e-postinfrastruktur och utmärkta leveransgrader.
Denna integration kräver din Resend API-nyckel för autentisering.
Komma igång
Öppna Webhook-sektionen
I din Dodo Payments-instrumentpanel, navigera till Webhooks → + Lägg till slutpunkt och expandera integrationsrullgardinsmenyn.
Välj Resend
Välj Resend integrationskortet.
Ange API-nyckel
Ange din Resend API-nyckel i konfigurationen.
Konfigurera transformation
Redigera transformationskoden för att formatera e-postmeddelanden för Resends API.
Testa & Skapa
Testa med exempelpayloads och klicka på Skapa för att aktivera e-postutskick.
Klart!
🎉 Betalningshändelser kommer nu automatiskt att utlösa transaktionella e-postmeddelanden via Resend.
Betalningsbekräftelse E-post
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 / 100 ). toFixed ( 2 ),
html: `
<h2>Payment Successful!</h2>
<p>Hi ${ p . customer . name } ,</p>
<p>Your payment of $ ${ ( p . total_amount / 100 ). toFixed ( 2 ) } has been processed successfully.</p>
<ul>
<li><strong>Payment ID:</strong> ${ p . payment_id } </li>
<li><strong>Amount:</strong> $ ${ ( p . total_amount / 100 ). toFixed ( 2 ) } </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 / 100 ). toFixed ( 2 ) } has been processed. Payment ID: ${ p . payment_id } `
};
}
return webhook ;
}
See all 25 lines
Välkomst-e-post för abonnemang
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 / 100 ). toFixed ( 2 ) } / ${ 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 / 100 ). toFixed ( 2 ) } / ${ s . payment_frequency_interval } `
};
}
return webhook ;
}
See all 25 lines
Meddelande om betalningsfel
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 / 100 ). toFixed ( 2 ) } .</p>
<ul>
<li><strong>Payment ID:</strong> ${ p . payment_id } </li>
<li><strong>Amount:</strong> $ ${ ( p . total_amount / 100 ). toFixed ( 2 ) } </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 / 100 ). toFixed ( 2 ) } payment. Please update your payment method.`
};
}
return webhook ;
}
See all 25 lines
Tips
Använd verifierade avsändardomäner för bättre leveranssäkerhet
Inkludera både HTML- och textversioner av e-postmeddelanden
Personalisera innehållet med kunddata
Använd tydliga, handlingsinriktade ämnesrader
Inkludera avregistreringslänkar för efterlevnad
Testa e-postmallar innan de går live
Felsökning
E-postmeddelanden skickas inte
Verifiera att API-nyckeln är korrekt och aktiv
Kontrollera att avsändardomänen är verifierad i Resend
Se till att mottagarens e-postadresser är giltiga
Granska Resends sändningsgränser och kvoter