填写我们座位附加组件的以下值:附加组件名称:Additional Team Seat描述:Add extra team members to your workspace with full access to all features价格:输入 → 2.00货币:必须与您的基础订阅货币匹配税务类别:选择适合您产品的类别。
// Add this new endpoint for dynamic seat quantitiesimport 'dotenv/config';import DodoPayments from 'dodopayments';import express, { Request, Response } from 'express';const app = express();// Initialize the Dodo Payments clientconst client = new DodoPayments({ bearerToken: process.env.DODO_PAYMENTS_API_KEY, environment: 'test_mode'});async function createCheckoutSession(seatCount: number) { try { const session = await client.checkoutSessions.create({ // Products to sell - use IDs from your Dodo Payments dashboard product_cart: [ { product_id: 'pdt_7Rl9OWT2Mz4wwUTKz74iZ', // Replace with your actual product ID quantity: 1, addons: [ { addon_id: 'adn_eKQbNakKrivDpaxmI8wKI', // Replace with your actual addon ID quantity: seatCount } ] } ], // Pre-fill customer information to reduce friction customer: { email: '[email protected]', name: 'Steve Irwin', }, // Where to redirect after successful payment return_url: 'https://example.com/checkout/success', }); // Redirect your customer to this URL to complete payment console.log('Checkout URL:', session.checkout_url); console.log('Session ID:', session.session_id); return session; } catch (error) { console.error('Failed to create checkout session:', error); throw error; }}// Example usage in an Express.js routeapp.post('/create-checkout/:seatCount', async (req: Request, res: Response) => { try { const seatCount = parseInt(req.params.seatCount); const session = await createCheckoutSession(seatCount); res.json({ checkout_url: session.checkout_url }); } catch (error) { res.status(500).json({ error: 'Failed to create checkout session' }); }});// Add this line after your other middlewareapp.use(express.static('public'));// Add this route to serve the demo pageapp.get('/', (req, res) => { res.sendFile(__dirname + '/../public/index.html');});app.listen(3000, () => { console.log('Server is running on port 3000');});
// Add this line after your other middlewareapp.use(express.static('public'));// Add this route to serve the demo pageapp.get('/', (req, res) => { res.sendFile(__dirname + '/../public/index.html');});