简体   繁体   中英

Android InApp purchase verification failing using Google API

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

Lots of users are experiencing the same issue, there appears to be a bug

https://groups.google.com/forum/#!topic/google-apis-explorer-users/sJ5glcRva_s

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM