跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://developers-sandbox.uqpaytech.com/llms.txt

Use this file to discover all available pages before exploring further.

UQPAY Go SDK 以带类型的方式访问 UQPAY API,内置自动 OAuth2 鉴权、自动幂等键和线程安全的凭证管理。

GitHub

github.com/uqpay/uqpay-sdk-go
SDK 需要 Go 1.19 或更高版本。当前版本:1.0.3

安装

go get github.com/uqpay/uqpay-sdk-go@latest

快速上手

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()

    // 创建持卡人
    cardholder, err := client.Issuing.Cardholders.Create(ctx, &issuing.CreateCardholderRequest{
        Email:       "[email protected]",
        PhoneNumber: "1234567890",
        FirstName:   "John",
        LastName:    "Doe",
        CountryCode: "US",
    })
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("Cardholder ID: %s\n", cardholder.CardholderID)
}

配置

// 沙盒(测试用)
client, err := uqpay.NewClient(clientID, apiKey, configuration.Sandbox())

// 生产
client, err := uqpay.NewClient(clientID, apiKey, configuration.Production())

鉴权

SDK 自动处理 OAuth2 鉴权:
  • 使用 client credentials 获取访问 token
  • 缓存 token 直至过期
  • 自动刷新过期 token
  • 线程安全的 token 管理

幂等性

每次 API 请求都会自动带上唯一幂等键,确保安全重试、避免重复操作。你无需手动设置。

错误处理

SDK 返回详细的错误信息,包含 HTTP 状态码和 API 错误详情:
card, err := client.Issuing.Cards.Get(ctx, cardID)
if err != nil {
    log.Printf("Error: %v\n", err)
    return
}
错误格式示例:
failed to get card: 404: card_not_found: Card not found (HTTP 404)

API 覆盖范围

Banking API

资源操作
BalancesGet、List、ListTransactions
TransfersCreate、List、Get
DepositsList、Get
BeneficiariesCreate、List、Get、Update、Delete、ListPaymentMethods、Check
PayoutsCreate、List、Get
Virtual AccountsCreate、List
ConversionsCreateQuote、Create、List、Get、ListConversionDates
Exchange RatesList

Issuing API

资源操作
CardholdersCreate、Get、List
CardsCreate、Get、GetSecure、List、Recharge、Withdraw、UpdateStatus
TransactionsGet、List
ProductsList