{"id":16617,"library":"dodo-sync","title":"Dodo Payments Sync Engine","description":"DodoSync is a JavaScript/TypeScript library and CLI tool designed to synchronize Dodo Payments data with various SQL and NoSQL databases. It currently supports MongoDB, PostgreSQL, MySQL, and ClickHouse, with plans to expand to Snowflake and other databases, as well as ETL/realtime sync pipelines. The current stable version is 0.4.0, with minor releases adding new database support and features like rate limiting. Releases appear to be driven by feature additions rather than a strict time-based cadence. It offers both a command-line interface for quick setup and programmatic usage for integration into larger applications, providing flexibility for developers to manage payment data locally. Key differentiators include its multi-database support and the ability to define specific data scopes for synchronization.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/dodopayments/dodo-sync","tags":["javascript","dodopayments","sync","database","mongodb","typescript"],"install":[{"cmd":"npm install dodo-sync","lang":"bash","label":"npm"},{"cmd":"yarn add dodo-sync","lang":"bash","label":"yarn"},{"cmd":"pnpm add dodo-sync","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for type checking and compilation, indicating strong TypeScript support.","package":"typescript","optional":false}],"imports":[{"note":"The library primarily uses named exports and is designed for ESM. CommonJS `require` might lead to issues or require accessing a `.default` property if transpiled.","wrong":"const DodoSync = require('dodo-sync');","symbol":"DodoSync","correct":"import { DodoSync } from 'dodo-sync';"},{"note":"The CLI is installed globally and invoked directly as `dodo-sync`. Do not try to run an internal script directly.","wrong":"node dodo-sync.js","symbol":"DodoSync (CLI)","correct":"dodo-sync --database mongodb --database-uri ... --api-key ... --scopes ..."},{"note":"Import types using `import type` to avoid bundling unnecessary runtime code and for clearer intent.","wrong":"import { DodoPaymentsOptions } from 'dodo-sync';","symbol":"DodoPaymentsOptions","correct":"import type { DodoPaymentsOptions } from 'dodo-sync';"}],"quickstart":{"code":"import { DodoSync } from 'dodo-sync';\n\nconst syncDodoPayments = new DodoSync({\n    interval: 60, // Sync every 60 seconds\n    database: 'mongodb',\n    databaseURI: process.env.MONGODB_URI ?? 'mongodb://localhost:27017/dodo',\n    scopes: ['licences', 'payments', 'customers', 'subscriptions'],\n    dodoPaymentsOptions: {\n        bearerToken: process.env.DODO_PAYMENTS_API_KEY ?? 'dp_test_someapikey',\n        environment: 'test_mode' // or 'live_mode'\n    }\n});\n\n// Initialize connection\nawait syncDodoPayments.init();\n\n// Start the sync loop\nsyncDodoPayments.start();\n\nconsole.log('DodoSync started. Data will be synchronized every 60 seconds.');","lang":"typescript","description":"Demonstrates programmatic usage of DodoSync to automatically synchronize Dodo Payments data with a MongoDB database at a specified interval."},"warnings":[{"fix":"For CLI, use `--api-key`. For programmatic usage, pass the key as `dodoPaymentsOptions: { bearerToken: 'YOUR_KEY' }`.","message":"CLI arguments (`--api-key`) and programmatic options (`bearerToken`) for the Dodo Payments API key use different naming conventions. Ensure you use the correct key name for your chosen method of integration.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Subscribe to release notes and thoroughly test integrations when upgrading to new minor or major versions to detect any subtle API changes.","message":"This library is in its early stages (v0.4.0) and while features are being added, the API might evolve in future minor or major versions. Review changelogs carefully during upgrades.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consult your database documentation for the correct connection string format. Examples are provided in the dodo-sync README for each supported database type.","message":"Database connection URIs are highly specific to the database type (MongoDB, PostgreSQL, MySQL, ClickHouse). Providing an incorrect or malformed URI will prevent the sync engine from connecting.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Refer to Dodo Payments documentation for a definitive list of available data scopes and ensure exact matches.","message":"The `--scopes` CLI argument and `scopes` programmatic option require a comma-separated string (CLI) or an array of strings (programmatic) representing valid Dodo Payments data entities (e.g., 'payments', 'customers'). Invalid or misspelled scopes will result in no data synchronization for those entities.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Add the `--database` argument with a supported type, e.g., `--database mongodb`.","cause":"The `--database` argument was not provided when running the CLI.","error":"Error: Missing required argument: --database"},{"fix":"Include `database: 'mongodb'` (or 'postgres', 'mysql', 'clickhouse') in the DodoSync constructor options.","cause":"The `database` property was omitted from the `DodoSync` constructor options.","error":"Error: `database` option is required."},{"fix":"Verify the `databaseURI` (CLI) or `databaseURI` option (programmatic) is correct, including hostname, port, user, and password. Ensure the database server is reachable and configured for remote connections if necessary.","cause":"Incorrect database URI, credentials, or network configuration preventing a successful database connection.","error":"Error: Failed to connect to database at mongodb://localhost:27017. Reason: Authentication failed."},{"fix":"Use a named ESM import: `import { DodoSync } from 'dodo-sync';`. If still encountering issues in a CommonJS environment, ensure your project is configured for ESM or use dynamic `import()`.","cause":"Attempting to import `DodoSync` using a CommonJS `require` statement or an incorrect ESM default import.","error":"TypeError: DodoSync is not a constructor"}],"ecosystem":"npm"}