The UQPAY Go SDK provides typed access to the UQPAY API, including automatic OAuth2 authentication, automatic idempotency keys, and thread-safe credential management.
GitHub github.com/uqpay/uqpay-sdk-go
The SDK requires Go 1.19 or higher. Current version: 1.0.3 .
Installation
go get github.com/uqpay/uqpay-sdk-go@latest
Quick start
package main
import (
" context "
" log "
" github.com/uqpay/uqpay-sdk-go "
" github.com/uqpay/uqpay-sdk-go/configuration "
" github.com/uqpay/uqpay-sdk-go/issuing "
)
func main () {
client , err := uqpay . NewClient (
"your-client-id" ,
"your-api-key" ,
configuration . Sandbox (),
)
if err != nil {
log . Fatal ( err )
}
ctx := context . Background ()
// Create a cardholder
cardholder , err := client . Issuing . Cardholders . Create ( ctx , & issuing . CreateCardholderRequest {
Email : "user@example.com" ,
PhoneNumber : "1234567890" ,
FirstName : "John" ,
LastName : "Doe" ,
CountryCode : "US" ,
})
if err != nil {
log . Fatal ( err )
}
log . Printf ( "Cardholder ID: %s \n " , cardholder . CardholderID )
}
Configuration
Direct parameters
Environment variables
Custom endpoint
// Sandbox (for testing)
client , err := uqpay . NewClient ( clientID , apiKey , configuration . Sandbox ())
// Production
client , err := uqpay . NewClient ( clientID , apiKey , configuration . Production ())
export UQPAY_CLIENT_ID = "your-client-id"
export UQPAY_API_KEY = "your-api-key"
Or create a .env file from the provided template: client , err := uqpay . NewClient ( clientID , apiKey , & configuration . Config {
BaseURL : "https://custom-api.example.com/api" ,
})
Authentication
The SDK handles OAuth2 authentication automatically:
Fetches access tokens using client credentials
Caches tokens until expiration
Automatically refreshes expired tokens
Thread-safe token management
Idempotency
Every API request automatically includes a unique idempotency key to ensure safe retries and prevent duplicate operations. You do not need to set this manually.
Error handling
The SDK returns detailed error information including HTTP status codes and API error details:
card , err := client . Issuing . Cards . Get ( ctx , cardID )
if err != nil {
log . Printf ( "Error: %v \n " , err )
return
}
Example error format:
failed to get card: 404: card_not_found: Card not found (HTTP 404)
API coverage
Banking API
Resource Operations Balances Get, List, ListTransactions Transfers Create, List, Get Deposits List, Get Beneficiaries Create, List, Get, Update, Delete, ListPaymentMethods, Check Payouts Create, List, Get Virtual Accounts Create, List Conversions CreateQuote, Create, List, Get, ListConversionDates Exchange Rates List
Issuing API
Resource Operations Cardholders Create, Get, List Cards Create, Get, GetSecure, List, Recharge, Withdraw, UpdateStatus Transactions Get, List Products List