Skip to main content

Payments API Reference (Endpoints and Parameters)

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:

HeaderDescription
APP_IDYour application’s unique identifier, provided by AppInChina.
APP_SECRETThe secret key associated with your APP_ID. Keep this value secure and do not expose it in client-side code.

Example (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
);
caution

Keep your APP_SECRET confidential. Do not include it in frontend code or expose it in logs or error messages.

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

FieldDescription
payChannelPayment method: WECHAT or ALIPAY
signStatusIndicates whether the payment method is properly configured: OK or NO
appEnvApplication environment: DEV or PROD
appName / appPackageNameApp metadata used to identify the registered app
gmtCreate / gmtModifiedTimestamps (in milliseconds) of record creation/modification
tip

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

ParameterTypeRequiredDescription
amountlongRequiredPayment amount in cents. (e.g., 100 = ¥1 RMB)
bizNostringRequiredUnique transaction number generated by the client for internal record keeping.
goodsTitlestringRequiredTitle or description of the item being purchased (displayed during payment).
payChannelstringRequiredPayment channel: WECHAT or ALIPAY.
paySourcestringOptionalPayment source: NATIVE, H5, or APP. (Default is APP if not specified.)
customerIdentitystringRecommendedUser identifier, useful for linking payments to accounts. See Login → Payments integration (customer identity).
customerNamestringRecommendedUser's username, phone number, or other human-readable identifier.
serviceNostringDeprecatedService order number tied to subscription or timed services.
serviceTypeNostringDeprecatedService type identifier created in the AppInChina Dashboard.
attachDatastringOptionalAdditional 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.
sourceFromstringOptionalIdentifier of the app store where the payment was initiated (see below for accepted values).

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
  • 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 attachData as 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 StoreValue
Tencent MyApptencent
Huawei App Markethuawei
Oppo Software Storeoppo
360 Mobile Assistant360
Baidu Mobile Assistant / 91 Assistant / Himarketbaidu
MIUI App Storemiui
VIVO App Storevivo
PP Assistant / Wandoujia / Taobaopp
China Mobile MM Storechinamm
Anzhi Marketanzhi
Sogou Mobile Assistantsogou
Meizu Flymemeizu
Coolpadcoolpad
Lenovo Storelenovo
Samsung App Storesamsung
AppChinaappchina
Othersothers

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
}
}

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 Request parameters

ParameterTypeRequiredDescription
bizNostringRequiredThe unique order identifier originally passed to the CreateOrder API.
customerIdentitystringRequiredThe identifier for the customer who initiated the order. This is used to prevent unauthorized order queries.

4.3 Successful response

{
"msg": "success",
"code": 0,
"data": {
"amount": 1,
"appId": "yourAppId",
"bizNo": "uniqueTransactionId",
"extInfo": {},
"gmtCreate": 1551676154000,
"gmtModified": 1551676154000,
"pmtDt": 1551676154000,
"attachData": {},
"sourceFrom": "huawei",
"goodsTitle": "Premium subscription 3 months",
"id": "orderId",
"payChannel": "WECHAT",
"paymentStatus": "PAID"
}
}

Key fields

FieldDescription
amountPayment amount in cents.
bizNoClient-generated unique transaction number.
paymentStatusPAID means payment completed successfully. Other values may include PENDING, CLOSE, REFUND.
pmtDtPayment timestamp (if completed).
goodsTitleDescription of the purchased item.
payChannelPayment channel used (WECHAT or ALIPAY).
sourceFromApp store identifier, if provided during order creation.
attachDataAny custom metadata sent with the original order.
extInfoReserved for platform use.
tip

Always treat a payment as successful only if paymentStatus === "PAID".


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

ParameterTypeRequiredDescription
customerIdentitystringUnique identifier of the customer whose order history is being queried
paymentStatusstringOptionalFilter by status: PAID, PENDING, CLOSE, REFUND, etc.
pageNumnumberOptionalPage number to retrieve (default: 1)
pageSizenumberOptionalNumber 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
}
}
note

Use totalCount to support pagination in your UI.


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

ParameterTypeRequiredDescription
customerIdentitystringRequiredUnique 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.

note

Always handle errors based on the code field rather than relying on HTTP status codes, as all responses may return HTTP 200 even when the request failed.