/stripe-guides

How to transfer funds between Stripe accounts using Connect?

Learn how to transfer funds between Stripe accounts using Connect, with step-by-step setup, API code examples, and best practices for secure, compliant payments.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free consultation

How to transfer funds between Stripe accounts using Connect?

How to Transfer Funds Between Stripe Accounts Using Connect

 

Step 1: Set Up Your Stripe Connect Platform

 

Before you can transfer funds between Stripe accounts, you need to set up your platform on Stripe Connect. This allows your platform to facilitate payments between connected accounts.

 

  1. Create a Stripe account at https://dashboard.stripe.com/register
  2. Navigate to the "Connect" section in your Stripe Dashboard
  3. Choose the Connect account type that suits your needs:
  • Standard: For platforms with minimal involvement
  • Express: For platforms with partial user experience control
  • Custom: For platforms with complete control over the user experience

 

Step 2: Register Your Platform

 

Register your platform in the Stripe Dashboard by providing the required information:

 

  1. Go to Dashboard > Connect > Settings
  2. Complete the platform profile information
  3. Set up your platform branding
  4. Configure webhook endpoints for notifications

 

Step 3: Connect User Accounts

 

To transfer funds, you need to connect user accounts to your platform. Here's how to create a connected account:

 


const stripe = require('stripe')('sk_test_YOUR_SECRET_KEY');

// Create a Standard connected account
async function createConnectedAccount() {
  const account = await stripe.accounts.create({
    type: 'standard',
    country: 'US',
    email: '[email protected]',
    capabilities: {
      card\_payments: {requested: true},
      transfers: {requested: true}
    }
  });
  
  return account;
}

 

For Express or Custom accounts:

 


// Create an Express connected account
async function createExpressAccount() {
  const account = await stripe.accounts.create({
    type: 'express',
    country: 'US',
    email: '[email protected]',
    capabilities: {
      card\_payments: {requested: true},
      transfers: {requested: true}
    },
    business\_type: 'individual',
    business\_profile: {
      mcc: '5734', // Computer Software Stores
      url: 'https://example.com'
    }
  });
  
  return account;
}

 

Step 4: Create an Account Link or Account URL

 

For Standard and Express accounts, you need to redirect users to complete their onboarding:

 


async function createAccountLink(accountId) {
  const accountLink = await stripe.accountLinks.create({
    account: accountId,
    refresh\_url: 'https://example.com/reauth',
    return\_url: 'https://example.com/return',
    type: 'account\_onboarding',
  });
  
  return accountLink.url;
}

 

Step 5: Transfer Funds Between Accounts

 

Once you have connected accounts, you can transfer funds in several ways:

 

Method 1: Direct Transfers

 

Use the Transfer API to move funds from your platform to a connected account:

 


async function transferToConnectedAccount(amount, destinationAccountId) {
  const transfer = await stripe.transfers.create({
    amount: amount, // amount in cents
    currency: 'usd',
    destination: destinationAccountId,
    transfer_group: 'ORDER_123', // Optional for grouping related transfers
  });
  
  return transfer;
}

 

Method 2: Destination Charges

 

Create a charge and automatically split the funds:

 


async function createDestinationCharge(amount, customerId, destinationAccountId, applicationFeeAmount) {
  const charge = await stripe.charges.create({
    amount: amount, // amount in cents
    currency: 'usd',
    customer: customerId,
    destination: {
      account: destinationAccountId,
    },
    application_fee_amount: applicationFeeAmount, // Your platform fee in cents
  });
  
  return charge;
}

 

Method 3: Payment Intents with Destination

 

For more complex payment flows, use Payment Intents:

 


async function createPaymentIntentWithDestination(amount, customerId, destinationAccountId, applicationFeeAmount) {
  const paymentIntent = await stripe.paymentIntents.create({
    amount: amount, // amount in cents
    currency: 'usd',
    customer: customerId,
    payment_method_types: ['card'],
    transfer\_data: {
      destination: destinationAccountId,
    },
    application_fee_amount: applicationFeeAmount, // Your platform fee in cents
  });
  
  return paymentIntent;
}

 

Step 6: Handle Transfers Between Connected Accounts

 

To transfer funds directly from one connected account to another, you'll need to:

 

  1. First, transfer funds from the source connected account to your platform
  2. Then, transfer from your platform to the destination connected account

 


