This repo is archived, and is now used for reference.
Library for interacting with the PayPal NVP endpoint.
Currently the library supports the following methods:
- MassPayment
With others coming soon.
Only API credentials are supported at present, however the client takes a compatible http client that implements
the TransportClient
interface so a net/http
client can be created with client cert authentication setup and passed in.
Below is an example setting up and preforming a Mass Payment
:
package main
import (
"fmt"
"github.com/vidsy/go-paypalnvp"
"github.com/vidsy/go-paypalnvp/payload"
)
func main() {
client := paypalnvp.NewClient(
nil,
paypalnvp.Sandbox,
"user",
"password",
"signature",
)
massPayment := payload.NewMassPayment("GBP", payload.ReceiverTypeEmail)
massPaymentItem := payload.MassPaymentItem{
Email: "[email protected]",
Amount: 100.50,
ID: "123456789",
Note: "Vidsy payment going out",
}
massPayment.AddItem(massPaymentItem)
response, err := client.Execute(massPayment)
if err != nil {
panic(err)
}
fmt.Printf("Successful: %t\n", response.Successful())
fmt.Printf("Errors count: %d\n", response.ErrorCount())
if response.ErrorCount() > 0 {
fmt.Printf("Error code: %s\n", response.Errors[0].Code)
fmt.Printf("Long message: %s\n", response.Errors[0].LongMessage)
}
}