エンタイトルメントを管理する
注釈:本資料はAI技術を用いて翻訳されています。
概要
AccelByte Gaming Services (AGS) エンタイトルメントサービスは、プレイヤーが購入または受け取ったアイテムの個別の所有権を管理します。エンタイトルメントを使用して、プレイヤーにアイテムのインスタンスを付与または取り消すことができます。アイテムの作成と設定はストアで処理されます。
エンタイトルメントには2つのタイプがあります:
- 永続エンタイトルメント: スタック不可で永続的です。使用後も消えません。永続エンタイトルメントの例には、ゲームスキン、武器、アンロック可能なキャラクター、その他多くの可能性が含まれます。
- 消耗品: 使用後に消えます。消耗品はスタック可能またはスタック不可です。複数のスタック可能なアイテムは同じエンタイトルメントの下にありますが、複数のスタック不可のアイテムは、同一のアイテムから生成された場合でも、それぞれ独自のエンタイトルメントを持ちます。消耗品エンタイトルメントの例には、弾薬、ポーション、食料が含まれます。
エンタイトルメント管理では、特定のプレイヤーのエンタイトルメント履歴、または特定のエンタイトルメントを所有するプレイヤーを確認できます。
この記事では、以下の方法について説明します:
- プレイヤーにエンタイトルメントを付与する
- プレイヤーのエンタイトルメントを検索する
- プレイヤーのエンタイトルメントを無効にする
- プレイヤーのエンタイトルメントを有効にする
- プレイヤーのエンタイトルメントを取り消す
- プレイヤーのエンタイトルメント履歴を一覧表示する
前提条件
- AGS管理者ポータルへのアクセス
- 適切なネームスペースを作成済みであること
プレイヤーにエンタイトルメントを付与する
-
管理者ポータルのサイドバーで、Commerce > Entitlements > User Entitlementsに移動します。
-
User Entitlementsページで、Grant Itemボタンをクリックします。

Grant Itemフォームが開きます。

-
必須フィールドに入力します:
- Add Itemフィールドで、プレイヤーに付与するアイテムを検索します。
- Select Userフィールドに、エンタイトルメントを付与するプレイヤーのUser IDを入力します。次に、Addをクリックします。
- プレイヤーに付与するアイテムのQuantityを入力します。
-
すべてのフィールドに入力したら、Grantボタンをクリックします。新しいエンタイトルメントがプレイヤーに付与され、プレイヤーのアカウントに表示されます。
プレイヤーのエンタイトルメントを検索する
-
管理者ポータルのサイドバーで、Commerce > Entitlements > User Entitlementsに移動します。
-
User Entitlementsページで、メールアドレス、ユーザーID、または完全なエンタイトルメントIDを使用してプレイヤーを検索します。

「Full Entitlement ID」検索オプションは、エンタイトルメントIDに基づいて特定のエンタイトルメントを表示し、所有プレイヤーのユーザーIDを表示します
-
(オプション) プレイヤーのユーザーIDまたはメールアドレスを使用して検索する場合は、検索にフィルターを適用します。Entitlement ClassとFeatures Nameに基づいて結果をフィルタリングできます。
-
Entitlement Class: アイテムタイプに基づいて結果をフィルタリングします。All、App、Entitlement、Code、Subscription、Media、Option Box、Loot Boxから選択できます。
注記Entitlement ClassフィールドのEntitlementオプションを使用すると、App、Code、Subscription、Media、Option Box以外のアイテムタイプを選択できます。アイテムタイプの詳細については、収益化ガイドを参照してください。
-
Features Name: 機能に基づいて結果をフィルタリングします。Enterキーを押してから別の機能を追加することで、複数の機能名を入力できます。アイテムへの機能の追加を含む機能名の追加の詳細については、ストアのセットアップを参照してください。
-
プレイヤーのエンタイトルメントを無効にする
-
管理者ポータルのサイドバーで、Commerce > Entitlements > User Entitlementsに移動します。
-
User Entitlementsページで、メールアドレス、ユーザーID、または完全なエンタイトルメントIDを使用してプレイヤーを検索します。
-
選択したレコードで、Action列の下にある**More Actions (...)**アイコンをクリックし、Disableをクリックします。

