Documentation

PurchaseItem

Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.

Request Details

Please note that the processing time for inventory grants and purchases increases fractionally the more items are in the inventory, and the more items are in the grant/purchase operation (with each item in a bundle being a distinct add).

PurchaseItemRequest
Request Properties
CatalogVersion String

Catalog version for the items to be purchased (defaults to most recent version.

CharacterId String

Unique PlayFab assigned ID for a specific character owned by a user

ItemId (required) String

Unique identifier of the item to purchase.

Price (required) int32

Price the client expects to pay for the item (in case a new catalog or store was uploaded, with new prices).

StoreId String

Store to buy this item through. If not set, prices default to those in the catalog.

VirtualCurrency (required) String

Virtual currency to use to purchase the item.

POST https://{{TitleID}}.playfabapi.com/Client/PurchaseItem
    Content-Type: application/json
    X-Authentication: <user_session_ticket_value>
{
  "ItemId": "shield_level_5",
  "VirtualCurrency": "GV",
  "Price": 25
}
        

Response Details

PurchaseItemResult
Result Properties
Items List<ItemInstance>

Details for the items purchased.

Sample Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
  "code": 200,
  "status": "OK",
  "data": {
    "Items": [
      {
        "ItemId": "shield_level_5",
        "ItemInstanceId": "123456789ABC",
        "PurchaseDate": "2014-03-07T00:00:00Z",
        "CatalogVersion": "5",
        "DisplayName": "Level 5 Shield",
        "UnitCurrency": "GV",
        "UnitPrice": 25
      }
    ]
  }
}

Authentication

SessionTicket

Possible Error Codes

Name Code
CharacterNotFound 1135
InsufficientFunds 1059
ItemNotFound 1047
OperationNotSupportedForPlatform 1219
WrongPrice 1053
WrongVirtualCurrency 1052