타입 안전성과 현대적인 async/await 지원을 통해 TypeScript 및 Node.js 애플리케이션에 Dodo Payments를 통합하세요.
TypeScript SDK는 TypeScript 및 JavaScript 애플리케이션을 위한 Dodo Payments REST API에 대한 편리한 서버 측 액세스를 제공합니다. 포괄적인 타입 정의, 오류 처리, 재시도, 타임아웃 및 원활한 결제 처리를 위한 자동 페이지 매김 기능을 갖추고 있습니다.
import DodoPayments from 'dodopayments';const client = new DodoPayments({ bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted environment: 'test_mode', // defaults to 'live_mode'});const checkoutSessionResponse = await client.checkoutSessions.create({ product_cart: [{ product_id: 'product_id', quantity: 1 }],});console.log(checkoutSessionResponse.session_id);
API 키는 항상 환경 변수를 사용하여 안전하게 저장하세요. 버전 관리에 커밋하거나 클라이언트 측 코드에 노출하지 마세요.
// Get a specific eventconst event = await client.usageEvents.retrieve('api_call_12345');// List events with filteringconst events = await client.usageEvents.list({ customer_id: 'cus_abc123', event_name: 'api_request', start: '2024-01-14T10:30:00Z', end: '2024-01-15T10:30:00Z'});
import DodoPayments from 'dodopayments';import * as undici from 'undici';const proxyAgent = new undici.ProxyAgent('http://localhost:8888');const client = new DodoPayments({ fetchOptions: { dispatcher: proxyAgent, },});