我使用條紋連接上我的網站,並在生產用戶嘗試他的條紋帳戶連接到我的網站,我有條紋回調以下錯誤:條紋回調將HTTP重定向代替https URI
{
"error": "invalid_redirect_uri",
"error_description": "Invalid redirect URI 'http://www.mywebsite.com/stripe_connections/callback'. Ensure this uri exactly matches one of the uris specified in your application settings",
"state": "4 »
}
,而我在我的條紋應用程序設置redirecti URIS是https://www.mywebsite.com/stripe_connections/callback
這裏是我的控制器:
require 'oauth2'
class StripeConnectionsController < ApplicationController
skip_after_action :verify_authorized
def new
stripe_auth_url = "https://connect.stripe.com/oauth"
client = OAuth2::Client.new(ENV['STRIPE_CONNECT_CLIENT_ID'], ENV['STRIPE_SECRET_KEY'], :site => stripe_auth_url)
@stripe_url = client.auth_code.authorize_url(:redirect_uri => "#{request.protocol}#{request.host_with_port}/stripe_connections/callback", :scope => 'read_write', state: params[:brief_id])
end
def callback
@brief = Brief.find(params[:state])
stripe_auth_url = "https://connect.stripe.com/oauth"
@user = current_user
client = OAuth2::Client.new(ENV['STRIPE_CONNECT_CLIENT_ID'], ENV['STRIPE_SECRET_KEY'], :site => stripe_auth_url)
access_token = client.auth_code.get_token(params[:code], :redirect_uri => '#{request.protocol}#{request.host_with_port}/oauth2/callback')
stripe_connection = StripeConnection.find_or_create_by(user_id: @user.id)
stripe_connection.update_attributes(access_token: access_token.token,
refresh_token: access_token.refresh_token,
livemode: access_token.params['livemode'],
stripe_user_id: access_token.params['stripe_user_id'],
publishable_key: access_token.params['stripe_publishable_key']
)
@user.profile.projects.where(state: 'pending').update_all(state: "on_sale")
end
end
我使用的Heroku和p已經擁有SSL加載項。 我不知道爲什麼stripe返回http而不是https。有人有想法嗎?謝謝。
PS:這已經在之前生產工作,你有用戶點擊連接到條帶按鈕的網站
我懷疑回調URL(HTTP)是由你提供的,而Stripe只是檢查它是否與你設置的(HTTPS)相匹配。 – awendt
我已將控制器添加到問題中。它被'request.protocol'調用。 –
它可以設置在一個條紋賬戶內的某個地方嗎? –