开发者

How to implement Paypal callbacks in Rails? (Getting InvalidAuthenticityToken error)

开发者 https://www.devze.com 2023-03-06 15:05 出处:网络
Edit: This is a mostly Rails question I\'m trying to implement instant payment notification API (IPN), which calls your server if the Paypal payment goes through. The problem I\'m seeing now is when P

Edit: This is a mostly Rails question

I'm trying to implement instant payment notification API (IPN), which calls your server if the Paypal payment goes through. The problem I'm seeing now is when Paypal IPN hits the url I designated, it is fail开发者_开发技巧ing with the following error:

> Started POST "/checkout/complete?id=1&amount=3445&authenticity_token=NkOwgJ1H2TEmwO6T+hROu96kWr4yGcTzHD6MbTswgyU="

> ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):

The authenticity_token it uses is the one I passed during the initial phase while redirecting to Paypal. Apparently, that's not a valid option. When I leave that blank, though, it's throwing the same error.

I wonder if I can disable authenticity_token requirement or get around it somehow, so that when Paypal posts to my app it can go through without any errors.


Sounds like the csrf is causing the issue, adding skip_before_filter :verify_authenticity_token to your controller should allow it to process.

If your using that authenticity_token as a security measure, then store and check it manually in your controllers.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号