The golang SDK for the paynow payment gateway developed for the Zimbabwe golang community so we don't have to always reinvent the wheel.
# Paynow Zimbabwe Go SDK
A clean, idiomatic Go SDK for the Paynow Zimbabwe payment gateway, ported from the official Node.js and Python SDKs.
- **Web payments** — redirect the customer to Paynow to choose how to pay.
- **Mobile (express checkout)** — charge EcoCash, OneMoney or InnBucks directly.
- **Status polling** and **result-URL webhooks**, with automatic hash verification.
- Context-aware, dependency-free (standard library only), and easy to mock in tests.
## Installation
```bash
go get
github.com
```
Requires Go 1.21 or newer.
## Getting started
Create a client with your integration credentials (available from your Paynow merchant dashboard):
```go
client := paynow.New(
"YOUR_INTEGRATION_ID",
"YOUR_INTEGRATION_KEY",
paynow.WithResultURL("
example.com"), // where Paynow POSTs status updates
paynow.WithReturnURL("
example.com"), // where the customer is sent back to
)
```
Build up a payment. A payment behaves like a shopping cart — add one or more items and the total is computed for you:
```go
payment := client.CreatePayment("INV-1001", "customer@example.com")
payment.Add("T-shirt", 10.00, 2) // title, unit amount, optional quantity (default 1)
payment.Add("Delivery", 3.50)
```
### Web payment
```go
resp, err := client.Send(context.Background(), payment)
if err != nil {
log.Fatal(err)
}
// Redirect the customer to resp.RedirectURL to complete payment,
// and keep resp.PollURL to check the status later.
fmt.Println(resp.RedirectURL)
```
### Mobile (express checkout)
Mobile transactions charge the customer directly and require a valid auth email.
```go
resp, err := client.SendMobile(context.Background(), payment, "0771234567", paynow.MethodEcocash)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.PollURL)
if resp.Instructions != "" {
fmt.Println(resp.Instructions) // e.g. a USSD prompt for the customer to confirm
}
```
Supported methods: `paynow.MethodEcocash`, `paynow.MethodOneMoney …