Skip to content

Sending consumption information

An API is provided to transmit user consumption information to the app store when an app user requests a refund.

The 'Consumption Information Transmission' API uses a Server-to-Server communication method between the Hive Server and the app server. When the Hive Server sends a consumption information transmission request to the app server, the app server returns the response value to the Hive Server.

Note

Currently, the transmission of consumption information is only supported by the Apple App Store.

Operation flow

The following summarizes the overall operation flow of the 'Consumption Information Transmission' API call and response.

  1. App: Prepare the server URL by configuring the API endpoint
  2. App: Select Enable Consumption Information Transmission in the Hive console, and register the server URL
  3. App client: While the app is running, agree to transmit in-app product consumption information
  4. App user: Request a refund in the app
  5. Apple: Send a consumption information request (CONSUMPTION_REQUEST) to the Hive server
  6. Hive server: Send a POST API request to the server URL registered by the app, and receive consumption information data as the response value from the app server
  7. Hive server: Transmit consumption information to the app store (Apple responds with HTTP 202 on success)
Warning

If the app client does not agree to the information transmission in the consent popup, the Hive server cannot transmit the data to the app store even if it receives the data from the app server. The user consent status (customerConsented) is not sent by the app server; it is set by the Hive server itself.

Some of the consumption information to be transmitted to the app store exists only on the app server. In this case, for the Hive server to transmit the consumption information to the app store, the app server must first pass the data to the Hive server.

The app server URL is the API endpoint opened by the app server for the app server to pass data to the Hive server. After configuring the API endpoint and registering it as the app server URL, the Hive server sends a POST request to this API endpoint each time a user requests a refund, and receives the necessary data from the app server. The Hive server aggregates this data and completes the transmission of consumption information to the app store on behalf of the app.


API endpoint configuration (server URL)

When the app server receives a request at the API endpoint registered as the server URL, it must look up the consumption information using the user information (player_id) and transaction information (transaction_id) in the request parameters, and return data that matches the response protocol.

Disable firewall rules

To allow the Hive server to send requests to the app server's API endpoint, the app server must disable the firewall inbound rules for the IP addresses below.

Hive server IP
15.165.223.210
3.34.158.195
43.202.20.33
13.209.91.38
3.34.235.15
15.165.134.120

After disabling the firewall rules, refer to the information below to configure the API endpoint.

API request (Hive server → app server) configuration

This is the POST request information sent from the Hive server to the app server.

API information Description
Method POST
Response Format JSON
Content-type application/json

Request body

The request body information is as follows.

Name Type Required (Required: M, Optional: O) Description
gameindex Integer M App Center Game Index
appid String M App Center AppID
server_id String M App server ID
player_id String M User identifier within the app (the user identification value used for purchase verification). Corresponds to user_seq in V1
transaction_id String M Apple original transaction ID (originalTransactionId)


The following is an example of the request body.

{
    "gameindex": 539,
    "appid": "com.com2us.hivesdk.normal.freefull.apple.global.ios.universal",
    "server_id": "server_01",
    "player_id": "222333",
    "transaction_id": "2000000123456789"
}

API response (app server → Hive server) configuration

The app server passes the processing result code (code), result message (message), and consumption information (data) to the Hive server.

Response body

The Hive server determines success based on the code value. If it is 200, the request is treated as successful and data is used; for any other code, the item is not transmitted and message is recorded as the reason. code is required, and if it is not sent, the item is treated as an error and not transmitted.

Name Type Required (Required: M, Optional: O) Description
code Integer M Processing result code (see the table below). Only 200 is treated as success; any other code is treated as an error
message String O Processing result message. Used to describe the reason in case of an error
data Object M Response data (required when successful)
┕ delivery_status String M Consumable item delivery status. One of the delivery status values below
┕ refund_preference String O Refund preference. One of the refund preference values below
┕ consumption_percentage Integer O Consumption percentage. In millipercent, 0-100000 (100000 = 100%)
┕ sample_content_provided Integer O Sample content provided. 0 or 1

The following is an example of a successful response.

{
    "code": 200,
    "message": "OK",
    "data": {
        "delivery_status": "DELIVERED",
        "refund_preference": "GRANT_FULL",
        "consumption_percentage": 100000,
        "sample_content_provided": 0
    }
}

Response codes

Value Description
200 Success
400 Invalid request value
500 Server error

Delivery status (delivery_status)

Indicates the delivery status of the consumable item, and must be one of the 5 values below (required).

Value Meaning
DELIVERED The consumable item was delivered normally and works correctly
UNDELIVERED_QUALITY_ISSUE Not delivered due to a quality issue
UNDELIVERED_WRONG_ITEM Delivered a different (incorrect) item than the one purchased
UNDELIVERED_SERVER_OUTAGE Not delivered due to a server outage
UNDELIVERED_OTHER Not delivered for another reason

Refund preference (refund_preference)

Passes the app's preferred refund handling direction to Apple (optional). If a value is sent, it must be one of the 3 values below.

Value Meaning
GRANT_FULL Prefers to grant a full refund
DECLINE Prefers not to refund (decline)
GRANT_PRORATED Prefers to grant a partial (prorated) refund (mainly for subscriptions)
Warning

If the values below are invalid, they are not transmitted to the app store and the item is excluded.

  • delivery_status is required and must be one of the 5 values above.
  • If refund_preference is sent, it must be one of the 3 values above.
  • If consumption_percentage is sent, it must be an integer in the range 0-100000.
Note

The following are behaviors that the Hive server automatically adjusts according to Apple's rules.

  • If delivery_status is not DELIVERED, consumption_percentage is sent as 0.
  • If refund_preference is GRANT_PRORATED (subscription), consumption_percentage is omitted.