API ตรวจสอบการจำกัดการซื้อของเว็บช็อป¶
“การตรวจสอบการจำกัดการซื้อของเว็บช็อป” คือฟังก์ชันที่ตรวจสอบว่าสินค้าที่ชำระเงินในเว็บช็อปเกินจำนวนซื้อสูงสุดหรือไม่ Hive Server ให้บริการ API ตรวจสอบข้อมูลการชำระเงินเว็บช็อป สำหรับฟังก์ชันนี้
การเตรียมล่วงหน้า¶
ก่อนเรียก API ตรวจสอบข้อมูลการชำระเงินเว็บช็อป ให้ตั้งค่าจำนวนซื้อสูงสุดใน Hive Console ที่ Hive Console > คอมมูนิตี้ & เว็บช็อป > เว็บช็อป > การจัดการสินค้า ใช้ การตั้งค่าการตรวจสอบการจำกัดจำนวนการซื้อ เพื่อตั้งค่าจำกัดการซื้อรายบัญชีและจำกัดจำนวนการซื้อสำหรับสินค้าเว็บช็อป และสามารถกำหนดจำนวนซื้อสูงสุดสำหรับแต่ละการตั้งค่าได้
โฟลว์การทำงาน¶
- แอป: สร้างกระบวนการให้เซิร์ฟเวอร์แอปมอบสินค้าเมื่อมีการชำระเงิน PG ในเว็บช็อป ดูการตั้งค่าที่เกี่ยวข้องได้ที่ การตั้งค่าการแจ้งเตือนการชำระเงิน
- เซิร์ฟเวอร์แอป: เมื่อผู้ใช้ซื้อสินค้า จำกัดจำนวนการซื้อ ในเว็บช็อป ให้เรียก API ตรวจสอบข้อมูลการชำระเงินเว็บช็อป ก่อนมอบสินค้า
- Hive Server: ตรวจสอบว่าออเดอร์สินค้าของผู้ใช้เกินจำนวนซื้อสูงสุดหรือไม่ จากนั้นส่งผลลัพธ์เป็นค่า API response ไปยังเซิร์ฟเวอร์แอป
- เซิร์ฟเวอร์แอป: มอบสินค้าเฉพาะเมื่อผล API response ผ่านเงื่อนไขการตรวจสอบ หากออเดอร์เกินจำนวนซื้อสูงสุด ต้องไม่มอบสินค้าและต้องยกเลิกการชำระเงิน เว็บช็อปจะสะท้อนเป็นจำนวนขายสำเร็จและลดจำนวนคงเหลือเฉพาะเมื่อผลตรวจสอบไม่มีปัญหา หาก API response ระบุว่าเป็นการชำระเงินไม่ถูกต้อง เซิร์ฟเวอร์แอปต้องไม่มอบสินค้าให้ผู้ใช้และต้องยกเลิกการชำระเงิน
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¶
| หมวดหมู่ | ข้อมูล |
|---|---|
| Production 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 |