Checkout Sessions
एक बार के भुगतान और subscriptions के लिए सुरक्षित, hosted checkout बनाएँ।
Payment Links
बिना code के भुगतान एकत्र करने के लिए URL साझा करें।
Webhooks
payment events सुनें और orders पूरे करें।
API Reference
endpoint documentation और live testing की पूरी जानकारी।
आवश्यकताएँ
शुरू करने से पहले आपके पास ये होना चाहिए:- एक Dodo Payments account.
- कम से कम एक product। इसे dashboard में Products के अंतर्गत बनाएँ। non-zero price वाले subscription product को उस currency के लिए subscription minimum पूरा करना होगा जिसमें customer भुगतान करता है: USD के लिए $1.00। USD, EUR और GBP के अलावा अन्य currencies का मूल्य भी कम से कम $1.00 होना चाहिए। $0 subscription भी समर्थित है।
- एक API key। इसे Developer → API Keys के अंतर्गत बनाएँ और
DODO_PAYMENTS_API_KEYenvironment variable में store करें। Build करते समय key को test mode में बनाएँ: इस page के examples test mode का उपयोग करते हैं और test mode key केवल test mode के विरुद्ध काम करती है। Authentication देखें। - आपकी language के लिए SDK। Node.js SDK के लिए Node.js 20 या बाद का version, Python SDK के लिए Python 3.9 या बाद का version और Go SDK के लिए Go 1.22 या बाद का version आवश्यक है। cURL examples के लिए SDK की आवश्यकता नहीं है।
standardwebhooks package का भी उपयोग किया गया है। इसे npm install standardwebhooks से install करें।
Integration Path चुनें
Overlay और inline checkout केवल web page पर चलते हैं। Native mobile app में अपने server पर checkout session बनाएँ और mobile checkout SDK से उसका
checkout_url खोलें।
किसी coding agent से यह integration बनवाने के लिए Agent Plugin install करें।
Checkout Sessions
एक secure, hosted checkout experience बनाएँ। अपने server पर एक session बनाएँ, फिर customer को लौटाए गएcheckout_url पर redirect करें।
Checkout Session बनाएँ
- Node.js SDK
- Python SDK
- cURL
Checkout पर redirect करें
Session बनाने के बाद customer कोcheckout_url पर redirect करें:
Errors संभालें
जब कोई request fail होती है, API एक HTTP status code औरcode तथा message वाली JSON body लौटाती है। अपने error handling को code पर branch करें, message पर नहीं। प्रत्येक code, उसके कारण और उसे resolve करने के तरीके के लिए Error Codes देखें। Failed payment अलग से report की जाती है: payment का status failed होता है, उसका error_code कारण बताता है और आपको एक payment.failed webhook मिलता है। Retry करना है या नहीं, यह तय करने के लिए Handle Payment Failures देखें।
Payment Links
Payment link एक URL है जो किसी product के लिए checkout खोलता है, इसलिए आप code लिखे बिना payments collect कर सकते हैं। Query parameters customer details को पहले से भरते हैं और checkout form को नियंत्रित करते हैं। जब कोई customer link खोलता है, checkout parameters को session में store करता है और URL कोsession parameter तक छोटा कर देता है, ताकि page refresh होने पर भी वे बने रहें।
Static Payment Links
Static payment link एक ऐसा URL है जिसे आप एक बार बनाकर कई बार share करते हैं। Base URL है:integer
डिफ़ॉल्ट:"1"
खरीदी जाने वाली items की संख्या।
string
आवश्यक
Payment links
redirect_url का उपयोग करते हैं। Checkout Sessions API इसी उद्देश्य के लिए return_url का उपयोग करती है।Payment के बाद redirect करने के लिए URL। Dodo Payments payment details को query parameters के रूप में जोड़ता है, जैसे https://example.com/?payment_id=pay_ts2ySpzg07phGeBZqePbH&status=succeeded&email=customer%40example.com। यदि product license keys जारी करता है, तो license_key parameter भी जोड़ा जाता है; कई keys commas से अलग होती हैं।string
Payment currency निर्दिष्ट करता है। Default billing country की currency होती है।
boolean
डिफ़ॉल्ट:"true"
Currency selector दिखाएँ या छिपाएँ।
boolean
डिफ़ॉल्ट:"true"
Discounts section दिखाएँ या छिपाएँ। Customers को coupon codes दर्ज करने से रोकने के लिए इसे
false पर set करें।number
Major currency units में charge की जाने वाली राशि तय करता है, जैसे $12.50 के लिए
12.5। केवल Pay What You Want products के साथ काम करता है और product की minimum price से कम होने पर ignore किया जाता है।string
Custom metadata fields, जैसे
metadata_orderId=123।Customer Information पहले से भरें
Checkout को सरल बनाने के लिए customer fields को query parameters के रूप में जोड़ें:string
Customer का पूरा नाम (यदि firstName या lastName दिया गया हो तो ignore किया जाता है)।
string
Customer का first name।
string
Customer का last name।
string
Customer का email address।
string
Customer का country (ISO 3166-1 alpha-2 code)।
string
Street address।
string
City।
string
State या province।
string
Postal या ZIP code।
Form Fields disable करें
Customers को पहले से भरी जानकारी बदलने से रोकने के लिए, उसका value provide करके और संबंधितdisable... flag को true पर set करके field disable करें:
Static Payment Link का Example
Dynamic Payment Links (Deprecated)
Dynamic payment links का उपयोग करने वाले existing integrations के लिए, link बनाने हेतु Create One-Time Payment या Create Subscription कोpayment_link: true pass करें। नीचे दिए गए examples one-time payment link बनाते हैं। Subscriptions के लिए Subscription Integration Guide देखें।
- Node.js SDK
- Python SDK
- Go SDK
Webhooks
Webhooks आपके server को बताते हैं कि payment सफल हुई है या fail, ताकि आप order fulfill कर सकें।Webhook Endpoint बनाएँ
Dashboard में Developer → Webhooks पर जाएँ और अपना endpoint URL जोड़ें। Endpoint का signing secretDODO_PAYMENTS_WEBHOOK_KEY environment variable में copy करें।
यहाँ Next.js का उपयोग करने वाला एक example है:
app/api/webhooks/dodo/route.ts
सुनने योग्य Events
कम से कम, one-time payment flow में इन events को सुनें:
यदि आप license keys वाले products बेचते हैं, तो
license_key.created को भी handle करें। Subscription, entitlement, credit, recovery और dunning events सहित events की पूरी list के लिए Webhook Event Guide देखें।
Complete Next.js और TypeScript example के लिए demo repository और उसका live deployment देखें।
Currency और Billing Address
किसी specific currency में charge करने के लिए checkout session बनाते समयbilling_currency और billing_address.country pass करें। यदि आप इन्हें omit करते हैं, तो Adaptive Currency customer के IP address से currency और country चुनता है, जो वह currency नहीं हो सकती जिसमें आप charge करना चाहते हैं।
Pay What You Want amounts product की base currency में होते हैं, जो USD, GBP या EUR होनी चाहिए। किसी अन्य currency में fixed amount collect करने के लिए Adaptive Currency का उपयोग करें, जो live exchange rates पर आपकी base price convert करता है, या Localized Pricing का उपयोग करें, जो प्रत्येक currency के लिए fixed price set करता है। Localized Pricing, Pay What You Want के साथ काम नहीं करता।
One-Click Repeat Purchase
Saved payment method वाले returning customer से charge करने के लिए उसकाpayment_method_id, confirm: true के साथ pass करें। payment_method_id केवल तब accepted होता है जब confirm, true हो, और आपको existing customer का customer_id भी pass करना होगा। क्योंकि confirm, true है, इसलिए आपको complete billing_address भी pass करना होगा, या केवल country और zipcode, जब minimal_address, true हो। Session saved payment method को सीधे charge करता है, इसलिए यह कोई checkout_url return नहीं करता। Payment सफल हुई या नहीं, यह जानने के लिए webhooks का उपयोग करें।
संबंधित Pages
Checkout Sessions
Advanced customization options वाली पूरी guide।
Overlay Checkout
Checkout को अपने page पर modal overlay के रूप में embed करें।
Inline Checkout
Checkout को सीधे अपने page layout में embed करें।
Subscription Integration
Recurring billing set up करें।
Webhook Event Guide
सभी webhook events की पूरी list।
API Reference
Checkout Sessions API documentation।