Android IAP - getting Duplicate Transcation errors when purchasing a consumable products.
Hello,
I ignored this issue for quite some time, however the dreaded release is coming, so I have to fix it quickly. We are developing a mobile game for Android and iOS and we've implemented UnityIAP. We only have 5 products which are all Consumables (in-game currency). The issue is that I am able to buy only 4 of them continuously and the remaining one always returns the Duplicate Transaction error. I triple-checked the code and the google play store settings and ran out of ideas on how to fix it.
.
The logic is as following:
- user clicks on the button corresponding to the item;
- on click our Shop controller subscribes to our fail/success events in our IStoreListener implementation and calls PurchaseItem method;
- in PurchaseItem our IStoreListener calls InitiatePurchase;
- on successful purchase, in the ProcessPurchase method we return PurchaseProcessingResult.Pending and send the success event;
- our Shop controller then unsubscribes from the fail/success events and sends a webservice to our server with the currency amount bought;
- when our server returns success, we call ConfirmPendingPurchase;
.
.
What method should I call, when our server fails to process the purchase, in order to cancel/refund the IAP purchase?
.
May the issue be caused by some old purchases that failed on either our server side or in the iap that are hung somewhere and we are not clearing them?
.
.
I hope someone will be able to help me with that.
B.