Search code examples
in-app-purchasein-app-subscription

google renewable subscriptions abuse


we have an application that utilizes auto renewable subscriptions in android.

The users are going subscribing through the app normally and the receipt is sent for our backend to be validated using the IAP Google API.

until this point everything is fine, but we recently discovred a loophole in our system, some users are subscribe and cancel their subscriptions and re-enable the auto subscription, this way google will issues a new receipt that is sent to our backend and we are giving them another year, this is easily solved by granting the only the duration given in the receipt

but then users started using the same google account with different accounts for our apps and they give everyone free subscriptions by the generated receipt

I read the API in here and I can't find any field that tells us that this receipt is only a re-activation not a new subscription https://developers.google.com/android-publisher/api-ref/purchases/subscriptions

when we send a request for google api to get the info this is what we are getting:

status_from_google_play
{
    "autoRenewing": true,
    "cancelReason": null,
    "countryCode": "SA",
    "developerPayload": "",
    "expiryTimeMillis": "1534073485784",
    "kind": "androidpublisher#subscriptionPurchase",
    "linkedPurchaseToken": "sometoken",
    "orderId": "GPA.xxxx-xxxx-xxxx-xxxxx",
    "paymentState": 1,
    "priceAmountMicros": "290000",
    "priceCurrencyCode": "SAR",
    "purchaseType": 0,
    "startTimeMillis": "1534071687580",
    "userCancellationTimeMillis": null
}

There is no field that gives me this piece of information

am I missing something? is there another way to validate this?


Solution

  • Turns out the linkedPurchaseToken field can be used for this purpose if the linked token is not empty it means it's a re-activation only or an upgrade/downgrade for the subscription.

    It's not a direct usage as you can see but it's how you know.