I have been trying from past few days to restore the purchased items in In-App Purchases in Amazon. I succeeded in purchasing items, and now I need to restore the items purchased after the app is uninstalled. I read the several links and including the following one as well:

Tracking In-App Purchases Using PurchaseUpdates

This link has got some good information, and after reading the following link:

How do I easily restore purchases using the Amazon API?

I know that I need to use onPurchaseUpdatesResponse() to get things done here, but the problem is that I am getting

    Set<Receipt> receipts = response.getReceipts();
    Set<String> revokedSkus = response.getRevokedSkus();

both empty in onPurchaseUpdatesResponse() method. I can see the purchased items in AmazonSDKTester app, and the userId obtained by:

    response.getUserId();

is same as in AmazonSDKTester app.

I think I might be doing something wrong in storing the offset after my purchases done successfully. But, I am not able to understand how to do things right here or what am I doing wrong, Thanks for listening and please help!

**EDIT: ** I am setting offset as:

        Offset offset = purchaseDataStorage.getPurchaseUpdatesOffset();
        PurchasingManager.initiatePurchaseUpdatesRequest(offset);

and I am doing this in onGetUserIdResponse() method when the case is SUCCESSFUL.

And I am storing the offset value in onPurchaseUpdatesResponse() when the case is SUCCESSFUL:

Offset offset = response.getOffset();
purchaseDataStorage.savePurchaseUpdatesOffset(offset);
有帮助吗?

解决方案

On the first call or when doing a user initiated restore, you want to use the Offset.BEGINNING key value to initiatePurchaseUpdatesRequest to get all transactions not just ones that have occurred since the last query.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top