async function transferBetweenConnectedAccounts(amount, sourceAccountId, destinationAccountId) {
  // Step 1: Create a Reverse Transfer (from connected account to platform)
  // You need to have the connected account's permissions to do this
  const reverseTransfer = await stripe.transfers.create({
    amount: amount,
    currency: 'usd',
    destination: 'self', // Transfer to your platform account
    source_transaction: 'ch_sourceTransaction', // A charge on the source account
  }, {
    stripeAccount: sourceAccountId, // Execute as the source connected account
  });
  
  // Step 2: Transfer from platform to destination connected account
  const forwardTransfer = await stripe.transfers.create({
    amount: amount,
    currency: 'usd',
    destination: destinationAccountId,
    source\_transaction: reverseTransfer.id, // Optional: link the transfers
  });
  
  return {
    reverseTransfer,
    forwardTransfer
  };
}

 

Step 7: Implement Webhooks to Track Transfer Status

 

Set up webhooks to be notified when transfers complete or fail:

 


const express = require('express');
const app = express();

app.post('/webhook', express.raw({type: 'application/json'}), (request, response) => {
  const signature = request.headers['stripe-signature'];
  let event;

  try {
    event = stripe.webhooks.constructEvent(
      request.body,
      signature,
      'whsec_your_webhook\_secret'
    );
  } catch (err) {
    console.log(`⚠️ Webhook signature verification failed.`, err.message);
    return response.sendStatus(400);
  }

  // Handle transfer events
  switch (event.type) {
    case 'transfer.created':
      const transferCreated = event.data.object;
      console.log(`Transfer of ${transferCreated.amount} created`);
      break;
    case 'transfer.paid':
      const transferPaid = event.data.object;
      console.log(`Transfer of ${transferPaid.amount} paid`);
      break;
    case 'transfer.failed':
      const transferFailed = event.data.object;
      console.log(`Transfer of ${transferFailed.amount} failed`);
      break;
    // ... handle other relevant events
  }

  response.json({received: true});
});

app.listen(8000, () => console.log('Running on port 8000'));

 

Step 8: Monitor and Manage Transfers

 

Implement monitoring and management functions for your transfers:

 


// Get all transfers
async function getAllTransfers() {
  const transfers = await stripe.transfers.list({
    limit: 100,
  });
  
  return transfers;
}

// Get a specific transfer
async function getTransfer(transferId) {
  const transfer = await stripe.transfers.retrieve(transferId);
  
  return transfer;
}

// Create a transfer reversal (refund a transfer)
async function createTransferReversal(transferId, amount) {
  const reversal = await stripe.transfers.createReversal(
    transferId,
    {
      amount: amount, // optional: if not provided, full amount is reversed
    }
  );
  
  return reversal;
}

 

Step 9: Implement Error Handling

 

Proper error handling is crucial for payment systems:

 


async function safeTransfer(amount, destinationAccountId) {
  try {
    const transfer = await stripe.transfers.create({
      amount: amount,
      currency: 'usd',
      destination: destinationAccountId,
    });
    
    return {
      success: true,
      transfer: transfer
    };
  } catch (error) {
    console.error('Transfer error:', error);
    
    return {
      success: false,
      error: {
        message: error.message,
        code: error.code,
        type: error.type
      }
    };
  }
}

 

Step 10: Implement Logging and Compliance

 

For compliance and auditability, implement proper logging:

 


async function loggedTransfer(amount, destinationAccountId, metadata) {
  // Add detailed metadata for your records
  const transferMetadata = {
    ...metadata,
    initiated\_at: new Date().toISOString(),
    initiated\_by: 'system' // or user ID
  };

  const transfer = await stripe.transfers.create({
    amount: amount,
    currency: 'usd',
    destination: destinationAccountId,
    metadata: transferMetadata,
  });
  
  // Log to your database or monitoring system
  await logTransferToDatabase(transfer);
  
  return transfer;
}

async function logTransferToDatabase(transfer) {
  // Implementation will depend on your database
  // Example using a hypothetical database client:
  await db.transfers.insert({
    stripe_transfer_id: transfer.id,
    amount: transfer.amount,
    currency: transfer.currency,
    destination: transfer.destination,
    created: transfer.created,
    status: transfer.status,
    metadata: transfer.metadata
  });
}

 

Conclusion

 

Transferring funds between Stripe accounts using Connect involves setting up your platform, connecting accounts, and using Stripe's transfer APIs. Always implement proper error handling, logging, and monitoring to ensure reliable operations. Remember that different countries have different regulatory requirements, so consult Stripe's documentation for specific regional considerations.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022