SDK Guide
Overview
DaxPay provides official signing SDKs for the open Payment API (/unipay/*). They encapsulate request signing, response verification and callback verification, so you don't have to implement the Signature Mechanism by hand. The Go / Java / Node.js / PHP / Python SDKs share the same contract and golden test vectors — their behavior is byte-for-byte identical.
Every SDK needs only two keys:
| Key | Purpose | Source |
|---|---|---|
Merchant private key (privateKey) | Sign requests | You generate an RSA key pair and keep the private key |
Platform public key (publicKey) | Verify responses and async notifications | Obtain from the admin panel (App Configuration) |
Languages & Repositories
| Language | Package Coordinate | Requirements | Repository |
|---|---|---|---|
| Go | github.com/opendaxpay/dax-pay-sdk-go | Go ≥ 1.21, zero third-party dependencies | Gitee / GitHub |
| Java | cn.daxpay.open:daxpay-open-sdk | Java ≥ 8 (depends on Hutool) | Gitee / GitHub |
| Node.js | @daxpay/open-sdk | Node ≥ 18 (ESM + TypeScript) | Gitee / GitHub |
| PHP | daxpay/open-sdk | PHP ≥ 7.4 (ext-json / openssl / mbstring) | Gitee / GitHub |
| Python | daxpay-open-sdk | Python ≥ 3.10 (depends on cryptography) | Gitee / GitHub |
Source-based installation for now
None of the SDKs are published to public package registries (Maven Central / npm / PyPI / Packagist). Use the source-based installation shown in each tab below.
Quick Start
Install
go get github.com/opendaxpay/dax-pay-sdk-go@mainimport "github.com/opendaxpay/dax-pay-sdk-go/daxpay"Initialize the Client
config := daxpay.Config{
ServiceUrl: "https://your-domain.com", // platform gateway URL
MchNo: "M200000001", // merchant number
AppId: "APP001", // app ID
PrivateKey: merchantPrivateKeyPem, // merchant private key (PEM text)
PublicKey: platformPublicKeyPem, // platform public key (PEM text)
Timeout: 30 * time.Second,
}
client := daxpay.NewClient(config)Pay
result, err := client.Pay(context.Background(), &daxpay.PayParam{
BizOrderNo: "PAY20260916001",
Title: "Test goods",
Amount: 100, // amount in cents
Method: "wechat_qr",
NotifyUrl: "https://example.com/notify",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(result.OrderNo, result.PayBody)Main fields of PayResult: orderNo (platform order number), tradeNo (trade number), status (order status), payBody (payment payload: QR link / invoke params / redirect URL), payBodyType (code_url / pay_info / redirect_url).
Verify Callback
// rawBody is the raw HTTP request body of the async notification
ok := client.VerifyNotice(rawBody)Generic Request (execute)
The convenience method currently covers payment only. Refund, refund sync, order query, close and all other endpoints can be called through each SDK's generic execute(path, param): path is the endpoint path (e.g. /unipay/refund), param holds the business fields (common fields such as mchNo/appId/sign/reqTime and the signature are filled in automatically by the SDK). See the API docs for field details.
result, err := client.Execute(ctx, "/unipay/refund", map[string]any{
"bizOrderNo": "PAY20260916001",
"amount": 100,
"reason": "customer refund",
})Notes
- Key format: every SDK accepts PEM text; for Python the private key is PKCS#8 and the public key is X.509 SPKI.
- Always verify callbacks against the raw body:
verifyNoticeneeds the original payload string. Parsing and re-serializing it changes field order/whitespace and breaks the signature. - Time and amount: the SDK generates
reqTime(Beijing time,yyyy-MM-dd HH:mm:ss) per platform convention; amounts are in cents (Long). - Sandbox: just point
serviceUrlat your test deployment — SDK behavior is environment-independent.