मुख्य सामग्री पर जाएं

सदस्यता वेबहुक घटनाएँ

सदस्यता जीवनचक्र परिवर्तनों को ट्रैक करने के लिए निम्नलिखित वेबहुक घटनाएँ उपलब्ध हैं:
घटनाविवरण
subscription.activeसदस्यता सफलतापूर्वक सक्रिय की गई
subscription.updatedसदस्यता ऑब्जेक्ट को अपडेट किया गया (किसी भी फ़ील्ड परिवर्तन से यह घटना ट्रिगर होती है)
subscription.on_holdसदस्यता नवीनीकरण में विफलता के कारण होल्ड पर है
subscription.renewedसदस्यता अगले बिलिंग अवधि के लिए नवीनीकरण की गई
subscription.plan_changedसदस्यता योजना को अपग्रेड, डाउनग्रेड, या संशोधित किया गया
subscription.cancelledसदस्यता रद्द की गई
subscription.failedजनादेश निर्माण के दौरान सदस्यता निर्माण विफल रहा
subscription.expiredसदस्यता अपनी अवधि के अंत तक पहुँच गई

वास्तविक समय समन्वय के लिए subscription.updated का उपयोग करना

जब भी कोई सदस्यता फ़ील्ड बदलता है, तो subscription.updated वेबहुक सक्रिय होता है, जिससे आप बिना पोलिंग के अपने एप्लिकेशन की स्थिति को समन्वयित रख सकते हैं:
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 });
});
subscription.updated पर सब्सक्राइब करें ताकि किसी भी सदस्यता परिवर्तन के बारे में वास्तविक समय में सूचनाएँ प्राप्त कर सकें, जिससे API से अपडेट के लिए पोलिंग करने की आवश्यकता समाप्त हो जाती है।

वेबहुक पेलोड स्कीमा

Response struct representing subscription details

addons
Addon Cart Response Item · object[]
आवश्यक

Addons associated with this subscription

billing
object
आवश्यक

Billing address details for payments

cancel_at_next_billing_date
boolean
आवश्यक

Indicates if the subscription will cancel at the next billing date

created_at
string<date-time>
आवश्यक

Timestamp when the subscription was created

currency
enum<string>
आवश्यक

Currency used for the subscription payments

उपलब्ध विकल्प:
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
आवश्यक

Customer details associated with the subscription

metadata
object
आवश्यक

Additional custom data associated with the subscription

meters
object[]
आवश्यक

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

next_billing_date
string<date-time>
आवश्यक

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

on_demand
boolean
आवश्यक

Wether the subscription is on-demand or not

payment_frequency_count
integer<int32>
आवश्यक

Number of payment frequency intervals

payment_frequency_interval
enum<string>
आवश्यक

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

उपलब्ध विकल्प:
Day,
Week,
Month,
Year
previous_billing_date
string<date-time>
आवश्यक

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

product_id
string
आवश्यक

Identifier of the product associated with this subscription

quantity
integer<int32>
आवश्यक

Number of units/items included in the subscription

recurring_pre_tax_amount
integer<int32>
आवश्यक

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

status
enum<string>
आवश्यक

Current status of the subscription

उपलब्ध विकल्प:
pending,
active,
on_hold,
cancelled,
failed,
expired
subscription_id
string
आवश्यक

Unique identifier for the subscription

subscription_period_count
integer<int32>
आवश्यक

Number of subscription period intervals

subscription_period_interval
enum<string>
आवश्यक

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

उपलब्ध विकल्प:
Day,
Week,
Month,
Year
tax_inclusive
boolean
आवश्यक

Indicates if the recurring_pre_tax_amount is tax inclusive

trial_period_days
integer<int32>
आवश्यक

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)