SDKBOX IAP Google Play: recover/restore a subscription

I’ve been using the SDKBOX IAP plugin and have recently been implementing subscriptions. At the moment I’m stuck on one thing - restoring a Google Play user’s subscription (eg., user plays game on a different device and no cloud save restore).

We need access to the purchaseToken of this active subscription. Using sdkbox::IAP::restore() does not work for the subscription type of purchase on Google Play, and productRequestSuccess does not have any purchase data filled in (which is expected).

Am I missing where I should be able to retrieve this old purchaseToken with SDKBOX IAP? This thread on Stackoverflow says that a previous purchaseToken can be obtained using getPurchases() in the Google In-app Billing API, but I don’t think this is exposed to us in SDKBOX at the moment.

you can get PurchaseToken in iap pay success callback.

void IAPListener::onSuccess(const Product &p)
{
    rapidjson::Document d;
    if (p.receipt.size() > 0) {
        d.Parse<0>(p.receipt.c_str());
        if (!d.HasParseError()) {
            if (d.IsObject() && d.HasMember("purchaseToken")) {
                INFO("IAP-onSuccess: purchaseToken: %s", d["purchaseToken"].GetString());
            }
        }
    }
}

Thanks for your reply. Yes you can get it in the initial purchase, that’s okay, but I’m talking about restoring that on another device without the user having a cloud save for your app.

we planned to test restore subscription with two android device.

in restore callback, also can get purchaseToken.

test steps:

  1. purchase a subscription
  2. uninstall app
  3. install app, launch
  4. restore, and purchaseToken show