الانتقال إلى المحتوى الرئيسي

Quick Start Guide

Get your first checkout session running in under 5 minutes

API Reference & Live Testing

Explore the full API documentation and interactively test Checkout Session requests and responses.

Preview Checkout

Calculate pricing, taxes, and totals before creating a session.
Session Validity: Checkout sessions are valid for 24 hours by default. If you pass confirm=true in your request, the session will only be valid for 15 minutes.

Prerequisites

1

Dodo Payments Account

You’ll need an active Dodo Payments merchant account with API access.
2

API Credentials

Generate your API credentials from the Dodo Payments dashboard:
3

Products Setup

Create your products in the Dodo Payments dashboard before implementing checkout sessions.

Creating Your First Checkout Session

API Response

All methods above return the same response structure:
1

Get the checkout URL

Extract the checkout_url from the API response.
2

Redirect your customer

Direct your customer to the checkout URL to complete their purchase.
Alternative Integration Options: Instead of redirecting, you can embed the checkout directly in your page using Overlay Checkout (modal overlay) or Inline Checkout (fully embedded). Both options use the same checkout session URL.
3

Handle the return

After payment, customers are redirected to your return_url with query parameters including payment/subscription ID, status, customer email, and any license keys. See the return_url parameter docs for the full list.

Request Body

Required Fields

Essential fields needed for every checkout session

Optional Fields

Additional configuration to customize your checkout experience

Required Fields

product_cart
array
مطلوب
Array of products to include in the checkout session. Each product must have a valid product_id from your Dodo Payments dashboard.
Mixed Checkout: You can combine one-time payment products and subscription products in the same checkout session. This enables powerful use cases like setup fees with subscriptions, hardware bundles with SaaS, and more.
Find Your Product IDs: You can find product IDs in your Dodo Payments dashboard under Products → View Details, or by using the List Products API.

Optional Fields

Configure these fields to customize the checkout experience and add business logic to your payment flow.
customer
object
Customer information. You can either attach an existing customer using their ID or create a new customer record during checkout.
Attach an existing customer to the checkout session using their ID.
billing_address
object
Billing address information for accurate tax calculation, fraud prevention, and regulatory compliance.
When confirm is set to true, all billing address fields become required for successful session creation.
allowed_payment_method_types
array
Control which payment methods are available to customers during checkout. This helps optimize for specific markets or business requirements.الخيارات المتاحة: credit, debit, upi_collect, apple_pay, google_pay, amazon_pay, klarna, affirm, afterpay_clearpay, cashapp, multibanco, bancontact_card, eps, ideal, przelewy24, paypal, sunbit
Critical: Always include credit and debit as fallback options to prevent checkout failures when preferred payment methods are unavailable.
Example:
billing_currency
string
Override the default currency selection with a fixed billing currency. Uses ISO 4217 currency codes.Supported Currencies: USD, EUR, GBP, CAD, AUD, INR, and moreExample: "USD" for US Dollars, "EUR" for Euros
This field is only effective when adaptive pricing is enabled. If adaptive pricing is disabled, the product’s default currency will be used.
show_saved_payment_methods
boolean
افتراضي:"false"
Display previously saved payment methods for returning customers, improving checkout speed and user experience.
return_url
string
URL to redirect customers after payment completion. Dodo Payments appends the following query parameters to your URL on redirect:Example redirect URLs:
Use the license_key and email query parameters to display license keys or send a confirmation immediately on your return page, without needing an extra API call.
cancel_url
string
URL to redirect customers when they click the back button or cancel the checkout session. If not provided, the back button will not be displayed.
Set a cancel_url to give customers a clear way to return to your site without completing the purchase. This improves the checkout experience and reduces friction.
confirm
boolean
افتراضي:"false"
If true, finalizes all session details immediately. API will throw an error if required data is missing.
discount_codes
array
Apply one or more stacked discount codes to the checkout session. Codes are applied in array order (the first code reduces the base price, the second reduces the already-discounted price, and so on), up to a maximum of 20 codes per session.
The singular discount_code field below is deprecated but still fully supported — existing integrations continue to work without changes. It cannot be combined with discount_codes in the same request. Migrate to discount_codes when convenient to take advantage of stacking.
discount_code
string
مهمل
Deprecated — prefer discount_codes for new integrations. This field still works for backward compatibility, but cannot be combined with discount_codes in the same request.
metadata
object
Custom key-value pairs to store additional information about the session.
force_3ds
boolean
Override merchant default 3DS behaviour for this session.
minimal_address
boolean
افتراضي:"false"
Enable minimal address collection mode. When enabled, the checkout only collects:
  • Country: Always required for tax determination
  • ZIP/Postal code: Only in regions where it’s necessary for sales tax, VAT, or GST calculation
