Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ammario/paypal-ipn

Golang PayPal IPN listener
https://github.com/ammario/paypal-ipn

payment-processing paypal

Last synced: 25 days ago
JSON representation

Golang PayPal IPN listener

Awesome Lists containing this project

README

        

# PayPal-IPN

A Paypal IPN listener for Go.

[![GoDoc](https://godoc.org/github.com/leebenson/paypal?status.svg)](https://godoc.org/github.com/ammario/paypal-ipn)

## Basic Usage

```go
mux := http.NewServeMux()
mux.Handle("/paypal-ipn", ipn.Listener(func(err error, n *ipn.Notification) {
if err != nil {
log.Printf("IPN error: %v", err)
return
}

//It's critical you verify the payment was sent to the correct business in the correct currency
const (
BusinessEmail = "[email protected]"
Currency = "USD"
)
if n.Business != BusinessEmail {
log.Printf("Payment sent to wrong business: %v", err)
return
}
if n.Currency != Currency {
log.Printf("Payment in wrong currency: %v", n.Currency)
return
}

log.Printf("%v sent me %v!", n.PayerEmail, n.Gross)
}))
log.Fatalf("failed to run http server: %v", http.ListenAndServe(":80", mux))
```