अवलोकन
Billing SDK में शामिल हैं:- React Components: React applications के लिए पहले से बने, अनुकूलन योग्य billing components।
- CLI Tooling: एक command-line interface जो projects को initialize करता है और components जोड़ता है।
- Framework Support: Next.js, Express.js, Hono, Fastify, NestJS और React के लिए templates।
- Payment Provider: Dodo Payments के साथ पूर्ण integration।
त्वरित प्रारंभ
किसी मौजूदा project में Billing SDK सेट अप करने के लिए, project root से CLI चलाएँ:1
Install the CLI
इसे install किए बिना या बार-बार उपयोग के लिए इसे globally install करें। Global install से
npx के साथ CLI चलाएँ:billingsdk command जुड़ती है, उदाहरण के लिए billingsdk init:2
Initialize a Project
अपने project में billing जोड़ने के लिए interactive setup चलाएँ:CLI आपको इन विकल्पों को चुनने के लिए कहता है:
- आपका framework: Next.js, Express.js, React, Hono, Fastify या NestJS। CLI आपके framework का पता लगाता है और उसे detected के रूप में चिह्नित करता है।
- आपका payment provider: Dodo Payments चुनें।
3
Add Components
अपने प्रोजेक्ट में व्यक्तिगत बिलिंग कंपोनेंट्स जोड़ें:
समर्थित ढांचे
Billing SDK में इनमें से प्रत्येक framework के लिए Dodo Payments template है:CLI कमांड
@billingsdk/cli init
init आपके project में billing सेट अप करता है: यह Dodo Payments integration वाले framework template और template के लिए आवश्यक dependencies install करता है।
यह क्या करता है:
- Framework Selection: आप अपना framework और payment provider चुनते हैं।
- Template Installation: CLI Billing SDK registry से आपके framework और provider का template download करता है और उसकी files install करता है।
- Dependency Management: CLI template की dependencies, जैसे
dodopayments,standardwebhooksऔरzod, npm, pnpm, Yarn या Bun के साथ install करता है। - File Generation: CLI configuration files और boilerplate code लिखता है। Express.js, Fastify, Hono और NestJS के लिए यह उन्हें
src/के अंतर्गत लिखता है।
init चलाने के लिए --framework, --provider और --yes पास करें, उदाहरण के लिए npx @billingsdk/cli init --framework nextjs --provider dodopayments --yes। Files को लिखे बिना उनकी सूची देखने के लिए --dry-run जोड़ें, dependency install छोड़ने के लिए --no-install, या npm, pnpm, yarn या bun चुनने के लिए --package-manager जोड़ें।
@billingsdk/cli add
add shadcn/ui registry system के ज़रिए आपके project में एक billing component install करता है। यह आपके package manager के runner के साथ shadcn@latest add @billingsdk/<component> चलाता है।
उदाहरण:
shadcnCLI registry से component configuration download करता है।- यह component files को आपकी
components/billingsdk/directory में install करता है। - आवश्यकता होने पर यह आपके project configuration को update करता है।
- यह कोई भी अतिरिक्त dependencies install करता है।
Generated Files Structure
init चलाने के बाद आपके project में ये शामिल होते हैं:
- API Routes: checkout, customers, customer payments, products, subscriptions और webhooks के लिए endpoints। React template में कोई API routes नहीं होते।
- Hooks: React और Next.js के लिए billing operations हेतु एक
useBillingReact hook। - Library Files: Dodo Payments client setup और helper functions,
lib/dodopayments.tsमें। - Environment Configuration: एक example environment file,
.env.example।
Next.js Example Structure
Next.js के लिएinit ये files लिखता है:
Environment Configuration
Initialization के बाद अपने environment variables सेट करें। Dashboard में Developer → API Keys से API key और Developer → Webhooks से webhook key प्राप्त करें:DODO_PAYMENTS_ENVIRONMENT को test_mode या live_mode पर सेट करें। Generated Dodo Payments client किसी अन्य value के लिए error throw करता है।
Available Components
Billing SDK इन groups में React components उपलब्ध कराता है:- Pricing Tables: product pricing दिखाने के लिए आठ variants,
pricing-table-oneसेpricing-table-eightतक। - Subscription Management:
subscription-management, साथ ही subscription cancel करने या plan update करने के लिए cards और dialogs। - Usage Monitoring: usage-based billing के लिए circular और linear usage meters तथा usage tables।
- Checkout Components: payment method selector, payment details forms और payment failure card।
- Customer Portal: customer self-service के लिए billing settings, billing screen, invoice history और upcoming charges।
Open Source
Billing SDK open source है:- Transparency: आप देख सकते हैं कि हर component कैसे काम करता है।
- Community: Developers इसे अन्य developers के लिए बनाते हैं।
- Security: Security issues के लिए कोई भी code की समीक्षा कर सकता है।
- Innovation: Community contributions development को तेज़ करती हैं।
Billing SDK GNU General Public License v3.0 (GPL-3.0) के अंतर्गत जारी किया गया है, जो project को open और free बनाए रखता है।
Getting Help
Billing SDK के लिए सहायता पाने हेतु इन resources का उपयोग करें:- GitHub Issues: issue खोलें
- Documentation: billingsdk.com/docs पर जाएँ
- LLMs Full Documentation: billingsdk.com/llms-full.txt
Contributing
Billing SDK contributions का स्वागत करता है। contribution guide बताती है कि कैसे:- Bugs report करें
- Features request करें
- Pull requests submit करें
- नए components जोड़ें
- Documentation बेहतर बनाएँ