Recover lost purchase token for subscription

I have a serious problem right now, we have cases where our server unsubscribes users in our application (and not on Google Play) and deletes our purchase tokens that we receive from Google Play after a successful purchase. We made sure that they were no longer deleted, but I need to process those that we have already lost.

So my question is: is there a way to restore the purchase token?

+4
source share
1 answer

You can get the token and order id processing the response from 'getPurchases'

https://developer.android.com/google/play/billing/billing_reference.html#getPurchases

, IabHelper TrialDrive. https://github.com/googlesamples/android-play-billing/tree/master/TrivialDrive

, , Inventory:

IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
           Log.d(TAG, "Query inventory finished.");

            // Have we been disposed of in the meantime? If so, quit.
            if (mHelper == null) return;

            // Is it a failure?
            if (result.isFailure()) {
                Log.d(TAG, "Failed to query inventory: " + result);
                return;
            }

            Purchase premiumMonthly = inventory.getPurchase(SKU_SUSCRIPTION);
            if (premiumMonthly != null && premiumMonthly.isAutoRenewing()) {
                    String token = premiumMonthly.getToken();
                    String orderid = premiumMonthly.getOrderId();

                    Log.d(TAG, token);
                    Log.d(TAG, orderid);
                } 
            }
   ....

    mHelper.queryInventoryAsync(mGotInventoryListener);
+1

All Articles