跳轉至

網頁商店購買限制驗證 API

「網頁商店購買限制驗證」用於驗證在網頁商店付款的商品是否超過最大購買數量。Hive 伺服器透過網頁商店付款資訊驗證 API提供此功能。

準備事項

呼叫網頁商店付款資訊驗證 API 前,請在 Hive Console 中設定最大購買數量。在 Hive Console > 社群 & 網頁商店 > 網頁商店 > 商品管理 中,透過購買數量限制驗證設定為網頁商店商品設定帳號購買限制購買數量限制,並可分別設定最大購買數量

運作流程

  1. 應用程式:在網頁商店進行 PG 付款時,建構由應用程式伺服器發放商品的流程。相關設定請參閱付款通知設定
  2. 應用程式伺服器:使用者在網頁商店購買購買數量限制商品時,在發放商品前呼叫網頁商店付款資訊驗證 API
  3. Hive 伺服器:驗證使用者商品訂單是否超過該商品最大購買數量,並將結果作為 API 回應值傳送給應用程式伺服器。
  4. 應用程式伺服器:確認 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_code responses 100 and 101.
  • result_code 3001 is an already validated order. Grant the product only if it was not granted previously.
  • result_code 3002 means 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