Day 1: How to use Stripe Connect —Managed Accounts with Ruby on Rails and Heroku

First thing I did: Read as many blog posts and watch as many tutorial videos as I can so I can see the scope of what a Stripe Connect implementation might look like. Turns out that information is pretty scarce.
I watched Chris Oliver’s (GoRails.com) videos on using Stripe for subscriptions. I won’t be doing this kind of implementation but I learned what is actually happening on a form when a user submits payment information. Stripe uses some nifty javascript to basically grab all information submitted on the form, send it to Stripe using the API, clears what the user inputted on the form, then Stripe sends back a unique token representing that information back into the form, then finally the form is “submitted” and Stripe’s API does all the validations to make sure everything is good and correct. It’s a lot of smoke and mirrors to make it seem like the user sent their card information to you, but really that information was sent to Stripe the whole time, and that card information was never actually was transmitted to your app’s database.
I also read this, this, and this on medium.
By now it is obvious I will have a lot to figure out on my own.
Here we go.
Step 0: Before you do anything, you need to make sure your heroku app has an SSL (aka TLS) certificate. Stripe requires that card information is sent over an HTTPS request that is TLS secure. So do that first. A great guide can be found here.
Step 1: Create a Stripe Account, and then activate your ability to use Stripe Connect (which means confirming your identity, providing your company’s EIN, and checking account information.)
Step 2: Include the Stripe gem in your gem file.
gem ‘stripe’Step 3: Include your Stripe account’s API key in your app. E.G. your Test Secret Key.
My way of doing this is by placing this into the application.yml file created by using the Figaro gem:
stripe_api_key: sk_test_yourstripeapikey
stripe_publishable_key: pk_test_yourstripepublishablekeyproduction:
stripe_api_key: ENV['stripe_api_key']
stripe_publishable_key: ENV['stripe_publishable_key']
I used the ENV[‘stripe_api_key’] replacer because once I use this in production, the api keys will be fetched from config vars that I’ll set in my Heroku production settings.
Then I created the file stripe.rb in the app/config/initializers folder. I put this code in:
Stripe.api_key = ENV['stripe_api_key']
Stripe.api_version = '2017-01-27'This sets the api key for your own Stripe account, the api version, the country your app is used in (required for Stripe Connect — Managed Accounts), and that you will be using the Managed Accounts version. This is all specified by Stripe here.
You can check what api_version you’ll need to put in by checking your API setting in your Stripe Dashboard on the Stripe website. If this is your first time using Stripe, just update the API version to the newest version and use that.
Creating an account for your users
I think the biggest difference between other Stripe implementations and what needs to be done in a Stripe Connect — Managed Accounts implementation will be that we are not creating customers, we are creating accounts for our users. More on this in the next post.
Things I already know I’ll have to do:
Having users agree to Stripe’s terms, even if I’m using Managed Accounts. This means that on the page where users will enter their card information, there will need to be a required checkbox and a link to the terms before submitting their Stripe registration.
After reading, and re-reading Stripe’s documentation 27 times today, I’m going to call it a day. I’ve emailed them in needing a few questions solved, we’ll see what tomorrow has in store. I’ll also be diving deep into Noel Rappin’s new book on dealing with web payments and Stripe, so that’ll be informative too.
