Skip to main content
Capabilities

Payments & top-up

The platform provides WeChat Pay Native (QR code) payments. Funds go to the platform's merchant account. The platform creates the order, receives WeChat Pay's notification, and notifies your server with a signed callback.

Flow​

Create an order​

POST/client/open/pay/v1/create

Content-Type: application/json, signed.

Request​

FieldRequiredDescription
appId / timestamp / nonce / signYesCommon signing parameters
merchantOrderNoYesYour order number, unique per appId; used as the idempotency key
priceModeNocustom (default) or product
subjectRequired for customItem description, truncated beyond 127 bytes
totalAmountRequired for customAmount in CNY as a string, e.g. "9.90"; must be greater than 0
productIdRequired for productProduct ID configured in the console
sukRequired for multi-variant productsVariant (SKU) value; omit for single-variant products
currencyNoDefault CNY
extraNoPass-through string (may hold JSON), returned unchanged in the callback

Pricing modes​

  • custom: you pass the amount. The platform only checks the format and that it is above zero; your server is responsible for the amount being correct.
  • product: amount and name come from the product configured in the console; subject and totalAmount are ignored. A missing, delisted or ambiguous product returns 商品不存在、已下架,或suk未指定/不唯一.

Response​

{
"code": 200,
"msg": "操作成功",
"type": "SUCCESS",
"data": {
"outTradeNo": "213e33af20cb4a5cb0b2cd754eef7b69",
"merchantOrderNo": "p12-a1b2c3d4e5f6",
"status": "待支付",
"code_url": "weixin://wxpay/bizpayurl?pr=XXXXXXX"
}
}
FieldDescription
outTradeNoPlatform order number (32 hex characters). Store it as-is
merchantOrderNoYour order number
statusOrder status (待支付 = awaiting payment)
code_urlWeChat Pay QR content; render it as a QR image yourself. Note the snake_case name
  • The QR code is valid for about 3 minutes. After it expires, create a new order with a new merchantOrderNo.
  • If the response has no code_url, treat it as a failed order and contact the platform to check the payment configuration.

Idempotency​

Repeating a call with the same appId + merchantOrderNo never creates a second order:

  • Unpaid: returns the same outTradeNo, and the same QR code while it is valid. After the QR code expires, a repeat call may return 微信下单失败:…; create a new order with a new merchantOrderNo.
  • Paid: returns {outTradeNo, merchantOrderNo, status: "支付成功", paid: true} without code_url.

Errors​

Besides signature errors, possible code=300 messages: merchantOrderNo不能为空, subject不能为空, totalAmount不能为空, totalAmount必须大于0, priceMode=product时productId不能为空, priceMode非法,仅支持custom或product, 微信下单失败:… (WeChat order failed), 微信下单未返回code_url (no code_url returned).

Example​