This significantly reduces checkout friction by eliminating unnecessary form fields.
Enable minimal address for faster checkout completion. Full address collection remains available for businesses that require complete billing details.
customization
object
Customize the appearance and behavior of the checkout interface.
feature_flags
object
Configure specific features and behaviors for the checkout session.
custom_fields
array
جمع معلومات إضافية من العملاء أثناء الدفع باستخدام حقول النموذج المخصصة. يمكنك تعريف ما يصل إلى 5 حقول مخصصة لكل جلسة دفع. يتم تضمين ردود العملاء في تحميلات webhook ومتاحة عبر API.
تتضمن ردود العملاء على الحقول المخصصة في:
  • Webhooks: payment.succeeded, subscription.active، وpayloads الأحداث ذات الصلة الأخرى تحتوي على مصفوفة custom_field_responses
  • استجابات API: تتضمن كائنات الدفع والاشتراك custom_field_responses
subscription_data
object
إعدادات إضافية لجلسات الدفع التي تحتوي على منتجات الاشتراكات.

أمثلة الاستخدام

إليكم 10 أمثلة شاملة تعرض تكوينات مختلفة لجلسات الدفع لسيناريوهات العمل المختلفة:

1. دفع بسيط لمنتج واحد

2. سلة متعددة المنتجات

3. اشتراك مع فترة تجريبية

4. دفع مؤكد مسبقاً

عندما يتم تعيين confirm إلى true، سيتم نقل العميل مباشرة إلى صفحة الدفع، متجاوزاً أي خطوات تأكيد.

5. الدفع مع تجاوز العملة

سيؤثر تجاوز billing_currency فقط عندما يتم تمكين العملة التكيفية في إعدادات حسابك. إذا تم تعطيل العملة التكيفية، فلن يكون لهذا المعامل أي تأثير.

6. طرق دفع محفوظة للعملاء العائدين

7. الدفع بين الشركات مع جمع معرف الضرائب

8. دفع بنمط داكن مع أكواد خصم مكدسة

9. طرق الدفع الإقليمية (UPI للهند)

لمزيد من المعلومات حول تكوين UPI والاختبار، انظر صفحة طرق الدفع في الهند.

10. الدفع الآن والدفع لاحقاً (BNPL)

لمزيد من المعلومات حول تكوين BNPL والاختبار، انظر صفحة الدفع الآن والدفع لاحقاً (BNPL).

11. استخدام طرق الدفع الحالية للدفع الفوري

استخدم طريقة الدفع المحفوظة للعميل لإنشاء جلسة دفع تتم على الفور، متخطية جمع معلومات طريقة الدفع:
عند استخدام payment_method_id، يجب تعيين confirm إلى true ويجب تقديم customer_id موجود. سيتم التحقق من أهلية طريقة الدفع بالنسبة لعملة الدفع.
يجب أن تكون طريقة الدفع تابعة للعميل ومتوافقة مع عملة الدفع. هذا يمكّن العملاء العائدين من الشراء بنقرة واحدة.

12. روابط قصيرة للحصول على روابط دفع أنظف

توليد روابط دفع قصيرة وقابلة للمشاركة مع عناوين مخصصة:
الروابط القصيرة مثالية للمشاركة عبر الرسائل النصية أو البريد الإلكتروني أو وسائل التواصل الاجتماعي. من الأسهل تذكرها وتبني ثقة العملاء بشكل أكبر من الروابط الطويلة.

13. تخطي صفحة نجاح الدفع بإعادة التوجيه الفوري

