Search Unity

UnityIAP: Finishing transaction XXXXXXXXXXXX

Discussion in 'Unity IAP' started by ArnauKokoro, Oct 8, 2021.

  1. ArnauKokoro

    ArnauKokoro

    Joined:
    Apr 27, 2021
    Posts:
    45
    Hi,

    I was testing another IAP plugins (not related to Unity) on my iPhone X (iOS 15) and makes me had errors when paying, so this cause that now I have a tons of pending transactions every time I initialize this Unity IAP plugin. Also I can just Initialize well this Unity IAP Plugin when I shutdown and on again my iPhone, so it initialize well just once every time I restart the iPhone, other times I start the app, the plugin does not initialize well. I want to know if there is some event to catch that Pending transactions to finish them manually. I read something about ProcessPurchase being fired when there are finish transaction but not my case.

    I tested this Unity IAP Plugin on other device with same Apple ID account and works well.

    Many Thanks!!
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, if the transaction is still in Pending, you should expect ProcessPurchase to trigger when you initialize IAP through script. If not, then it might be an issue with the transaction from the other product. How do you know you have "tons of pending transactions"? Where do they show up with Unity IAP?
     
  3. ArnauKokoro

    ArnauKokoro

    Joined:
    Apr 27, 2021
    Posts:
    45
    Yes, I have a pending transactions from 4 products at least. I have added them all to the IAP catalog and when initializing the IAPManager.

    This is what I see from Unity IAP plugin logs when I start the app:

    [This is when the app starts but not the initializer script]

    Code (CSharp):
    1. UnityIAP UnityEarlyTransactionObserver: Created
    2. UnityIAP UnityEarlyTransactionObserver: Registered for lifecycle events
    3. UnityIAP UnityEarlyTransactionObserver: Added to the payment queue
    4. Event dropped. Reason: Subscription purchase is a duplicate. Product ID: xxx
    5. Event dropped. Reason: Subscription purchase is a duplicate. Product ID: xxx2
    6. Event dropped. Reason: Subscription purchase is a duplicate. Product ID: xxx3
    7.  
    Tons of "Event dropped. Reason: Subscription purchase is a duplicate. Product ID: xxx" from 4 different products of the app

    [This is when the script initialize]
    Code (CSharp):
    1. UnityIAP: Requesting 5 products...
    2. UnityIAP: Received 5 products
    3. OnInitialized: PASS
    4. UnityIAP: Add transaction observer
    5. UnityIAP: UpdatedTransactions
    6. UnityIAP UnityEarlyTransactionObserver: Request to initiate queued payments
    7. UnityIAP: Finishing transaction xxx
    8. UnityIAP: Finishing transaction xxx
    9. UnityIAP: Finishing transaction xxx
    Tons of "UnityIAP: Finishing transaction" there.


    So, this just happen once when I restart the phone and open the app. If I close the app and open again it stucks on "UnityIAP: Requesting 5 products...".

    One question here: If I use the script initializer, do I need to fill the IAP Catalog with the products or just in the script when initializing?

    I don't receive any ProcessPurchase event when transaction pending appears on the logs

    Many thanks.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @ArnauKokoro You mention "the IAP catalog and when initializing the IAPManager", are you using IAP Buttons (Codeless)? It sounds like you might be mixing Codeless with Scripted IAP. You should not be using the IAP Catalog if you're also writing IAP script. That would explain the missing ProceessPurchase calls (because Codeless also tries to initialize IAP) You might want to compare to the Sample IAP Project v2 here for an example of using Scripted IAP and using ProcessPurchase https://forum.unity.com/threads/sample-iap-project.529555/#post-6950270
     
  5. ArnauKokoro

    ArnauKokoro

    Joined:
    Apr 27, 2021
    Posts:
    45

    Yes, I had Codeless Buttons before, but now I want to use the script. So I unchecked the Automatically Initialize option on the IAP Catalog. I thought this was enough to not use Codeless initializing, I don't have IAP Codeless Buttons either.

    What else should I do to remove Codeless?

    Other question is, what means:
    Event dropped. Reason: Subscription purchase is a duplicate. Product ID: xxxx. ??

    I'm testing with Sample v2 and when Initializing my products just have id, so no transactionID, no receipt...Is that right?

    I have the script on the main scene and ProcessPurchase is not called and I still have transactions pending.

    I think when it says "Finishing transaction xxxxxxx" it never finish the transaction. Otherwise that xxxxxx each time are different...maybe I have too much to finish in one time so that's why each time I load the app there are finishing different transactions but maybe each time can finish just an amount of them and not all of them in one time.

    I'm lost with this...Is there a way to finish all my pending transactions?

    Thanks.
     
    Last edited: Oct 9, 2021
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We would need specific steps to understand how these transactions were generated. You might consider just creating a new product to test with, use a new tester, or as a last resort, create a new application on Google. As another test to see if ProcessPurchase is working correctly on initialization is to purposely return Pending from ProcessPurchase from a purchase. This should trigger ProcessPurchase on the next app start. As well as purchasing a non-consumable, return Complete, then reinstall the app. This should trigger auto-restore and fire off a ProcessPurchase upon IAP initialization. Ensure you don't have any products defined in your IAP Catalog.
     
  7. ArnauKokoro

    ArnauKokoro

    Joined:
    Apr 27, 2021
    Posts:
    45
    Something strange here is that the same Apple ID Account on other iPhone is working fine with no pending transactions.

    Are pending transactions related to a serial number iPhone or Apple ID Account?

    Yes, I will test with a new product. This is just happening on an iPhone X.

    Seems that I have a huge amount of pending transactions and each time I reset the phone they try to finish some but not all off them, because each time are different transactions.

    Thanks.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Do you have an autorenewing subscription by chance? That could create a lot of transactions at it renews every few minutes. Transactions are associated with the Apple ID.
     
  9. ArnauKokoro

    ArnauKokoro

    Joined:
    Apr 27, 2021
    Posts:
    45
    Yes, it is like that. Shouldn't it stop autorenewing some time automatically?

    So, I write some logs to analyze:

    This is what happens first time I run the app after restarting the iphone (the transactions seems not to finish):

    Code (CSharp):
    1. UnityIAP UnityEarlyTransactionObserver: Created
    2. UnityIAP UnityEarlyTransactionObserver: Registered for lifecycle events
    3. UnityIAP UnityEarlyTransactionObserver: Added to the payment queue
    4. UnityIAP: Requesting 5 products
    5. UnityIAP: Requesting product data...
    6. UnityIAP: Received 5 products
    7. UnityIAP: No App Receipt found
    8. UnityIAP: No App Receipt found
    9. OnInitialized: PASS
    10. UnityIAP: Add transaction observer
    11. UnityIAP UnityEarlyTransactionObserver: Request to initiate queued payments
    12. UnityIAP: UpdatedTransactions
    13. UnityIAP: Finishing transaction xxxxxxxxxx
    14. UnityIAP: Finishing transaction xxxxxxxxxx
    15. UnityIAP: Finishing transaction xxxxxxxxxx
    16. ...
    17. UnityIAP: Finishing transaction xxxxxxxxxx

    This happens when trying to buy a product that has a transaction pending:

    Code (CSharp):
    1. Purchasing product:xxxxxxxx
    2. UnityIAP: PurchaseProduct: xxxxxxxxx
    3. UnityIAP: UpdatedTransactions
    4. UnityIAP: DuplicateTransaction error with product xxxxxxxxx and transactionId xxxxxxxxx
    5. onPurchaseFailedEvent(productId:xxxxxx message:Duplicate transaction occurred)
    6. OnPurchaseFailed: FAIL. Product: xxxxxxxxx, PurchaseFailureReason: DuplicateTransaction

    This happens when trying to buy a other product that also has transactions pending but no Duplicate message is shown:

    Code (CSharp):
    1. Purchasing product:xxxxxxx
    2. UnityIAP: PurchaseProduct: xxxxxxx
    3. UnityIAP: UpdatedTransactions
    4.  
    Non of these are firing the native payment popup.


    This happens if I try to run the app after first time

    Code (CSharp):
    1. UnityIAP UnityEarlyTransactionObserver: Created
    2. UnityIAP UnityEarlyTransactionObserver: Registered for lifecycle events
    3. UnityIAP UnityEarlyTransactionObserver: Added to the payment queue
    4. UnityIAP: Requesting 5 products
    5. UnityIAP: Requesting product data...

    Just the first time I run the app after a restart is Initializing the plugin and showing transactions pending. Non if these transactions seems to finish. Is there any option to purge all the transactions pending on these products?

    Finishing transactions doesn't fire ProcessPurchase event to complete payment.
     
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide complete steps to reproduce. How do you have Pending transactions? Auto renew don't "stop sometime". Although in Sandbox they renew up to 6 times. Please share the code you are using. You can safely ignore the "Finishing transaction..." message. What type of product is giving you duplicate transaction? If non-consumable or a subscription, this would be expected. If they have a current subscription, you would disable the purchase button, for example.
     
  11. ArnauKokoro

    ArnauKokoro

    Joined:
    Apr 27, 2021
    Posts:
    45
    We have pending transaction because an error with other payments plugins from other technologies, not Unity.
    Pending transactions are from a Sandbox subscriptions. Even if I ignore it, I can't purchase any other subscriptions on the app. We don't have any subscription active, we have cancel all of them from the Settings/AppStore/Sandbox Subscription.

    The only solution I could found is restoring the iPhone.
     
  12. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I'm not sure why you would use two IAP plugins in the same app, I would advise against that. How are the transactions left in pending? Again, we would need steps to reproduce to offer any suggestions. But for testing non-consumables and subscriptions on iOS, I always create multiple testers and multiple IAP products.