bSupportsInAppPurchasing

bSupportsInAppPurchasing

#Overview

name: bSupportsInAppPurchasing

The value of this variable can be defined or overridden in .ini config files. 2 .ini config files referencing this setting variable.

It is referenced in 4 C++ source files. Also referenced in 1 C# build file meaning it may affect the build system logic.

#Summary

#Usage in the C++ source code

The purpose of bSupportsInAppPurchasing is to enable or disable in-app purchasing functionality within the game or application. This setting variable is primarily used for configuring the online subsystem’s store capabilities across different platforms.

This setting variable is relied upon by several Unreal Engine subsystems and plugins, specifically:

  1. OnlineSubsystemGameCircle (for Amazon GameCircle)
  2. OnlineSubsystemGooglePlay (for Android)
  3. OnlineSubsystemIOS (for iOS)
  4. Android JNI wrapper (for Google Play Billing)

The value of this variable is typically set in the engine configuration file (GEngineIni). It can be found under different sections depending on the platform:

In the iOS implementation, there’s an additional variable “bSupportInAppPurchasing” (note the missing ’s’ in “Support”) that is also checked. The iOS version returns true if either of these variables is true.

This variable interacts with platform-specific in-app purchase APIs and methods. For example, in the Android JNI wrapper, it determines whether certain Java methods related to in-app purchases should be considered optional.

Developers must be aware that:

  1. This setting needs to be properly configured in the engine initialization file for the target platform.
  2. Enabling this feature may require additional setup and configuration in the respective app stores.
  3. The exact behavior and implementation can vary across different platforms.

Best practices when using this variable include:

  1. Ensure it’s correctly set for each target platform in the appropriate configuration section.
  2. Implement proper error handling and fallback mechanisms in case in-app purchases are not supported or enabled.
  3. Test the in-app purchase functionality thoroughly on each target platform.
  4. Be aware of and comply with the policies and guidelines for in-app purchases on each platform’s app store.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/Android/BaseAndroidEngine.ini:7, section: [OnlineSubsystemGooglePlay.Store]

Location: <Workspace>/Engine/Config/IOS/BaseIOSEngine.ini:78, section: [OnlineSubsystemIOS.Store]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Online/Android/OnlineSubsystemGameCircle/Source/OnlineSubsystemGameCircle/Private/OnlineSubsystemGameCircle.cpp:182

Scope (from outer to inner):

file
function     bool FOnlineSubsystemGameCircle::IsInAppPurchasingEnabled

Source code excerpt:

{
	bool bEnabledIAP = false;
	GConfig->GetBool(TEXT("/Script/GameCircleRuntimeSettings.GameCircleRuntimeSettings"), TEXT("bSupportsInAppPurchasing"), bEnabledIAP, GEngineIni);
	return bEnabledIAP;
}

std::string FOnlineSubsystemGameCircle::ConvertFStringToStdString(const FString& InString)
{
	int32 SrcLen  = InString.Len() + 1;

#Loc: <Workspace>/Engine/Plugins/Online/Android/OnlineSubsystemGooglePlay/Source/Private/OnlineSubsystemGooglePlay.cpp:215

Scope (from outer to inner):

file
function     bool FOnlineSubsystemGooglePlay::IsInAppPurchasingEnabled

Source code excerpt:

bool FOnlineSubsystemGooglePlay::IsInAppPurchasingEnabled()
{
	bool bSupportsInAppPurchasing = false;
	GConfig->GetBool(TEXT("OnlineSubsystemGooglePlay.Store"), TEXT("bSupportsInAppPurchasing"), bSupportsInAppPurchasing, GEngineIni);

	FPlatformMisc::LowLevelOutputDebugStringf(TEXT("FOnlineSubsystemGooglePlay::IsInAppPurchasingEnabled %d"), bSupportsInAppPurchasing);
	return bSupportsInAppPurchasing;
}

void FOnlineSubsystemGooglePlay::QueueAsyncTask(FOnlineAsyncTask* AsyncTask)
{
	check(OnlineAsyncTaskThreadRunnable);
	OnlineAsyncTaskThreadRunnable->AddToInQueue(AsyncTask);

#Loc: <Workspace>/Engine/Plugins/Online/IOS/OnlineSubsystemIOS/Source/Private/OnlineSubsystemIOS.cpp:325

Scope (from outer to inner):

file
function     bool FOnlineSubsystemIOS::IsInAppPurchasingEnabled

Source code excerpt:

{
	bool bEnableIAP = false;
	GConfig->GetBool(TEXT("OnlineSubsystemIOS.Store"), TEXT("bSupportsInAppPurchasing"), bEnableIAP, GEngineIni);
	
	bool bEnableIAP1 = false;
	GConfig->GetBool(TEXT("OnlineSubsystemIOS.Store"), TEXT("bSupportInAppPurchasing"), bEnableIAP1, GEngineIni);
	return bEnableIAP || bEnableIAP1;
}

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/Android/AndroidJNI.cpp:219

Scope (from outer to inner):

file
function     void FJavaWrapper::FindGooglePlayBillingMethods

Source code excerpt:

{
	// In app purchase functionality
	bool bSupportsInAppPurchasing = false;
	if (!GConfig->GetBool(TEXT("OnlineSubsystemGooglePlay.Store"), TEXT("bSupportsInAppPurchasing"), bSupportsInAppPurchasing, GEngineIni))
	{
		FPlatformMisc::LowLevelOutputDebugString(TEXT("[JNI] - Failed to determine if app purchasing is enabled!"));
	}
	bool bIsStoreOptional = !bSupportsInAppPurchasing;
	
	JavaStringClass = FindClassGlobalRef(Env, "java/lang/String", false);
	AndroidThunkJava_IapSetupService = FindMethod(Env, GoogleServicesClassID, "AndroidThunkJava_IapSetupService", "(Ljava/lang/String;)V", bIsStoreOptional);
	AndroidThunkJava_IapQueryInAppPurchases = FindMethod(Env, GoogleServicesClassID, "AndroidThunkJava_IapQueryInAppPurchases", "([Ljava/lang/String;)Z", bIsStoreOptional);
	AndroidThunkJava_IapBeginPurchase = FindMethod(Env, GoogleServicesClassID, "AndroidThunkJava_IapBeginPurchase", "([Ljava/lang/String;Ljava/lang/String;)Z", bIsStoreOptional);
	AndroidThunkJava_IapIsAllowedToMakePurchases = FindMethod(Env, GoogleServicesClassID, "AndroidThunkJava_IapIsAllowedToMakePurchases", "()Z", bIsStoreOptional);

#References in C# build files

This variable is referenced in the following C# build files:

Location: <Workspace>/Engine/Source/Programs/UnrealBuildTool/Platform/Android/UEDeployAndroid.cs:2644

			bool bPackageForMetaQuest = IsPackagingForMetaQuest(Ini);
			bool bEnableIAP = false;
			Ini.GetBool("OnlineSubsystemGooglePlay.Store", "bSupportsInAppPurchasing", out bEnableIAP);
			bool bShowLaunchImage = false;
			Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bShowLaunchImage", out bShowLaunchImage);
			string AndroidGraphicsDebugger;
			Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "AndroidGraphicsDebugger", out AndroidGraphicsDebugger);
			bool bSupportAdMob = true;
			Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bSupportAdMob", out bSupportAdMob);