Auth Code
Two endpoints, both using AuthCodeParam:
| Endpoint | Path | Returns | Purpose |
|---|---|---|---|
| Get auth result | POST /unipay/assist/channel/auth/auth | Result<AuthResult> | Exchange auth code for openId/userId and return to caller |
| Get and set | POST /unipay/assist/channel/auth/auth-and-set | Result<Void> | Exchange and write to session directly (no openId returned) for later payment reuse |
Response type
These two endpoints return the platform-level Result (field message), not DaxResult (no sign/resTime/reqId). See Error Codes - Response Structure.
AuthCodeParam
Common params same as Pay - Common Parameters. Business parameters:
| Parameter | Type | Required | Max | Description |
|---|---|---|---|---|
| authCode | string | Yes | — | Channel OAuth code (to exchange for openId/userId); may also be a pre-obtained openId |
| authType | string | No | 32 | Auth type (required for multi-type channels: wechat/alipay/union_pay/douyin) |
| authToken | string | No | 64 | Auth session token (issued by Generate Auth URL for H5 redirect scenarios; restores context) |
| product | string | No | 32 | Payment product code (required for direct Mini Program scenarios without session) |
| capability | string | No | 32 | Payment capability code (needed for Mini Program) |
| channelAppId | string | No | 128 | Channel App ID (optional when session restores context) |
| accessToken | string | No | — | AccessToken (filled when channel returns it directly) |
| unionIdentifier | string | No | — | QuickPass App identifier (extracted from UA UnionPay/<version> <identifier>) |
| queryCode | string | No | — | Query code (associates with the one returned by generate-auth-url) |
Endpoint 1: Get Auth Result
Request
POST /unipay/assist/channel/auth/auth
- Auth: No
@PaymentVerify(note: this endpoint is not signature-verified; relies on gateway-layer protection) - Response:
Result<AuthResult>
Example
json
{
"mchNo": "M200000001",
"appId": "APP001",
"authCode": "061XYYxxx0xxx",
"authType": "wechat",
"authToken": "AT20241201020"
}Response AuthResult
| Field | Type | Description |
|---|---|---|
| openId | string | OpenId (WeChat scenario) |
| userId | string | User ID (some Alipay legacy merchants) |
| accessToken | string | AccessToken (WeChat returns for user info) |
| status | string | Status (ChannelAuthStatusEnum: waiting/success/not_exist) |
| returnPath | string | Source redirect path (backfilled on session restore) |
Example
json
{
"code": 0,
"message": "success",
"data": {
"openId": "oXxX_xxxxxxxxxxxxx",
"status": "success",
"returnPath": "/pay/result"
}
}Endpoint 2: Get and Set
Request
POST /unipay/assist/channel/auth/auth-and-set
- Auth: No
@PaymentVerify - Response:
Result<Void>
Same input as "Get Auth Result". The difference: the result is written directly to the session context and openId is not returned. Suitable for frontend polling — the caller only cares whether authorization is complete (HTTP 200 + code=0); openId is auto-reused by subsequent payment requests.
Example
json
{
"code": 0,
"message": "success",
"data": null
}