Story: Tạo platform cho seller với Stripe connect.
Ref: https://docs.stripe.com/connect/accounts

  1. Tạo connect account

1.1 Cài đặt Controller

a. stripe_dashboard

Ref: https://docs.stripe.com/connect/migrate-to-controller-properties
- https://docs.stripe.com/api/accounts/create#create_account-controller-stripe_dashboard

Lựa chọn dashboard mà user có thể truy cập.

- Nếu muốn chọn stripe_dashboardexpress thì người thu thập requirement_collection phải là stripe.
- Còn nếu requirement_collectionapplication thì không có quyền truy cập vào stripe dashboard và phải set stripe_dashboard về none

=> Như vậy là hơi bất cập ở một chỗ là mình muốn người cung cấp thông tin là application và vẫn muốn seller có thể truy cập vào stripe express dashboard.

b. prefill data

Vì bắt buộc phải dùng express dashboard rồi, nên phải chuyển người thu thập thông tin là Stripe.

Question 1: Nếu vậy thì còn prefill được data ko?

Question 2: Nếu đang nhập dở thông tin thì làm sao để quay lại và tiếp tục update thông tin.

Question 3: Làm sao để biết seller đã onboard xong?

Question 4: Làm sao để xác định seller đã đăng ký với thông tin hợp lệ

c. Link đăng nhập vào stripe dashboard cho seller (Express Dashboard)

Ref: https://docs.stripe.com/connect/integrate-express-dashboard#create-login-link

  async getLoginLink(connectedAccountId: string): Promise<Stripe.LoginLink> {
    try {
      const loginLink =
        await this.stripe.accounts.createLoginLink(connectedAccountId);
      return loginLink;
    } catch (error) {
      console.error(error);
      throw new Error('Failed to get login link');
    }
  }

1.2 Cài đặt Webhook

ref: https://docs.stripe.com/webhooks

  1. Chú ý

QUAN TRỌNG: Webhook trên dashboard/workbench phải sử dụng api version giống với code của app, nếu ko webhook sẽ không nhận được.

Code/App:

    this.stripe = new Stripe(
      this.configService.getOrThrow('STRIPE_SECRET_KEY'),
      {
        apiVersion: '2025-11-17.clover', // for Stripe v20.0.0
      },
    );

Dashboard/workbench

imagen

  1. Test webhook

Sử dụng StripeCLI để test webhook xem đã cài đặt đúng chưa.

# install
brew install stripe/stripe-cli/stripe
# login/authentication
stripe login
# navigate all event to your local
stripe listen --forward-to localhost:3000/v1/stripe-webhook
# trigger test event
stripe trigger payment_intent.succeeded
  1. Cài đặt

Nên cài đặt 1 cái local nhận hết các thể loại event để test.

Link: https://dashboard.stripe.com/acct_1RzxcsDOkFIW5byO/test/workbench/webhooks

imagen

Question 5: Như vậy là không có event xác định xem connected account đã submit xong hay chưa?

Question 6: Kiểm tra trạng thái của connected account.

1.3 Cài đặt quyền cho account

Dóc: https://docs.stripe.com/connect/account-capabilities
API: https://docs.stripe.com/api/capabilities/list

Desc: Mỗi account sẽ có một số khả năng / quyền hành vi nhất định. Ta cần xác định và giới hạn xem account có thể có những quyền gì, để khả năng quản lý là tối thiếu, tránh account có quá nhiều quyền, khiến cho quá nhiều use-case phức tạp có thể xảy ra, khiến việc quản lý trở nên khó khăn hơn!

This post is imported from: https://thebrownbox.hashnode.dev/stripe-connect-onboarding