SDKBOX IAP Google Play: recover/restore a subscription

SDKBOX IAP Google Play: recover/restore a subscription
0

#1

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.


SDKBox 2.4.3.0 bugfix
#2

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());
            }
        }
    }
}


#3

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.