//https://github.dev/falconitconsultant/Sindoor-Node const express = require('express'); const stripe = require('stripe')('YOUR_STRIPE_SECRET_KEY'); const bodyParser = require('body-parser'); const app = express(); const port = 3000; app.use(bodyParser.json()); // Set up a route to create a charge with an application fee app.post('/create-charge', async (req, res) => { try { const { amount, source, connectedAccountId } = req.body; // Create a charge with an application fee const charge = await stripe.charges.create({ amount, currency: 'usd', source, application_fee_amount: 123, // Specify your application fee amount transfer_data: { destination: connectedAccountId, // Specify the connected account ID }, }); res.status(200).json(charge); } catch (error) { console.error(error); res.status(500).json({ error: 'Internal Server Error' }); } }); // Set up a route to create a transfer to a connected account app.post('/create-transfer', async (req, res) => { try { const { amount, connectedAccountId } = req.body; // Create a transfer to a connected account const transfer = await stripe.transfers.create({ amount, currency: 'usd', destination: connectedAccountId, // Specify the connected account ID }); res.status(200).json(transfer); } catch (error) { console.error(error); res.status(500).json({ error: 'Internal Server Error' }); } }); // Set up a route to create a connected account (for admin) app.post('/create-connected-account', async (req, res) => { try { const { businessType, email, accountHolderName, accountNumber, routingNumber } = req.body; // Create a connected account with bank account details const account = await stripe.accounts.create({ type: 'custom', country: 'US', email, business_type: businessType, external_account: { object: 'bank_account', account_holder_name: accountHolderName, account_number: accountNumber, routing_number: routingNumber, currency: 'usd', }, requested_capabilities: ['transfers'], }); res.status(200).json(account); } catch (error) { console.error(error); res.status(500).json({ error: 'Internal Server Error' }); } }); app.listen(port, () => { console.log(`Server is running on port ${port}`); }); // Set up a route to create a charge with an application fee and transfer to a connected account app.post('/create-charge', async (req, res) => { try { const { amount, source, connectedAccountId } = req.body; // Create a charge with an application fee and transfer to a connected account const charge = await stripe.charges.create({ amount, currency: 'usd', source, application_fee_amount: 123, // Specify your platform fee amount transfer_data: { destination: connectedAccountId, // Specify the connected account ID }, }); res.status(200).json(charge); } catch (error) { console.error(error); res.status(500).json({ error: 'Internal Server Error' }); } });