Posted By

gmericksen on 07/02/10


Tagged

rails IPN activemerchant


Versions (?)

Rails IPN Sample


 / Published in: Rails
 

  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  

You need to login to post a comment.