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 Billing (for Windows, Unity, iOS, Android)

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. Implement marketConnect() in the IAPV4 class to initialize IAP v4.

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    
         }    
}];
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 connection to some markets among multiple markets fails, the marketList passed to the callback includes all markets configured in the Hive console. Regardless of the actual connection success or failure of markets, the market list registered in the console is delivered as is.

For example, if an app with both App Store and Hive Store configured in the Hive console fails to connect only to Hive Store:

  • ResultAPI: Returns error code
  • marketList: [APPLE_APPSTORE, HIVESTORE] (all configured markets delivered)

Therefore, even if ResultAPI returns failure, not all markets in marketList are connected normally. If you receive a failed Result API code, you must implement your own response by retrying until a success callback is received or exposing an error situation (market unavailable) to users via popup in the game client.

Check related Result API codes in 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 must log in with a Google account in the PC Google Play Games app before calling initialization (IAPV4.marketConnect).
  • You must prepare the manifest.xml file.

Hive SDK v4 iOS 26.3.2 이후 버전부터 HIVESTORE(PG) 마켓을 사용할 수 있습니다.

You can use the HIVESTORE(PG) market from Hive SDK v4 iOS version 26.3.2 onwards.