-
Disable Entitlementフォームが開きます。Confirmをクリックします。
アイテムのステータスが管理者ポータルでInactiveに変更され、アイテムはプレイヤーから非表示になり、使用できなくなります。

プレイヤーのエンタイトルメントを有効にする
-
管理者ポータルのサイドバーで、Commerce > Entitlements > User Entitlementsに移動します。
-
User Entitlementsページで、メールアドレス、ユーザーID、または完全なエンタイトルメントIDを使用してプレイヤーを検索します。
-
選択したレコードで、Action列の下にある**More Actions (...)**アイコンをクリックし、Enableをクリックします。

-
Enable Entitlementフォームが開きます。Confirmをクリックします。
アイテムのステータスが管理者ポータルでActiveに変更され、アイテムは再びプレイヤーが使用できるようになります。

プレイヤーのエンタイトルメントを取り消す
-
管理者ポータルのサイドバーで、Commerce > Entitlements > User Entitlementsに移動します。
-
User Entitlementsページで、メールアドレス、ユーザーID、または完全なエンタイトルメントIDを使用してプレイヤーを検索します。
-
選択したレコードで、Action行の下にある**More Actions (...)**アイコンをクリックし、Revokeをクリックします。

-
Revoke Entitlementフォームが表示されます。Confirmをクリックします。
管理者ポータルで、アイテムのステータスがRevokedに変更され、アイテムはプレイヤーのアカウントから削除されます。
プレイヤーのエンタイトルメント履歴を一覧表示する
エンタイトルメント履歴は、エンタイトルメントの履歴ステータスのリストです。たとえば、最初に付与され、後で取り消されました。AGS管理者ポータルを通じて、プレイヤーのエンタイトルメントの履歴を確認できます。これを行うには、以下の手順に従います:
-
管理者ポータルのサイドバーで、Commerce > Entitlements > User Entitlementsに移動します。
-
User Entitlementsページで、メールアドレス、ユーザーID、または完全なエンタイトルメントIDを使用してプレイヤーを検索します。
-
エンタイトルメントのリストから表示したいレコードを選択し、Viewをクリックします。
-
Entitlement Historyポップアップに、エンタイトルメント履歴が降順で表示されます。
SDKでエンタイトルメントを実装する
プレイヤーがアイテムの注文を行うと、エンタイトルメントが自動的に付与されます。エンタイトルメントはプレイヤーのアカウントに追加されます。
プレイヤーのエンタイトルメントを確認する
このセクションでは、サブスクリプションありとなしのプレイヤーのエンタイトルメントを確認する方法について説明します。
サブスクリプションありのプレイヤーの場合
ゲームまたはプラットフォームがプレイヤーにサブスクリプションを提供している場合、次のコードを使用してプレイヤーのエンタイトルメントとサブスクリプションプランを確認できます。
- Unreal SDK
- Unity SDK
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->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);
var entitlements = AccelByteSDK.GetClientRegistry().GetApi().GetEntitlement();
string entitlementName = "Entitlement";
string itemId = "ItemId";
string[] features = new string[] { "feature1" };
int offset = 0;
int limit = 20;
entitlements.QueryUserEntitlements(entitlementName, itemId, offset, limit, result =>
{
if (result.IsError)
{
// Handle API failure or error here
Debug.Log($"Error: {result.Error.Message}");
return;
}
// Handle API success here
},
EntitlementClazz.NONE,
EntitlementAppType.NONE,
features);
string entitlementName = "<entitlement>";
string itemId = "<item-id>";
string[] features = new[] { "feature1" };
string userId = "<user-id>";
var response = sdk.Platform.Entitlement.QueryUserEntitlementsOp
.SetEntitlementName(entitlementName)
.SetItemId(new List<string>() { itemId })
.SetFeatures(new List<string>(features))
.SetOffset(0)
.SetLimit(20)
.Execute(sdk.Namespace, userId);
if (response != null)
{
//do something if success
}
entitlementService := &platform.EntitlementService{
Client: factory.NewPlatformClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
userId := "myuserid"
entitlementName := "entitlementName"
features := []string{"feature1"}
itemId := []string{"itemId"}
limit := int32(20)
offset := int32(0)
input := &entitlement.QueryUserEntitlementsParams{
Namespace: namespace,
UserID: userId,
EntitlementName: &entitlementName,
Features: features,
ItemID: itemId,
Limit: &limit,
Offset: &offset,
}
result, err := entitlementService.QueryUserEntitlementsShort(input)
final Entitlement entitlementWrapper = new Entitlement(sdk);
String entitlementName = "<entitlement>";
List<String> itemId = Arrays.asList("<item-id>");
List<String> features = Arrays.asList("feature1");
String userId = "<user-id>";
EntitlementPagingSlicedResult response;
try {
response = entitlementWrapper.queryUserEntitlements(QueryUserEntitlements.builder()
.namespace("<namespace>")
.userId(userId)
.entitlementName(entitlementName)
.itemId(itemId)
.features(features)
.offset(0)
.limit(20)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if success
}
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_query_user_entitlements(
entitlement_name="entitlementName",
features=["feature1"],
item_id="itemId",
limit=20,
offset=0,
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
サブスクリプションなしのプレイヤーの場合
サブスクリプションを提供していない場合は、次のコードを使用してプレイヤーのエンタイトルメントを確認できます。プレイヤーのすべてのエンタイトルメントを取得するには、EntitlementNameとItemIdを""(つまり、空の文字列)に設定します。
- Unreal SDK
- Unity SDK
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->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
);
var entitlements = AccelByteSDK.GetClientRegistry().GetApi().GetEntitlement();
string entitlementName = "";
string itemId = "";
int offset = 0;
int limit = 20;
entitlements.QueryUserEntitlements(entitlementName, itemId, offset, limit, result =>
{
if (result.IsError)
{
// Handle API failure or error here
Debug.Log($"Error: {result.Error.Message}");
return;
}
// Handle API success here
},
EntitlementClazz.NONE,
EntitlementAppType.NONE);
string userId = "<user-id>";
var response = sdk.Platform.Entitlement.QueryUserEntitlementsOp
.SetOffset(0)
.SetLimit(20)
.Execute(sdk.Namespace, userId);
if (response != null)
{
//do something if success
}
entitlementService := &platform.EntitlementService{
Client: factory.NewPlatformClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
userId := "myuserid"
limit := int32(20)
offset := int32(0)
input := &entitlement.QueryUserEntitlementsParams{
Namespace: namespace,
UserID: userId,
Limit: &limit,
Offset: &offset,
}
result, err := entitlementService.QueryUserEntitlementsShort(input)
final Entitlement entitlementWrapper = new Entitlement(sdk);
String userId = "<user-id>";
EntitlementPagingSlicedResult response;
try {
response = entitlementWrapper.queryUserEntitlements(QueryUserEntitlements.builder()
.namespace("<namespace>")
.userId(userId)
.features(features)
.offset(0)
.limit(20)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if success
}
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_query_user_entitlements(
limit=20,
offset=0,
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
QueryUserEntitlements()からのレスポンスオブジェクトには、すべてのエンタイトルメント関連IDを含むエンタイトルメント情報の配列が含まれています。これには、EntitlementId、ItemId、SKUIdが含まれます。これらのIDは、後でアイテムまたは特定のエンタイトルメント情報を取得するために使用できます。
場合によっては、ネームスペースや環境に依存しない独自のアイテムIDがある場合は、SKU関連の関数を使用することをお勧めします。ItemIdは自動的に生成されますが、SKU IDは管理者ポータルで手動で定義できます。詳細については、アイテムの作成に関するドキュメントを参照してください。
エンタイトルメントで引き換えられたアイテムを確認する
引き換えられたアイテムを確認するには、Entitlement APIからgetUserEntitlementByIdを呼び出すことができます。レスポンスには、引き換えられたアイテムに関する詳細情報を含むitemSnapshotが含まれています。エンタイトルメントがコード引き換えプロセスの結果である場合、レスポンスに表示されるエンタイトルメントソースはREDEEM_CODEである必要があります。
- Unreal SDK
- Unity SDK
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FString EntitlementId = "EntitlementId"
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->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){}));
var entitlements = AccelByteSDK.GetClientRegistry().GetApi().GetEntitlement();
string entitlementId = "entitlementId";
entitlements.GetUserEntitlementById(entitlementId, result =>
{
if (result.IsError)
{
// Handle API failure or error here
Debug.Log($"Error: {result.Error.Message}");
return;
}
// Handle API successful here
});
string entitlementId = "entitlementId";
string userId = "<user-id>";
var response = sdk.Platform.Entitlement.PublicGetUserEntitlementOp
.Execute(entitlementId, sdk.Namespace, userId);
if (response != null)
{
//do something if success
}
entitlementService := &platform.EntitlementService{
Client: factory.NewPlatformClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
entitlementId := "entitlementId"
namespace := "mygame"
userId := "myuserid"
input := &entitlement.PublicGetUserEntitlementParams{
EntitlementID: entitlementId,
Namespace: namespace,
UserID: userId,
}
result, err := entitlementService.PublicGetUserEntitlementShort(input)
final Entitlement entitlementWrapper = new Entitlement(sdk);
String userId = "<user-id>";
String entitlementId = "entitlementId";
EntitlementInfo response;
try {
response = entitlementWrapper.publicGetUserEntitlement(PublicGetUserEntitlement.builder()
.namespace("<namespace>")
.userId(userId)
.entitlementId(entitlementId)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if success
}
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_get_user_entitlement(
entitlement_id="entitlementId",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
SKUでユーザーエンタイトルメントを取得する
この機能はまだSDKでサポートされていませんが、エンドポイントはAPIで利用可能です。
サードパーティアイテムエンタイトルメントの同期
このセクションでは、サードパーティプラットフォームでエンタイトルメントを同期する方法について説明します。
Apple
Appleエンタイトルメントを同期するには、この関数を使用します:
- Unreal SDK
- Unity SDK
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->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);
})
);
User user = AccelByteSDK.GetClientRegistry().GetApi().GetUser();
// Log in with Apple account
string AppleAuthCode = "apple-auth-code";
Result loginAppleResults = null;
user.LoginWithOtherPlatform(PlatformType.Apple, AppleAuthCode, result =>
{
loginAppleResults = result;
});
...
var entitlements = AccelByteSDK.GetClientRegistry().GetApi().GetEntitlement();
var platformSyncMobileApple = new PlatformSyncMobileApple()
{
excludeOldTransactions = false,
language = "en",
productId = "testProductId",
receiptData = "testReceiptData",
region = "US",
transactionId = "testTransactionId"
};
entitlements.SyncMobilePlatformPurchaseApple(platformSyncMobileApple, result =>
{
if (result.IsError)
{
// Handle API failure or error here
Debug.Log($"Error: {result.Error.Message}");
return;
}
// Handle API success here
});
string appleAuthCode = "<apple-auth-code>";
string userId = "<user-id>";
//login using apple auth code
sdk.LoginPlatform("apple", appleAuthCode);
sdk.Platform.IAP.PublicFulfillAppleIAPItemOp
.SetBody(new AppleIAPReceipt()
{
ExcludeOldTransactions = false,
Language = "en",
ProductId = "<test-product-id>",
ReceiptData = "<test-receipt-data>",
Region = "US",
TransactionId = "<test-transaction-id>"
})
.Execute(sdk.Namespace, userId);
tokenRepository := auth.DefaultTokenRepositoryImpl()
configRepository := auth.DefaultConfigRepositoryImpl()
oAuth20Service := &iam.OAuth20Service{
Client: factory.NewIamClient(auth.DefaultConfigRepositoryImpl()),
ConfigRepository: configRepository,
TokenRepository: tokenRepository,
}
authCode := "myauthcode"
inputLogin := &o_auth2_0.PlatformTokenGrantV3Params{
DeviceID: nil,
PlatformID: "apple",
PlatformToken: &authCode,
}
oAuth20Service.LoginPlatform(inputLogin)
iapService := &platform.IAPService{
Client: factory.NewPlatformClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
userId := "myuserid"
productId := "myproductid"
receiptData := "myreceiptdata"
transactionId := "mytransactionid"
body := platformclientmodels.AppleIAPReceipt {
ExcludeOldTransactions: false,
Language: "en",
ProductID: &productId,
ReceiptData: &receiptData,
Region: "US",
TransactionID: &transactionId,
}
input := &iap.PublicFulfillAppleIAPItemParams{
Body: &body,
Namespace: namespace,
UserID: userId,
}
err := iapService.PublicFulfillAppleIAPItemShort(input)
final AccelByteSDK sdk = new AccelByteSDK(httpClient, tokenRepository, configRepository);
...
String appleAuthCode = "<apple-auth-code>";
String userId = "<user-id>";
// Login using apple auth code
final boolean isLoginOk = sdk.loginPlatform("apple", appleAuthCode);
if (isLoginOk) {
final IAP iapWrapper = new IAP(sdk);
try {
AppleIAPReceipt reqBody = AppleIAPReceipt.builder()
.excludeOldTransactions(false)
.language("en")
.productId("<test-product-id>")
.receiptData("<test-receipt-data>")
.region("US")
.transactionId("<test-transaction-id>")
.build();
iapWrapper.publicFulfillAppleIAPItem(PublicFulfillAppleIAPItem.builder()
.namespace("<namespace>")
.userId(userId)
.body(reqBody)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if success
}
}
import accelbyte_py_sdk.api.platform as platform_service
import accelbyte_py_sdk.api.platform.models as platform_models
result, error = platform_service.public_fulfill_apple_iap_item(
body=platform_models.AppleIAPReceipt()
.with_product_id("testProductId")
.with_receipt_id("testReceiptData")
.with_transaction_id("testTransactionId")
.with_exclude_old_transactions(false)
.with_language("en")
.with_region("US"),
user_id="********************************",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
Google
Googleエンタイトルメントを同期するには、この関数を使用します:
- Unreal SDK
- Unity SDK
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->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);
})
);
}
Unity SDKガイドのGoogle Play向けコード実装手順に従ってください。
string authCode = "<google-auth-code>";
string userId = "<user-id>";
//login using google auth code
sdk.LoginPlatform("google", authCode);
//item entitlement type from google play store
string itemEntitlementType = "DURABLE";
bool autoAckValue = (itemEntitlementType == "DURABLE");
var response = sdk.Platform.IAP.PublicFulfillGoogleIAPItemOp
.SetBody(new GoogleIAPReceipt()
{
OrderId = "<test-order-id>",
PackageName = "<test-package-name>",
ProductId = "<test-product-id>",
Language = "en",
Region = "US",
PurchaseTime = 160388387672672,
PurchaseToken = "<test-purchase-token>",
AutoAck = autoAckValue
})
.Execute(sdk.Namespace, userId);
if (response != null)
{
//do something if success
}
tokenRepository := auth.DefaultTokenRepositoryImpl()
configRepository := auth.DefaultConfigRepositoryImpl()
oAuth20Service := &iam.OAuth20Service{
Client: factory.NewIamClient(auth.DefaultConfigRepositoryImpl()),
ConfigRepository: configRepository,
TokenRepository: tokenRepository,
}
authCode := "myauthcode"
inputLogin := &o_auth2_0.PlatformTokenGrantV3Params{
DeviceID: nil,
PlatformID: "google",
PlatformToken: &authCode,
}
oAuth20Service.LoginPlatform(inputLogin)
iapService := &platform.IAPService{
Client: factory.NewPlatformClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
userId := "myuserid"
orderId := "myorderid"
packageId := "mypackagename"
productId := "myproductid"
purchaseTime := int64(160388387672672)
purchaseToken := "mypurchasetoken"
body := platformclientmodels.GoogleIAPReceipt {
OrderID: &orderId,
PackageName: &packageId,
ProductID: &productId,
Language: "en",
Region: "US",
PurchaseTime: &purchaseTime,
PurchaseToken: &purchaseToken,
AutoAck: true,
}
input := &iap.PublicFulfillGoogleIAPItemParams{
Body: &body,
Namespace: namespace,
UserID: userId,
}
result, err := iapService.PublicFulfillGoogleIAPItemShort(input)
final AccelByteSDK sdk = new AccelByteSDK(httpClient, tokenRepository, configRepository);
...
String authCode = "<google-auth-code>";
String userId = "<user-id>";
// Login using google auth code
final boolean isLoginOk = sdk.loginPlatform("google", authCode);
if (isLoginOk) {
final IAP iapWrapper = new IAP(sdk);
//item entitlement type from google play store
String itemEntitlementType = "DURABLE";
boolean autoAckValue = (itemEntitlementType == "DURABLE");
GoogleReceiptResolveResult response;
try {
GoogleIAPReceipt reqBody = GoogleIAPReceipt.builder()
.orderId("<test-order-id>")
.packageName("<test-package-name>")
.productId("<test-product-id>")
.language("en")
.region("US")
.purchaseTime(160388387672672)
.purchaseToken("<test-purchase-token>")
.autoAck(autoAckValue)
.build();
response = iapWrapper.publicFulfillGoogleIAPItem(PublicFulfillGoogleIAPItem.builder()
.namespace("<namespace>")
.userId(userId)
.body(reqBody)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if success
}
}
import accelbyte_py_sdk.api.platform as platform_service
import accelbyte_py_sdk.api.platform.models as platform_models
result, error = platform_service.public_fulfill_google_iap_item(
body=platform_models.GoogleIAPReceipt()
.with_order_id("testOrderId")
.with_package_name("testPackageName")
.with_product_id("testProductId")
.with_purchase_time(0)
.with_purchase_token("testPurchaseToken")
.with_auto_ack(false)
.with_language("en")
.with_region("US"),
user_id="********************************",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
Twitch
Twitchエンタイトルメントを同期するには、この関数を使用します:
- Unreal SDK
- Unity SDK
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FString TwitchAuthToken = "Token-from-twitch";
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->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
}));
User user = AccelByteSDK.GetClientRegistry().GetApi().GetUser();
// Log in with Twitch account
string twitchAuthToken = "twitch-auth-token";
Result loginTwitch = null;
user.LoginWithOtherPlatform(PlatformType.Twitch, twitchAuthToken, result =>
{
loginTwitch = result;
});
...
var entitlements = AccelByteSDK.GetClientRegistry().GetApi().GetEntitlement();
var twitchDropSyncReq = new TwitchDropSync()
{
gameId = "testGameId",
language = "en",
region = "US"
};
entitlements.SyncTwitchDropItem(twitchDropSyncReq, result =>
{
if (result.IsError)
{
// Handle API failure or error here
Debug.Log($"Error: {result.Error.Message}");
return;
}
// Handle API success here
});
string authToken = "<token-from-twitch>";
//login using twitch auth token
sdk.LoginPlatform("twitch", authToken);
var response = sdk.Platform.IAP.SyncTwitchDropsEntitlementOp
.SetBody(new TwitchSyncRequest()
{
GameId = "<test-game-id>",
Language = "en",
Region = "US",
})
.Execute(sdk.Namespace);
if (response != null)
{
//do something if success
}
tokenRepository := auth.DefaultTokenRepositoryImpl()
configRepository := auth.DefaultConfigRepositoryImpl()
oAuth20Service := &iam.OAuth20Service{
Client: factory.NewIamClient(auth.DefaultConfigRepositoryImpl()),
ConfigRepository: configRepository,
TokenRepository: tokenRepository,
}
authCode := "myauthcode"
inputLogin := &o_auth2_0.PlatformTokenGrantV3Params{
DeviceID: nil,
PlatformID: "google",
PlatformToken: &authCode,
}
oAuth20Service.LoginPlatform(inputLogin)
iapService := &platform.IAPService{
Client: factory.NewPlatformClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
body := platformclientmodels.TwitchSyncRequest {
GameID: "mygameid",
Language: "en",
Region: "US",
}
input := &iap.SyncTwitchDropsEntitlementParams{
Body: &body,
Namespace: namespace,
}
result, err := iapService.SyncTwitchDropsEntitlementShort(input)
final AccelByteSDK sdk = new AccelByteSDK(httpClient, tokenRepository, configRepository);
...
String authToken = "<token-from-twitch>";
//login using twitch auth token
final boolean isLoginOk = sdk.loginPlatform("twitch", authToken);
if (isLoginOk) {
final IAP iapWrapper = new IAP(sdk);
List<TwitchSyncResult> response;
try {
TwitchSyncRequest reqBody = TwitchSyncRequest.builder()
.gameId("<test-game-id>")
.language("en")
.region("US")
.build();
response = iapWrapper.syncTwitchDropsEntitlement(SyncTwitchDropsEntitlement.builder()
.namespace("<namespace>")
.body(reqBody)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if success
}
}
import accelbyte_py_sdk.api.platform as platform_service
import accelbyte_py_sdk.api.platform.models as platform_models
result, error = platform_service.sync_twitch_drops_entitlement_1(
body=platform_models.TwitchSyncRequest()
.with_game_id("testGameId")
.with_language("en")
.with_region("US"),
user_id="********************************",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)