IAP v4 initialization
To activate IAP v4, request IAP initialization before purchase. If you request to initialize IAP, Game Client returns available store information. Store information is defined as IAPV4Type enum, and details in field are as following;
Market information¶
| Field Name | Description |
|---|---|
| APPLE_APPSTORE | Apple App Store |
| GOOGLE_PLAYSTORE | Google Play Store |
| HIVE_LEBI | Lebi Store |
| ONESTORE | ONE Store |
| AMAZON_APPSTORE | Amazon Appstore (Available with Hive SDK v4 only) |
| SAMSUNG_GALAXYSTORE | Samsung Galaxy Store |
| HUAWEI_APPGALLERY | Huawei AppGallery |
| HIVESTORE | PG (for Windows, Unity, iOS, Android) |
| ANIMATE_GO | animate Games Online (Android only) |
| DMM | DMM Point Store. Used when running on Windows through DMM GAME PLAYER. |
HIVESTOREPG only supports Product Search and Purchase, and the client-based receipt verification is not supported.- The
DMMstore is used only when running on Windows through DMM GAME PLAYER, and operates based on DMM Points. For details, see Prerequisites for DMM billing.
Soft currency market in game should be available for users who enjoy the gameplay even after the game stops download service. Therefore, each game company is required to code hard currency market and soft currency market separately. The result value sent by initializing IAP v4 is not for access to in-game market, so do not use the result value in different ways.
Prerequisites for DMM billing¶
DMM billing is used only when running on Windows through DMM GAME PLAYER. The DMM-related content in this document applies to the Windows environment. For DMM login and management token constraints, see DMM login first.
DMM billing is a payment method in which users purchase products using DMM Points they have charged. The purchase request and restore flow follow the general IAP v4 purchase flow, but DMM-specific branches, such as checking the DMM Point balance and prompting the user to charge points, operate alongside it. Therefore, even in the Windows DMM environment, the existing IAP v4 flow is maintained while handling DMM Point-based purchase conditions together.
Prerequisites: Console registration¶
To use DMM authentication, first see Log in with DMM.
DMM billing characteristics¶
Payments are confirmed immediately after calling purchase(), without a separate payment window UI. However, depending on server processing, the receipt may not be returned immediately after purchase. In this case, call restore() to retrieve the receipt again.
Calling the DMM billing API requires a valid management token, onetime_token. For token lifetime, automatic renewal, and handling upon expiration, see DMM login.
Initialize IAP v4¶
Implement marketConnect() in the IAPV4 class to initialize IAP v4.
Followings are sample codes to initialize IAP v4.
API Reference: hive.IAPV4.marketConnect
API Reference: IAPV4::marketConnect
API Reference: IAPV4.marketConnect
API Reference: com.hive.IAPV4.marketConnect
API Reference: IAPV4Interface .marketConnect
API Reference: HIVEIAPV4::marketConnect
Check the initialization result¶
If you use multiple markets, the marketList passed to the callback includes the markets configured in the Hive console, and the callback differs depending on whether market initialization succeeds, as follows.
- If all markets, or only some markets, succeed in connecting:
ResultAPIreturns success, and only the markets that succeeded in connecting are delivered inmarketList. - If all market connections fail:
ResultAPIreturns an error code, andmarketListreturns no value (null).
For example, in an app that has configured both the App Store and PG (Hive Store) in the Hive console, if only the PG (Hive Store) connection fails:
ResultAPI: Returns successmarketList:[APPLE_APPSTORE](only the market that succeeded is delivered)
Warning
If the marketConnect() method call fails, you cannot proceed with product list inquiry or purchase normally. The failure causes are as follows:
- Device account login is not processed normally
- Login to market platform apps such as Google Play Store or Apple App Store is not processed normally
- Market settings for the app ID in the Hive console are not processed normally
Even if ResultAPI returns success, it does not mean that all markets configured in the console are connected. If the number of markets configured in the console differs from the number of markets in marketList, some market connections have failed, so proceed with the subsequent purchase flow using only the markets in the returned marketList.
If ResultAPI returns failure (a complete failure), you must implement your own response, such as retrying in the app client until a success callback is received, or exposing an error situation (market unavailable) to the user via a popup.
Check the related Result API codes in the IAP v4 Result API Guide.
Notes for initialization¶
From Hive SDK v4 Unity Windows 25.8.0, Windows apps for Google Play are supported, and the GOOGLE_PLAYSTORE market can be used. In this case, please note the following during development:
- Before calling
IAPV4.marketConnect, the user must complete Google account sign-in in the PC Google Play Games app. - The manifest.xml file must be prepared.
You can use the HIVESTORE(PG) market from Hive SDK v4 iOS version 26.3.2 onwards.
Handling Google Play for native PC initialization failures (Hive SDK v4 Unity Windows 26.4.2 or later)¶
If the app needs to terminate due to an initialization failure of the Google Play Games PC SDK, the result is delivered through the IAPV4.marketConnect callback instead of forcing termination. This allows the app to directly control when and how it terminates.
When the Google Play Games PC SDK initialization fails (kActionRequiredShutdownClientProcess), the IAPV4.marketConnect callback delivers the IAPV4PlayStoreActionRequiredShutdown(-6100706) result code.
When you receive this result code, it is recommended that you terminate the app process as soon as possible. Since ResultAPI.needExit() returns true, you can use needExit() to determine whether termination is required. When the process terminates, the Google Play Games PC SDK attempts follow-up actions to support the user.