Player Item Management - Purchase Item

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.

POST https://titleId.playfabapi.com/Client/PurchaseItem

Request Body

Name Required Type Description
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 True
  • string

Unique identifier of the item to purchase.

Price True
  • number

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 True
  • string

Virtual currency to use to purchase the item.

Responses

Name Type Description
200 OK
400 Bad Request

This is the outer-wrapper for all responses with errors

Security

SessionTicket

This API requires a client session ticket, available from any Client Login function.

Type: apiKey
In: header

Definitions

ApiErrorWrapper

The basic wrapper around every failed API response

ItemInstance

A unique instance of an item in a user's inventory. Note, to retrieve additional information for an item instance (such as Tags, Description, or Custom Data that are set on the root catalog item), a call to GetCatalogItems is required. The Item ID of the instance can then be matched to a catalog entry, which contains the additional information. Also note that Custom Data is only set here from a call to UpdateUserInventoryItemCustomData.

PurchaseItemRequest

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).

PurchaseItemResult

ApiErrorWrapper

The basic wrapper around every failed API response

Name Type Description
code
  • number

Numerical HTTP code

error
  • string

Playfab error code

errorCode
  • number

Numerical Playfab error code

errorDetails
  • object

Detailed description of individual issues with the request object

errorMessage
  • string

Description for the Playfab errorCode

status
  • string

String HTTP code

ItemInstance

A unique instance of an item in a user's inventory. Note, to retrieve additional information for an item instance (such as Tags, Description, or Custom Data that are set on the root catalog item), a call to GetCatalogItems is required. The Item ID of the instance can then be matched to a catalog entry, which contains the additional information. Also note that Custom Data is only set here from a call to UpdateUserInventoryItemCustomData.

Name Type Description
Annotation
  • string

Game specific comment associated with this instance when it was added to the user inventory.

BundleContents
  • string[]

Array of unique items that were awarded when this catalog item was purchased.

BundleParent
  • string

Unique identifier for the parent inventory item, as defined in the catalog, for object which were added from a bundle or container.

CatalogVersion
  • string

Catalog version for the inventory item, when this instance was created.

CustomData
  • object

A set of custom key-value pairs on the inventory item.

DisplayName
  • string

CatalogItem.DisplayName at the time this item was purchased.

Expiration
  • string

Timestamp for when this instance will expire.

ItemClass
  • string

Class name for the inventory item, as defined in the catalog.

ItemId
  • string

Unique identifier for the inventory item, as defined in the catalog.

ItemInstanceId
  • string

Unique item identifier for this specific instance of the item.

PurchaseDate
  • string

Timestamp for when this instance was purchased.

RemainingUses
  • number

Total number of remaining uses, if this is a consumable item.

UnitCurrency
  • string

Currency type for the cost of the catalog item.

UnitPrice
  • number

Cost of the catalog item in the given currency.

UsesIncrementedBy
  • number

The number of uses that were added or removed to this item in this call.

PurchaseItemRequest

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).

Name Type Description
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
  • string

Unique identifier of the item to purchase.

Price
  • number

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
  • string

Virtual currency to use to purchase the item.

PurchaseItemResult

Name Type Description
Items

Details for the items purchased.

Error Codes

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