Adding IPN validation

This commit is contained in:
2013-08-24 03:40:34 -07:00
parent ec4cf4dea9
commit eb782f11d5
6 changed files with 69 additions and 15 deletions

View File

@@ -15,11 +15,21 @@ class IpnsController < ApplicationController
end
def create
#TODO: ensure the request is actually from paypal
@ipn = Ipn.new_from_dynamic_params(params)
@ipn.data = params.to_json
@ipn.save
render :nothing => true
unless @ipn.validate!
Rails.logger.error "Unable to validate IPN: #{@ipn.inspect}"
end
end
def validate
if @ipn.validate!
redirect_to ipns_url, :notice => 'Valid!'
else
redirect_to ipns_url, :notice => 'INVALID'
end
end
def link