Introduzione
Tieni il tuo team informato dove già collaborano. L’integrazione di Discord invia eventi di pagamento, abbonamento, controversia e altri eventi importanti direttamente a qualsiasi canale tu scelga—senza necessità di polling o dashboard.
Questa guida presuppone che tu abbia accesso alla sezione Integrazioni della dashboard di Dodo Payments.
Iniziare
Open the Webhook Section
Nel pannello Dodo Payments, apri Webhooks → + Aggiungi endpoint e espandi il menu a tendina per visualizzare le integrazioni.
Select Discord
Seleziona la scheda Discord e poi clicca su Collega il tuo workspace Discord .
Authorize the Bot
Concedi le autorizzazioni richieste affinché il bot possa inviare messaggi nel canale selezionato.
Edit Transformation Code
Adatta la mappatura payload → embed alle tue esigenze oppure inizia con i modelli sottostanti.
Test & Create
Usa payload di esempio per visualizzare l’embed in anteprima, poi clicca su Crea .
Done!
🎉 Il tuo canale Discord riceverà ora aggiornamenti live da Dodo Payments.
Embed di Pagamento Minimo
function handler ( webhook ) {
if ( webhook . eventType === "payment.succeeded" ) {
const p = webhook . payload . data ;
webhook . payload = {
embeds: [{
title: "✅ Payment Successful" ,
description: `**Amount:** $ ${ ( p . total_amount / 100 ). toFixed ( 2 ) } \n **Customer:** ${ p . customer . email } ` ,
color: 0x2ecc71 // green
}]
};
}
return webhook ;
}
See all 13 lines
Eventi di Abbonamento
function handler ( webhook ) {
const s = webhook . payload . data ;
switch ( webhook . eventType ) {
case "subscription.active" :
webhook . payload = {
embeds: [{
title: "📄 Subscription Activated" ,
fields: [
{ name: "Customer" , value: s . customer . email , inline: true },
{ name: "Product" , value: s . product_id , inline: true },
{ name: "Next Billing" , value: new Date ( s . next_billing_date ). toLocaleDateString (), inline: true }
],
color: 0x2ecc71
}]
};
break ;
case "subscription.cancelled" :
webhook . payload = {
embeds: [{
title: "⚠️ Subscription Cancelled" ,
fields: [
{ name: "Customer" , value: s . customer . email , inline: true },
{ name: "Product" , value: s . product_id , inline: true }
],
color: 0xf1c40f
}]
};
break ;
}
return webhook ;
}
See all 31 lines
Avvisi di Controversia
function handler ( webhook ) {
if ( webhook . eventType . startsWith ( "dispute." )) {
const d = webhook . payload . data ;
webhook . payload = {
embeds: [{
title: d . dispute_status === "won" ? "🏆 Dispute Won" : d . dispute_status === "lost" ? "❌ Dispute Lost" : "🚨 Dispute Update" ,
fields: [
{ name: "Payment ID" , value: d . payment_id , inline: true },
{ name: "Amount" , value: `$ ${ ( d . amount / 100 ). toFixed ( 2 ) } ` , inline: true },
{ name: "Status" , value: d . dispute_status , inline: true }
],
color: d . dispute_status === "won" ? 0x2ecc71 : d . dispute_status === "lost" ? 0xe74c3c : 0xe67e22
}]
};
}
return webhook ;
}
See all 17 lines
Suggerimenti
Preferisci gli embed per una formattazione ricca e colori.
Mantieni i titoli brevi; metti i dettagli nei campi.
Usa colori intuitivi: verde (successo), rosso (errore), arancione (avvisi).
Risoluzione dei Problemi
Conferma che il bot abbia accesso al canale.
Verifica che la trasformazione restituisca un oggetto JSON con embeds.