NewClient gives you the SolvaPay SDK API. The paywall and the MCP server use it too, so you usually create one client and pass it to both.
Create a client
Config fields fall back to the environment:
Common operations
Most methods take and return the API’s JSON asmap[string]any, with the API’s camelCase keys. Customer methods return a typed api.CustomerResponse.
main.go
The API reference tab lists each endpoint’s fields; see Authentication and base URL to start. For paid calls, use the paywall (
Payable or NewMCPServer) rather than CheckLimits and RecordUsage: it caches limits, creates customers on first use and records each outcome once.
Handle errors
Every error the SDK returns is a*solvapay.Error:
solvapay.ErrorCode(err) is the Code of an error that is or wraps a *solvapay.Error, and "" for anything else.
An API error carries the API’s own code when it sends one, and http_<status> otherwise. Codes the SDK sets itself include:
Next steps
- Webhooks: get told when purchases and payments change instead of polling.
- The TypeScript equivalent: Purchase management.