Giter Site home page Giter Site logo

omniauth-stripe-connect's Introduction

OmniAuth::StripeConnect

Stripe Connect OAuth2 Strategy for OmniAuth 1.0.

Supports the OAuth 2.0 server-side and client-side flows. Read the Stripe Connect docs for more details: https://stripe.com/connect

Installation

Add this line to your application's Gemfile:

gem 'omniauth-stripe-connect'

And then execute:

$ bundle

Or install it yourself as:

$ gem install omniauth-stripe-connect

Usage

OmniAuth::Strategies::StripeConnect is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.

Non-Devise

Here's a quick example, adding the middleware to a Rails app in config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :stripe_connect, ENV['STRIPE_CONNECT_CLIENT_ID'], ENV['STRIPE_SECRET']
end

Devise

You need to declare the provider in your config/initializers/devise.rb:

config.omniauth :stripe_connect, "STRIPE_CONNECT_CLIENT_ID", "STRIPE_SECRET"

General Usage

Your STRIPE_CONNECT_CLIENT_ID is application-specific and your STRIPE_SECRET is account-specific and may also be known as your Stripe API key or Stripe Private key.

Edit your routes.rb file to have: devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks" }

And create a file called omniauth_callbacks_controller.rb which should have this inside:

class OmniauthCallbacksController < Devise::OmniauthCallbacksController

  def stripe_connect
    # Delete the code inside of this method and write your own.
    # The code below is to show you where to access the data.
    raise request.env["omniauth.auth"].to_yaml
  end
end

Make sure to go to Stripe's Account Settings > Applications and set your Redirect URL to: http://localhost:3003/users/auth/stripe_connect/callback

The Webhook URL will be something similar: http://www.yourdomain.com/users/auth/stripe_connect/callback

Then you can hit /auth/stripe_connect

If you hit /auth/stripe_connect with any query params, they will be passed along to Stripe. Read Stripe's OAuth Reference for more information.

Auth Hash

Here is an example of the Auth Hash you get back from calling request.env['omniauth.auth']:

{
  "provider"=>"stripe_connect",
  "uid"=>"<STRIPE_USER_ID>",
  "info"=> {
    "scope"=>"read_write", # or "read_only"
    "livemode"=>false,
    "stripe_publishable_key"=>"<STRIPE_PUBLISHABLE_KEY>",
  },
  "credentials"=> {
    "token"=>"<STRIPE_ACCESS_TOKEN>",
    "expires"=>false
  },
  "extra"=> {
    "raw_info"=> {
      "token_type"=>"bearer",
      "stripe_user_id"=>"<STRIPE_USER_ID>",
      "scope"=>"read_only",
      "stripe_publishable_key"=>"<STRIPE_PUBLISHABLE_KEY>",
      "livemode"=>false
    }
  }
}

Additional Tutorials

Stripe Connect in Rails Tutorial

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

omniauth-stripe-connect's People

Contributors

andrew-stripe avatar bcackerman avatar guncha avatar hfwang avatar isaacsanders avatar richrines avatar todddickerson avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.