メインコンテンツまでスキップ

エンタイトルメントを管理する

Last updated on September 27, 2024

Overview

The AccelByte Gaming Services (AGS) Entitlements service manages individual player ownership of items that they have purchased or otherwise received. You can use Entitlements to grant or revoke instances of items to or from players. Item creation and configuration is handled in Stores.

There are two types of entitlements:

  • Durable entitlements: are non-stackable and permanent. They do not disappear after use. Examples of durable entitlements include, game skins, weapons, unlockable characters, and many other possibilities.
  • Consumables: disappear after use. Consumables can be stackable or non-stackable; multiple stackable items will be under the same entitlement whereas multiple non-stackable items will each have their own entitlement, even if they result from identical items. Examples of consumable entitlements include: ammo, potions, and food.

Entitlement management lets you see the entitlement history of a particular player, or the player who owns a particular entitlement.

This article walks you through how to:

  • Grant an Entitlement to a Player
  • Search for a Player's Entitlements
  • Disable a Player's Entitlement
  • Enable a Player's Entitlement
  • Revoke a Player's Entitlement
  • List a Player's Entitlement History

Prerequisites

  • Access to the AGS Admin Portal
  • You have created the appropriate namespaces

Grant an entitlement to a player

  1. On the Admin Portal sidebar, go to Commerce > Entitlements > User Entitlements.

  2. On the User Entitlements page, click on the Grant Item button.

    Grant Item

    The Grant Item form will open.

    Grant Item Form

  3. Fill in the required fields:

    • In the Add Item field, search for the item you want to grant to a player.
    • Input the User ID of the player that you want to grant an entitlement to, in the Select User field. Then, click Add.
    • Input the Quantity of the item you want to grant to the player.
  4. Once you have completed all the fields, click the Grant button. The new entitlement will be granted to the player and will appear in the player's account.

Search for a player's entitlements

  1. On the Admin Portal sidebar, go to Commerce > Entitlements > User Entitlements.

  2. On the User Entitlements page, search for a player using their email address, user ID, or full entitlement ID.

    Search entitlements

    The "Full Entitlement ID" search option will show the specific entitlement based on the entitlement ID which will display the user ID of the owning player

  3. (Optional) Apply filters to your search if you're searching using the player's user ID or email address. You can filter the results based on the Entitlement Class and Features Name.

    • Entitlement Class: filters results based on their item type. You can choose All, App, Entitlement, Code, Subscription, Media, Option Box, and Loot Box.

      :::note The Entitlement option in the Entitlement Class field gives you the option to choose an item type other than App, Code, Subscription, Media, or Option Box. To read more about item types, refer to the Monetization guide. :::

    • Features Name: filter results based on their features. You can enter multiple feature names by pressing Enter then adding another feature. To read more about adding feature names, including adding a feature to an item, see Set up a store.

Disable a player's entitlement

  1. On the Admin Portal sidebar, go to Commerce > Entitlements > User Entitlements.

  2. On the User Entitlements page, search for the player using their email address, user ID, or full entitlement ID.

  3. In the selected record, click the More Actions (...) icon under the Action column, then click Disable.

    Disable player entitlements

  4. The Disable Entitlement form will open. Click Confirm.

The Status of the item will be changed to Inactive in the Admin Portal, and the item will be hidden from the player and unusable by them.

Disable player entitlements

Enable a player's entitlement

  1. On the Admin Portal sidebar, go to Commerce > Entitlements > User Entitlements.

  2. On the User Entitlements page, search for the player using their email address, user ID, or full entitlement ID.

  3. In the selected record, click the More Actions (...) icon under the Action column, then click Enable.

    Enable player entitlements

  4. The Enable Entitlement form will open. Click Confirm.

The Status of the item will be changed to Active in the Admin Portal and the item will be again usable by the player.

Active player entitlements

Revoke a player's entitlement

  1. On the Admin Portal sidebar, go to Commerce > Entitlements > User Entitlements.

  2. On the User Entitlements page, search for the player using their email address, user ID, or full entitlement ID.

  3. In the selected record, click the More Actions (...) icon under the Action row, and then click Revoke.

    Revoke player entitlements

  4. The Revoke Entitlement form appears. Click Confirm.

In the Admin Portal, the Status of the item will be changed to Revoked and the item will be removed from the player's account.

List a Player's Entitlement History

