网页商店购买限制验证 API¶
“网页商店购买限制验证”用于验证在网页商店支付的商品是否超过最大购买数量。Hive 服务器通过网页商店支付信息验证 API提供此功能。
准备事项¶
调用网页商店支付信息验证 API 前,请在 Hive Console 中设置最大购买数量。在 Hive Console > 社区 & 网页商店 > 网页商店 > 商品管理 中,通过购买数量限制验证设置为网页商店商品设置账号购买限制和购买数量限制,并可分别设置最大购买数量。
运行流程¶
- 应用:在网页商店进行 PG 支付时,构建由应用服务器发放商品的流程。相关设置请参阅支付通知设置。
- 应用服务器:用户在网页商店购买购买数量限制商品时,在发放商品前调用网页商店支付信息验证 API。
- Hive 服务器:验证用户商品订单是否超过该商品最大购买数量,并将结果作为 API 响应值发送给应用服务器。
- 应用服务器:确认 API 响应值后,仅在通过验证条件时发放商品。如果订单超过最大购买数量,则不发放商品并取消支付。网页商店仅在验证结果无问题时反映为销售完成数量并减少剩余数量。若 API 响应值显示为无效支付,应用服务器不得向用户发放商品,且必须取消支付。
Warning
If steps 2 and 4 above are not implemented, the purchase quantity limit configured in Hive Console Web Shop will not work properly. In that case, the Web Shop assumes no quantity has been sold, so the displayed remaining quantity does not decrease. This means the product can continue to be purchased.
Note
For details about payment cancellation, see Grant result processing.
网页商店支付信息验证 API¶
Validates whether the payment is valid based on completed Web PG payment information, including whether the product exceeds the maximum purchase quantity.
Request information¶
| 分类 | 信息 |
|---|---|
| 生产 URL | https://shop.withhive.com/api/v2/webstore/check-quantity-limit |
| SANDBOX URL | https://sandbox-shop.withhive.com/api/v2/webstore/check-quantity-limit |
| HTTP Method | POST |
| Data Format | JSON |
Request header¶
| 字段 | 说明 | 类型 | 必填 | 备注 |
|---|---|---|---|---|
| Content-Type | application/json | String | Y | |
| X-Access-Token | 用于应用服务器认证的 OAuth 2.0 Access Token (发行 OAuth Token) | String | Y |
Request header 示例¶
Content-Type : application/json
X-Access-Token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InByb2plY3RfYWJjMTIzIn0.eyJwcm9qZWN0X2lkIjoiY29tLmNvbTJ1cy5leGFtcGxlIiwidG9rZW5fdHlwZSI6ImFjY2Vzc190b2tlbiIsImdyYW50X3R5cGUiOiJwcm9qZWN0IiwiaWF0IjoxNzE1NTg0MDAwLCJleHAiOjE3MTU1ODc2MDAsImF1dGhfdmVyIjoidjQiLCJ1c2VyX2lkIjoiIiwiaXNfd2hpdGVsaXN0Ijp0cnVlfQ.signature
Request body¶
| 字段 | 说明 | 类型 | 必填 |
|---|---|---|---|
| type | Notification type (paid: payment completed, cancelled: payment cancellation or refund) | String | Y |
| market_pid | Product ID | String | Y |
| order_id | Order number | String | Y |
| server_id | App server identification code accessed by the purchasing user | String | Y |
| appid | Web Shop App ID of the app; the App ID where the market_pid above is registered | String | Y |
| cs_code | Player ID of the purchasing user | String | Y |
| paid_datetime | Payment completion time (Y-m-d H:i:s) | String | Y |
| quantity | Purchase quantity | String | Y |
| iap_payload | Additional account information for item grant by the app server | String | Y |
Request body 示例¶
{
"type": "paid",
"market_pid": "com.com2us.hivesdk.windows.microsoftstore.global.normal.item01",
"order_id": "H3175513391360875943",
"server_id": "1",
"appid": "com.com2us.hivesdk.windows.hivepc",
"cs_code": "20000023100",
"paid_datetime": "2025-08-14 10:12:18",
"quantity": "10",
"iap_payload": "{"cs_code":20000023100,"data":{"server_id":"1","server_name":"Server 1","channels":{"channel_id":"11","channel_name":"Channel 11","characters":{"character_id":"111","character_name":"Character 111"}}}}"
}
Response body¶
| 字段 | 说明 | 类型 |
|---|---|---|
| result_code | Response result code | Integer |
| result_msg | Response result message | String |
| token_validation | JWT validation result (JWT validation error codes) | Object |
| token_validation.result_code | JWT validation result code | Integer |
| token_validation.result_msg | JWT validation result message | String |
- Products should be granted normally only for
result_coderesponses100and101. result_code3001is an already validated order. Grant the product only if it was not granted previously.result_code3002means the product maximum purchase quantity was exceeded. You must cancel the payment for that order. For details, see Grant result processing.
Response body 示例¶
成功¶
{
"result_code": 100,
"result_msg": "success",
"token_validation": {
"result_code": 0,
"result_msg": "success"
}
}
JWT 验证失败¶
{
"result_code": 2499,
"result_msg": "JWT validation failed. See token_validation for details.",
"token_validation": {
"result_code": 2408,
"result_msg": "The access token is expired. Please refresh your token."
}
}
Note
When JWT validation fails, you can check detailed error information through the token_validation field. For details, see JWT validation error codes.
响应代码¶
| code | msg | description |
|---|---|---|
| 100 | success | Success |
| 101 | success(product no limit) | Success (product without quantity limit; no separate validation required) |
| 3001 | fail(already completed) | Already validated order number reflected in quantity. If the product was already granted, no additional grant is needed. |
| 3002 | fail(purchase fail, purchase cancellation required) | Failed (quantity limit exceeded). If a product whose quantity limit is already exceeded was purchased, payment cancellation is required. |
| 2499 | fail(JWT validation failed. See token_validation for details.) | JWT validation failed (see token_validation: JWT validation error codes) |
| 2000 | fail(method error) | Invalid HTTP METHOD |
| 2001 | fail(request parameter error) | Request parameter does not exist |
| 2002 | fail(type parameter error) | Invalid parameter (type) |
| 2003 | fail(market_pid parameter error) | Invalid parameter (market_pid) |
| 2004 | fail(order_id parameter error) | Invalid parameter (order_id) |
| 2005 | fail(server_id parameter error) | Invalid parameter (server_id) |
| 2006 | fail(appid parameter error) | Invalid parameter (appid) |
| 2007 | fail(cs_code parameter error) | Invalid parameter (cs_code) |
| 2008 | fail(paid_datetime parameter error) | Invalid parameter (paid_datetime) |
| 2009 | fail(quantity parameter error) | Invalid parameter (quantity) |
| 2010 | fail(iap_payload parameter error) | Invalid parameter (iap_payload) |
| 500 | fail(appid in DB not exist) | App information matching the App ID does not exist |
| 501 | fail(gameprefix not exist) | Failed to retrieve Web Shop information matching the App ID. Create the Web Shop first. |
| 502 | fail(####) | Other #### error occurred |
| 503 | fail(product info in DB not exist) | Product information matching the market_pid does not exist. Register the product first in Hive Console > Community & Web Shop > Web Shop > Product Management. |
| 504 | fail(####) | Other #### error occurred |
| 505 | fail(temporary error : ####) | Other temporary #### error occurred |