Payments API Reference (Endpoints and Parameters)
Endpoint contracts on this page correspond to the currently supported SDK artifact. See the Compatibility Matrix & Changelog for the artifact/version and dependency ranges, and review it before copying behaviour if your project uses a different artifact.
1. Authentication and base URL
To use the AppInChina Payments API, all requests must include authentication headers that identify your application.
1.1 Required headers
Each request must include the following two headers:
| Header | Description |
|---|---|
APP_ID | Your AppInChina App ID — your application’s unique identifier in the AppInChina IAP system, provided by AppInChina. Not the same as your WeChat App ID. |
APP_SECRET | The secret associated with your APP_ID for REST API authentication. Keep it on your backend when calling the REST API directly. Exception: the current Android SDK requires this credential in the app; see the warning below. |
Example (server-side Java)
private static final String APP_ID = "your_app_id_here";
private static final String APP_SECRET = "your_app_secret_here";
private static final Headers headers = Headers.of(
"APP_ID", APP_ID,
"APP_SECRET", APP_SECRET
);
For direct REST API integrations (including PC/H5), keep APP_SECRET in backend configuration: do not ship it in web frontend code or expose it in logs and error messages. This does not mean the current Android SDK can keep the secret server-side. The Android SDK payments_sdk_v20220912 requires APP_SECRET in on-device AcpClientConfig, making it extractable from a distributed app. It does not expose a supported server-signed mode for launching payment from an order created on your backend. See Android SDK initialization.
Related docs
- Identity mapping (
customerIdentity): Login → Payments integration (customer identity) - High-level flow: Understanding the IAP SDK/API Flow
- Android SDK guide: Payments SDK Integration Guide for Android
- PC & H5 guide: PC and H5 Payments Integration Guide
- Troubleshooting errors: Error Reference
1.2 Base URL
All API requests should be made to the following base URL:
https://api.appinchinaservices.com
You will append specific endpoints (such as /order.json, /detail.json, etc.) to this base URL.
2. Pay channel initialization
2.1 Endpoint
GET /payTools.json
This endpoint retrieves a list of payment channels (e.g., WeChat Pay, Alipay) that are available and signed for your application. It is typically used to dynamically determine which payment methods should be shown to the user during checkout.
2.2 Purpose
Use this endpoint to:
- Determine whether WeChat Pay and/or Alipay are available.
- Identify the configured environment (DEV or PROD) for each channel.
- Validate whether the required payment credentials are properly set up (
signStatus).
2.3 Required headers
Authentication headers (APP_ID and APP_SECRET) must be included in the request.
See Authentication and base URL for details.
2.4 Successful response
{
"msg": "success",
"code": 0,
"data": [
{
"accountId": "exampleAccountId",
"appEnv": "PROD",
"appName": "MyApp",
"appPackageName": "com.example.myapp",
"appSignature": "hash",
"extInfo": {},
"gmtCreate": 1551099989000,
"gmtModified": 1551099989000,
"id": "payToolId123",
"payChannel": "WECHAT",
"signStatus": "OK"
}
]
}
Key fields
| Field | Description |
|---|---|
payChannel | Payment method: WECHAT or ALIPAY |
signStatus | Indicates whether the payment method is properly configured: OK or NO |
appEnv | Application environment: DEV or PROD |
appName / appPackageName | App metadata used to identify the registered app |
gmtCreate / gmtModified | Timestamps (in milliseconds) of record creation/modification |
Only show payment methods where signStatus == "OK" and appEnv == "PROD" to real users.
2.5 Error response
{
"code": "error_code",
"msg": "error_message"
}
3. Create order
3.1 Endpoint
POST /order.json
This endpoint is used to create a new payment order.
It generates the necessary information to initiate a payment with either WeChat Pay or Alipay, depending on the selected payment channel and environment.
3.2 Purpose
Use this endpoint to:
- Create a unique payment order for a user transaction.
- Initiate payment through the appropriate channel (WeChat or Alipay).
- Receive parameters needed to proceed with payment (e.g.,
prepayid,sign, etc. for WeChat).
3.3 Required headers
Authentication headers (APP_ID and APP_SECRET) must be included in the request.
See Authentication and base URL for details.
3.4 Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | long | Required | Payment amount in cents. (e.g., 100 = ¥1 RMB) |
bizNo | string | Required | Unique transaction number generated by the client for internal record keeping. |
goodsTitle | string | Required | Title or description of the item being purchased (displayed during payment). |
payChannel | string | Required | Payment channel: WECHAT or ALIPAY. |
paySource | string | Optional | Payment source: NATIVE, H5, or APP. (Default is APP if not specified.) |
customerIdentity | string | Required¹ | Stable, non-secret internal user identifier. Required for account-based apps unless you use a documented alternate identity design. Not a wallet account, email, card number, or per-attempt value. See Login → Payments integration (customer identity). |
customerName | string | Recommended | User's username, phone number, or other human-readable identifier. |
serviceNo | string | Deprecated | Service order number tied to subscription or timed services. |
serviceTypeNo | string | Deprecated | Service type identifier created in the AppInChina Dashboard. |
attachData | string | Optional | Additional metadata to associate with the order (custom JSON string or plain text). If you use the Android SDK, you may provide a key/value map which the SDK serializes for you. |
sourceFrom | string | Optional | Identifier of the app store where the payment was initiated (see below for accepted values). |
¹ customerIdentity and bizNo are operational requirements, not incidental fields. bizNo is your client-controlled business reference: it must be unique per attempt, immutable once created, and retry-safe (reusing it re-queries the same order without creating a duplicate). Store both in your backend so a payment attempt can be correlated across verification, entitlement, purchase history, and support. See Server Verification and Entitlements and Purchase History & Refunds.
bizNo — not the value AppInChina returns laterThe immutability rule above covers the client-generated reference you create and store. It does not guarantee that the bizNo AppInChina returns will stay the same. After a refund, the returned value has been observed to change (a timestamp suffix such as <originalBizNo>_YYYYMMDDHHMMSS). Store the latest returned bizNo as a separate field and use it for subsequent /detail.json lookups. See Query single order.
3.4.1 Using attachData effectively
attachData is your order metadata field. AppInChina Payments records it with the transaction and returns it back in order query responses (for example /detail.json and /history.json).
Use it when you need more than “a transaction happened” — for example, to connect payments to:
- Your SKU / product ID
- Subscription plan ID / tier
- A promo / campaign identifier
- A pricing version (useful for A/B tests or regional price tables)
- Any internal IDs your backend needs to reconcile and fulfill correctly
Recommended format
- Keep it small and stable.
- Prefer a compact JSON object encoded as a string (or plain text if you prefer).
- If you use the Android SDK, you can pass a key/value map and the SDK serializes it.
Security and privacy
- Do not store secrets (tokens, API keys) in
attachData. - Avoid raw PII when possible (phone, email, full name).
- Treat
attachDataas metadata for reporting/reconciliation — not as an authorization mechanism.
Example (CreateOrder request body)
{
"amount": 999,
"bizNo": "ORDER_20260205_0001",
"goodsTitle": "Pro plan (3 months)",
"payChannel": "WECHAT",
"customerIdentity": "user_12345",
"attachData": "{\"productId\":\"pro_3m\",\"promoId\":\"winter25\",\"priceVersion\":\"v3\"}"
}
Accepted values for sourceFrom
| App Store | Value |
|---|---|
| Tencent MyApp | tencent |
| Huawei App Market | huawei |
| Oppo Software Store | oppo |
| 360 Mobile Assistant | 360 |
| Baidu Mobile Assistant / 91 Assistant / Himarket | baidu |
| MIUI App Store | miui |
| VIVO App Store | vivo |
| PP Assistant / Wandoujia / Taobao | pp |
| China Mobile MM Store | chinamm |
| Anzhi Market | anzhi |
| Sogou Mobile Assistant | sogou |
| Meizu Flyme | meizu |
| Coolpad | coolpad |
| Lenovo Store | lenovo |
| Samsung App Store | samsung |
| AppChina | appchina |
| Others | others |
3.5 Successful response examples
WeChat Pay example
{
"msg": "success",
"traceId": "b7c04e1317476299292752036",
"code": 0,
"data": {
"appid": "wxappidexample",
"noncestr": "randomString",
"package": "Sign=WXPay",
"partnerid": "wechatPartnerId",
"prepayid": "wechatPrepayId",
"sign": "generatedSignature",
"timestamp": 1747629929
}
}
appid here is WeChat's, not yoursIn the WeChat response above, appid (all lowercase) is your WeChat App ID — the WeChat Open Platform Mobile Application AppID that WeChat needs to launch its payment UI. It is not your AppInChina App ID.
By contrast, order-query responses (/detail.json, /history.json, /payTools.json) return appId (camelCase) = your AppInChina App ID. The two differ only by casing, so map them carefully.
Alipay example
{
"msg": "success",
"traceId": "b7c04e1317476298157356165",
"code": 0,
"data": {
"app_id": "2021001156621375",
"biz_content": "{\"body\":\"1\",\"out_trade_no\":\"20250519000916970200108462\",\"product_code\":\"QUICK_MSECURITY_PAY\",\"subject\":\"1\",\"total_amount\":\"0.01\"}",
"charset": "utf-8",
"format": "json",
"method": "alipay.trade.app.pay",
"notify_url": "https://api.appinchinaservices.com/payBackAlipay",
"return_url": "https://api.appinchinaservices.com/payBackAlipay",
"sign": "...",
"sign_type": "RSA2",
"timestamp": "2025-05-19 12:43:35",
"version": "1.0"
},
"message": "success"
}
3.6 Error response
{
"code": "error_code",
"msg": "error_message"
}
4. Query single order
4.1 Endpoint
GET /detail.json
This endpoint retrieves the details of a specific payment order using the transaction identifier (bizNo) and the associated user identity (customerIdentity).
4.2 Required headers
Authentication headers (APP_ID and APP_SECRET) must be included in the request. See Authentication and base URL for details.
4.3 Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
bizNo | string | Required | The order identifier. In normal paid or pending flows this is the original bizNo passed to CreateOrder. After a refund it may change (see the caution below) — in that case use the latest bizNo returned by /history.json. |
customerIdentity | string | Required | The identifier for the customer who initiated the order. Must match the identity used when the order was created. Used to prevent unauthorized order queries. |
4.4 Example request
curl -G "https://api.appinchinaservices.com/detail.json" \
-H "APP_ID: <YOUR_APP_ID>" \
-H "APP_SECRET: <YOUR_APP_SECRET>" \
--data-urlencode "bizNo=<ORDER_BIZ_NO>" \
--data-urlencode "customerIdentity=<CUSTOMER_ID>"
4.5 Successful response
The example below is abbreviated. Live responses also include extra top-level fields (traceId, message) and extra data fields — for example customerIdentity, customerName, paySource, paymentNo, paymentStatusDesc, checkStatus, invoiceStatus, and, on refunds, gmtRefund and extInfo.refundAmount.
{
"msg": "success",
"code": 0,
"data": {
"amount": 1,
"appId": "yourAppId",
"bizNo": "uniqueTransactionId",
"extInfo": {},
"gmtCreate": 1551676154000,
"gmtModified": 1551676154000,
"pmtDt": 1551676154000,
"attachData": "{\"planId\":\"pro_3m\"}",
"goodsTitle": "Premium subscription 3 months",
"id": "orderId",
"payChannel": "WECHAT",
"paymentStatus": "PAID"
}
}
Key fields
| Field | Description |
|---|---|
amount | Payment amount in cents. |
bizNo | Order identifier. May differ from your original client reference after a refund (see caution). |
paymentStatus | PAID means payment completed successfully. Other values include PENDING, CLOSE, REFUND. |
paymentStatusDesc | Human-readable (often localized) status, e.g. 已支付, 已退款. |
pmtDt | Payment timestamp (if completed). |
goodsTitle | Description of the purchased item. |
payChannel | Payment channel used (WECHAT or ALIPAY). |
attachData | Any custom metadata sent with the original order. Returned as a string that often contains escaped JSON — JSON.parse it defensively rather than assuming an object. |
sourceFrom | App store identifier, if provided during order creation. Not always present. |
extInfo | Reserved for platform use; on refunds may include refundAmount. |
Always treat a payment as successful only if paymentStatus == "PAID".
4.6 Failure response (10002)
If the order cannot be found for the exact lookup key, the endpoint returns code: 10002 (observed with an HTTP 400 status):
{
"code": 10002,
"msg": "Data does not exist or has been deleted"
}
Refund processing may cause the order returned by /history.json to use a modified bizNo, commonly the original value plus a timestamp suffix such as <originalBizNo>_YYYYMMDDHHMMSS.
After that happens, /detail.json may return code: 10002 (Data does not exist or has been deleted) when queried with the original unsuffixed bizNo. Querying the suffixed bizNo succeeds and returns paymentStatus: REFUND.
Treat 10002 on /detail.json as "not found for this exact lookup key", not as proof that the user never had a transaction. For refund reconciliation, support tooling, and restore flows, query /history.json by customerIdentity and match by exact bizNo first, then by the original bizNo prefix before a _YYYYMMDDHHMMSS suffix.
5. Query order list
5.1 Endpoint
GET /history.json
This endpoint retrieves a paginated list of historical payment orders associated with a given customer.
5.2 Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
customerIdentity | string | ✅ | Unique identifier of the customer whose order history is being queried |
paymentStatus | string | Optional | Filter by status: PAID, PENDING, CLOSE, REFUND, etc. |
pageNum | number | Optional | Page number to retrieve (default: 1) |
pageSize | number | Optional | Number of records per page (default: 20) |
5.3 Successful response
{
"msg": "success",
"code": 0,
"data": {
"payOrderList": [
{
"amount": 1,
"appId": "",
"bizNo": "",
"extInfo": {},
"gmtCreate": 1551676154000,
"gmtModified": 1551676154000,
"pmtDt": 1551676154000,
"attachData": {},
"sourceFrom": "",
"goodsTitle": "",
"id": "",
"payChannel": "",
"paymentStatus": "PAID"
}
],
"totalCount": 1
}
}
Use totalCount to support pagination in your UI.
Use /history.json as the fallback source when a known order cannot be found by exact /detail.json lookup. This matters especially after refunds, where the order may appear in history under a timestamp-suffixed bizNo (<originalBizNo>_YYYYMMDDHHMMSS) and paymentStatus == REFUND. Match records by exact bizNo first, then by the original bizNo prefix before the _YYYYMMDDHHMMSS suffix.
6. Query customer expire time
6.1 Endpoint
GET /customerServiceMgmt/{customerIdentity}.json
This endpoint returns a list of service records associated with a given customer, including each service’s expiration time.
6.2 Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
customerIdentity | string | Required | Unique identifier for the customer. Used to look up associated services. |
6.3 Successful response
{
"msg": "success",
"code": 0,
"data": {
"totalCount": 1,
"customerServiceList": [
{
"expireTime": 1600560000000,
"serviceName": "Demo的VIP服务",
"serviceNo": "VIP"
}
],
"serverTime": 1600560000000
}
}
7. Error codes and meanings
All API endpoints return a standardized error response format:
{
"code": "error_code",
"msg": "error_message"
}
For the full list of error codes and their meanings, see the Error reference.
Always handle errors based on the code field in the JSON body rather than relying on HTTP status codes. Many failures return HTTP 200 with a non-zero code, but some (for example 10002 on /detail.json) have been observed with an HTTP 400 status — so parse the JSON body even on non-2xx responses.