2

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!

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);
starball
  • 20,030
  • 7
  • 43
  • 238
class Android
  • 762
  • 1
  • 6
  • 17
  • Are you using PurchasingManager.initiatePurchaseUpdatesRequest(Offset.BEGINNING)? Note the parameter value. – DrC Dec 30 '13 at 19:33
  • @DrC Please read the Edited version of my question and thanks for the quick response, really thankful. – class Android Dec 31 '13 at 15:02

1 Answers1

2

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.

DrC
  • 7,528
  • 1
  • 22
  • 37
  • Thanks for the response, now I am getting receipts non empty and the revoked skus as empty. Two more questions here 1) when are revoked skus called. 2) what is the best place to call PurchasingManager.initiatePurchaseUpdatesRequest(Offset.BEGINNING); – class Android Dec 31 '13 at 19:52
  • 1
    I call it in response to a user request (button) and in onGetUSerIdResponse when I have no offset recorded for the user (basically, first run). – DrC Dec 31 '13 at 22:14
  • Thanks for your answer, really helped solving my problem. Have a great New Year. Happy New Year!!! – class Android Jan 01 '14 at 07:53