BODY=$(python3 -c '
import json, footoo_sign
print(json.dumps(footoo_sign.signed({
"merchantOrderNo": "p12-a1b2c3d4e5f6",
"subject": "Credits top-up CNY 10",
"totalAmount": "10.00",
"extra": json.dumps({"companyId": 12}),
}, "ak_xxx", "<appSecret>"), ensure_ascii=False))')
curl -s -X POST https://cloud.ifootoo.com/client/open/pay/v1/create \
-H 'Content-Type: application/json' -d "$BODY"

Query an order​

GET/client/open/pay/v1/query

Parameters go in the query string; signing works the same way.

ParameterRequiredDescription
appId / timestamp / nonce / signYesCommon signing parameters
merchantOrderNoOne of the twoYour order number
outTradeNoOne of the twoPlatform order number; takes precedence if both are sent
warning

Only the parameters above are used for verification. Do not add other query parameters, or you will get 签名校验失败 (signature mismatch). Sign the raw values; URL encoding is only for transport.

Response data: {outTradeNo, merchantOrderNo, status, paid}. status is one of 待支付 (awaiting payment), 支付成功 (paid), 已关闭 (closed), 已退款 (refunded).

If the order is still unpaid on the platform, the platform checks WeChat Pay for the latest status. If it has been paid, the platform updates the order and re-sends the callback. So polling this endpoint always reaches the final result, even if callbacks are lost.

Errors: merchantOrderNo和outTradeNo不能同时为空 (one of the two is required), 订单不存在 (order not found).

QS=$(python3 -c '
import urllib.parse, footoo_sign
print(urllib.parse.urlencode(footoo_sign.signed({"merchantOrderNo": "p12-a1b2c3d4e5f6"}, "ak_xxx", "<appSecret>")))')
curl -s "https://cloud.ifootoo.com/client/open/pay/v1/query?$QS"

Payment callback​

When an order is paid, the platform sends a POST with Content-Type: application/json to your configured notifyUrl.

info

The callback URL is fixed when the order is created. Changing it later does not affect existing orders.

Fields​

FieldTypeDescription
appIdstringApp ID
merchantOrderNostringYour order number
outTradeNostringPlatform order number
transactionIdstringWeChat Pay transaction ID
amountstringAmount paid in CNY, always two decimals, e.g. "10.00"
statusstringAlways SUCCESS
payTimestringPayment time, yyyy-MM-dd HH:mm:ss
extrastringThe extra you sent when creating the order
timestampnumberTime the callback was generated (seconds)
noncestringRandom string
signstringSignature computed with notifySecret using the signing algorithm

Empty fields are omitted. Verify using the fields you actually receive.

{
"appId": "ak_xxx",
"merchantOrderNo": "p12-a1b2c3d4e5f6",
"outTradeNo": "213e33af20cb4a5cb0b2cd754eef7b69",
"transactionId": "4200002xxxxxxxxxxxxxxxxxxxxxx",
"amount": "10.00",
"status": "SUCCESS",
"payTime": "2026-10-04 12:00:00",
"extra": "{\"companyId\": 12}",
"timestamp": 1791000000,
"nonce": "9b2f0c1d7e3a4b5c8d6e7f8091a2b3c4",
"sign": "…"
}

What your server must do​

  1. Verify the signature. Parse every field of the body except sign, compute the signature with notifySecret and compare in constant time. Keep numbers as their original text when parsing (in Python: json.loads(raw, parse_float=str, parse_int=str)).
  2. Do not check freshness. Retries resend the original body, so timestamp may be hours old. Rely on order-level idempotency against replays.
  3. Credit once. The same order can be notified several times. De-duplicate by merchantOrderNo.
  4. Check the amount. Confirm amount matches what the order should cost before crediting.
  5. Return 2xx. Any HTTP status from 200 to 299 counts as delivered; the body does not matter. Other statuses, timeouts and connection errors trigger a retry.

Retry schedule​

The callback is sent within 30 seconds of payment. After a failure, it is retried after:

Failures so far12345–9
Next retry after30 s2 min10 min30 min1 h

At most 10 attempts (about 5.7 hours). After that, no more callbacks are sent; reconcile with Query an order.

Verification example​

FastAPI
import hmac
import json
from fastapi import FastAPI, Request, Response
from footoo_sign import sign

NOTIFY_SECRET = "<notifySecret>"
app = FastAPI()


@app.post("/api/footoo/notify")
async def footoo_notify(request: Request):
raw = await request.body()
body = json.loads(raw, parse_float=str, parse_int=str)
given = body.get("sign", "")
if not given or not hmac.compare_digest(sign(body, NOTIFY_SECRET), given):
return Response(status_code=401) # non-2xx: the platform will retry
if body.get("fapiaoApplyId"):
handle_invoice(body) # invoice callback, see "E-invoices"
elif body.get("status") == "SUCCESS":
credit_order_once(body["merchantOrderNo"], body["outTradeNo"], body["amount"])
return {"ok": True}

Top-up best practices​

  • Encode ownership in merchantOrderNo, e.g. p{companyId}-{uuid12}, to simplify reconciliation.
  • After showing the QR code, have the frontend poll your own order-status endpoint every ~2 seconds. Your server credits on callback, and falls back to the query endpoint if no callback arrives.
  • Use the same idempotent crediting function for both the callback and the query path.
  • Refund and close-order endpoints are not available yet. Contact the platform for refunds.