Vai al contenuto principale

Eventi Webhook di Abbonamento

I seguenti eventi webhook sono disponibili per il monitoraggio delle modifiche al ciclo di vita dell’abbonamento:
EventoDescrizione
subscription.activeL’abbonamento è stato attivato con successo
subscription.updatedL’oggetto abbonamento è stato aggiornato (qualsiasi modifica di campo attiva questo evento)
subscription.on_holdL’abbonamento è stato messo in attesa a causa di un rinnovo non riuscito
subscription.renewedL’abbonamento è stato rinnovato per il prossimo periodo di fatturazione
subscription.plan_changedIl piano di abbonamento è stato aggiornato, declassato o modificato
subscription.cancelledL’abbonamento è stato annullato
subscription.failedLa creazione dell’abbonamento è fallita durante la creazione del mandato
subscription.expiredL’abbonamento ha raggiunto la fine del suo termine

Utilizzo di subscription.updated per la sincronizzazione in tempo reale

Il webhook subscription.updated si attiva ogni volta che cambia un campo dell’abbonamento, consentendoti di mantenere lo stato della tua applicazione sincronizzato senza polling:
app.post('/webhooks/dodo', async (req, res) => {
  const event = req.body;
  
  if (event.type === 'subscription.updated') {
    const subscription = event.data;
    
    // Sync subscription changes to your database
    await syncSubscription(subscription.subscription_id, {
      status: subscription.status,
      next_billing_date: subscription.next_billing_date,
      metadata: subscription.metadata,
      // ... other fields you want to track
    });
    
    console.log(`Subscription ${subscription.subscription_id} updated`);
  }
  
  res.json({ received: true });
});
Iscriviti a subscription.updated per ricevere notifiche in tempo reale su qualsiasi modifica dell’abbonamento, eliminando la necessità di interrogare l’API per aggiornamenti.

Schema del Payload Webhook

Response struct representing subscription details

addons
Addon Cart Response Item · object[]
obbligatorio

Addons associated with this subscription

billing
object
obbligatorio

Billing address details for payments

cancel_at_next_billing_date
boolean
obbligatorio

Indicates if the subscription will cancel at the next billing date

created_at
string<date-time>
obbligatorio

Timestamp when the subscription was created

currency
enum<string>
obbligatorio

Currency used for the subscription payments

Opzioni disponibili:
AED,
ALL,
AMD,
ANG,
AOA,
ARS,
AUD,
AWG,
AZN,
BAM,
BBD,
BDT,
BGN,
BHD,
BIF,
BMD,
BND,
BOB,
BRL,
BSD,
BWP,
BYN,
BZD,
CAD,
CHF,
CLP,
CNY,
COP,
CRC,
CUP,
CVE,
CZK,
DJF,
DKK,
DOP,
DZD,
EGP,
ETB,
EUR,
FJD,
FKP,
GBP,
GEL,
GHS,
GIP,
GMD,
GNF,
GTQ,
GYD,
HKD,
HNL,
HRK,
HTG,
HUF,
IDR,
ILS,
INR,
IQD,
JMD,
JOD,
JPY,
KES,
KGS,
KHR,
KMF,
KRW,
KWD,
KYD,
KZT,
LAK,
LBP,
LKR,
LRD,
LSL,
LYD,
MAD,
MDL,
MGA,
MKD,
MMK,
MNT,
MOP,
MRU,
MUR,
MVR,
MWK,
MXN,
MYR,
MZN,
NAD,
NGN,
NIO,
NOK,
NPR,
NZD,
OMR,
PAB,
PEN,
PGK,
PHP,
PKR,
PLN,
PYG,
QAR,
RON,
RSD,
RUB,
RWF,
SAR,
SBD,
SCR,
SEK,
SGD,
SHP,
SLE,
SLL,
SOS,
SRD,
SSP,
STN,
SVC,
SZL,
THB,
TND,
TOP,
TRY,
TTD,
TWD,
TZS,
UAH,
UGX,
USD,
UYU,
UZS,
VES,
VND,
VUV,
WST,
XAF,
XCD,
XOF,
XPF,
YER,
ZAR,
ZMW
customer
object
obbligatorio

Customer details associated with the subscription

metadata
object
obbligatorio

Additional custom data associated with the subscription

meters
object[]
obbligatorio

Meters associated with this subscription (for usage-based billing)

next_billing_date
string<date-time>
obbligatorio

Timestamp of the next scheduled billing. Indicates the end of current billing period

on_demand
boolean
obbligatorio

Wether the subscription is on-demand or not

payment_frequency_count
integer<int32>
obbligatorio

Number of payment frequency intervals

payment_frequency_interval
enum<string>
obbligatorio

Time interval for payment frequency (e.g. month, year)

Opzioni disponibili:
Day,
Week,
Month,
Year
previous_billing_date
string<date-time>
obbligatorio

Timestamp of the last payment. Indicates the start of current billing period

product_id
string
obbligatorio

Identifier of the product associated with this subscription

quantity
integer<int32>
obbligatorio

Number of units/items included in the subscription

recurring_pre_tax_amount
integer<int32>
obbligatorio

Amount charged before tax for each recurring payment in smallest currency unit (e.g. cents)

status
enum<string>
obbligatorio

Current status of the subscription

Opzioni disponibili:
pending,
active,
on_hold,
cancelled,
failed,
expired
subscription_id
string
obbligatorio

Unique identifier for the subscription

subscription_period_count
integer<int32>
obbligatorio

Number of subscription period intervals

subscription_period_interval
enum<string>
obbligatorio

Time interval for the subscription period (e.g. month, year)

Opzioni disponibili:
Day,
Week,
Month,
Year
tax_inclusive
boolean
obbligatorio

Indicates if the recurring_pre_tax_amount is tax inclusive

trial_period_days
integer<int32>
obbligatorio

Number of days in the trial period (0 if no trial)

cancelled_at
string<date-time> | null

Cancelled timestamp if the subscription is cancelled

discount_cycles_remaining
integer<int32> | null

Number of remaining discount cycles if discount is applied

discount_id
string | null

The discount id if discount is applied

expires_at
string<date-time> | null

Timestamp when the subscription will expire

payment_method_id
string | null

Saved payment method id used for recurring charges

tax_id
string | null

Tax identifier provided for this subscription (if applicable)