Skip to content

Aidutu Universal API

  • Notes on the Aidutu universal API

QR Code Login

Login via QR code involves 2 steps.

1. Get Login QR Code

POST https://www.lingduquan.com/wx/qrlogin

shell
curl --request POST \
  --url https://www.lingduquan.com/wx/qrlogin \
  --header 'Content-Type: application/json' \
  --data '{
    "app":"aidutu",
    "prefix":"yi"
}'
curl --request POST \
  --url https://www.lingduquan.com/wx/qrlogin \
  --header 'Content-Type: application/json' \
  --data '{
    "app":"aidutu",
    "prefix":"yi"
}'

Request body:

json
{
  "app": "aidutu",
  "prefix": "yi"
}
{
  "app": "aidutu",
  "prefix": "yi"
}
  • app: Official Account identifier
  • prefix: service prefix

Response:

  • url — QR code link for following the Official Account; display as a QR code for WeChat scanning
  • token — used in the next step
json
{
  "token": "yi:abc1212233",
  "url": "http://weixin.qq.com/q/02gemzBCLXdwF1TjUhxEcf"
}
{
  "token": "yi:abc1212233",
  "url": "http://weixin.qq.com/q/02gemzBCLXdwF1TjUhxEcf"
}

2. Get Login Result

GET https://www.lingduquan.com/wx/qrlogin/{token}

Response:

json
{
  "open_id": "ob7tg6a6-L4pn8d0vueJPMfq4ZFk",
  "status": "success",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user_id": "21324"
}
{
  "open_id": "ob7tg6a6-L4pn8d0vueJPMfq4ZFk",
  "status": "success",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user_id": "21324"
}
FieldTypeDescription
open_idstringWeChat Official Account open_id
statusstringsuccess or wait_scan
tokenstringJWT token — include in the Authorization header for future calls
user_idstringUser ID

The JWT token contains user_id, open_id, and expiry time. Contact staff for the signing secret.

WeChat Pay

  • Outside WeChat: user scans a QR code to get a payment link, then pays inside WeChat
  • Inside WeChat: link directly to the payment page
  • Requires a pre-agreed webhook URL and return URL

Direct the user to: https://www.lingduquan.com/pay/weixin/yi-{user_id}-{amount}

  • yi — service prefix
  • user_id — user UID
  • amount — payment amount in RMB cents

Example: https://www.lingduquan.com/pay/weixin/yi-9-100 — UID 9, amount 1 RMB

If outside WeChat, convert the link to a QR code for scanning.

2. Webhook

POST https://your.com/webhook

json
{
  "do": "finish",
  "act": "yi",
  "ctime": 1758611970,
  "payload": {}
}
{
  "do": "finish",
  "act": "yi",
  "ctime": 1758611970,
  "payload": {}
}

Respond with ok.

2.1 Order Created

json
{
  "do": "create",
  "act": "yi",
  "ctime": 1758611970,
  "payload": {
    "user_id": "9",
    "open_id": "ob7tg6a6-L4pn8d0vueJPMfq4ZFk",
    "amount": "10",
    "trade_no": "WJ202509231447447592"
  }
}
{
  "do": "create",
  "act": "yi",
  "ctime": 1758611970,
  "payload": {
    "user_id": "9",
    "open_id": "ob7tg6a6-L4pn8d0vueJPMfq4ZFk",
    "amount": "10",
    "trade_no": "WJ202509231447447592"
  }
}
  • do: create — order created
  • payload.trade_no — external order number

2.2 Payment Completed

json
{
  "do": "finish",
  "act": "yi",
  "ctime": 1758611970,
  "payload": {
    "user_id": "9",
    "trade_no": "WJ202509231519185462",
    "amount": "10",
    "pay_id": "4200002792202509233954521750",
    "pay_time": "1758611970",
    "payer": "ob7tg6a6-L4pn8d0vueJPMfq4ZFk"
  }
}
{
  "do": "finish",
  "act": "yi",
  "ctime": 1758611970,
  "payload": {
    "user_id": "9",
    "trade_no": "WJ202509231519185462",
    "amount": "10",
    "pay_id": "4200002792202509233954521750",
    "pay_time": "1758611970",
    "payer": "ob7tg6a6-L4pn8d0vueJPMfq4ZFk"
  }
}
  • do: finish — payment completed
  • payload.payer — payer's open_id
  • payload.pay_id — WeChat payment order number

3. Query Payment Result

GET https://www.lingduquan.com/pay/weixin/feed/{trade_no}

Example: https://www.lingduquan.com/pay/weixin/feed/WJ202509231519185462

json
{
  "data": {
    "status": "success",
    "payload": {
      "user_id": "9",
      "trade_no": "WJ202509231519185462",
      "amount": "1",
      "ctime": "1758611958",
      "act": "yi",
      "pay_id": "4200002792202509233954521750",
      "pay_time": "1758611970",
      "payer": "ob7tg6a6-L4pn8d0vueJPMfq4ZFk"
    }
  },
  "error": 0,
  "error_des": ""
}
{
  "data": {
    "status": "success",
    "payload": {
      "user_id": "9",
      "trade_no": "WJ202509231519185462",
      "amount": "1",
      "ctime": "1758611958",
      "act": "yi",
      "pay_id": "4200002792202509233954521750",
      "pay_time": "1758611970",
      "payer": "ob7tg6a6-L4pn8d0vueJPMfq4ZFk"
    }
  },
  "error": 0,
  "error_des": ""
}

data.status = success means payment was successful.

WeChat In-App Login

  • Requires a pre-agreed return URL, e.g. http://a.cn/login
  • Final redirect: http://a.cn/login?code={code}

1. Get Login Code

GET https://www.lingduquan.com/oauth/weixin?f=api&prefix=yi

  • This is a user-triggered redirect, not a programmatic request
  • prefix=yi — requires a pre-agreed return URL
  • Redirects the user to http://a.cn/login?code={code}

2. Fetch Login Info via Code

GET https://www.lingduquan.com/wx/qrlogin/c/{code}

json
{
  "open_id": "ob7tg6a6-L4pn8d0vueJPMfq4ZFk",
  "status": "success",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user_id": "21324"
}
{
  "open_id": "ob7tg6a6-L4pn8d0vueJPMfq4ZFk",
  "status": "success",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user_id": "21324"
}
FieldTypeDescription
open_idstringWeChat Official Account open_id
statusstringsuccess or wait_scan
tokenstringJWT token — include in the Authorization header for future calls
user_idstringUser ID