There are official code samples for several languages but couldn\'t find one for Rails.
There are a few PayPal gems, and at least one of them (paypal-sdk-rest) includes the PayPal::SDK::Core::API::IPN.valid?
method.
Here's how to use it:
class YourController < ApplicationController
skip_before_action :verify_authenticity_token, only: :your_action
def your_action
verified = PayPal::SDK::Core::API::IPN.valid?(request.raw_post)
if verified
# Verification passed, do something useful here.
render nothing: true, status: :ok
else
# Verification failed!
render nothing: true, status: :unprocessable_entity
end
end
end