question

giorgiotino avatar image
giorgiotino asked

iOS consumable pending transaction validation problem

Good morning,

I use UnityIAP to implement IAP and PlayFab to validate receipts. At the moment we only have CONSUMABLE items and we are testing on iOS. Both Sandbox and Production environment worked fine, so the whole system seemed pretty reliable, but recently we stumbled upon a problem:

For some reason, a perfectly valid receipt from the Apple store failed to validate. The error returned by PlayFabClientAPI.ValidateIOSReceipt was:

"PaymentType": "ReceiptValidation",
"Error": "A third-party downstream provider returned an error to the PlayFab service",
"Valid": false


Internally this would keep the transaction in the Pending state, as suggested, until PayFab returns that the validation did succeed: https://docs.unity3d.com/Manual/UnityIAPProcessingPurchases.html

The problem is that when this call fails and the app is restarted, so that UnityIAP performs another attempt automatically, the receipt returned by the Apple Store is the same as before, I guess. So when I try again to validate it, this time I get ReceiptAlreadyUsed

At this point I am stuck, as it looks like the IAP won't even be validated. If I try to purchase the consumable item again Apple will tell me that it has already been purchased and that it will be restored for free, but that's not the case as I cannot validate it though PlayFab.

I am kind of stuck and I don't really know what was the initial problem or how to break this loop.

thanks in advance for your help!

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

Seth Du avatar image Seth Du ♦ commented ·

According to my experience, receipts from Apple are for one-time use, if you catch a ReceiptAlreadyUsed error, you may retrieve a new one from Apple. Moreover, if you try to validate a receipt, but with "already purchased" or "will be restored" prompts. I will suggest catching this condition and call RestoreIOSPurchases API instead.

0 Likes 0 ·
giorgiotino avatar image giorgiotino Seth Du ♦ commented ·

But isn't RestoreIOSPurchase API to be used for non-consumable an subscription items only? This is what both the API docs and UnityIAP docs suggest: in our case this is due to a consumable item - would this work too?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ giorgiotino commented ·

Ah, consumable doesn't support restoration. Can a finishTransaction call to Apple break the loop?

May I ask how often does it occur? Has the purchase been billed?

0 Likes 0 ·
Show more comments
Seth Du avatar image
Seth Du answered

All the information can be reviewed in the PlayStream Event, however there is a retention of 30 days. Even in a paid tier, the span can be extended, it still has expiration date. If necessary, you may need to use Data Export for future review.

Otherwise, you may also consider maintaining receipt record somewhere, such as Player Internal Data, and use a Rule, which will be triggered by the corresponding events to transfer data in your customized format.

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.

giorgiotino avatar image giorgiotino commented ·

That sounds like a good idea, I will try to figure something out. Thanks!

0 Likes 0 ·
giorgiotino avatar image
giorgiotino answered

So we ended up making sure that the transaction is completed on the Apple side of things no matter what the PlayFab validation returns.This means that the purchase was considered successful from the Apple point of view, the player's card has been charged but we didn't grant the purchased item. If this ever happens, the player can contact our customer support team and we will be happy to check the receipt and grant the items if everything was ok. I see that the transaction receipt is part of the validate API call we perform against the PlayFab server, but I wonder if those events persist or if we need to make sure we save the receipt in case of this problem somewhere else. Does PlayFab have a suggested approach?

Thanks a lot...

10 |1200

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

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.