项目作者: ammario

项目描述 :
Golang PayPal IPN listener
高级语言: Go
项目地址: git://github.com/ammario/paypal-ipn.git
创建时间: 2017-05-11T04:22:33Z
项目社区:https://github.com/ammario/paypal-ipn

开源协议:

下载


PayPal-IPN

A Paypal IPN listener for Go.

GoDoc

Basic Usage

  1. mux := http.NewServeMux()
  2. mux.Handle("/paypal-ipn", ipn.Listener(func(err error, n *ipn.Notification) {
  3. if err != nil {
  4. log.Printf("IPN error: %v", err)
  5. return
  6. }
  7. //It's critical you verify the payment was sent to the correct business in the correct currency
  8. const (
  9. BusinessEmail = "ammar@ammar.io"
  10. Currency = "USD"
  11. )
  12. if n.Business != BusinessEmail {
  13. log.Printf("Payment sent to wrong business: %v", err)
  14. return
  15. }
  16. if n.Currency != Currency {
  17. log.Printf("Payment in wrong currency: %v", n.Currency)
  18. return
  19. }
  20. log.Printf("%v sent me %v!", n.PayerEmail, n.Gross)
  21. }))
  22. log.Fatalf("failed to run http server: %v", http.ListenAndServe(":80", mux))