question

EducationGames avatar image
EducationGames asked

IAP not restored on 2nd device via call to getPurchaseUpdates(true)

We’re having a problem implementing v2 of the IAP.

Here’s what happens :

-We install app, we buy the IAP, it works.

-We delete app, and reinstall app, and via a call to getPurchaseUpdates, the IAP is automatically restored on launch, on the original device used to purchase the IAP.

Here’s the problem

-Via a second Kindle, same user ID (in the IAP tester app), we install the app

-The IAP is NOT restored (it says it finds 0 receipts, but the call to getPurchaseUpdates is successful)

We are using PurchasingService.getPurchaseUpdates(true), on the first call as that returns a paginated response of all the user’s purchases, but it doesn’t work on the 2nd device, and works on the original device used for purchase, after deletion and reinstall.

We’re pretty lost at this point. We got rejected on our first try because of this. That’s when we got a 2nd kindle to test this more completely, and realized it won't restore the purchase as it does on the original device used to purchase.

Thanks,

Mathieu

iap
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Levon@Amazon avatar image
Levon@Amazon answered

Hi EducationGames,

Thanks for posting! Do you call notifyFulfillment() when the user purchases an item, as outlined here in step 8:

https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs-v2/implementing-iap#integrating-the-iap-api-with-your-app

Also, when your app starts, how do you determine whether the user purchased an item previously? See a short sample I've written that demonstrates the purchase flow and feel free to modify as you see fit for your app:

https://forums.developer.amazon.com/questions/16686/onpurchaseupdatesresponse-gets-called-before-onpur.html

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Levon@Amazon avatar image
Levon@Amazon answered

And here's a short sample demonstrating the code I'd run when the app launches to find out whether the user purchased an item previously:

private void SetupInAppBilling() {
    final boolean reset =  false ;

    PurchasingService.registerListener(TheGame.getContext(), new AmazonPurchasingListener() {
        @Override
        public void onPurchaseUpdatesResponse(PurchaseUpdatesResponse response) {
            // Process receipts
            final PurchaseUpdatesResponse.RequestStatus status = response.getRequestStatus();
            switch (status) {
                case SUCCESSFUL:
                    for (final Receipt receipt : response.getReceipts()) {
                        // Process receipts
                        if (receipt.getSku().equalsIgnoreCase(TheGame.SKU_FULL_GAME)) {
                            if (receipt.isCanceled()) {
                                TheGame.isFullGameEnabled = false;
                            } else {
                                TheGame.isFullGameEnabled = true;
                            }

                            TheGame.persistPurchaseStatus();
                        }
                    }

                    if (response.hasMore()) {
                        PurchasingService.getPurchaseUpdates(reset);
                    }
                    break;
                case FAILED:
                case NOT_SUPPORTED:
                    Log.d(TAG, "onPurchaseUpdatesResponse: failed, should retry request");
                    break;
            }
        }
    });

    PurchasingService.getPurchaseUpdates(reset);
}
 
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

EducationGames avatar image
EducationGames answered

Thanks for the reply.

We are indeed calling this line:

"PurchasingService.notifyFulfillment(receipt.getReceiptId(), FulfillmentResult.FULFILLED);"

To check what purchases were made at launch, we use this :

PurchasingService.getPurchaseUpdates(true);

When I open the Amazon App Tester, and go to Manage Transactions, I only see the ones made on that specific device. Even after I do refresh all, I don't get the ones I did, with same user ID, on the other device.

Should the Amazon App Tester app see those transactions? If they are not in there, I understand why it won't give them to me via getPurchaseUpdates. Am I right to expect to see them when I do refresh, in the Amazon App Tester app, under "4. Manage Transactions" ?

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Levon@Amazon avatar image
Levon@Amazon answered

Hi EducationGames,

The App Tester is fine for basic testing, just to see whether your IAP implementation is correct in general, however it does not support all of the features that you'd expect from a live system. I would strongly suggest uploading your app to Live App Testing (LAT) service, and testing your IAP implementation that way. Thanks!

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.