Skip to content

Go SDK — getting started

The Go SDK is a single module split into three packages:

PackagePurpose
github.com/paylera/paylera-goTyped client for api.paylera.dev (every operation in the OpenAPI spec)
github.com/paylera/paylera-go/relaynet/http relay handler — the ten-route SDK protocol the React SDK calls into
github.com/paylera/paylera-go/webhookWebhook signature verifier + dispatcher

Each is independently importable; you only pull in what you use.

Install

Terminal window
go get github.com/paylera/paylera-go

Requires Go 1.25 or newer.

Build a client

package main
import (
"context"
"fmt"
"log"
"os"
paylera "github.com/paylera/paylera-go"
)
func main() {
c, err := paylera.NewClient(
paylera.WithAPIToken(os.Getenv("PAYLERA_API_TOKEN")),
)
if err != nil {
log.Fatal(err)
}
check, err := c.CheckEntitlement(context.Background(), nil, paylera.CheckRequest{
FeatureCode: "api_calls",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("allowed=%v balance=%v\n", check.Allowed, check.Balance)
}

The token prefix picks the base URL automatically:

PrefixBase URL
pl_live_*https://api.paylera.dev
pl_test_*https://api.test.paylera.dev
anything elsecall WithBaseURL(...)

Construction options

paylera.WithAPIToken(token) // required (or WithBaseURL on self-hosted)
paylera.WithBaseURL(url) // override the auto-selected host
paylera.WithAPIVersion("2026-04-01")
paylera.WithHTTPClient(httpClient) // inject your transport / proxy
paylera.WithTracer(tracer) // custom OpenTelemetry tracer
paylera.WithRetry(paylera.RetryConfig{
MaxAttempts: 3,
InitialBackoff: 500 * time.Millisecond,
MaxBackoff: 5 * time.Second,
Multiplier: 2.0,
JitterFraction: 0.1,
})

The client is safe for concurrent use — build one at process start and share it.

Typed methods at a glance

MethodEndpointIdempotency
CheckEntitlementPOST /v1/checkoptional
TrackUsagePOST /v1/trackauto-stamped
AttachPOST /v1/attachauto-stamped
CreateCustomerPOST /v1/customersauto-stamped
GetCustomerGET /v1/customers/{id}n/a
ListPlansGET /v1/plansn/a
ResolveSubscriptionEntitlementsGET /v1/subscriptions/{id}/entitlementsn/a

Anything not in the typed surface is reachable via c.Raw().* — the generated client, with the same auth + retry + idempotency middleware applied.

Run a working example

The repo ships two reference apps:

Both mount the relay at /api/paylera/, the webhook at /webhooks/paylera, and ship a mock JWT-claim auth middleware so relay.Identify has something to resolve.

Terminal window
git clone https://github.com/paylera/paylera
cd paylera/examples/go/stdlib-server
cp .env.example .env
# edit .env: PAYLERA_API_TOKEN, PAYLERA_WEBHOOK_SECRET
go run .

Where to next

  • Relay handler — mount in chi, gorilla/mux, gin, echo, fiber
  • Webhooks — verify, dispatch, rotate secrets
  • IdempotencyIdempotency-Key, UUIDv7 auto-stamping
  • Errorserrors.As against typed subtypes

Source

github.com/paylera/paylera-go — issues and PRs welcome.