Ask A Question

Notifications

You’re not receiving notifications from this thread.

Stripe connect issues

Fatumata Jalloh asked in Rails

I am currently working on integrating stripe connect to my app but it isn't working. I don't get any errors when I run it and it asks me to create an account and redirects back to the website but when I check my stripe dashboard, it doesn't show any added accounts. Any help would be appreciated! I looked over their documentation and copied that but I got the same results.

Here is some of my code:

class StripeController < ApplicationController
def connect
response = HTTParty.post("https://connect.stripe.com/oauth/token",
query: {
client_secret: ENV["STRIPE_SECRET_KEY"],
code: params[:code],
grant_type: "authorization_code"
}
)

   if response.parsed_response.key?("error")
       redirect_to welcome_path,
       notice: response.parsed_response["error_description"]
   else
       stripe_user_id = response.stripe_user_id
       current_user.stripe_user_id = stripe_user_id
       redirect_to mypage_path,
       notice: 'User successfully connected with Stripe!'
   end

end
end
module UsersHelper
def stripe_button_link
stripe_url = "https://connect.stripe.com/express/oauth/authorize"
redirect_uri = stripe_connect_url
client_id = ENV["STRIPE_CLIENT_ID"]

   "#{stripe_url}?response_type=code&redirect_uri=#{redirect_uri}&client_id=#{client_id}&scope=read_write"
  end

end
<% if current_user.stripe_user_id %>
<%= link_to "Go to Stripe Dashboard", stripe_dashboard_path(current_user.id) %>
<% else %>
<%= link_to image_tag("ConnectwithStripe.png", width:"120px", height:"40px"), stripe_button_link %>
<% end %>

Reply

Stripe recommends using AccountLink instead of OAuth. It's a bit easier and supports both Express and Standard accounts.

Check out the docs for that here: https://stripe.com/docs/api/account_links

Reply

thank you !
Using accountLink, how would I be able to connect this back to the current user? Would I still be able to do current_user.stripe_user_id?

Reply

Yep, you will:

  1. Create an account with Stripe::Account.create()
  2. Save the account ID to your user
  3. Create an AccountLink so the user can be onboarded.

https://stripe.com/docs/connect/connect-onboarding

Reply

It worked. Thank you!

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.