Skip to content

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.

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

using hive;    
    IAPV4.marketConnect((ResultAPI result, List marketIdList) => {    
         if (result.isSuccess()) {    
            // call successful    
        }    
});
#include "HiveIAPV4.h"

FHiveIAPV4::MarketConnect(FHiveIAPV4OnMarketConnectDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TArray<EHiveIAPV4Type>& MarketIds) {
        if (Result.IsSuccess()) {
                // call successful 
        }
}));

API Reference: IAPV4::marketConnect

#include <HIVE_SDK_Plugin/HIVE_CPP.h>    
    using namespace std;    
    using namespace hive;    
    IAPV4::marketConnect([=](ResultAPI const & result, vector const & marketIdList) {    
         if (result.isSuccess()) {    
            // call successful    
         }    
});

API Reference: IAPV4.marketConnect

import com.hive.IAPV4    
    import com.hive.ResultAPI    
    IAPV4.marketConnect(object : IAPV4.IAPV4MarketInfoListener {    
         override fun onIAPV4MarketInfo(result: ResultAPI, iapV4TypeList: ArrayList<IAPV4.IAPV4Type>?) {    
             if (result.isSuccess) {    
                 // call successful    
             }    
         }    
})

API Reference: com.hive.IAPV4.marketConnect

import com.hive.IAPV4;    
    import com.hive.ResultAPI;    
    IAPV4.INSTANCE.marketConnect((result, iapV4TypeList) -> {    
         if (result.isSuccess()) {    
             // call successful    
         }    
});

API Reference: IAPV4Interface .marketConnect

import HIVEService    
    IAPV4Interface.marketConnect() { result, marketIdList in    
        if result.isSuccess() {    
        // call successful    
        }    
}

API Reference: HIVEIAPV4::marketConnect

#import <HIVEService/HIVEService-Swift.h>    
    [HIVEIAPV4 marketConnect: ^(HIVEResultAPI *result, NSArray<NSNumber *> *marketIdList) {    
         if ([result isSuccess]) {    
            // call successful    
         }    
}];

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: ResultAPI returns success, and only the markets that succeeded in connecting are delivered in marketList.
  • If all market connections fail: ResultAPI returns an error code, and marketList returns 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 success
  • marketList: [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:

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.