Skip to main content
Version: 5.7.0

PurchaseUserItem

Purchases a quantity of an item from the specified store, if the user has enough funds. If includeDef is true, response includes associated itemDef with language fields limited to the current or default language.

ServiceOperation
userItemsPURCHASE_USER_ITEM

Method Parameters

ParameterDescription
defIdThe unique id of the item definition to purchase.
quantityThe quantity of the item to purchase.
shopIdThe id identifying the store the item is being purchased from (not yet supported). Use null or empty string to specify the default shop price.
includeDefIf true, the associated item definition will be included in the response.

Usage

http://localhost:3000
string defId = "sword001";
int quantity = 1;
string shopId = "";
bool includeDef = true;
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.UserItemsService.PurchaseUserItem(defId, quantity, shopId, includeDef, successCallback, failureCallback);
JSON Response
{
"data": {
"items": {
"8e12e907-3f54-4971-b84a-b685ce50b684": {
"itemId": "8e12e907-3f54-4971-b84a-b685ce50b684",
"defId": "boost_rapidfire",
"quantity": 1,
"usesLeft": null,
"coolDownStart": -1,
"recoveryStart": -1,
"itemData": {},
"giftedTo": null,
"giftedFrom": null,
"blockId": null,
"createdAt": 1566850132554,
"updatedAt": 1566850132554,
"version": 1,
"maxUses": null,
"coolDownUntil": -1,
"recoveryUntil": -1,
"itemDef": {
"defId": "boost_rapidfire",
"name": "Rapid Fire",
"desc": "Rapid fire for the next match.",
"type": "ITEM",
"category": "boost",
"tags": null,
"buyPrice": {
"coins": 200
},
"sellPrice": {},
"image": null,
"resourceGroup": null,
"resourceTag": null,
"meta": {},
"pState": "PUBLISHED",
"publishedAt": 1566850042148,
"stackable": false,
"consumable": false,
"uses": null,
"coolDownSecs": 0,
"recoverySecs": 0,
"activatable": true,
"statusName": "boosted",
"activeSecs": 900000,
"tradable": false,
"blockchain": false,
"blockchainDefId": null
}
}
},
"currencySpent": {
"coins": 200
},
"currencyBalances": {
"createdAt": 1566850026783,
"currencyMap": {
"coins": {
"consumed": 200,
"balance": 2999800,
"purchased": 0,
"awarded": 3000000
}
},
"playerId": "55ffc16e-f92b-44f3-98b0-68a7a4f24106",
"updatedAt": 1566850132552
}
},
"status": 200
}