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 App Store (Available with SDK v4 only)
SAMSUNG_GALAXYSTORE Samsung Galaxy Store
HUAWEI_APPGALLERY Huawei App Gallery
HIVESTORE PG Payment (for Windows, Unity only)

Soft currency market in game should be available for users who enjoy the gameplay even after the game stops download service. Therefore, each game studio 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 IAPv4

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

Failing to call marketConnect() method enables not to search the product list or purchase the product. This problem occurs for one of the following reasons:

  • In case the account login to the terminal is processed abnormally
  • In case of abnormal login in marketplaces such as Google Play Store, Apple App Store, and others
  • In case of abnormal handling market settings in Hive Console according to an AppID It requires the game client to directly implement the responses for returning failure of Result API, such as retry until getting a success callback or expose an error popup (e.g., market unavailable) to the user. For details of Result API code, see Result API Code - IAP v4.

Notes for initialization

From Hive SDK v4 Unity Windows 23.0.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:

  • Initialization (IAPV4.marketConnect) must be executed only after the IdP login with AuthV4.
  • When IAPV4.marketConnect is called for the first time, a Google account login screen for product payment, which allows the app user to select a Google account for payment in the market, will appear. This login process is not a feature that the app developer implements, but is automatically performed by the Hive SDK.
  • The Google account login for product payments is different from the Google IdP login provided by the Hive SDK authentication module (AuthV4). When a user logs out from any IdP (AuthV4), including Google IdP, the Google account used for product payments will also be automatically logged out.