I have a problem with the Google Play Android Developer API. I need to verify the purchase of Managed Product and Subscription Type purchases and grant access to content on a server when verified.
I use Oauth to generate an access_token to authorize the API calls. I use the androidpublisher.purchases.get to verify Subscription Type purchases and this works as expected.
However with I use androidpublisher.inapppurchases.get to verify the purchase I am returned an unhelpful error
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}
Both API calls use the same values from the receipts - packageName, productID, purchaseToken and use the same access_token.
I'm stumped - any help would be appreciated.
Edit 1. Here is the inapp code. The only difference with the working subscription verify is replacing /inapp/ with /subscriptions/
string restAPI = "https://www.googleapis.com/androidpublisher/v1.1/applications/{0}/inapp/{1}/purchases/{2}";
string url = String.Format(restAPI, APP_PACKAGE, SUBSCRIPTION_ID, PURCHASE_TOKEN);
string postcontents = string.Format("access_token={0}", HttpUtility.UrlEncode(AUTH_TOKEN));
string responseFromServer = "";
url += "?" + postcontents;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "GET";
request.UserAgent = "RVGP";
WebResponse response = request.GetResponse();
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(responseStream))
{
responseFromServer = reader.ReadToEnd();
reader.Close();
responseStream.Close();
response.Close();
}
}