Entitlement history is a list of the historical status of an entitlement. For example , it was initially granted and later revoked. You can see the history of a player's entitlements through the AGS Admin Portal. To do so, follow the steps below:

  1. On the Admin Portal sidebar, go to Commerce > Entitlements > User Entitlements.

  2. On the User Entitlements page, search for the player using their email address, user ID, or full entitlement ID.

  3. Choose the record you want to view from the list of entitlements by clicking View.

  4. The Entitlement History pop-up displays the entitlement history in descending order.

Implement Entitlements with the SDKs

An entitlement is granted automatically when a player places an order for an item. The entitlement is added to their account.

Check a player's entitlements

This section covers how to check the entitlements of players with and without subscriptions.

For players with a subscription

If your game or platform offers a subscription to your players, you can use the following code to check a player's entitlements and subscription plan.

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient("key"); 

FString EntitlementName = "Entitlement";
FString ItemId = "ItemId";
TArray<FString> Features = { "feature1" };
int Offset = 0;
int Limit = 20;
ApiClient->Entitlement.QueryUserEntitlements(EntitlementName, ItemId, Offset, Limit
, THandler<FAccelByteModelsEntitlementPagingSlicedResult>::CreateLambda(
[=](const FAccelByteModelsEntitlementPagingSlicedResult& Result)
{
UE_LOG(LogTemp Log, TEXT(" Success"));
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Error, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage)
}
, EAccelByteEntitlementClass::NONE
, EAccelByteAppType::NONE);

For players without a subscription

If you don't offer subscriptions, you can use the following code to check a player's entitlements. To get all of the player's entitlements, set the EntitlementName and ItemId to "" (i.e., an empty string).

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient("key");

FString EntitlementName = "";
FString ItemId = "";
int32 Offset = 0;
int32 Limit = 20;

