question

Joss Harris avatar image
Joss Harris asked

Get cost of past transaction

Hello,

I am working on an app in Unity and using PlayFabEconomyAPI.GetTransactionHistory() to get the user's transactions in order to display them in a list.

The intention is for it to be like a purchase history list, where the user can see all the item's they have purchased.

I would like to be able to display the cost of each purchase to the player, whether that is real or virtual currency. However, I can't seem to find the data that I need within the Transaction data that is returned from the GetTransactionHistory() function. Could you point me in the right direction?

If this is not possible, I am thinking that I will have to manually save each purchase that the user makes to their read only data, using the player_paid_for_purchase PlayStream event, and then display that in the list instead.

Any help would be greatly appreciated. Thanks!

Player Dataunity3dIn-Game EconomyPlayer Inventory
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Neils Shi avatar image
Neils Shi answered

Could you tell us what transaction data you want to retrieve? In my testing, the API GetTransactionHistory can successfully return the item ID purchased by the user and the currency item ID they cost on this purchase :

 {
                 "TransactionId": "39",
                 "ItemType": "catalogItem",
                 "OperationType": "Purchase",
                 "ApiName": "PurchaseInventoryItems",
                 "Timestamp": "2023-05-15T02:24:49Z",
                 "Operations": [
                     {
                         "Type": "Subtract",
                         "ItemType": "currency",
                         "ItemId": "5d04207c-ee8d-46c2-8948-xxxxxxxxxxxx",
                         "StackId": "default",
                         "Amount": 5
                     },
                     {
                         "Type": "Add",
                         "ItemType": "catalogItem",
                         "ItemId": "80018a65-9e8d-47e7-91f3-xxxxxxxxxxxx",
                         "StackId": "default",
                         "Amount": 1
                     }
                 ]
             },
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Joss Harris avatar image Joss Harris commented ·

Thank you for the reply. If the user purchased an item with real money, would that data also show in these transactions? Or is this only for transactions involving items and virtual currencies (which are also technically items)?

0 Likes 0 ·
Neils Shi avatar image Neils Shi Joss Harris commented ·

The purchase history of API GetTransactionHistory 's response contains two info, the Add info records the added PlayFab item ID and the number of added items. The Subtract info records the consumed PlayFab item ID and the amount spent. Since the real money is not a PlayFab item, it should not be recorded. However, it should record the number of items purchased, then you can know the cost of real money based on the price you set earlier. And the corresponding supplier should also have a complete real money purchase history.

0 Likes 0 ·
kylemc@microsoft.com avatar image kylemc@microsoft.com Joss Harris commented ·

"Real Money" numbers aren't available in PlayFab yet, but we're actively looking at how to incorporate them. For now, if you have a mapping of $$ to VC, you should be able to do that calculation in the game.

0 Likes 0 ·
Joss Harris avatar image Joss Harris kylemc@microsoft.com commented ·

I see. Thank you for the information and suggestions!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.