Skip to content

Instantly share code, notes, and snippets.

@copyhacker
Created March 23, 2009 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save copyhacker/83727 to your computer and use it in GitHub Desktop.
Save copyhacker/83727 to your computer and use it in GitHub Desktop.
def notify
notify = Paypal::Notification.new(request.raw_post)
enrollment = Enrollment.find(notify.item_id)
if notify.acknowledge
@payment = Payment.find_by_confirmation(notify.transaction_id) ||
enrollment.invoice.payments.create(:amount => notify.amount,
:payment_method => 'paypal', :confirmation => notify.transaction_id,
:description => notify.params['item_name'], :status => notify.status,
:test => notify.test?)
begin
if notify.complete?
@payment.status = notify.status
else
logger.error("Failed to verify Paypal's notification, please investigate")
end
rescue => e
@payment.status = 'Error'
raise
ensure
@payment.save
end
end
render :nothing => true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment