Vai al contenuto principale

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.

Introduzione

Invia automaticamente email transazionali professionali quando si verificano eventi di pagamento. Fornisci conferme di pagamento, aggiornamenti di abbonamento e notifiche importanti con l’infrastruttura email affidabile di Resend e ottimi tassi di deliverability.
Questa integrazione richiede la tua chiave API Resend per l’autenticazione.

Iniziare

1

Open the Webhook Section

Nel tuo dashboard Dodo Payments, vai a Webhooks → + Aggiungi Endpoint e espandi il menu a tendina delle integrazioni.
Aggiungi Endpoint e menu a tendina delle integrazioni
2

Select Resend

Seleziona la scheda di integrazione Resend.
3

Enter API Key

Inserisci la tua chiave API Resend nella configurazione.
4

Configure Transformation

Modifica il codice di trasformazione per formattare le email per l’API di Resend.
5

Test & Create

Testa con payload di esempio e clicca Crea per attivare l’invio delle email.
6

Done!

🎉 Gli eventi di pagamento attiveranno automaticamente email transazionali tramite Resend.

Esempi di Codice di Trasformazione

Email di Conferma di Pagamento

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: "payments@yourdomain.com",
      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;
}

Email di Benvenuto per Abbonamento

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: "welcome@yourdomain.com",
      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;
}

Notifica di Fallimento del Pagamento

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: "support@yourdomain.com",
      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;
}

Suggerimenti

  • Utilizza domini di mittente verificati per una migliore deliverability
  • Includi sia versioni HTML che testo delle email
  • Personalizza i contenuti con i dati dei clienti
  • Usa oggetti chiari e orientati all’azione
  • Includi link per disiscriversi per conformità
  • Testa i modelli di email prima di andare in diretta

Risoluzione dei Problemi

  • Verifica che la chiave API sia corretta e attiva
  • Verifica che il dominio mittente sia verificato in Resend
  • Assicurati che gli indirizzi email dei destinatari siano validi
  • Controlla i limiti di invio e le quote di Resend
  • Convalida che la struttura JSON corrisponda al formato dell’API Resend
  • Verifica che tutti i campi obbligatori siano presenti
  • Assicurati che il contenuto HTML sia formattato correttamente
  • Verifica che l’indirizzo email del mittente sia verificato
Last modified on April 20, 2026