Managing currencies
Overview
This article will explain how you can configure the currencies that can be accepted for Store transactions using your Admin Portal. You can configure both real-world and virtual currencies to allow your players to transact using those currencies. Virtual currencies that you create can also be earned by or awarded to players. You will need to set up at least one currency prior to creating a store or item.
If you create your currency in the Publisher Namespace, your currency will be available in every namespace.
If you create your currency in a specific Game Namespace, your currency will only be available in that specific namespace.
If you create a currency with the same code and symbol in multiple Namespaces, they will be treated as different currencies.
Goals
- Explain how to Manage Real Currencies
- Explain how to Manage Virtual Currencies
Prerequisites
- Access to the AccelByte Admin Portal
- You have created the appropriate Namespaces
Manage Real Currencies in Admin Portal
Creating a real currency in the Admin Portal will make that currency available to your players for transactions.
In the desired Namespace, go to the E-Commerce section and open the Currencies menu.
On the Currencies page, click Add to add a new currency.
The Add Currency form will open. Fill out the required fields:
- Real Currency will have two decimals when used in prices.
- Select the Currency Type and select Real to create a real currency.
- Input the unique identifying code for the currency in the Currency Code field. For real currencies, follow ISO_4217 standardization, such as USD for United States Dollar.
- Input the symbol associated with the currency in the Currency Symbol field, such as "$". To input a symbol that isn't on your keyboard, input the Unicode for that symbol.
- Once completed, click Add. Your new currency will be added to the list.
Manage Virtual Currencies in Admin Portal
Creating a virtual currency in the Admin Portal will make that currency available to your players for transactions.
In the desired Namespace, go to the E-Commerce section and open the Currencies menu.
On the Currencies page, click Add to add a new currency
The Add Currency form will open. Fill out the required fields:
- Select the Currency Type, and select Virtual to create a virtual currency.
- For virtual currencies, you can create your own currency code.
- Input the symbol associated with the currency in the Currency Symbol field (e.g., "$"). To input a symbol that isn't on your keyboard, input the Unicode for that symbol. For virtual currencies, you can input any character combination you like, up to eight characters.
Once completed, click Add. Your new currency will be added to the list.
Retrieve Supported Currencies Using the SDK
Our client SDKs for Unity and Unreal Engine can also be used to allow game clients to retrieve information about the currencies you've configured in the Admin Portal.
- Unreal Engine
- Unity
Unreal SDK
FAccelByteModelsCurrencyList currencyListResult;
bool bGetCurrencyListDone = false;
FString Namespace = TEXT("sample-namespace");
TArray<FAccelByteModelsCurrencyList> GetCurrencyListAllTypeResult;
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient(TEXT(“your-key”));
ApiClient->Currency.GetCurrencyList(Namespace,
THandler<TArray<FAccelByteModelsCurrencyList>>::CreateLambda([=]
(const TArray<FAccelByteModelsCurrencyList>& Result)
{
// Do something if GetCurrencyList has been successful
UE_LOG(LogTemp, Error, TEXT(" Success"));
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if QueryUserAchievements has an error
UE_LOG(LogTemp, Error, TEXT("Error. Code: %d, Reason: %s"), ErrorCode, *ErrorMessage)
});
Unity SDK
Result<CurrencyList[]> currencyListResult = null;
// Check for CurrencyType
AccelBytePlugin.GetCurrencies().GetCurrencyList(result =>
{
if (result.IsError)
{
// Do something if QueryUserAchievements has an error
Debug.Log($"Error GetCurrencyList, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetCurrencyList has been successful
}
});