Redeeming apple app store purchase fails for receipts containing more than one IAP transaction

I am getting a following exception from the economy service when trying to redeem a consumable purchase:
“The product ID specified in the configuration does not match the product ID specified in the receipt”. The real money purchase ID is correct and it’s associated with the correct product ID matching the purchase and the receipt.

I am testing in development using a sandbox account. The error only happens when trying to redeem a consumable purchase after successfully processing a non-consumable purchase first. The receipt contains not only the consumable product ID but the non-consumable one as well (which is expected behaviour documented by Apple).

It seems the economy service assumes the receipt will only contain the product associated with the real money purchase. This is not the case as the receipt always contains all non-consumable purchases as well as pending purchases awaiting confirmation. The economy service should iterate through the entire receipt and find a product matching the real money purchase.

Steps to reproduce:

  1. Create a sandbox account with Apple
  2. Define 1 consumable real-money purchase and 1 non-consumable purchase with the economy service
  3. Process, redeem and confirm the non-consumable purchase first.
  4. Trying to process and redeem the consumable purchase will result with the error

Hey Martin, thanks for the report. To clarify, Are you using the same receipt for both redeems?

Hi! I obtain the receipt payload from the Unity IAP by deserializing purchaseEvent.purchasedProduct.receipt from the ProcessPurchase method (IDetailedStoreListener). In both cases (the consumable and non-consumable product) the receipt looks the same. I hope this clarifies it, let me know if you need me to share code / anything. Thanks!

Hello Martin,
Apple doesn’t keep consumables that were confirmed in the receipt.
Is it possible that you are using a receipt after this has happened?

In your code, you should be calling RedeemAppleAppStorePurchaseArgs during the IDetailedStoreListener.ProcessPurchase or returning PurchaseProcessingResult.Pending to IDetailedStoreListener.ProcessPurchase and once you have handled the consumable, you call ConfirmPendingPurchase.

If this doesn’t work, could you share your code related to this?

Hi Yannic! Yes, I do confirm processed purchases via ConfirmPendingPurchase. Consumable purchases do disappear from the receipt after confirmation as you said.

But my original post concerns the non-consumable purchase. If I do the non-consumable purchase first, it stays in the receipt. Then for all subsequent consumable purchases when I try to process them via the economy service I get the error saying “The product ID specified in the configuration does not match the product ID specified in the receipt”. My assumption is this happens because the receipt contains multiple purchases.

If that does not make sense I can create a test project for you and upload it to github with better steps to reproduce.

We investigated the issue and our iOS receipt validation takes for account only the first product in the receipt.
The Apple App Store returns a single receipt containing every purchases from the start (non-consumables and subscriptions) and these will persist forever, so the moment a non-consumable or subscription is purchased, there’s a risk to run into this issue.

A workaround we can recommend is to only use consumables, and then manage them with Economy to persist the non-consumables and subscriptions while also preventing the user from purchasing them again.

Thanks for looking into the issue. Yes, that’s what we ended up doing for now (replacing the purchase with consumable), but definitely would like to change it to non-consumable once the issue is resolved. Pls keep us posted :slight_smile:

same issue!

it gives me first product as non consumable, second product consumable

EconomyAppleAppStorePurchaseFailedException: The product ID specified in the configuration does not match the product ID specified in the receipt

1 Like

@Yannick_D Any update on the fix?

I think no,
try consumable purchase type instead non-consumable and handle if user has that item or not on economy unity

I have to say how Economy handles this is ridiculous. Are you really suggesting to not work with product types as they were designed, but set all of them to consumable? :smile:
I’m glad I didn’t offer an integration for Economy in my assets but instead developed my own receipt validation service (you can find it on my website, I don’t want to promote it here).

I would agree this issue deserves more urgency. Not only because the workaround by using consumable product is not ideal, but mainly because games currently using the economy service in production might be affected.

@Yannick_D - Any update on this one? This is a critical issue which affects apps that are currently using the Economy service in production.

Hey Martin, I confirm it’s on our radar. I can’t give an ETA at this time though.

Hey guys, we have pushed an update to allow for multiple consumables & non-consumables to be present in a receipt for Apple transactions.

Keep in mind that if the receipt contains a renewable subscription, the validation will fail because it triggers additional authentication requirements on Apple’s side of things.

Feel free to try it and give us feedback!

@martinstava

1 Like

Great to hear, thank you for the update, @anthonylord. I’ll test it out and let you know if it fixed our issue.

@anthonylord - Just tested the above-mentioned purchase scenario and I can confirm it now works as expected. Thanks for fixing this!