Hello Bubblers!
Having built many bubble apps, I still feel like I know nothing about Stripe. There are many great resources but it is never enough because Stripe is really powerful! So I decided to write a thread and share my experience of integrating Stripe. Hope this helps someone in the future. And if you have any suggestions, please let me know.
My first documentation is about Stripe connect and subscription. Our team just built an app that allows users to create their own subscription plans. It has the following features:
- onboarding sellers with Stripe Connect
- create product and price with APIs (subscription plan)
- create a checkout session
- webhooks to receive messages when a subscription is paid
If you are building a subscription platform like Patreon or SubStack, this guide may help.
Onboarding sellers
There are three types of seller accounts.
https://stripe.com/docs/connect/accounts#choosing-approach
We decided to use the Standard Account this time. There are at least two ways to create a standard account: With APIs, or with OAuth Connect. We choose OAuth Connect because it enables users to connect their existing Stripe accounts. Basically, we only need to create a button that links to Stripe and a redirect page to redirect the users when they have created the seller account.
Step 1: Enable Stripe Connect on the settings page
To create a Standard Account, we need to navigate our users to a Stripe onboarding page. Stripe will handle the onboarding and identity verification processes.
Before onboarding your sellers, make sure you have set up and activated your Stripe account. Go to your Stripe dashboard > Settings > Connect > Settings. Customize the visual appearance of the onboarding page.
Remember to enable OAuth flow and add a redirect link. Create an empty bubble page to be the redirect link. We will add workflows to this page later.
Copy the client id. We will use the id to create an URL for the OAuth flow.
Client ID example: ca_HUgW0aGkpo4hR9y4qJmCTnVd0vozGvjV
Step 2: Create an URL for the OAuth Connect
https://connect.stripe.com/oauth/authorize?response_type=code&client_id={{CLIENT_ID}}&scope=read_write&redirect_uri=https://sub2.example.com
Parameters:
- client_id: Your Stripe Connect client id. Find your client id here: https://dashboard.stripe.com/settings/connect
- redirect_uri: The URL must be added in step 1. If no
redirect_uri
is specified, Stripe uses the first URI configured in your platform settings.
Create a button with the workflow action âOpen an external websiteâ. Add the URL into the destination field.
Now we should be able to see the onboarding page when we click the button.
Step 3: Add workflows to the redirect page
When users completed the onboarding flow, Stripe redirects them back to our page. We can add a âpage is loadedâ workflow to complete the onboarding flow. We will need an API to create an account and get the account ID.
POST https://connect.stripe.com/oauth/token
Headers:
- Authorization: Bearer <client_secret>.
Parameters:
grant_type
: âauthorization_codeâcode
: Get âcodeâ from page URL. Stripe will add parameters to our redirect URL. We can get the code by the dynamic expression âGet data from page URLâ
Response:
Parameters:
stripe_user_id
: The unique ID of the seller account.
The Standard account has been successfully created. Remember to save the seller ID. We will use the ID to make requests on behalf of the seller. Next, we are going to create a subscription plan for our users with APIs.