المقدمة
قم بمزامنة عملائك الذين يدفعون تلقائيًا إلى قوائم المشتركين في MailerLite عند حدوث أحداث الدفع. أضف العملاء إلى مجموعات محددة، وفعل سير العمل الأوتوماتيكي، وابقِ قوائم التسويق عبر البريد الإلكتروني محدثة ببيانات الدفع الحقيقية.
MailerLite هي منصة قوية للتسويق عبر البريد الإلكتروني للنشرات الإخبارية، والحملات، والأتمتة. تساعدك هذه التكاملات على إدارة المشتركين تلقائيًا بناءً على نشاط الدفع - مثالية لتسلسلات الانضمام، وتقسيم العملاء، وحملات التسويق المستهدفة.
البدء
Open the Webhook Section
في لوحة تحكم Dodo Payments، انتقل إلى Webhooks + Add Endpoint وقم بتوسيع قائمة التكاملات المنسدلة.
Select MailerLite
اختر بطاقة التكامل MailerLite .
Enter API Key
قم بتوفير مفتاح API الخاص بـ MailerLite في الإعدادات.
Configure Transformation
قم بتحرير كود التحويل لتنسيق بيانات المشتركين لواجهة MailerLite البرمجية.
Test & Create
اختبر باستخدام عينات الحمولة وانقر على Create لتفعيل مزامنة المشتركين.
Done!
ستقوم أحداث الدفع الآن بمزامنة العملاء تلقائيًا مع قوائم MailerLite الخاصة بك.
أمثلة كود التحويل
إضافة عميل عند الدفع الناجح
function handler ( webhook ) {
if ( webhook . eventType === "payment.succeeded" ) {
const p = webhook . payload . data ;
webhook . url = "https://connect.mailerlite.com/api/subscribers" ;
webhook . payload = {
email: p . customer . email ,
fields: {
name: p . customer . name ,
company: p . customer . business_name || "" ,
last_name: ""
},
groups: [ "your-group-id-here" ],
status: "active"
};
}
return webhook ;
}
See all 17 lines
إضافة مشترك إلى مجموعات متعددة بناءً على المنتج
function handler ( webhook ) {
if ( webhook . eventType === "payment.succeeded" ) {
const p = webhook . payload . data ;
// Determine groups based on product or amount
const groups = [ "customers-group-id" ];
// Add to premium group if high-value purchase
if ( p . total_amount >= 10000 ) { // $100+
groups . push ( "premium-customers-group-id" );
}
webhook . url = "https://connect.mailerlite.com/api/subscribers" ;
webhook . payload = {
email: p . customer . email ,
fields: {
name: p . customer . name ,
last_purchase_amount: ( p . total_amount / 100 ). toFixed ( 2 ),
last_purchase_date: new Date ( webhook . payload . timestamp ). toISOString (). split ( 'T' )[ 0 ],
payment_id: p . payment_id
},
groups: groups ,
status: "active"
};
}
return webhook ;
}
See all 27 lines
إضافة مشترك جديد عند تفعيل الاشتراك
subscription_subscriber.js
function handler ( webhook ) {
if ( webhook . eventType === "subscription.active" ) {
const s = webhook . payload . data ;
webhook . url = "https://connect.mailerlite.com/api/subscribers" ;
webhook . payload = {
email: s . customer . email ,
fields: {
name: s . customer . name ,
subscription_plan: s . product_id ,
subscription_amount: ( s . recurring_pre_tax_amount / 100 ). toFixed ( 2 ),
billing_frequency: s . payment_frequency_interval ,
subscription_start: new Date (). toISOString (). split ( 'T' )[ 0 ]
},
groups: [ "subscribers-group-id" , "active-subscriptions-group-id" ],
status: "active"
};
}
return webhook ;
}
See all 19 lines
تحديث مشترك عند إلغاء الاشتراك
subscription_cancelled.js
function handler ( webhook ) {
if ( webhook . eventType === "subscription.cancelled" ) {
const s = webhook . payload . data ;
// Use PUT to update existing subscriber
webhook . url = "https://connect.mailerlite.com/api/subscribers/" + encodeURIComponent ( s . customer . email );
webhook . method = "PUT" ;
webhook . payload = {
fields: {
subscription_status: "cancelled" ,
cancellation_date: new Date (). toISOString (). split ( 'T' )[ 0 ]
},
groups: [ "churned-customers-group-id" ]
};
}
return webhook ;
}
See all 16 lines
إضافة عميل مع حقول مخصصة
function handler ( webhook ) {
if ( webhook . eventType === "payment.succeeded" ) {
const p = webhook . payload . data ;
webhook . url = "https://connect.mailerlite.com/api/subscribers" ;
webhook . payload = {
email: p . customer . email ,
fields: {
name: p . customer . name ,
company: p . customer . business_name || "" ,
country: p . customer . country || "" ,
city: p . customer . city || "" ,
phone: p . customer . phone || "" ,
// Custom fields (must be created in MailerLite first)
total_spent: ( p . total_amount / 100 ). toFixed ( 2 ),
customer_since: new Date (). toISOString (). split ( 'T' )[ 0 ],
payment_method: p . payment_method || "unknown" ,
currency: p . currency || "USD"
},
groups: [ "paying-customers-group-id" ],
status: "active" ,
subscribed_at: new Date (). toISOString (). replace ( 'T' , ' ' ). split ( '.' )[ 0 ]
};
}
return webhook ;
}
See all 25 lines
تفعيل الأتمتة عبر الحدث
function handler ( webhook ) {
if ( webhook . eventType === "payment.succeeded" ) {
const p = webhook . payload . data ;
// First, ensure subscriber exists
webhook . url = "https://connect.mailerlite.com/api/subscribers" ;
webhook . payload = {
email: p . customer . email ,
fields: {
name: p . customer . name ,
// Add a trigger field that your automation watches
last_payment_trigger: new Date (). toISOString (),
last_payment_amount: ( p . total_amount / 100 ). toFixed ( 2 )
},
status: "active"
};
// Tip: Create an automation in MailerLite that triggers
// when 'last_payment_trigger' field is updated
}
return webhook ;
}
See all 22 lines
نصائح
أنشئ حقولًا مخصصة في MailerLite قبل استخدامها في التحويلات الخاصة بك
استخدم المجموعات لتقسيم العملاء حسب المنتج، أو مستوى الخطة، أو سلوك الشراء
قم بإعداد سير العمل الأوتوماتيكي في MailerLite الذي يتم تفعيله عند تحديث الحقول
استخدم سلوك upsert (POST إلى /subscribers) لتجنب أخطاء المشتركين المكررين
قم بتخزين بيانات الدفع الوصفية في حقول مخصصة للحصول على رؤى أفضل عن العملاء
اختبر مع مجموعة صغيرة قبل التفعيل لجميع المدفوعات
إعداد الحقول المخصصة
قبل استخدام الحقول المخصصة، تحتاج إلى إنشائها في MailerLite:
انتقل إلى لوحة تحكم MailerLite الخاصة بك
انتقل إلى حقول المشتركين
انقر على Create field وأضف حقول مثل:
total_spent (رقم)
customer_since (تاريخ)
subscription_plan (نص)
payment_method (نص)
last_payment_amount (رقم)
استكشاف الأخطاء وإصلاحها
Subscribers not being added
تحقق من أن مفتاح API صحيح ونشط
تأكد من أن عنوان البريد الإلكتروني صالح (متوافق مع RFC 2821)
تأكد من أن معرفات المجموعات صحيحة وموجودة في حسابك
ملاحظة: لا يمكن إعادة تنشيط المشتركين الذين ألغوا الاشتراك أو ارتدت رسائلهم أو تم تصنيفهم كرسائل غير مرغوب فيها عبر واجهة برمجة التطبيقات
Custom fields not updating
تحقق من وجود الحقول المخصصة في MailerLite قبل استخدامها
تأكد من تطابق أسماء الحقول تمامًا (حساسية لحالة الأحرف)
تأكد من أن قيم الحقول تتطابق مع النوع المتوقع (نص، رقم، تاريخ)
واجهة برمجة تطبيقات MailerLite لها حد سرعة يبلغ 120 طلبًا في الدقيقة
استخدم نقاط النهاية الدُفعية إذا كنت تعالج العديد من المشتركين
نفذ استراتيجيات تراجع في حالات الحجم الكبير
Group assignment not working
تحقق من أن معرفات المجموعات هي سلاسل رقمية
تحقق من وجود المجموعات في حساب MailerLite الخاص بك
ملاحظة: سيؤدي استخدام PUT مع المجموعات إلى إزالة المشترك من المجموعات غير المدرجة
مرجع API
تقبل واجهة برمجة تطبيقات مشتركي MailerLite المعلمات الرئيسية التالية:
الوسيط النوع مطلوب الوصف emailstring Yes عنوان بريد إلكتروني صالح (RFC 2821) fieldsobject No كائن يحتوي على أزواج اسم/قيمة للحقول fields.namestring No الاسم الأول للمشترك fields.last_namestring No اسم عائلة المشترك fields.companystring No اسم الشركة fields.countrystring No البلد fields.citystring No المدينة fields.phonestring No رقم الهاتف groupsarray No مصفوفة بمعرفات المجموعات التي يجب إضافة المشترك إليها statusstring No أحد الخيارات: active، unsubscribed، unconfirmed، bounced، junk subscribed_atstring No تاريخ بالتنسيق yyyy-MM-dd HH:mm:ss ip_addressstring No عنوان بروتوكول الإنترنت (IP) للمشترك
للحصول على وثائق API الكاملة، قم بزيارة مطورين MailerLite . Last modified on February 27, 2026