简体   繁体   中英

Not found. Authentication passthru. stripe_connect and Devise

I'm trying to allow a user who is logged in to connect their Stripe account and take payments through my platform.

I'm using this gem: https://github.com/isaacsanders/omniauth-stripe-connect

Whenever I click the link to connect to Stripe, it simply gives me the "Not found. Authentication passthru" error.

Here is my code:

Gemfile
    ...
    #Use Stripe for payment processing
    gem 'stripe', '1.48.0'
    gem 'omniauth-stripe-connect'
    ...

config/routes.rb
    ...
    devise_for :users, controllers: { :omniauth_callbacks => "omniauth_callbacks" }
    ...

controllers/omniauth_callbacks_controller.rb
    class OmniauthCallbacksController < Devise::OmniauthCallbacksController

        def stripe_connect
          @user = User.find_for_stripe_connect(request.env['omniauth.auth'], current_user)
          set_notice_and_redirect
        end

        private

        def set_notice_and_redirect          
          if @user.persisted?
              flash[:notice] = 'Successfully signed in'
              set_flash_message(:notice, :success, :kind => "Stripe") if is_navigational_format?
            else
              session["devise.stripe_connect_data"] = request.env["omniauth.auth"]
              redirect_to new_user_registration_url
          end
        end
    end

/models/user.rb
    ...
    devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :omniauth_providers => [:stripe_connect]
         ...

/config/initializers/devise.rb
    ...
    config.omniauth :stripe_connect,
        ENV['stripe_connect_client_id'],
        ENV['stripe_api_key'],
        :scope => 'read_write',
        :stripe_landing => 'register'
    ...

/config/initializers/stripe.rb
    Stripe.api_key = ENV["stripe_api_key"]
    STRIPE_PUBLIC_KEY = ENV["stripe_publishable_key"]
    STRIPE_CONNECT_CLIENT_ID = ENV["stripe_connect_client_id"]

View link
    <%= link_to image_tag("light-on-light.png"), user_stripe_connect_omniauth_authorize_path %>


application.yml (figaro)
    stripe_api_key: sk_test_mysecretstripeapikeyfortheapplicationaccount
    stripe_publishable_key: pk_test_mypublicstripeapikeyfortheapplicationaccount
    stripe_connect_client_id: ca_myclientidfortheappregisteredwithstripe
    #
    production:
      stripe_api_key: sk_test_mysecretstripeapikeyfortheapplicationaccount
      stripe_publishable_key: pk_test_mypublicstripeapikeyfortheapplicationaccount
      stripe_connect_client_id: ca_myclientidfortheappregisteredwithstripe

If you can find my error, great. I'd also appreciate any reference to an example rails application that uses Devise and Stripe Connect.

So I went through my code line by line and nothing changed, but somehow the passthru error is gone. Maybe it took overnight for Stripe to register my application. I honestly don't know. Once that error disappeared I was getting a different one regarding the request.env["omniauth.auth"] when I passed it through a function in my User model. so I changed my controller back to using the code found in the winvoice tutorial ( http://www.munocreative.com/nerd-notes/winvoice ) and now everything works smoothly. The user attributes get updated with the tokens from stripe.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM