Skip to content

Commit

Permalink
Add some docs about Stripe Connect
Browse files Browse the repository at this point in the history
The starter repo comes with a Stripe Connect integration all ready to
go, but it's not documented so it's hard to know how to use it.

This ia  quick and dirty pass at getting _something_ documented so it's
not quite so mysterious.
  • Loading branch information
jagthedrummer committed Jan 27, 2025
1 parent 3aae1a2 commit 006617b
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bullet_train/docs/oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ rails generate super_scaffold:oauth_provider
## Stripe Connect Example
Similar to the "Tangible Things" template for [Super Scaffolding CRUD workflows](/docs/super-scaffolding.md), Bullet Train includes a Stripe Connect integration by default and this example also serves as a template for Super Scaffolding to implement other providers you might want to add.

See [the docs about Stripe Connect](/docs/stripe-connect.md) for more info about setting up Stripe Connect in your app.

## Dealing with Last Mile Issues

You should be able to add many third-party OAuth providers with Super Scaffolding without any manual effort. However, there are sometimes quirks from provider to provider, so if you need to dig in to get things working on a specific provider, here are the files you'll probably be looking for:
Expand Down
77 changes: 77 additions & 0 deletions bullet_train/docs/stripe-connect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Stripe Connect

Bullet Train comes with a Stripe Connect integration ready to go. All you have to do is configure your Stripe account and set
a couple of ENV variables.

Once Stripe Connect is configured it allows for two things:

1. Users can connect their Stripe account as a form of sign in to your app. A "Sign in with Stripe" button will appear on the
login form. Users who have already signed up with email address and password will continue to be able to use those credentials,
but they'll also be able to connect a Stripe account for auth.
2. Teams can add a new Stripe Installation for marketplace type sales. (It's up to you to build out the marketplace and the sales process
we just make it easy to allow your users to connect their Stripe accounts.)

## Initial Setup

In order to get things working you'll need to configure the OAuth settings under "Settings > Connect" in your Stripe account.

* [OAuth Settings for test mode](https://dashboard.stripe.com/test/settings/connect/onboarding-options/oauth)
* [OAuth Settings for production](https://dashboard.stripe.com/settings/connect/onboarding-options/oauth)

### Set the `STRIPE_CLIENT_ID` ENV var

From the OAuth Settings page you need to grab the "Test client ID" and/or "Live client ID" depending on whether you're configuring test mode
or live mode. Copy that value and set is as the `STRIPE_CLIENT_ID` ENV var in your environment.

### Enable OAuth

On the Stripe OAuth Settings page make sure that the switch for "Enable OAuth"/"OAuth for Stripe Dashboard accounts" is turned on.

### Set your redirect URL

In the "Redirects" section of the OAuth Settings click "+ Add URI" and set the callback URL. The path for the callback is
`/users/auth/stripe_connect/callback` and the host will vary depending on your environment and how you access it.

For test mode on localhost you can usually set the redirect URL to be:

```
http://localhost:3000/users/auth/stripe_connect/callback
```

For live mode it will need to be an `https` URL and it should point to your production environment.

```
https://your-apps-fancy-domain-goes-here/users/auth/stripe_connect/callback
```

### Set the `STRIPE_SECRET_KEY` ENV var

Finally you need to set the secret key. These can be found under "Developers > API Keys"

* [API Keys for test mode](https://dashboard.stripe.com/test/apikeys)
* [API Keys for production](https://dashboard.stripe.com/apikeys)

Copy the "Secret key" value and set is as the `STRIPE_SECRET_KEY` ENV var in the appropriate environment.

## Using Stripe Connect

Once you've configured your Stripe account and set the necessary ENV vars you'll need to restart your server.

### Create a second Stripe account for testing.

The Stripe account that you configured above is kind of a "host account" that "owns" the connections between your app and _other_ Stripe accounts
(Stripe accounts that are not your app). So in order to test connections you'll need a second Stripe account.

### Using Stripe Connect for sign in

Under the user menu in your Bullet Train app, go to the "Account Details" link (`/account/users/XXX/edit`).

There you should see a section for "Connected Stripe Accounts".

Click the "Connect Stripe Account" button and then follow the prompts. At the end of the process you should be redirected back to your
"Account Details" screen and you should see that you now have a Stripe account connected.

### Using Stripe Connect for marketplace sales

In the top menu you should now see an "Integrations" menu with a "Stripe Installations" menu item. When you go there you'll be able to
add a new Stripe Installation. The process is pretty much the same as connecting a new account for auth purposes.

0 comments on commit 006617b

Please sign in to comment.