Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] New subscription (for google) need the v2 endpoint to verify them #88

Open
Hoegje opened this issue Sep 12, 2023 · 0 comments
Open
Labels

Comments

@Hoegje
Copy link

Hoegje commented Sep 12, 2023

Subscriptions can soon no longer be validated with the original subscription link, but should go to the v2 version.

https://developer.android.com/google/play/billing/compatibility

Description

I tried a long time to get things working with the current code, but google was giving me cryptic error message saying I provided wrong arguments to the API call when calling the URL:
Method: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}

Expected Behavior

I would have expected it to say something about the subscription.

Actual Behavior

I always received : no matter what I tried
Error Response: { "error": { "code": 400, "message": "Your request is invalid for this subscription purchase.", "errors": [ { "message": "Your request is invalid for this subscription purchase.", "domain": "androidpublisher", "reason": "subscriptionInvalidArgument" } ] } }

Possible Fix

Looking at the following link, I noticed there is now a subscriptionv2 endpoint that should be used.
https://developer.android.com/google/play/billing/compatibility

Also present in the androidpublisher.v3.json file:
"subscriptionsv2": {
"methods": {
"get": {
"description": "Get metadata about a subscription",
"flatPath": "androidpublisher/v3/applications/{packageName}/purchases/subscriptionsv2/tokens/{token}",
"httpMethod": "GET",
"id": "androidpublisher.purchases.subscriptionsv2.get",
"parameterOrder": [
"packageName",
"token"
],
"parameters": {
"packageName": {
"description": "The package of the application for which this subscription was purchased (for example, 'com.some.thing').",
"location": "path",
"required": true,
"type": "string"
},
"token": {
"description": "Required. The token provided to the user's device when the subscription was purchased.",
"location": "path",
"required": true,
"type": "string"
}
},
"path": "androidpublisher/v3/applications/{packageName}/purchases/subscriptionsv2/tokens/{token}",
"response": {
"$ref": "SubscriptionPurchaseV2"
},
"scopes": [
"https://www.googleapis.com/auth/androidpublisher"
]
}
}
}

Steps to Reproduce

When using the new v2 framework in googleplay.py, it seems to work again:

    def check_purchase_subscription(self, purchase_token: str, product_sku: str, service) -> dict:
        try:
            purchases = service.purchases()
            subscriptions = purchases.subscriptionsv2()
            subscriptions_get = subscriptions.get(
                packageName=self.bundle_id,  token=purchase_token
            )
            result = subscriptions_get.execute(http=self.http)
            return result
        except HttpError as e:
            if e.resp.status == 400:
                raise GoogleError(e.resp.reason, repr(e))
            else:
                raise e

Your Environment

  • Version used: 2.5.2
@Hoegje Hoegje added the bug label Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant