Go Paystack 
go-paystack is a library that provides a go-style wrapper over the Paystack API.
Installation
go-paystack is available using the standard go get command.
go get github.com/edosssa/go-paystack
Before running tests, you need to set the PAYSTACK_KEY environment variable.
You can easily do this by creating a .env file in your project root with the following contents and we'll load it automatically when tests are run. Replace paystack-secret-key with your test secret key.
PAYSTACK_KEY=<paystack-secret-key>
If you don't have a test secret key, you can create one from your paystack dashboard.
⚠️ We don't allow the use of production secret keys while running tests. Test secret keys always have an sk_test_ prefix.
Run tests
go test ./...
Quickstart
Getting up and running using go-paystack is simple, see for yourself.
import "github.com/edosssa/go-paystack"
// <paystack-secret-key> can be gotten from your Paystack dashboard
apiKey := "<paystack-secret-key>"
// The second param is an optional http client, allowing you set the HTTP client to use.
// This is useful if you're running in a Google AppEngine environment where http.DefaultClient is not available.
client := paystack.NewClient(apiKey, nil)
recipient := &TransferRecipient{
Type: "Nuban",
Name: "Customer 1",
Description: "Demo customer",
AccountNumber: "0100000010",
BankCode: "044",
Currency: "NGN",
Metadata: map[string]interface{}{"job": "Plumber"},
}
recipient1, err := client.Transfer.CreateRecipient(recipient)
req := &TransferRequest{
Source: "balance",
Reason: "Delivery pickup",
Amount: 30,
Recipient: recipient1.RecipientCode,
}
transfer, err := client.Transfer.Initiate(req)
if err != nil {
// Do something with error
panic(err)
}
// retrieve list of plans
plans, err := client.Plan.List()
for i, plan := range plans.Values {
fmt.Printf("%+v", plan)
}
c := &Customer{
FirstName: "User123",
LastName: "AdminUser",
Email: "user123@gmail.com",
Phone: "+23400000000000000",
}
// create the customer
customer, err := client.Customer.Create(c)
if err != nil {
// Do something with error
panic(err)
}
// Get customer by ID
customer, err := client.Customers.Get(customer.ID)
See the test files for more examples.
Made wth ❤️ by Kelvin