Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

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

Discussion in 'Economy' started by martinstava, Apr 16, 2024.

  1. martinstava

    martinstava

    Joined:
    Aug 19, 2022
    Posts:
    6
    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
     
  2. anthonylord

    anthonylord

    Unity Technologies

    Joined:
    Dec 8, 2022
    Posts:
    8
    Hey Martin, thanks for the report. To clarify, Are you using the same receipt for both redeems?
     
  3. martinstava

    martinstava

    Joined:
    Aug 19, 2022
    Posts:
    6
    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!
     
  4. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    269
    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?
     
  5. martinstava

    martinstava

    Joined:
    Aug 19, 2022
    Posts:
    6
    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.
     
  6. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    269
    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.
     
  7. martinstava

    martinstava

    Joined:
    Aug 19, 2022
    Posts:
    6
    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 :)
     
  8. hexdecc

    hexdecc

    Joined:
    Oct 24, 2014
    Posts:
    160
    same issue!

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


    https://capture.dropbox.com/EyVzx5pLURF1i8YF


    EconomyAppleAppStorePurchaseFailedException: The product ID specified in the configuration does not match the product ID specified in the receipt
     
    martinstava likes this.
  9. martinstava

    martinstava

    Joined:
    Aug 19, 2022
    Posts:
    6
  10. hexdecc

    hexdecc

    Joined:
    Oct 24, 2014
    Posts:
    160
    I think no,
    try consumable purchase type instead non-consumable and handle if user has that item or not on economy unity
     
  11. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,291
    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? :D
    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).
     
  12. martinstava

    martinstava

    Joined:
    Aug 19, 2022
    Posts:
    6
    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.