Go
Official server-side SDK (github.com/wajub/wajub-go) for Go 1.22+ — payments, payouts, webhooks, and the full merchant API.
12 min read
Go is Wajub's official server-side SDK. It is published as github.com/wajub/wajub-go.
Use it with your API key (pk_… / sk_… / rk_…, including test variants) and context.Context. Pair it with @wajub/js in the browser.
Browser vs server
@wajub/js runs in the browser with publishable keys.
wajub-go runs on the server — pass any merchant API key
(pk., sk., rk.) and use webhook verification for inbound
events. Never expose sk. keys to the client.
Install
go get github.com/wajub/wajub-goRequires Go 1.22+. Zero external dependencies (stdlib only).
Quick start
package main
import (
"context"
"log"
"os"
wajub "github.com/wajub/wajub-go"
)
func main() {
client, err := wajub.New(wajub.Config{
APIKey: os.Getenv("WAJUB_SECRET_KEY"),
})
if err != nil {
log.Fatal(err)
}
payment, err := client.Payments.Create(context.Background(), map[string]any{
"amount": 15000,
"currency": "XAF",
"email": "buyer@example.com",
"callback": "https://shop.example.com/order/complete",
}, nil)
if err != nil {
log.Fatal(err)
}
log.Println(payment["authorization_url"])
}Configuration
| Field | Description |
|---|---|
APIKey | Merchant API key (pk.… / sk.… / rk.…, test or live) |
WebhookSecret | Signing secret (whsec_…) for Webhooks.ConstructEvent() |
IdempotencyKeyPrefix | Prefix for auto-generated Idempotency-Key headers |
HTTPClient | Custom *http.Client (timeouts, transport) |
Resources
| Service | Methods |
|---|---|
client.Global | Ping, Channels, Countries, Currencies |
client.Payments | Create, Initialize, Retrieve, List, Cancel, Process, ProcessSplit, ListRefunds |
client.Customers | CRUD + Block, Unblock, Activate, Deactivate, tax IDs |
client.Refunds | CRUD + list |
client.Transfers | CRUD + list |
client.Beneficiaries | CRUD + list |
client.Links | CRUD + list |
client.Invoices | CRUD + Send, MarkPaid, Cancel |
client.Accounts | CRUD + RegenerateToken |
client.WebhookEndpoints | CRUD + RotateSecret |
client.Balance | Retrieve |
client.Events | List, Retrieve, Resend |
client.Disputes | List, Retrieve, SubmitEvidence, Accept, Close, SendMessage |
client.Identity | Resolve, Validate |
client.Tax | settings, rates, calculate, reports, codes, registrations |
client.Shield | settings, stats, blocklist |
client.Listen | Config, Auth |
client.Webhooks | ConstructEvent |
Webhooks
event, err := client.Webhooks.ConstructEvent(
body,
r.Header.Get("X-Wajub-Signature"),
r.Header.Get("X-Wajub-Timestamp"),
0, // tolerance — 0 uses default 300s
)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// Handle payment.succeeded, transfer.succeeded, etc.Sync (Connect)
client.Payments.Create(ctx, params, &wajub.RequestOptions{
Sync: "acct_sync_ref",
})Was this page helpful?