Rails IPN Sample


/ Published in: Rails
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def paypal_ipn
  2. begin
  3. # Handle regular IPN
  4. notify = Paypal::Notification.new(request.raw_post)
  5. invoice = Payment.find(notify.invoice)
  6. receive_invoice_payment(notify, invoice) if notify.acknowledge
  7. end
  8.  
  9. render :nothing => true
  10. end
  11.  
  12. def receive_invoice_payment(notify, invoice)
  13. if notify.complete? and invoice.amount == notify.amount
  14. invoice.update_attribute(:status, 'paid')
  15. else
  16. # raise invoice payment errors
  17. end
  18. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.