Skip to content

Auth Code

Updated: 7/26/26, 9:23:52 PM

Two endpoints, both using AuthCodeParam:

EndpointPathReturnsPurpose
Get auth resultPOST /unipay/assist/channel/auth/authResult<AuthResult>Exchange auth code for openId/userId and return to caller
Get and setPOST /unipay/assist/channel/auth/auth-and-setResult<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:

ParameterTypeRequiredMaxDescription
authCodestringYesChannel OAuth code (to exchange for openId/userId); may also be a pre-obtained openId
authTypestringNo32Auth type (required for multi-type channels: wechat/alipay/union_pay/douyin)
authTokenstringNo64Auth session token (issued by Generate Auth URL for H5 redirect scenarios; restores context)
productstringNo32Payment product code (required for direct Mini Program scenarios without session)
capabilitystringNo32Payment capability code (needed for Mini Program)
channelAppIdstringNo128Channel App ID (optional when session restores context)
accessTokenstringNoAccessToken (filled when channel returns it directly)
unionIdentifierstringNoQuickPass App identifier (extracted from UA UnionPay/<version> <identifier>)
queryCodestringNoQuery 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

FieldTypeDescription
openIdstringOpenId (WeChat scenario)
userIdstringUser ID (some Alipay legacy merchants)
accessTokenstringAccessToken (WeChat returns for user info)
statusstringStatus (ChannelAuthStatusEnum: waiting/success/not_exist)
returnPathstringSource 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
}

Released under the GNU LGPL v3.0