Skip to main content

Player Wallet

1. What Is the Player Wallet?

The player wallet is designed to help you manage the currencies held by players. You can view the balances and consumption of the currency that players purchased and received in their wallets. For security reasons, we only provide APIs that grant currency to wallets for game servers and virtual servers.

2. Using the Wallet in the Portal

Go to Portal -> Players and find the desired player. In the Economy tab of the player details, you can find the player's wallet. Here, you can see all the currencies held by the player.

  • Currency Code: The unique identifier of a currency.
  • Type: Only Virtual Currency is supported currently.
  • Amount: The balance of this currency.
  • Total Spend: The amount of this currency spent by the player.

image-20210630151847301

In some circumstances, you may have to directly place currency in a player's wallet or remove a specified amount from a player's wallet. To do this, go to the Portal, find the player in the Player Query area, and open the player wallet page:

  • Click Operation -> “+‘’ to grant the specified currency to the player.

    image-20210630151720104

  • Click Operation -> ”-“ to subtract the specified currency from the player.

    image-20210630151803646

3. Using Balances Through the Client SDK

3.1 Acquire Balances

This operation acquires player balances. Call the GetBalances method of the Client Economy module:

#include "PgosSDKCpp/Public/PgosSDKCpp.h"
#include "PgosSDKCpp/Public/Core/PgosErrorCode.h"

void SomeUObjectClass::GetBalances()
{
auto economy = IPgosSDKCpp::Get().GetClientEconomyAPI();
if (economy)
{
economy->GetBalances(
[](const FPgosResult& Ret, const FClientGetBalancesResult* Response) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("GetBalances Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("GetBalances Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

4. Using Balances Through the DS SDK

4.1 Grant Currency

This operation grants specified currencies to specified players.

Call the GrantCurrencyToPlayer method of the Server Economy module:

#include "PgosSDKCpp/Public/PgosSDKCpp.h"
#include "PgosSDKCpp/Public/Core/PgosErrorCode.h"

void SomeUObjectClass::GrantCurrencyToPlayer()
{
auto economy = IPgosSDKCpp::Get().GetServerEconomyAPI();
if (economy)
{
FString PlayerId = "13148";
FServerGrantCurrency Currency;
Currency.currency_code = "DIAMOND";
Currency.amount = 888;
economy->GrantCurrencyToPlayer(
PlayerId, Currency,
[](const FPgosResult& Ret, const FServerGrantCurrencyResult* Response) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("GrantCurrencyToPlayer Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("GrantCurrencyToPlayer Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

6. Key Errors Handling

Error CodeRelevant APIHandling Suggestion
kBackendThrottlingGrantCurrencyToPlayerToo many operations for current player detected, please retry shortly.
kBackendShouldRetryGrantCurrencyToPlayerThe failure request can be retried for a success.
kBackendIdempotentParamsMismatchGrantCurrencyToPlayerA idempotency_token input parameter was reused with an operation, but at least one of the other input parameters is different from the previous call to the operation. By now the error will be returned when player id is not consistent.