Skip to main content
Version: 5.7.0

ConsumeCurrency

caution

WARNING: This call, ConsumeCurrency(), is included in the client libraries for convenience and backwards compatibility, but for app security reasons we recommend it only be called server-side via Cloud Code. By default the brainCloud servers will block any client-side invocations of currency altering methods. To enable client-side support (not recommended), you need to enable the [x] Allow Currency Calls from Client compatibility setting on the Design | Core App Info | Advanced Settings page of the portal.

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.

ServiceOperation
productCONSUME_VC

Method Parameters

ParameterDescription
currencyTypeThe currency type to consume.
amountThe amount of currency to consume.

Usage

http://localhost:3000
string currencyType = "coins";
int amount = 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.ProductService.ConsumeCurrency(currencyType, amount, successCallback, failureCallback);
JSON Response
{
"status": 200,
"data": {
"updatedAt": 1395693913234,
"currencyMap": {
"gems": {
"purchased": 0,
"balance": 0,
"consumed": 0,
"awarded": 0
},
"gold": {
"purchased": 0,
"balance": 123,
"consumed": 0,
"awarded": 123
}
},
"playerId": "acf11847-055f-470d-abb7-b93052201491",
"createdAt": 1395693907421
}
}