1

我正在尝试使用 Stripe Connect 实现独立帐户。在 localhost 中,通过条带连接帐户一直有效。

在我将应用程序上传到 Heroku 并尝试相同的入职流程后,它不起作用。我得到以下信息:

2015-07-27T02:24:05.246351+00:00 app[web.1]: Started GET "/item?state=5666f072b6f0540a0b15a1f01da569ae0921028e22d9f655&scope=read_only&code=ac_6gO3YJ6RcAHT55faJR4heB0jerrB4u5H" for 68.58.216.7 at 2015-07-27 02:24:05 +0000
2015-07-27T02:24:05.317551+00:00 app[web.1]:   CACHE (0.0ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
2015-07-27T02:24:05.422659+00:00 app[web.1]:   Rendered items/new.html.erb within layouts/application (80.2ms)
2015-07-27T02:24:05.427443+00:00 app[web.1]: /app/app/views/layouts/_header.html.erb:80: warning: string literal in condition
2015-07-27T02:24:05.430481+00:00 app[web.1]:   Rendered layouts/_footer.html.erb (0.7ms)
2015-07-27T02:24:05.266065+00:00 app[web.1]: Processing by ItemsController#new as HTML
2015-07-27T02:24:05.266080+00:00 app[web.1]:   Parameters: {"state"=>"5666f072b6f0540a0b15a1f01da569ae0921028e22d9f655", "scope"=>"read_only", "code"=>"ac_6gO3YJ6RcAHT55faJR4heB0jerrB4u5H"}
2015-07-27T02:24:05.287254+00:00 app[web.1]:   User Load (1.4ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
2015-07-27T02:24:05.420258+00:00 app[web.1]:   Rendered shared/_error_messages.html.erb (71.1ms)
2015-07-27T02:24:05.426030+00:00 app[web.1]:   Rendered layouts/_shim.html.erb (0.3ms)
2015-07-27T02:24:05.429015+00:00 app[web.1]:   Rendered layouts/_header.html.erb (2.4ms)
2015-07-27T02:24:05.431155+00:00 app[web.1]: Completed 200 OK in 165ms (Views: 95.4ms | ActiveRecord: 19.4ms)

重定向工作得很好,问题是stripe_connect函数没有执行update_attributes调用。这就是我所拥有的:

class OmniauthCallbacksController < Devise::OmniauthCallbacksController

def stripe_connect
@user = current_user
if @user.update_attributes({
  provider: request.env["omniauth.auth"].provider,
  uid: request.env["omniauth.auth"].uid,
  access_code: request.env["omniauth.auth"].credentials.token,
  publishable_key: request.env["omniauth.auth"].info.stripe_publishable_key
})
  redirect_to item_path, :event => :authentication
  flash[:success] = "Success"
else
  session["devise.stripe_connect_data"] = request.env["omniauth.auth"]
  redirect_to item_path
end
end
end

我的omniauth.rb 是:

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

我的 devise.rb 配置是:

config.omniauth :stripe_connect, ENV['STRIPE_CONNECT_CLIENT_ID'],
                               ENV['STRIPE_SECRET_KEY'],
                               :scope => 'read_write'

我在 routes.rb 文件中的设计路线是:

devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks" }

连接条带帐户后,应该和确实会发生以下情况:

Started GET "/users/auth/stripe_connect" for ::1 at 2015-07-26 22:25:19 -0400
I, [2015-07-26T22:25:19.445331 #32143]  INFO -- omniauth: (stripe_connect) Request phase initiated.


Started GET "/users/auth/stripe_connect/callback?state=fcd450c95ba0ffcc335ba67b34d0b31736de846aa0d78aea&scope=read_write&code=ac_6gO5sx4LQnvyoPowVRq5Ck9da7Z6KYvH" for ::1 at 2015-07-26 22:25:25 -0400
I, [2015-07-26T22:25:25.289157 #32143]  INFO -- omniauth: (stripe_connect) Callback phase initiated.
  Processing by OmniauthCallbacksController#stripe_connect as HTML
  Parameters: {"state"=>"fcd450c95ba0ffcc335ba67b34d0b31736de846aa0d78aea", "scope"=>"read_write", "code"=>"ac_6gO5sx4LQnvyoPowVRq5Ck9da7Z6KYvH"}
  User Load (0.2ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 17]]
  (0.1ms)  begin transaction
  User Exists (0.2ms)  SELECT  1 AS one FROM "users" WHERE (LOWER("users"."email") = LOWER('andy@test.com') AND "users"."id" != 17) LIMIT 1
  SQL (0.5ms)  UPDATE "users" SET "provider" = ?, "uid" = ?, "access_code" = ?, "publishable_key" = ?, "updated_at" = ? WHERE "users"."id" = ?  [["provider", "stripe_connect"], ["uid", "acct_16T12ZBPUpjt04Z3"], ["access_code", "sk_test_J7csQFlq63TswouZ04m1G06Q"], ["publishable_key", "pk_test_ukvJ2U96sY1DTK5kAxA2W0DQ"], ["updated_at", "2015-07-27 02:25:28.789176"], ["id", 17]]
  (0.8ms)  commit transaction
Redirected to http://localhost:3000/item
Completed 302 Found in 13ms (ActiveRecord: 1.8ms)

有任何想法吗 ?

4

0 回答 0