Android In-app subscription receipt validation response showing an error 503 - An internal error occurred

808 Views Asked by At

We were trying to validate the receipt generated from the mobile app from the server-side. It was working initially, but we were providing the receipt details directly to the code. Now we are trying it from the mobile app API functions, we are getting an error code 503.

{
  "error": {
    "code": 503,
    "message": "An internal error occurred.",
    "errors": [
      {
        "message": "An internal error occurred.",
        "domain": "androidpublisher",
        "reason": "subscriptionInternal"
      }
    ]
  }
}

What I am doing is validating my receipt by using google API. For that, I have created a service account in google play console and grant permission for the same. And also created OAuth 2.0 Client IDs in the developer console.

By using the client_id, client secret and redirect URI am validating the receipt.

If I am giving an invalid data in the Google API, for example, I enter the package name incorrectly then it will show a correct response like

{
  "error": {
    "code": 400,
    "message": "The purchase token does not match the package name.",
    "errors": [
      {
        "message": "The purchase token does not match the package name.",
        "domain": "androidpublisher",
        "reason": "purchaseTokenDoesNotMatchPackageName",
        "location": "token",
        "locationType": "parameter"
      }
    ]
  }
}

The issue is happening when I give all the data correctly in my code.

And I already did the same in another project and I get a correct response also. But I have no idea why here the response is always 503.

below one is sample URL which I am using to make receipt validation in server-side

'https://www.googleapis.com/androidpublisher/v3/applications/appId/purchases/subscriptions/subscriptionId/tokens/myPrchaseToken?access_token=myAccesstoken'

1

There are 1 best solutions below

0
Ilja Booij On

We have also been having this same issue. Google support is quiet, so not helpful at all. What we've done to fix the situation temporarily is to call v1 of the API when v2 repeatedly fails with a 503 error.

So, we first try the endpoint described in https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2/get

For some purchase tokens this just returns 503, so then we call the v1 endpoint described in https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions/get

Note that the v1 response is different from the v2 response, but you can get most information from there, except the product id. So you need to make sure that your app provides this product id to your backend.

We have not seen any instances where both the v1 and v2 endpoints returned the error.