Rails IPN示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Rails IPN示例相关的知识,希望对你有一定的参考价值。

  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

以上是关于Rails IPN示例的主要内容,如果未能解决你的问题,请参考以下文章