Integrate with flexible pricing bundle
Overview
The flexible pricing bundle in AccelByte Gaming Services (AGS) enables you to provide reasonable pricing options for players in your game who already own some items in the bundle. This also helps you offer more consistent discounting experience as pricing will be in-sync when contents of a bundle go on sale.
As demonstrated in the below image, the final bundle price is calculated by the following factors: player already owns an item in the bundle, item has a discount, and bundle has a discount.
Integrate with using SDK
This section covers how to integrate the flexible pricing bundle using SDK.
Login
Add your AGS Admin Portal login credentials to call the API endpoints for the flexible pricing bundle.
- AGS OSS for Unreal Engine
- Unreal Engine SDK
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
Before you start, ensure that you have the correct configuration and have integrated your game with OSS. For more information, see AGS OSS for Unreal Engine.
IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get(ACCELBYTE_SUBSYSTEM);
FOnlineIdentityAccelBytePtr IdentityInterface = StaticCastSharedPtr<FOnlineIdentityAccelByte>(OnlineSubsystem->GetIdentityInterface());
if (!IdentityInterface.IsValid())
{
return;
}
const int32 LocalUserNum = 0;
auto AccelByteLoginCompletehandle = IdentityInterface->AddAccelByteOnLoginCompleteDelegate_Handle(LocalUserNum
, FAccelByteOnLoginCompleteDelegate::CreateLambda(
[this]
(int32 LoggedInLocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId,
const FOnlineErrorAccelByte& Error)
{
UE_LOG(LogTemp, Log, TEXT("Get AccelByteOnLoginComplete: LocalUserNum=%d"), LoggedInLocalUserNum);
})
);
const EAccelByteLoginType Type = EAccelByteLoginType::AccelByte;
const FString ID = TEXT("username");
const FString Password = TEXT("password");
IdentityInterface->Login(LocalUserNum, FOnlineAccelByteAccountCredentials{ Type , ID, Password });
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
const FString Username = TEXT("username");
const FString Password = TEXT("password");
ApiClient->User.LoginWithUsernameV3(Username, Password, FVoidHandler::CreateLambda([&]()
{
UE_LOG(LogTemp, Log, TEXT(" Success"));
bDeviceLoginSuccessful = true;
}), FOAuthErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage, const FErrorOAuthInfo& ErrorObject)
{
UE_LOG(LogTemp, Error, TEXT(" Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);
});
var user = AccelByteSDK.GetClientRegistry().GetApi().GetUser();
string emailAddress = "emailAddress";
string password = "password";
user.LoginWithUsernameV3(emailAddress, password, (Result<TokenData, OAuthError> result) =>
{
if (result.IsError)
{
// Your logic to handle errors in LoginWithUsernameV3
// ...
Debug.Log($"Error. Code: {result.Error.error} Reason: {result.Error.error_description}");
return;
}
// Your logic to run after LoginWithUsernameV3 is successful
});
// prepare the IAM Oauth service
oauth := &iam.OAuth20Service{
Client: factory.NewIamClient(&configRepo),
ConfigRepository: &configRepo,
TokenRepository: &tokenRepo,
}
// call the endpoint tokenGrantV3Short through the wrapper 'LoginUser'
err := oauth.LoginUser(os.Getenv("AB_USERNAME"), os.Getenv("AB_PASSWORD"))
if err != nil {
fmt.Println("failed login user")
} else {
fmt.Println("successful login")
}
// get the token
token, _ := oauth.TokenRepository.GetToken()
fmt.Printf("print %v\n", *token.AccessToken)
import accelbyte_py_sdk.services.auth as auth_service
from accelbyte_py_sdk.core import AccelByteSDK
from accelbyte_py_sdk.core import MyConfigRepository
sdk = AccelByteSDK()
sdk.initialize(
options={
"config": MyConfigRepository(
base_url="https://****.accelbyte.io",
client_id="********************************",
client_secret="********************************",
namespace="********",
)
}
)
result, error = auth_service.login_user(
username="********",
password="********",
sdk=sdk,
)
if error:
exit(error)
String emailAddress = "<email-address>";
String password = "<user-password>";
var success = sdk.loginUser(emailAddress, password);
if (success)
{
//do something when user login is success
}
string emailAddress = "<email-address>";
string password = "<user-password>";
var success = sdk.LoginUser(emailAddress, password);
if (success)
{
//do something when user login is success
}
Get flexible pricing bundle
To get flexible pricing bundles, make sure you have already created them in Admin Portal. You can check the boolean field "Flexible" from the response to determine whether it is a flexible pricing bundle. To create a flexible pricing bundle, see Create flexible pricing bundle.
- AGS OSS for Unreal Engine
- Unreal Engine SDK
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
Before you start, ensure that you have the correct configuration and have integrated your game with OSS. For more information, see AGS OSS for Unreal Engine.
const FOnlineStoreV2AccelBytePtr OnlineStoreV2AccelByte = StaticCastSharedPtr<FOnlineStoreV2AccelByte>(StoreInterface);
const FOnlinePurchaseAccelBytePtr OnlinePurchaseAccelByte = StaticCastSharedPtr<FOnlinePurchaseAccelByte>(PurchaseInterface);
// GetItemsByCriteria to get flexible bundle item
FAccelByteModelsItemPagingSlicedResult ItemPagingSlicedResult{};
OnlineStoreV2AccelByte->AddOnGetItemsByCriteriaCompleteDelegate_Handle(FOnGetItemsByCriteriaCompleteDelegate::CreateLambda(
[this, &ItemPagingSlicedResult]
(bool bWasSuccessful, const FAccelByteModelsItemPagingSlicedResult& Value, const FOnlineError& Error) {
if (bWasSuccessful)
{
ItemPagingSlicedResult = Value;
}
}));
const FString Region = TEXT("US");
FAccelByteModelsItemCriteria ItemCriteria;
ItemCriteria.Language = TEXT("en");
ItemCriteria.Region = Region;
ItemCriteria.ItemType = EAccelByteItemType::BUNDLE;
ItemCriteria.CategoryPath = ECommerceTestFlexibleBundleItemCategoryPath;
auto UserId = IdentityInterface->GetUniquePlayerId(LocalUserNum).Get();
OnlineStoreV2AccelByte->GetItemsByCriteria(*UserId, ItemCriteria);
FString ItemId = ItemPagingSlicedResult.Data[0].ItemId;
FAccelByteModelsItemInfo Item;
FAccelByteModelsItemCriteria ItemCriteria;
ItemCriteria.Language = TEXT("en");
ItemCriteria.Region = Region;
ItemCriteria.ItemType = EAccelByteItemType::BUNDLE;
ItemCriteria.CategoryPath = TEXT("/flexibleBundle");
UE_LOG(LogTemp, Log, TEXT("GetItemsByCriteria"));
ApiClient->Item.GetItemsByCriteria(ItemCriteria, 0, 20, THandler<FAccelByteModelsItemPagingSlicedResult>::CreateLambda([&]
(const FAccelByteModelsItemPagingSlicedResult& Result)
{
UE_LOG(LogTemp, Log, TEXT(" ChildFound: %d"), Result.Data.Num());
for (int i = 0; i < Result.Data.Num(); i++)
{
if (Result.Data[i].Flexible)
{
UE_LOG(LogTemp, Log, TEXT(" Found"));
Item = Result.Data[i];
break;
}
}
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Error, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage)
});
var items = AccelByteSDK.GetClientRegistry().GetApi().GetItems();
var itemCriteria = new ItemCriteria()
{
language = "yourStoreLanguage",
region = "yourStoreRegion",
itemType = ItemType.BUNDLE,
categoryPath = "/yourCategoryPath"
};
ItemInfo itemInfo;
items.GetItemsByCriteria(itemCriteria, result =>
{
if (result.IsError)
{
// Your logic to handle errors in GetItemsByCriteria
// ...
Debug.Log($"Error. Code: {result.Error.Code} Reason: {result.Error.Message}");
return;
}
Debug.Log($"ChildFound: {result.Value.data.Length}");
for (int i = 0; i < result.Value.data.Length; i++)
{
if (result.Value.data[i].Flexible)
{
Debug.Log("Found");
itemInfo = result.Value.data[i];
break;
}
}
});
itemService := &platform.ItemService{
Client: factory.NewPlatformClient(&configRepo),
TokenRepository: &tokenRepo,
}
categoryPath := "/yourCategoryPath"
itemType := "BUNDLE"
language := "yourStoreLanguage"
region := yourStoreRegion
input := &item.PublicQueryItemsParams{
Namespace: "namespace",
CategoryPath: &categoryPath,
ItemType: &itemType,
Language: &language,
Region: ®ion,
}
ok, errOK := itemService.PublicQueryItemsShort(input)
if errOK != nil {
logrus.Error(errOK)
return
}
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_query_items(
language="yourStoreLanguage",
region="yourStoreRegion",
item_type="BUNDLE",
category_path="/yourCategoryPath",
)
if error:
exit(error)
final Item itemWrapper = new Item(sdk);
ItemPagingSlicedResult response;
try {
response = itemWrapper.publicQueryItems(PublicQueryItems.builder()
.namespace("<namespace>")
.language("<your-store-language>")
.region("<your-store-region")
.itemTypeFromEnum(PublicQueryItems.ItemType.BUNDLE)
.categoryPath("/yourCategoryPath")
.build());
} catch (Exception e) {
// Do something when failed
return;
}
ItemInfo itemInfo = null;
if (response == null || response.getData() == null) {
// Null response from server
} else {
for (var item : response.getData() ) {
if (item.getFlexible() != null && item.getFlexible() == true)
{
//flexible item found
itemInfo = item;
break;
}
}
}
var items = sdk.Platform.Item.PublicQueryItemsOp
.SetLanguage("<your-store-language>")
.SetRegion("<your-store-region")
.SetItemType(PublicQueryItemsItemType.BUNDLE)
.SetCategoryPath("/yourCategoryPath")
.Execute(sdk.Namespace);
ItemInfo? itemInfo = null;
if (items != null)
{
if (items.Data != null)
{
foreach (var item in items.Data )
{
if (item.Flexible.HasValue && item.Flexible.Value)
{
//flexible item found
itemInfo = item;
break;
}
}
}
}
Get estimated price
As the price can be varied by who is buying a flexible pricing bundle and when, the game client needs to call the GetEstimatedPrice
endpoint to get the latest pricing for players.
- AGS OSS for Unreal Engine
- Unreal Engine SDK
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
Before you start, ensure that you have the correct configuration and have integrated your game with OSS. For more information, see AGS OSS for Unreal Engine.
// GetEstimatedPrice to get the proper price when creating order
bool bGettingEstimatedPriceDone = false;
bool bGettingEstimatedPriceSuccess = false;
TArray<FAccelByteModelsEstimatedPrices> EstimatedPrices{};
OnlineStoreV2AccelByte->AddOnGetEstimatedPriceCompleteDelegate_Handle(FOnGetEstimatedPriceCompleteDelegate::CreateLambda(
[this, &EstimatedPrices]
(bool bWasSuccessful, const TArray<FAccelByteModelsEstimatedPrices>& Value, const FOnlineErrorAccelByte& Error) {
if (bWasSuccessful)
{
EstimatedPrices = Value;
}
}));
auto UserId = IdentityInterface->GetUniquePlayerId(LocalUserNum).Get();
OnlineStoreV2AccelByte->GetEstimatedPrice(*UserId, {ItemId}, Region);
TArray<FAccelByteModelsEstimatedPrices> EstimatedItems{};
UE_LOG(LogTemp, Log, TEXT("GetItemsByCriteria"));
ApiClient->Item.GetEstimatedPrice({ItemId}, Region,
THandler<TArray<FAccelByteModelsEstimatedPrices>>::CreateLambda([&EstimatedItems]
(const TArray<FAccelByteModelsEstimatedPrices>& Result)
{
EstimatedItems = Result;
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Error, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage)
});
var items = AccelByteSDK.GetClientRegistry().GetApi().GetItems();
string[] itemIds = new string[]
{
"yourItemId1",
"yourItemId2"
};
string region = "yourStoreRegion";
EstimatedPricesInfo[] estimatedItems;
items.GetEstimatedPrice(itemIds, region, result =>
{
if (result.IsError)
{
// Your logic to handle errors in GetEstimatedPrice
// ...
Debug.Log($"Error. Code: {result.Error.Code} Reason: {result.Error.Message}");
return;
}
estimatedItems = result.Value;
});
region := "yourStoreRegion"
input := &item.PublicGetEstimatedPriceParams{
Namespace: "namespace",
Region: ®ion,
ItemIds: "yourItemId1, yourItemId2",
}
ok, errOK := itemService.PublicGetEstimatedPriceShort(input)
if errOK != nil {
logrus.Error(errOK)
return
}
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_get_estimated_price(
item_ids=",".join(["yourItemId1", "yourItemId2"]),
region="yourStoreRegion",
)
if error:
exit(error)
final Item itemWrapper = new Item(sdk);
String userId = "<user-id>";
String itemIds = "itemId1,itemId2,itemId3";
List<AvailablePrice> estimatedItems;
EstimatedPriceInfo response;
try {
response = itemWrapper.getEstimatedPrice(GetEstimatedPrice.builder()
.namespace("<namespace>")
.region("<your-store-region")
.itemIds(itemIds)
.userId(userId)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
estimatedItems = response.getEstimatedPrices();
}
string userId = "<user-id>";
string itemIds = "itemId1,itemId2,itemId3";
List<AvailablePrice> estimatedItems;
var response = sdk.Platform.Item.GetEstimatedPriceOp
.SetRegion("<your-store-region")
.Execute(sdk.Namespace, itemIds, userId);
if (response != null)
{
estimatedItems = response.EstimatedPrices!;
}
Create order
Ensure that you use th estimated price when placing an order for a flexible pricing bundle.
- AGS OSS for Unreal Engine
- Unreal Engine SDK
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
Before you start, ensure that you have the correct configuration and have integrated your game with OSS. For more information, see AGS OSS for Unreal Engine.
// Create Order to enabling OrderBundleItemInfos
const FString CurrencyCode = EstimatedPrices[0].EstimatedPrices[0].CurrencyCode;
const int32 DiscountedPrice = EstimatedPrices[0].EstimatedPrices[0].DiscountedPrice;
const int32 Price = EstimatedPrices[0].EstimatedPrices[0].Price;
FString OrderNo{};
constexpr int32 Quantity = 1;
FAccelByteModelsOrderCreate OrderCreate;
OrderCreate.CurrencyCode = CurrencyCode;
OrderCreate.DiscountedPrice = DiscountedPrice * Quantity;
OrderCreate.Price = Price * Quantity;
OrderCreate.Quantity = Quantity;
OrderCreate.ReturnUrl = TEXT("https://sdk.example.com");
OrderCreate.ItemId = ItemId;
OrderCreate.Region = Region;
OrderCreate.Language = TEXT("en");
bool bCreatingOrderDone = false;
bool bCreatingOrderSuccess = false;
FAccelByteModelsOrderInfo OrderInfo{};
OnlinePurchaseAccelByte->AddOnCreateNewOrderCompleteDelegate_Handle(FOnCreateNewOrderCompleteDelegate::CreateLambda(
[this, &OrderInfo]
(bool bWasSuccessful, FAccelByteModelsOrderInfo Value, const FOnlineErrorAccelByte& Error) {
if (bWasSuccessful)
{
OrderInfo = Value;
}
}));
auto UserId = IdentityInterface->GetUniquePlayerId(LocalUserNum).Get();
OnlinePurchaseAccelByte->CreateNewOrder(*UserId, OrderCreate);
FString OrderNo{};
constexpr int32 Quantity = 1;
FAccelByteModelsOrderCreate OrderCreate;
OrderCreate.CurrencyCode = EstimatedItems[0].EstimatedPrices[0].CurrencyCode;
OrderCreate.DiscountedPrice = EstimatedItems[0].EstimatedPrices[0].DiscountedPrice * Quantity;
OrderCreate.Price = EstimatedItems[0].EstimatedPrices[0].Price * Quantity;
OrderCreate.Quantity = 1;
OrderCreate.ReturnUrl = TEXT("https://sdk.example.com");
OrderCreate.ItemId = Item.ItemId;
OrderCreate.Region = TEXT("US");
OrderCreate.Language = TEXT("en");
UE_LOG(LogTemp, Log, TEXT("CreateNewOrder"));
ApiClient->Order.CreateNewOrder(OrderCreate
, THandler<FAccelByteModelsOrderInfo>::CreateLambda(
[&](const FAccelByteModelsOrderInfo& Result)
{
UE_LOG(LogTemp, Log, TEXT(" Success"));
OrderNo = Result.OrderNo;
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Error, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage)
});
var orders = AccelByteSDK.GetClientRegistry().GetApi().GetOrders();
string language = "yourStoreLanguage";
string region = "yourStoreRegion";
int quantity = 1;
var itemToOrder = itemInfo; // Retrieved from items.GetItemsByCriteria
var storeItemData = estimatedItems[0]; // Retrieved from items.GetEstimatedPrice
string orderNumber;
var orderRequest = new OrderRequest()
{
currencyCode = storeItemData.EstimatedPrices[0].CurrencyCode,
discountedPrice = storeItemData.EstimatedPrices[0].DiscountedPrice * quantity,
price = storeItemData.EstimatedPrices[0].Price * quantity,
quantity = quantity,
itemId = itemToOrder.itemId,
language = language,
region = region
};
orders.CreateOrder(orderRequest, result =>
{
if (result.IsError)
{
// Your logic to handle errors in CreateOrder
// ...
Debug.Log($"Error. Code: {result.Error.Code} Reason: {result.Error.Message}");
return;
}
orderNumber = result.Value.orderNo;
});
orderService := &platform.OrderService{
Client: factory.NewPlatformClient(&configRepo),
TokenRepository: &tokenRepo,
}
//itemInfo retrieved from PublicQueryItemsShort
//estimatedPriceInfo retrieved from GetEstimatedPriceShort
quantity := int32(1)
price := estimatedPriceInfo[0].EstimatedPrices[0].DiscountedPrice
discountedPrice := *price * quantity
input := &order.PublicCreateUserOrderParams{
Body: &platformclientmodels.OrderCreate{
CurrencyCode: estimatedPriceInfo[0].EstimatedPrices[0].CurrencyCode,
DiscountedPrice: &discountedPrice,
ItemID: itemInfo.Data[0].ItemID,
Language: "yourStoreLanguage",
Price: 0,
Quantity: &quantity,
Region: "yourStoreRegion",
ReturnURL: "https://sdk.example.com",
SectionID: "",
},
Namespace: "namespace",
UserID: "userId",
}
ok, errOK := orderService.PublicCreateUserOrderShort(input)
if errOk != nil {
logrus.Error(errOk)
return
}
import accelbyte_py_sdk.api.platform as platform_service
import accelbyte_py_sdk.api.platform.models as platform_models
# result, error = platform_service.public_get_estimated_price(...)
# estimated_price_info = result[i]
# assert isinstance(estimated_price_info, platform_models.EstimatedPriceInfo)
# estimated_price = estimated_price_info.estimated_prices[j]
# assert isinstance(estimated_price, platform_models.AvailablePrice)
quantity = 1
result, error = platform_service.public_create_user_order(
user_id="********************************",
body=platform_models.OrderCreate()
.with_currency_code(estimated_price.currency_code)
.with_discounted_price(estimated_price.discounted_price)
.with_price(estimated_price.price * quantity)
.with_quantity(quantity)
.with_return_url("https://sdk.example.com")
.with_item_id("yourItemId1")
.with_language("yourStoreLanguage")
.with_region("yourStoreRegion"),
)
if error:
exit(error)
String userId = "<user-id>";
//itemInfo retrieved from PublicQueryItemsOp
//estimatedItems retrieved from GetEstimatedPriceOp
int quantity = 1;
OrderInfo orderResponse;
try {
orderResponse = orderWrapper.publicCreateUserOrder(PublicCreateUserOrder.builder()
.namespace("<namespace>")
.userId(userId)
.body(OrderCreate.builder()
.currencyCode(estimatedItems.get(0).getCurrencyCode())
.discountedPrice(estimatedItems.get(0).getDiscountedPrice() * quantity)
.price(estimatedItems.get(0).getPrice() * quantity)
.quantity(quantity)
.itemId(itemInfo.getItemId())
.language("<your-store-language>")
.region("<your-store-region")
.build())
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (orderResponse != null)
{
//do something when order is created
}
string userId = "<user-id>";
//itemInfo retrieved from PublicQueryItemsOp
//estimatedItems retrieved from GetEstimatedPriceOp
int quantity = 1;
var orderResponse = sdk.Platform.Order.PublicCreateUserOrderOp
.SetBody(new OrderCreate()
{
CurrencyCode = estimatedItems[0].CurrencyCode,
DiscountedPrice = estimatedItems[0].DiscountedPrice * quantity,
Price = estimatedItems[0].Price * quantity,
Quantity = quantity,
ItemId = itemInfo.ItemId,
Language = "<your-store-language>",
Region = "<your-store-region"
})
.Execute(sdk.Namespace, userId);
if (orderResponse != null)
{
//do something when order is created
}
Query order
Use the QueryUserOrders
endpoint to retrieve information on the bundle order.
- AGS OSS for Unreal Engine
- Unreal Engine SDK
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
Before you start, ensure that you have the correct configuration and have integrated your game with OSS. For more information, see AGS OSS for Unreal Engine.
// QueryUserOrders to check OrderBundleItemInfos exist
bool bGettingUserOrdersDone = false;
bool bGettingUserOrdersSuccess = false;
FAccelByteModelsPagedOrderInfo PagedOrderInfo{};
OnlinePurchaseAccelByte->AddOnQueryUserOrdersCompleteDelegate_Handle(FOnQueryUserOrdersCompleteDelegate::CreateLambda(
[this, &PagedOrderInfo]
(bool bWasSuccessful, const FAccelByteModelsPagedOrderInfo& Value, const FOnlineErrorAccelByte& Error) {
if (bWasSuccessful)
{
PagedOrderInfo = Value;
}
}));
FAccelByteModelsUserOrdersRequest UserOrdersRequest{};
UserOrdersRequest.ItemId = ItemId;
auto UserId = IdentityInterface->GetUniquePlayerId(LocalUserNum).Get();
OnlinePurchaseAccelByte->QueryUserOrders(*UserId, UserOrdersRequest);
You can find the bundle order information in the OrderBundleItemInfos
variable.
auto BundleInfo = PagedOrderInfo.Data[0].OrderBundleItemInfos;
UE_LOG(LogTemp, Log, TEXT("GetUserOrder"));
FAccelByteModelsOrderInfo OrderInfo{};
ApiClient->Order.GetUserOrder(OrderNo
, THandler<FAccelByteModelsOrderInfo>::CreateLambda(
[&](const FAccelByteModelsOrderInfo& Result)
{
UE_LOG(LogTemp, Log, TEXT(" Success"));
OrderInfo = Result;
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Error, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage)
});
You can find the bundle order information in the OrderBundleItemInfos
variable.
auto BundleInfo = OrderInfo.OrderBundleItemInfos;
var orders = AccelByteSDK.GetClientRegistry().GetApi().GetOrders();
OrderInfo orderInfo;
// orderNumber is retrieved from orders.CreateOrder
orders.GetUserOrder(orderNumber, result =>
{
if (result.IsError)
{
// Your logic to handle errors in GetEstimatedPrice
// ...
Debug.Log($"Error. Code: {result.Error.Code} Reason: {result.Error.Message}");
return;
}
orderInfo = result.Value;
});
You can find the bundle order information in the OrderBundleItemInfos
variable.
var bundleInfo = orderInfo.OrderBundleItemInfos;
input := &order.PublicGetUserOrderParams{
Namespace: "namespace",
OrderNo: "orderNo",
UserID: "userId",
}
ok, errOk := orderService.PublicGetUserOrderShort(input)
if errOk != nil {
logrus.Error(errOk)
return
}
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_get_user_order(
order_no="yourOrderNo",
user_id="********************************",
)
if error:
exit(error)
You can find the bundle order information in the order_bundle_item_infos
variable.
# assert isinstance(result, platform_models.OrderInfo)
bundle_infos = result.order_bundle_item_infos
final Order orderWrapper = new Order(sdk);
String userId = "<user-id>";
String orderNo = "<order-no>";
OrderInfo response;
try {
response = orderWrapper.getUserOrder(GetUserOrder.builder()
.namespace("<namespace>")
.userId(userId)
.orderNo(orderNo)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something when order data is retrieved
// You can find the bundle order information in the OrderBundleItemInfos field.
var bundleInfo = response.getOrderBundleItemInfos();
}
string userId = "<user-id>";
string orderNo = "<order-no>";
var response = sdk.Platform.Order.GetUserOrderOp
.Execute(sdk.Namespace, orderNo, userId);
if (response != null)
{
//do something when order data is retrieved
//you can find the bundle order information in the OrderBundleItemInfos field.
var bundleInfo = response.OrderBundleItemInfos;
}
Auto-calculate estimated price
In order to simplify getting flexible bundle items with an estimated price, set the autoCalcEstimatedPrice
parameter to true
when getting the item.
Get item by ID
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
string itemId = "YourItemId";
string storeLanguage = "en-US";
string storeRegion = "US";
bool autoCalcEstimatedPrice = true;
PopulatedItemInfo itemInfo;
int itemPrice;
Items items = AccelByteSDK.GetClientRegistry().GetApi().GetItems();
items.GetItemById(itemId, storeRegion, storeLanguage, autoCalcEstimatedPrice, result =>
{
if (result.IsError)
{
// Your logic to handle errors in GetItemById
// ...
Debug.Log($"Error GetItemById, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
itemInfo = result.Value;
itemPrice = itemInfo.regionData[0].price;
});
autoCalcEstimatedPrice := true
language := "en-US"
region := "US"
input := &item.PublicGetItemParams{
ItemID: "YourItemId",
Namespace: "namespace",
AutoCalcEstimatedPrice: &autoCalcEstimatedPrice,
Language: &language,
Region: ®ion,
}
ok, errOK := itemService.PublicGetItemShort(input)
if errOK != nil {
logrus.Error(errOK)
return
}
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_get_item(
item_id="YourItemId",
auto_calc_estimated_price=True,
language="en-US",
region="US",
)
if error:
exit(error)
final Item itemWrapper = new Item(sdk);
String itemId = "<your-item-id>";
PopulatedItemInfo response;
try {
response = itemWrapper.publicGetItem(PublicGetItem.builder()
.namespace("<namespace>")
.itemId(itemId)
.language("<your-store-language>")
.region("<your-store-region")
.autoCalcEstimatedPrice(true)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something with items data
}
string itemId = "<your-item-id>";
var itemsData = sdk.Platform.Item.PublicGetItemOp
.SetLanguage("<your-store-language>")
.SetRegion("<your-store-region")
.SetAutoCalcEstimatedPrice(true)
.Execute(itemId, sdk.Namespace);
if (itemsData != null)
{
//do something with items data
}
Get item by SKU
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
string itemSku = "ItemSku";
string itemLanguage = "en-US";
string itemRegion = "US";
bool autoCalcEstimatedPrice = true;
ItemInfo itemInfo;
int itemPrice;
Items items = AccelByteSDK.GetClientRegistry().GetApi().GetItems();
items.GetItemBySku(itemSku, itemLanguage, itemRegion, autoCalcEstimatedPrice, result =>
{
if (result.IsError)
{
// Your logic to handle errors in GetItemBySku
// ...
Debug.Log($"Error GetItemBySku, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
itemInfo = result.Value;
itemPrice = itemInfo.regionData[0].price;
});
autoCalcEstimatedPrice := true
language := "en-US"
region := "US"
input := &item.PublicGetItemBySkuParams{
Namespace: "namespace",
AutoCalcEstimatedPrice: &autoCalcEstimatedPrice,
Language: &language,
Region: ®ion,
Sku: "YourItemSKU",
}
ok, errOK := itemService.PublicGetItemBySkuShort(input)
if errOK != nil {
logrus.Error(errOK)
return
}
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_get_item_by_sku(
sku="YourItemSKU",
auto_calc_estimated_price=True,
language="en-US",
region="US",
)
if error:
exit(error)
final Item itemWrapper = new Item(sdk);
String itemSku = "<your-item-sku>";
ItemInfo response;
try {
response = itemWrapper.publicGetItemBySku(PublicGetItemBySku.builder()
.namespace("<namespace>")
.sku(itemSku)
.language("<your-store-language>")
.region("<your-store-region")
.autoCalcEstimatedPrice(true)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something with items data
}
string itemSku = "<your-item-sku>";
var itemsData = sdk.Platform.Item.PublicGetItemBySkuOp
.SetLanguage("<your-store-language>")
.SetRegion("<your-store-region")
.SetAutoCalcEstimatedPrice(true)
.Execute(sdk.Namespace, itemSku);
if (itemsData != null)
{
//do something with items data
}
Get local items by bulk
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
string[] itemIds = { "YourItemId1", "YourItemId2" };
string storeLanguage = "en-US";
string storeRegion = "US";
bool autoCalcEstimatedPrice = true;
ItemInfo[] itemsInfo;
Items items = AccelByteSDK.GetClientRegistry().GetApi().GetItems();
items.BulkGetLocaleItems(itemIds, storeLanguage, storeRegion, autoCalcEstimatedPrice, result =>
{
if (result.IsError)
{
// Your logic to handle errors in BulkGetLocaleItems
// ...
Debug.Log($"Error BulkGetLocaleItems, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
itemsInfo = result.Value;
});
autoCalcEstimatedPrice := true
language := "en-US"
region := "US"
input := &item.PublicBulkGetItemsParams{
Namespace: "namespace",
AutoCalcEstimatedPrice: &autoCalcEstimatedPrice,
Language: &language,
Region: ®ion,
ItemIds: "YourItemId1, YourItemId2",
}
ok, errOK := itemService.PublicBulkGetItemsShort(input)
if errOK != nil {
logrus.Error(errOK)
return
}
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_bulk_get_items(
item_ids=",".join(["YourItemId1", "YourItemId2"]),
auto_calc_estimated_price=True,
language="en-US",
region="US",
)
if error:
exit(error)
final Item itemWrapper = new Item(sdk);
String itemIds = "itemId1,itemId2,itemId3";
List<ItemInfo> response;
try {
response = itemWrapper.publicBulkGetItems(PublicBulkGetItems.builder()
.namespace("<namespace>")
.itemIds(itemIds)
.language("<your-store-language>")
.region("<your-store-region")
.autoCalcEstimatedPrice(true)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
/ / Do something with items data
}
string itemIds = "itemId1,itemId2,itemId3";
var bulkItems = sdk.Platform.Item.PublicBulkGetItemsOp
.SetLanguage("<your-store-language>")
.SetRegion("<your-store-region")
.SetAutoCalcEstimatedPrice(true)
.Execute(sdk.Namespace, itemIds);
if (bulkItems != null)
{
//do something with items data
}
Search item
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
string itemKeyword = "ItemKeyword";
string itemRegion = "US";
int offset = 0;
int limit = 5;
bool autoCalcEstimatedPrice = true;
ItemInfo[] itemsInfo;
Items items = AccelByteSDK.GetClientRegistry().GetApi().GetItems();
items.SearchItem(storeLanguage, itemKeyword, offset, limit, itemRegion, autoCalcEstimatedPrice, result =>
{
if (result.IsError)
{
// Your logic to handle errors in SearchItem
// ...
Debug.Log($"Error SearchItem, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
itemsInfo = result.Value.data;
});
autoCalcEstimatedPrice := true
region := "US"
limit := int32(10)
offset := int32(1)
input := &item.PublicSearchItemsParams{
Namespace: "namespace",
AutoCalcEstimatedPrice: &autoCalcEstimatedPrice,
Limit: &limit,
Offset: &offset,
Region: ®ion,
Keyword: "ItemKeyword",
Language: "en-US",
}
ok, errOK := itemService.PublicSearchItemsShort(input)
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_search_items(
keyword="ItemKeyword",
auto_calc_estimated_price=True,
language="en-US",
region="US",
limit=5,
offset=0,
)
if error:
exit(error)
final Item itemWrapper = new Item(sdk);
String itemKeyword = "<keyword>";
ItemPagingSlicedResult response;
try {
response = itemWrapper.publicSearchItems(PublicSearchItems.builder()
.namespace("<namespace>")
.keyword(itemKeyword)
.language("<your-store-language>")
.region("<your-store-region")
.autoCalcEstimatedPrice(true)
.offset(0)
.limit(5)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something with items data
}
string itemKeyword = "<keyword>";
var itemsData = sdk.Platform.Item.PublicSearchItemsOp
.SetOffset(0)
.SetLimit(5)
.SetRegion("<your-store-region")
.SetAutoCalcEstimatedPrice(true)
.Execute(sdk.Namespace, itemKeyword, "<your-store-language>");
if (itemsData != null)
{
//do something with items data
}
List active section contents
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
string storeId = "YourStoreIdFromAdminPortal";
string viewId = "YourViewId";
string storeLanguage = "en-US";
string storeRegion = "US";
bool autoCalcEstimatedPrice = true;
SectionInfo[] sectionsInfo;
StoreDisplay storeDisplay = AccelByteSDK.GetClientRegistry().GetApi().GetStoreDisplayService();
storeDisplay.ListActiveSectionContents(storeId
, viewId
, storeRegion
, storeLanguage
, autoCalcEstimatedPrice
, result =>
{
if (result.IsError)
{
// Your logic to handle errors in ListActiveSectionContents
// ...
Debug.Log($"Error ListActiveSectionContents, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
sectionsInfo = result.Value;
// Your logic to run after ListActiveSectionContents is successful
});
sectionService := &platform.SectionService{
Client: factory.NewPlatformClient(&configRepo),
TokenRepository: &tokenRepo,
}
autoCalcEstimatedPrice := true
region := "US"
language := "en-US"
storeId := "YourStoreId"
viewId := "YourViewId"
input := §ion.PublicListActiveSectionsParams{
Namespace: "namespace",
UserID: "userId",
AutoCalcEstimatedPrice: &autoCalcEstimatedPrice,
Language: &language,
Region: ®ion,
StoreID: &storeId,
ViewID: &viewId,
}
ok, errOK := sectionService.PublicListActiveSectionsShort(input)
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_list_active_sections(
store_id="YourStoreId",
view_id="YourViewId",
keyword="ItemKeyword",
auto_calc_estimated_price=True,
language="en-US",
region="US",
)
if error:
exit(error)
final Section sectionWrapper = new Section(sdk);
String userId = "<user-id>";
List<SectionInfo> response;
try {
response = sectionWrapper.publicListActiveSections(PublicListActiveSections.builder()
.namespace("<namespace>")
.userId(userId)
.language("<your-store-language>")
.region("<your-store-region")
.autoCalcEstimatedPrice(true)
.storeId("<your-store-id>")
.viewId("<your-view-id>")
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something after sections info is retrieved
}
string userId = "<user-id>";
var response = sdk.Platform.Section.PublicListActiveSectionsOp
.SetLanguage("<your-store-language>")
.SetRegion("<your-store-region")
.SetAutoCalcEstimatedPrice(true)
.SetStoreId("<your-store-id>")
.SetViewId("<your-view-id>")
.Execute(sdk.Namespace, userId);
if (response != null)
{
//do something after sections info is retrieved
}