إعادة توجيه العملاء مباشرة بعد إتمام الدفع، متجاوزاً صفحة النجاح الافتراضية:
استخدم redirect_immediately: true عندما يكون لديك صفحة نجاح مخصصة توفر تجربة مستخدم أفضل من صفحة نجاح الدفع الافتراضية. هذا مفيد بشكل خاص لتطبيقات الجوال وتدفق الدفع المضمنة.
عندما يتم تمكين redirect_immediately، يتم إعادة توجيه العملاء إلى return_url بعد إتمام الدفع مباشرةً، متجاوزين صفحة النجاح الافتراضية تماماً.

14. فرض لغة معينة

إجبار الدفع ليظهر بلغة معينة، متجاوزاً كشف لغة متصفح العميل:
استخدم force_language عندما تعرف لغة العميل المفضلة (مثلما هو موضح في إعدادات حسابه) أو عند استهداف أسواق إقليمية معينة.
اللغات المدعومة: العربية (ar)، الكتالونية (ca)، الصينية (zh)، الهولندية (nl)، الإنجليزية (en)، الفرنسية (fr)، الألمانية (de)، العبرية (he)، الإندونيسية (id)، الإيطالية (it)، اليابانية (ja)، الكورية (ko)، الملايوية (ms)، البولندية (pl)، البرتغالية (pt)، الرومانية (ro)، الروسية (ru)، الإسبانية (es)، السويدية (sv)، التايلاندية (th)، التركية (tr)

15. جمع الحقول المخصصة

جمع معلومات إضافية من العملاء أثناء الدفع باستخدام الحقول المخصصة:
يتم تضمين ردود الحقول المخصصة تلقائيًا في تحميلات webhook (payment.succeeded, subscription.active، إلخ.) ويمكن استردادها عبر API. استخدامها لإثراء إدارة علاقات العملاء، تشغيل تدفقات الإعداد، أو تخصيص تجربة العميل.
أنواع الحقول المتاحة: text, number, email, url, date, dropdown, boolean

معاينة لجلسات الدفع

قبل إنشاء جلسة دفع، يمكنك معاينة تفاصيل الأسعار بما في ذلك الضرائب، الخصومات، والإجماليات. هذا مفيد لعرض أسعار دقيقة للعملاء قبل متابعة عملية الدفع.

Preview API Reference

عرض وثائق نقطة النهاية الكاملة للمعاينة.

الانتقال من الروابط الديناميكية إلى جلسات الدفع

الاختلافات الرئيسية

في السابق، عند إنشاء رابط دفع باستخدام الروابط الديناميكية، كان يتعين عليك توفير عنوان الفواتير الكامل للعميل. مع جلسات الدفع، لم يعد ذلك ضرورياً. يمكنك ببساطة تمرير أي معلومات تمتلكها، وسنتولى نحن الباقي. على سبيل المثال:
  • إذا كنت تعرف فقط بلد فواتير العميل، فقط قدم ذلك.
  • سيجمع تدفق الدفع تلقائياً التفاصيل المفقودة قبل نقل العميل إلى صفحة الدفع.
  • من ناحية أخرى، إذا كان لديك جميع المعلومات المطلوبة بالفعل وترغب في التوجه مباشرة إلى صفحة الدفع، يمكنك تمرير مجموعة البيانات الكاملة وتضمين confirm=true في طلبك.

عملية الانتقال

الانتقال من الروابط الديناميكية إلى جلسات الدفع بسيط:
1

Update your integration

قم بتحديث التكامل الخاص بك لاستخدام الطريقة الجديدة لـ API أو SDK.
2

Adjust request payload

قم بتعديل حمولة الطلب وفقًا لتنسيق جلسات الدفع.
3

That's it!

نعم. لا يتطلب الأمر معالجة إضافية أو خطوات انتقال خاصة على جانبك.

المرجع الكامل لـ API ذو الصلة

Create Checkout Session

المرجع الكامل لإنشاء جلسات الدفع مع جميع المعلمات والخيارات المتاحة

Preview Checkout Session

مرجع API لمعاينة التسعير، الضرائب، والإجماليات قبل إنشاء جلسة
آخر تعديل في ٩ يوليو ٢٠٢٦