question

Kevin avatar image
Kevin asked

Economy V2 returns wrong error codes

It looks like Economy V2 always returns PlayFab error code 1071 InvalidRequest for any error in the request, instead of returning the specific error code.

If we try to purchase an item for the wrong price (e.g. an item costs 500 gold but we send a Purchase Inventory Request trying to buy it for 300 gold), PlayFab returns error code 1071 InvalidRequest. The correct error code for this situation would be 1053 WrongPrice.

If we try to purchase an item for the correct price but don't have enough funds to purchase it, we get back 1071 InvalidRequest. The correct error code would be 1059 InsufficientFunds (or 1050 ItemNotAffordable?)

If we try to purchase an item with an invalid Item ID, we get back 1071 InvalidRequest. The correct error code would be 1093 InvalidItemId.

If we try to purchase an item with an invalid item ID for one of the purchase prices (e.g. the currency's ID is "abc-123" but we accidentally use "123-abc"), we get back 1071 InvalidRequest. The correct error code would be 1093 InvalidItemId or 1179 InvalidCurrencyCode

If the store ID is invalid, we get back 1071 InvalidRequest. The correct error code would be 1221 StoreNotFound.

If the Collection ID is invalid, we get back 1071. It looks like there currently is no specific error code for this error, so you'll need to create a new one.

apis
1 comment
10 |1200

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

Kevin avatar image Kevin commented ·

It is frustrating having to test your API like this. Please do a QA pass on Economy V2.

0 Likes 0 ·

1 Answer

·
kylemc@microsoft.com avatar image
kylemc@microsoft.com answered

In Economy V2, we took the approach that non-actionable bad requests would be handled under the 1071 error code. This may contrast with V1 error codes for similar scenarios.

For purchase specifically, we only focused on a few main codes.

https://learn.microsoft.com/en-us/rest/api/playfab/economy/inventory/purchase-inventory-items?view=playfab-rest#error-codes

  • DatabaseThroughputExceeded 1113

  • InsufficientFunds 1059

  • ItemNotFound 1047

That said, all errors related to not having enough funds should route to 1059 and all errors related to invalid ids should route to 1047. It sounds like you have a few repros where this might not be the case. If so, I'd love to know what they are so we can investigate further.

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.

Kevin avatar image Kevin commented ·

@kylemc@microsoft.com There's nothing special about the repros. Just do as described above:

  • Try to purchase an item and pass in an invalid item ID

  • Try to purchase an item when you don't have enough funds for the item

  • Try to purchase an item with an invalid ID in one of the PriceAmount fields

I'm using the Unity SDK, if that matters, but I can see in the JSON that the server always returns 1071, so it's not a Unity-specific problem.

For some of these, the error message is correct, but the error code is incorrect.

0 Likes 0 ·
kylemc@microsoft.com avatar image kylemc@microsoft.com Kevin commented ·

Thanks for pointing these out. We should have updates for the 1059 and 1047 error codes out next week.

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.