Skip to main content

In-app Purchase Integration

Last updated on

Overview

AccelByte Gaming Services (AGS) Starter In-app Purchase Integration enables you to track player purchases and sync entitlements from third-party platforms such as PlayStation or Xbox. This way, any In-app items that are sold and granted to players from third-party platforms will also be transferred to our AccelByte Gaming Services (AGS) Starter platform, so long as our platform has the proper item IDs set up. Items that can be sold include coins, bundles, loot boxes, and in-game items (consumable and durable).

Supported Platforms

Here's a table showing the platforms we support and the features each platform offers:

Platform3rd-party> LoginIn-app PurchasesEntitlements
AppleNYY
Google PlayNYY
Epic Online ServicesYYY
PlayStation 4 + 5YYY
SteamYYY
Xbox LiveYYY
TwitchYYY

Manage In-app Purchase Integration in the Admin Portal

Add a New Configuration

Before continuing on to the following steps, make sure you have registered the PS4 Client to our IAM.

  1. In the desired game title, expand the E-Commerce section, click In-app Purchase, and select Third-party Store Integrations.

  2. Select the platform you wish to configure from the tabs at the top and click Add Configuration.

    Add a New In-app Purchase Configuration

    NOTE

    Each game title can have only one configuration per third-party platform.

  3. The Add Configuration form will appear. This will be different for each platform.

    PSN

    Add a New In-app Purchase Configuration

    • Select the Environment, e.g. sp-int for Development, prod-qa for QA, or np for Live Environment.

    Make sure you have also created a service in PlayStation Store Delivered Content inside your AppServer.

    Xbox

    Add a New In-app Purchase Configuration

    Steam

    Make sure you’ve created an item with the same SKU in both the Steam Store and your AccelByte Gaming Services (AGS) Starter Platform namespace. Once you've done this, input the Publisher Authentication Key.

    Add a New In-app Purchase Configuration

    Epic

    Input the Sandbox ID of your Epic Developers account.

    Add a New In-app Purchase Configuration

    Google Play

    Make sure you’ve created your android app and set the Product ID to Publish your app in the Google Play store.

    Add a New In-app Purchase Configuration

    Apple

    Make sure you’ve created an item in App Store Connect. Use the SKU/Item ID of this item as a Product ID to sync with your App in your namespace’s store.

    Add a New In-app Purchase Configuration

    • Input the Bundle ID.
    • Input the Password with the App-Specific Shared Secret found in your item’s details in App Store Connect.
  4. Once your configuration is complete, the information you have entered will be visible under the Configuration Details section of the relevant platform. You can also edit or remove configurations on this page.

Change Your Business Partner Certificate

  1. In your desired game title, expand the E-Commerce section, click In-app Purchase, and select Third-party Store Integrations. Click the Xbox tab.

  2. In the Configuration Details window, click Edit next to Business Partner Certificate.

    Change Business Partner Certificate

  3. The Change Business Partner Certificate form will appear. Fill in the required fields:

    Change Business Partner Certificate

    • Upload your Business Partner Certificate in .pkf format.
    • Input your Certificate Password.

Integrate In-app Purchase using SDK

Sync Durable Entitlement

Epic Games

FString EpicGameJwtToken = TEXT("Some-token-value");

FRegistry::Entitlement.SyncEpicGameDurableItems(EpicGameJwtToken,
FVoidHandler::CreateLambda([&]()
{
UE_LOG(LogAccelByte, Log, TEXT("Success"));
}),
FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogAccelByte, Error, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);
});

Xbox

FAccelByteModelsXBoxDLCSync XBoxDLCSyncToken;
XBoxDLCSyncToken.XstsToken = "XBox Xsts token from XBox One Manager sample apps";

FRegistry::Entitlement.SyncXBoxDLC(XBoxDLCSyncToken, FVoidHandler::CreateLambda([&bSyncDone]()
{
UE_LOG(LogAccelByte, Log, TEXT(" Success"));
}), FErrorHandler::CreateLambda([&bSyncDone](int32 ErrorCode, const FString& ErrorMessage)
{
bSyncDone = true;
UE_LOG(LogAccelByte, Error, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);

}));

Third-Party Entitlement Consumption

void Entitlement::ConsumeUserEntitlement(FString const& EntitlementId, int32 const& UseCount, THandler<FAccelByteModelsEntitlementInfo> const& OnSuccess, FErrorHandler const& OnError,
TArray<FString> Options, FString const& RequestId )
{
FReport::Log(FString(__FUNCTION__));

FAccelByteModelsConsumeUserEntitlementRequest ConsumeUserEntitlementRequest;
ConsumeUserEntitlementRequest.UseCount = UseCount;
ConsumeUserEntitlementRequest.Options = Options;
ConsumeUserEntitlementRequest.RequestId = RequestId;

FString Url = FString::Printf(TEXT("%s/public/namespaces/%s/users/%s/entitlements/%s/decrement"), *SettingsRef.PlatformServerUrl, *CredentialsRef.GetNamespace(), *CredentialsRef.GetUserId(), *EntitlementId);

FString Content;
TSharedPtr<FJsonObject> Json = FJsonObjectConverter::UStructToJsonObject(ConsumeUserEntitlementRequest);
FAccelByteUtilities::RemoveEmptyStrings(Json);
TSharedRef<TJsonWriter<>> const Writer = TJsonWriterFactory<>::Create(&Content);
FJsonSerializer::Serialize(Json.ToSharedRef(), Writer);


HttpClient.ApiRequest("PUT", Url, {}, Content, OnSuccess, OnError);
}