Skip to main content
Version: 5.7.0

ConsumeCurrency

Consume the passed-in amount of currency from the player.

note

Consuming 0 or negative currency will return an error. Use AwardCurrency to add currency values.

caution

For security reasons calling this API from the client is not recommended, and is rejected at the server by default. To over-ride, enable the 'Allow Currency Calls from Client' compatibility setting in the Design Portal.

ServiceOperation
virtualCurrencyCONSUME_VC

Method Parameters

ParameterDescription
vcIdThe currency type to consume.
vcAmountThe amount of currency to consume.

Usage

http://localhost:3000
string vcId = "coins";
int vcAmount = 1;
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};

_bc.VirtualCurrencyService.ConsumeCurrency(vcId, vcAmount, successCallback, failureCallback);
JSON Response
{
"status": 200,
"data": {
"currencyMap": {
"gems": {
"purchased": 0,
"balance": 0,
"consumed": 0,
"awarded": 0,
"revoked": 0
},
"gold": {
"purchased": 0,
"balance": 123,
"consumed": 0,
"awarded": 123,
"revoked": 0
}
}
}
}