isaacsanders / omniauth-stripe-connect

Stripe Connect OAuth2 Strategy for OmniAuth 1.0
MIT License
130 stars 75 forks source link

Clarify RoR example in README.md #11

Closed andrewjanssen closed 11 years ago

andrewjanssen commented 11 years ago

Hi! On my first read through the README.md, I thought I needed to include both the config/initializers/omniauth.rb and the config/initializers/devise.rb code blocks. Doing so seems to result in duplicate oauth calls. Stripe allows the first one but denies the second one, saying that the code has already been used and is now revoked. I spent a bunch of time debugging devise's and OmniAuth's callbacks, only to realize that I should only use the devise initializer.

I thought I should include both initializers because the "Ruby on Rails apps with Devise" section currently says

...you only need to add the following line of code...

I understood that to mean that I should add the devise initializer on top of the previous example code, which was an OmniAuth initializer. Anyway, the README.md patch I included may save the next developer some time.

Thanks @isaacsanders for such an awesome gem! This is very useful.

isaacsanders commented 11 years ago

LOL! Thanks for helping, Andrew! I am glad that I could be of help.

andrewjanssen commented 11 years ago

:thumbsup: :smile:

iftikhar0005 commented 11 years ago

@thecurator Hi there, I see that you have used the stripe connect gem, i am also using the gem but have no idea how to integerate stripe connect in my rails app. Will you please guide me if i have to create a new model to hanfle the checkout process and where the post request goes in my rails app? I apologize this bothers you, but i really need some help. Thank you

isaacsanders commented 11 years ago

I can help, Jaffery.

iftikhar0005 commented 11 years ago

@isaacsanders Thanks you, I am trying to make the post request as mentioned in the stripe connect docs: and i don't know whether where that post request is to be made from Whether form CONTROLLER or MODEL?

isaacsanders commented 11 years ago

The post request from stripe will come to your controller. You should write a controller action that will store the data that you need from stripe for your application.

isaacsanders commented 11 years ago

The data will come in from request.env['omniauth.auth'].

The following methods are what I used to extract the data my application needed:

  def stripe_account_attributes
    {
      :stripe_user_id => oauth_hash['uid'],
      :stripe_publishable_key => oauth_hash['info']['stripe_publishable_key'],
      :token => oauth_hash['credentials']['token']
    }
  end

  def oauth_hash
    request.env['omniauth.auth']
  end

Note: They are methods in my controller.

iftikhar0005 commented 11 years ago

@isaacsanders Please take a look at this gist: https://gist.github.com/iftikhar0005/d59554a7f4697056d74f Here i have the controller, where i am making the post request? I apologize in advance if i am not making the right request.

iftikhar0005 commented 11 years ago

@isaacsanders Do you have a omniauthcallbacks_controller or a saperate controller where you are making the post request?

isaacsanders commented 11 years ago

What POST request are you talking about?

iftikhar0005 commented 11 years ago

@isaacsanders Stripe-connect docs says that after the user has connected, you must make a post request to access request token:

screen shot 2013-08-13 at 2 28 53 pm

isaacsanders commented 11 years ago

You don't need to know how this works, if you are using omniauth-stripe-connect. The gem is a strategy for OmniAuth.

isaacsanders commented 11 years ago

The gem takes care of the request level abstraction. You just need to link to the right endpoint, and then setup the handler, then you are done.

iftikhar0005 commented 11 years ago

@isaacsanders Oh.. I see :100:
What part of the stripe docs do i have to follow? If i am using the omniauth-stripe-connect gem.

isaacsanders commented 11 years ago

What are you trying to do?

iftikhar0005 commented 11 years ago

I am trying to setup payment system for a marketplace like app.

isaacsanders commented 11 years ago

And the application receives payments from the marketplace vendors, and the vendors receive payment from the users?

iftikhar0005 commented 11 years ago

That's right.

isaacsanders commented 11 years ago

Your vendors need to connect their Stripe Accounts before they can sell, correct? So the integration for this gem would go in their sign up process, or as part of their account details.

iftikhar0005 commented 11 years ago

You are right. This is part of the signup process for all type of users which are buyers and as well as sellers.

iftikhar0005 commented 11 years ago

Do i need to use the Stripe API library to make transactions between two users in my app?

isaacsanders commented 11 years ago

For people signing up to be vendors, they need to connect their stripe account. At this point in the app, vendors need to go to /<devise-mapping>/stripe-connect/auth. Then you need to create a controller action to deal with the data that comes back, and then puts them back into the sign-up process.

isaacsanders commented 11 years ago

The JS API library would be preferable for making the sales, but Stripe also has that capability with their Ruby lib, I believe.

iftikhar0005 commented 11 years ago

Thank you very much @isaacsanders , i kinda get the idea how would i set it up.. I think you should update the readme a little bit as it would help newbies like myself get insight or at least give them direction where they are headed. I appreciate the work you are doing.