question

Hayrettin Yucel avatar image
Hayrettin Yucel asked

How can I get user's last purchased item and date?

I want to be able to change a value in user data if that user does not make any purchases last 7 days. Is there any way to handle this with the existing Playfab system?

Player DataPlayer 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.

Hayrettin Yucel avatar image
Hayrettin Yucel answered

I got it working by using the CloudScripts. This is my workaround.

- Created a Rule which is getting fired when there is a receipt validation event happens. If receipt validation is valid then the Rule runs a cloud script which updates player data with the date and the value that I want to set.

Thanks for your recommendation as well. Appreciated for your time.

10 |1200

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

Deekshith avatar image
Deekshith answered

It will have to be done manually in the code. You can go ahead with the following approach.

Get the Player Inventory Items and sort them based on PurchaseDate and then after sorting check the last item in the list(After sorting the last item will be the last purchased item). Using this last purchased item you can check if the user has made any purchases in last 7 days

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

Hayrettin Yucel avatar image Hayrettin Yucel commented ·

Thanks for the answer. I tried your recommendation before, however when I try to get Player Inventory, I dont get anything back because all items are already expired. So, GetPlayerInventory is disregarding the expired items. By the way, my setup is when user does in-app purchase, I grant the user with and inventory item which has 5 second expiration time. Am I missing anything here?

0 Likes 0 ·
Deekshith avatar image Deekshith Hayrettin Yucel commented ·

So I believe everytime something is been added to inventory it will have a 5 seconds expiry time and later on there will be no item in inventory after expiry. As far as I know, playfab hasn't added a support for getting expired items yet.

So in this case the workaround I could think of is

- When the player does an in app purchase, an item is added to inventory. So store that Timestamp in their respective player data. Since all items have 5 seconds expiration time when a new item is purchased the old timestamp in player data should be replaced with the new timestamp and same can be accessed to check when was the last purchase made.

Will this work for you?

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.