DEV Community

Cover image for Creating a stripe connect account.
Moin Akhter
Moin Akhter

Posted on

Creating a stripe connect account.

In this tutorial, we will learn about how to create stripe connect account.

Goals

By the end of this tutorial, you knew about:

  1. What is stripe connect account.
  2. When we should use.
  3. How to create stripe connect account.

Prerequisites

You must have knowledge about javascript and nodejs for this.

All code will be available on this link.
https://github.com/MOIN-AKHTAR/stripe-connect.git

Last time i was working on a backend and the application was like we have advisros and those advisors can give advices and customer can pay to advisor for their services.Now for collecting payment we have multiple payment gateways like stripe,paypal and much more but stripe is more reliable and recomended because it provides multiple ways of collecting payment and make easier for developers to deal with these scnerios.Now stripe provides multiple ways to collect payment now for my scnerio i have used a feature called stripe connect.

Now what's this stripe connect account.In simple words you can think of as a stripe account which will collect money on others behalf in our scnerio advisors.Now for each of my advisors i have created a stripe connect so that we can put payment to their account.

But before of that make sure you set up a business in your platform stripe account(mean account who's secret key you are using).You can set by going to this link.

https://dashboard.stripe.com/login?redirect=%2Fsettings%2Fconnect
Enter fullscreen mode Exit fullscreen mode

Now follow these step to setup your business.

  1. Go to branding section.
  2. Set business name
  3. Than go to Appearance section.
  4. Set icon,logo,brand color and accent color and than click on save branding changes button which will next to "Branding Section Heading". After all steps you may see this type of result.

Image description

Now aftre setting up business first we need a secret key of stripe platform account you can create your account on stripe and use test or live keys for this purpose.

To get secret key you can go to Home tab and there you can find keys.

Image description

For creating stripe connect account we need to create a url which will redirect you to a prebuilt form of stripe where you have to provide all necessary information about your business,personal information and bank account info which stripe will use to payout.

BACKEND PART:

Before starting our backend we have to install few dependencies.

1. express (For setting up our server).
2. dotenv (To read environment variables from .env file).
3. cors (To resolve cors issue).
4. stripe (To deal with stripe related tasks).
5. nodemon (Install as dev dependency it will auto restart your 
            server whenever any changes occur in your code).
Enter fullscreen mode Exit fullscreen mode

Now this piece of code will create that url which will redirect you to prebuilt from provided by stripe for collecting necessary info.

const account = await stripe.accounts.create({
        type: 'standard',
      });
const accountLinks = await stripe.accountLinks.create({
        account: account.id,
        refresh_url: `${process.env.ORIGIN}/verify-wallet?account_id=${account.id}`,
        return_url: `${process.env.ORIGIN}/verify-wallet?account_id=${account.id}`,
        type: 'account_onboarding',
      });
Enter fullscreen mode Exit fullscreen mode

Now when you will redirect to url you will see this kind of screen.

Image description

Here we also have used ORIGIN this origin is nothing but your web page such as http://localhost:3000 stripe will redirect you to this page with accountId as we set in refresh_url and return_url.So, you can do some sort of action on this page like we can check whether user has provided all info which stripe was expecting and than save this accountId to database.

After all this setup if all required info provided to stripe so we can pay to this account using stripe charge api for that you can visit to https://stripe.com/docs/api/charges/create.

Top comments (0)