ApiClient->Entitlement.QueryUserEntitlements(EntitlementName, ItemId, Offset, Limit,
THandler<FAccelByteModelsEntitlementPagingSlicedResult>::CreateWeakLambda(this, [](const FAccelByteModelsEntitlementPagingSlicedResult& Result)
{
UE_LOG(LogTemp, Log, TEXT("Query User Entitlements Success!"));
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Error, TEXT("Query User Entitlements Failed, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}),
EAccelByteEntitlementClass::NONE,
EAccelByteAppType::NONE
);

The response object from QueryUserEntitlements() contains an array of entitlement info that includes all entitlement-related IDs. This includes EntitlementId, ItemId and SKUId. These IDs can later be used to get item or specific entitlement information.

注記

In some cases, we recommend using the SKU-related functions if you have your own item ID that isn't namespace and environment dependent. You can define the SKU ID manually in the Admin Portal, unlike ItemId which is generated automatically. See our Create an Item documentation for more details.

Check redeemed items in entitlements

To check redeemed items, you can call getUserEntitlementById from the Entitlement API. The response includes itemSnapshot which contains detailed information regarding the redeemed item. When the entitlement is a result of a redeem code process, the entitlement source shown in the response should be `REDEEM_CODE.

FString EntitlementId = "EntitlementId"
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient("key");

ApiClient->Entitlement.Entitlement.GetUserEntitlementById(EntitlementId, THandler<FAccelByteModelsEntitlementInfo>::CreateLambda([](const FAccelByteModelsEntitlementInfo& Result)
{
UE_LOG(LogTemp, Log, TEXT("The redeemed item ID: %s with name %s"), *Result.ItemId, *Result.ItemSnapshot.Name);
}), FErrorHandler::CreateLambda([](int32 Code, const FString& Message){}));

Get user entitlements by SKU

注記

This function is not yet supported by our SDKs, but the endpoint is available in the API.

Third-party item entitlement synchronization

This section covers how to synchronize entitlements in third-party platforms.

Apple

To synchronize Apple entitlements, use this function:

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient("key");

// Log in with Apple account
FString AppleAuthToken = "Token-from-apple";
ApiClient->User.LoginWithOtherPlatform(EAccelBytePlatformType::Apple, AppleAuthToken), FVoidHandler::CreateLambda([&]()
{
UE_LOG(LogTemp, Log, TEXT(" Success"));
// Do something when successful
}), FErrorHandler::CreateLambda([&](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Error, TEXT(" Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);
// Do something when an error occurs
}));

...

// Sync Apple item entitlement
bSyncDone = false;
FAccelByteModelsPlatformSyncMobileApple SyncReqApple;
SyncReqApple.ProductId = "testProductIdInvalid";
SyncReqApple.TransactionId = "testTransactionIdInvalid";
SyncReqApple.ReceiptData = "testReceiptDataInvalid";
SyncReqApple.ExcludeOldTransactions = true;
SyncReqApple.Region = "ID";
SyncReqApple.Language = "en";
ApiClient->Entitlement.SyncMobilePlatformPurchaseApple(SyncReqApple
, FVoidHandler::CreateLambda(
[=]()
{
UE_LOG(LogTemp, Log, TEXT(" Success"));
})
, FErrorHandler::CreateLambda(
[](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogAccelByteEcommerceTest, Log, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);
})
);

Google

To synchronize Google entitlements, use this function:

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient("key");
// Log in with Google account
FString GoogleAuthToken = "Token-from-Google";
ApiClient->User.LoginWithOtherPlatform(EAccelBytePlatformType::Google, GoogleAuthToken ), FVoidHandler::CreateLambda([&]()
{
UE_LOG(LogTemp, Log, TEXT(" Success"));
// Do something when successful
}), FErrorHandler::CreateLambda([&](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Error, TEXT(" Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);
// Do something when an error occurs
}));

...

FAccelByteModelsItemInfo itemInfo;
ApiClient->Item.GetItemBySku(TEXT("sku-number")
, TEXT("en")
, TEXT("US")
, THandler<FAccelByteModelsItemInfo>::CreateLambda(
[=](const FAccelByteModelsItemInfo& Response)
{
itemInfo = Response;
})
,FErrorHandler::CreateLambda(
[&bGetItemDone](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Log, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);
})
);

...

FAccelByteModelsPlatformSyncMobileGoogle SyncReqGoogle;
SyncReqGoogle.OrderId = TEXT("test-OrderId");
SyncReqGoogle.PackageName = TEXT("test-packageName");
SyncReqGoogle.ProductId = TEXT("testProductId");
SyncReqGoogle.PurchaseTime = 0;
SyncReqGoogle.PurchaseToken = TEXT("test.PurchaseToken");
if (bGetItemSuccess == true && itemInfo.EntitlementType == EAccelByteEntitlementType::DURABLE)
{
SyncReqGoogle.AutoAck = true;
}
else
{
SyncReqGoogle.AutoAck = false;
}
SyncReqGoogle.Region = TEXT("ID");
SyncReqGoogle.Language = TEXT("en");

if (!GoogleConfig.ApplicationName.IsEmpty())
{
ApiClient->Entitlement.SyncMobilePlatformPurchaseGooglePlay(SyncReqGoogle
, THandler<FAccelByteModelsPlatformSyncMobileGoogleResponse>::CreateLambda(
[&bSyncDone](FAccelByteModelsPlatformSyncMobileGoogleResponse const& response)
{
UE_LOG(LogTemp, Log, TEXT(" Success"));
if (response.NeedConsume)
UE_LOG(LogTemp, Log, TEXT("The item is consumable"));
if (!response.NeedConsume)
UE_LOG(LogTemp, Log, TEXT("The item is durable"));
})
, FErrorHandler::CreateLambda(
[&bSyncDone](int32 ErrorCode, const FString& ErrorMessage)
{
bSyncDone = true;
UE_LOG(LogTemp, Log, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);
})
);
}

Twitch

To synchronize Twitch entitlements, use this function:

FString TwitchAuthToken = "Token-from-twitch";
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient("key");

// Log in with Apple account
ApiClient->User.LoginWithOtherPlatform(EAccelBytePlatformType::Twitch, TwitchAuthToken), FVoidHandler::CreateLambda([&]()
{
UE_LOG(LogTemp, Log, TEXT(" Success"));
// Do something when successful
}), FErrorHandler::CreateLambda([&](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Error, TEXT(" Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);
// Do something when an error occurs
}));

...

// Sync Twitch entitlement
FAccelByteModelsTwitchDropEntitlement model;
model.GameId = TEXT("123456"); // Your gameId
model.Region = TEXT("US");
model.Language = TEXT("en-US");
ApiClient->Entitlement.SyncTwitchDropEntitlement(model,
FVoidHandler::CreateLambda([&]()
{
UE_LOG(LogTemp, Log, TEXT(" Success"));
// Do something when successful
}),FErrorHandler::CreateLambda([&](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Warning, TEXT(" Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);
// Do something when an error occurs
}));