ウェブショップ購入制限検証API¶
「ウェブショップ購入制限検証」は、ウェブショップで決済された商品が最大購入数量を超過しているかを検証する機能です。Hiveサーバーでは、この機能としてウェブショップ決済情報検証APIを提供します。
事前準備¶
ウェブショップ決済情報検証APIを呼び出す前に、Hive Consoleで最大購入数量を設定します。Hive Console > コミュニティ & ウェブショップ > ウェブショップ > 商品管理で、購入数量制限検証設定を通じてウェブショップ商品にアカウント別購入制限と購入数量制限を設定します。それぞれに最大購入数量を設定できます。
動作フロー¶
- アプリ: WebショップでPG決済時、アプリサーバーで商品を付与するプロセスを構築します。関連設定は決済通知設定を参照してください。
- アプリサーバー: Webショップでユーザーが購入数量制限商品を購入した場合、商品付与前にWebショップ決済情報検証APIを呼び出します。
- Hiveサーバー: ユーザーの商品注文が最大購入数量を超過しているか検証し、結果をAPIレスポンスとしてアプリサーバーへ送信します。
- アプリサーバー: APIレスポンスを確認し、検証条件を通過した場合のみ商品を付与します。最大購入数量を超過した注文の場合は商品を付与せず、決済をキャンセルします。Webショップは検証結果に問題がない場合のみ販売完了数量として反映し、残数量を減少させます。無効な決済と判定された場合、アプリサーバーはユーザーに商品を付与せず、決済をキャンセルする必要があります。
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 |