2017-07-07 40 views
-1

我目前正在上線課程,使用軌道上的紅寶石製作airbnb,類似於web應用程序。它利用條紋付款,我想從我的應用程序的登陸頁面條紋註冊頁面,而不是登錄頁面。條紋着陸頁設置無法正常工作

我完全按照以下代碼成功使註冊頁面成爲登錄頁面的教程。

stripe_landing: '註冊'

但我的着陸頁仍是登錄頁面。我搜索了上面的代碼,但所有我能找到的是2-4年前的頁面。我想知道最近Stripe是否改變了它。 (但hpar回答說沒有任何變化)

我把整個代碼放在這裏......當我點擊鏈接到條紋,它會去條紋#oauth。

class StripeController < ApplicationController 
     # Connect yourself to a Stripe account. 
     # Only works on the currently logged in user. 
     # See app/services/stripe_oauth.rb for #oauth_url details. 

     def oauth 
     connector = StripeOauth.new(current_user) 
     url, error = connector.oauth_url(redirect_uri: stripe_confirm_url) 

     if url.nil? 
      flash[:error] = error 
      redirect_to manage_listing_payment_path(session[:listing_id]) 
     else 
      redirect_to url 
     end 
     end 

    end 

然後,

class StripeOauth < Struct.new(:user) 

     def oauth_url(params) 
     url = client.authorize_url({ 
      scope: 'read_write', 
      stripe_landing: 'register', 
      stripe_user: { 
      email: user.email 
      } 
     }.merge(params)) 

     [ url, nil ] 
     end 

     # A simple OAuth2 client we can use to generate a URL 
     # to redirect the user to as well as get an access token. 
     # Used in #oauth_url and #verify! 
     # see this docs https://github.com/intridea/oauth2 
     def client 
     @client ||= OAuth2::Client.new(
      ENV['STRIPE_CONNECT_CLIENT_ID'], 
      Stripe.api_key, 
      { 
      site: 'https://connect.stripe.com', 
      authorize_url: '/oauth/authorize', 
      token_url: '/oauth/token' 
      } 
     ).auth_code 
     end 

    end 

終端說;

發起者GET 「/連接/ OAuth的」 在2017年7月9日零點37分55秒0800 處理由StripeController#OAuth進行:: 1 HTML 用戶負載(0.1毫秒)選擇 「用戶」。* FROM「users」WHERE「users」。「id」=? ORDER BY「users」。「id」ASC LIMIT 1 [[「id」,1]] 重定向到https://connect.stripe.com/oauth/authorize?client_id=ca_AuidWGx68TXWlWO3d3UbWcRcuPqfSeNH&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fconnect%2Fconfirm&response_type=code&scope=read_write&stripe_landing=register&stripe_user%5Bemail%5D=aaa%40gmail.com

所以我想我在這裏得到正確的URL(與教程視頻獲取相同)。但是,在Chrome中,它實際上是這樣;

https://connect.stripe.com/login?redirect=%2Foauth%2Fauthorize%3Fclient_id%3Dca_AuidWGx68TXWlWO3d3UbWcRcuPqfSeNH%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A3000%252Fconnect%252Fconfirm%26response_type%3Dcode%26scope%3Dread_write%26stripe_landing%3Dregister%26stripe_user%255Bemail%255D%3Daaa%2540gmail.com&force_login=true

對不起,我可憐的解釋,但它會是巨大的,如果任何人都可以解開這個謎。非常感謝!

+0

我們希望看到其他代碼或圖像以幫助您解答問題。 –

回答

0

我嘗試在Safari和它的工作正確,所以我刪除了鉻上的相關cookie,它工作。

0
+0

感謝您的回覆。我剛剛嘗試了示例鏈接並獲得了此信息。它仍然是登錄頁面,我不知道我是否設置了任何錯誤,因爲url結尾處有「force_login = true」。如果你有什麼想法? https://connect.stripe.com/login?redirect=%2Foauth%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3Dca_32D88BD1qLklliziD7gYQvctJIhWBSQ7%26scope%3Dread_write%26stripe_landing%3Dregister&force_login=true – ymatt