/bolt.new-ai-integrations

Bolt.new AI and Stripe Connect integration: Step-by-Step Guide 2025

Discover how to seamlessly integrate Bolt.new AI with Stripe Connect using our step-by-step guide for secure, efficient payment processing.

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 No-Code consultation

How to integrate Bolt.new AI with Stripe Connect?

 

Adding the Stripe Dependency

 

Since Bolt.new AI does not have a terminal, you need to add the dependency manually by creating (or updating) a package file in your project. Create a file named package.json in your project’s root (if it does not exist) and include the following content:


{
  "dependencies": {
    "stripe": "^10.0.0"
  }
}

This tells your project to use the Stripe package. When your project builds, Bolt.new AI will include this dependency automatically.

 

Creating the Stripe Initialization File

 

Create a new file called stripe.ts in your project’s source directory. This file initializes the Stripe API with your secret key. Replace YOURSTRIPESECRET_KEY with your actual secret key which you can store securely (for example, using environment variables).


import Stripe from 'stripe';

const stripe = new Stripe('YOURSTRIPESECRET_KEY', {
  apiVersion: '2022-11-15'
});

export default stripe;

Place this file in the same directory as other backend helper files or utilities.

 

Creating a Stripe Connect Onboarding Function

 

Next, create a file named createAccountLink.ts. This file will export a function that creates a Stripe Connect onboarding link for your users. Customize refreshurl and returnurl to point to the appropriate routes in your project.


import stripe from './stripe';

export async function createAccountLink(accountId: string): Promise<{ url: string }> {
  // Create an account link for onboarding
  const accountLink = await stripe.accountLinks.create({
    account: accountId,
    refresh_url: 'https://yourdomain.com/reauth',
    return_url: 'https://yourdomain.com/return',
    type: 'account_onboarding'
  });
  return { url: accountLink.url };
}

Place this file in the same directory as stripe.ts.

 

Integrating the Onboarding Function into Your Server Endpoint

 

Assuming you have a backend endpoint handling API requests (for example, using Express), add an endpoint that calls the onboarding function. If you have a main server file (e.g., server.ts), add the following code snippet where you define your routes.


import express, { Request, Response } from 'express';
import { createAccountLink } from './createAccountLink';

const app = express();
app.use(express.json());

// Endpoint to start the Stripe Connect onboarding flow
app.post('/api/stripe/onboard', async (req: Request, res: Response) => {
  try {
    // Expect the Stripe account ID to be sent with the request
    const { accountId } = req.body;
    if (!accountId) {
      return res.status(400).json({ error: 'Missing accountId' });
    }
    const { url } = await createAccountLink(accountId);
    // Redirect the user to the Stripe Connect onboarding URL
    res.redirect(url);
  } catch (error) {
    console.error(error);
    res.status(500).json({ error: 'Internal Server Error' });
  }
});

// Your existing server code may go here...
app.listen(3000, () => console.log('Server running on port 3000'));

Insert this code into your main server file or the file where you define API endpoints. Adjust the port, routing, or error handling as needed.

 

Setting Up Webhook Handling (Optional)

 

To receive events from Stripe about account updates, create a new file named webhook.ts with the following code. Remember to replace YOURENDPOINTSECRET with your actual Stripe webhook secret.


import stripe from './stripe';
import { Request, Response } from 'express';

export function handleStripeWebhook(req: Request, res: Response) {
  const sig = req.headers['stripe-signature'] as string;
  let event;

  try {
    // Construct event using Stripe's library and your endpoint secret
    event = stripe.webhooks.constructEvent(req.body, sig, 'YOURENDPOINTSECRET');
  } catch (err: any) {
    console.error('Webhook signature verification failed.', err);
    return res.status(400).send(Webhook Error: ${err.message});
  }

  // Process the event (customize cases as needed)
  switch (event.type) {
    case 'account.updated':
      console.log('Account updated:', event.data.object);
      break;
    default:
      console.log(Unhandled event type: ${event.type});
  }

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

Then add a route to your main server file similar to:


import { handleStripeWebhook } from './webhook';

app.post('/api/stripe/webhook', express.raw({ type: 'application/json' }), handleStripeWebhook);

Make sure that your request body is parsed correctly for webhook verification; Express’s express.raw middleware is used in this example.

 

Final Integration Notes

 
  • Ensure you securely store your Stripe secret key and webhook secret. Bolt.new AI may support environment variables, so consider using them rather than hardcoding keys.
  • Customize the refreshurl and returnurl parameters to connect to your Bolt.new AI project’s pages.
  • Test the endpoints by simulating API calls from your frontend or using Stripe’s test mode features.

By following these steps, you integrate Stripe Connect into your Bolt.new AI project using TypeScript.

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