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);
// 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, },});
DodoPayments API 中的列表方法是分页的。您可以使用 for await … of 语法遍历所有页面中的项目:TODO: 代码占位符_20831acc0088b6925fa9c28b685e3a40或者,您可以一次请求一页:TODO: 代码占位符_87be751d1b2ac11515bd21053c8b98aa