简体   繁体   English

PayPal IPN无法通过网站登录

[英]PayPal IPN not able to pass website sign in

I am working on a ruby on rails project and need to use Paypal to allow a user to buy some coins usable on the website. 我正在研究ruby on rails项目,需要使用Paypal来允许用户购买一些可在网站上使用的硬币。 To make the process as simple as possible I am just using a buy now button supplied by Paypal. 为了使过程尽可能简单,我仅使用贝宝提供的立即购买按钮。 The button is set up to notify a URL that will add the coins to a current user when accessed. 该按钮设置为通知URL,该URL在访问时会将硬币添加到当前用户。

The website is set up so that if you are not logged in you can not access any page on the site. 该网站已建立,因此,如果您未登录,则无法访问该网站上的任何页面。 Here in lies the problem. 问题就在这里。 I assumed that devise would be able to access the URL Paypal is trying to use by using the account last logged in. This dose not seem to be the case as tailing the heroku logs informs me that Paypal tries to go to the correct URL but is then forwarded to the sign in screen and the coins are not added. 我以为devise可以通过使用上次登录的帐户来访问Paypal尝试使用的URL。这种情况似乎并非如此,因为拖尾heroku日志会告诉我Paypal尝试转到正确的URL,但是然后转发到登录屏幕,并且不会添加硬币。

In short my question is how can I allow the Paypal IPN to bypass the sign in screen while keeping the info for the last user that was signed in (So that I can access the correct current user in the code) 简而言之,我的问题是如何允许Paypal IPN绕过登录屏幕,同时保留最后一个已登录用户的信息(以便我可以在代码中访问正确的当前用户)

Hopefully I have provided enough info. 希望我提供了足够的信息。 If not I can post any requested code, or logs. 如果没有,我可以发布任何请求的代码或日志。 Thanks for any assistance. 感谢您的协助。

Update Useing the code below the program no longer forwards to paypal. 更新使用程序下面的代码将不再转发给Paypal。 Unfortunately current user is now null. 不幸的是,当前用户现在为空。 So now the question becomes how can I retain the current use information? 因此,现在的问题变成了如何保留当前的使用信息?

Controller the url points to 将网址指向控制器

class PaymentNotificationsController < ApplicationController
before_action :authenticate_user!, :except => [:create]
# POST /payment_notifications
# POST /payment_notifications.json

def create
puts "made it here"
#PaymentNotification.create!(:params => params)
current_user.coins += 100
current_user.save!
render :nothing => true
end

end

Aplication Controller 应用控制器

class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate_user!
skip_before_filter :verify_authenticity_token
end

我不太熟悉PayPal的工作原理,我猜想对端点使用:require_no_authentication可以使Paypal访问并使用令牌来限制访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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